Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Romin Tomasetti
gmsh
Commits
a0201fb7
Commit
a0201fb7
authored
3 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
generalize computation of elements on one side of the crack (cf. #1750)
parent
9d83aefe
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.txt
+1
-1
1 addition, 1 deletion
CHANGELOG.txt
examples/api/crack.py
+5
-0
5 additions, 0 deletions
examples/api/crack.py
src/plugin/Crack.cpp
+47
-29
47 additions, 29 deletions
src/plugin/Crack.cpp
with
53 additions
and
30 deletions
CHANGELOG.txt
+
1
−
1
View file @
a0201fb7
4.10.2 (Work-in-progress): fixed regression introduced in 4.9 for recombined
4.10.2 (Work-in-progress): fixed regression introduced in 4.9 for recombined
meshes with boundary layers; small bug fixes.
meshes with boundary layers;
generalized Crack plugin;
small bug fixes.
4.10.1 (May 1, 2022): small bug fixes.
4.10.1 (May 1, 2022): small bug fixes.
...
...
This diff is collapsed.
Click to expand it.
examples/api/crack.py
+
5
−
0
View file @
a0201fb7
...
@@ -33,6 +33,11 @@ gmsh.model.mesh.generate(2)
...
@@ -33,6 +33,11 @@ gmsh.model.mesh.generate(2)
gmsh
.
plugin
.
setNumber
(
"
Crack
"
,
"
PhysicalGroup
"
,
101
)
gmsh
.
plugin
.
setNumber
(
"
Crack
"
,
"
PhysicalGroup
"
,
101
)
gmsh
.
plugin
.
run
(
"
Crack
"
)
gmsh
.
plugin
.
run
(
"
Crack
"
)
# save all the elements in the mesh (even those that do not belong to any
# physical group):
gmsh
.
option
.
setNumber
(
"
Mesh.SaveAll
"
,
1
)
gmsh
.
write
(
"
crack.msh
"
)
if
'
-nopopup
'
not
in
sys
.
argv
:
if
'
-nopopup
'
not
in
sys
.
argv
:
gmsh
.
fltk
.
run
()
gmsh
.
fltk
.
run
()
...
...
This diff is collapsed.
Click to expand it.
src/plugin/Crack.cpp
+
47
−
29
View file @
a0201fb7
...
@@ -21,7 +21,8 @@ StringXNumber CrackOptions_Number[] = {
...
@@ -21,7 +21,8 @@ StringXNumber CrackOptions_Number[] = {
{
GMSH_FULLRC
,
"NormalX"
,
nullptr
,
0.
},
{
GMSH_FULLRC
,
"NormalX"
,
nullptr
,
0.
},
{
GMSH_FULLRC
,
"NormalY"
,
nullptr
,
0.
},
{
GMSH_FULLRC
,
"NormalY"
,
nullptr
,
0.
},
{
GMSH_FULLRC
,
"NormalZ"
,
nullptr
,
1.
},
{
GMSH_FULLRC
,
"NormalZ"
,
nullptr
,
1.
},
{
GMSH_FULLRC
,
"NewPhysicalGroup"
,
nullptr
,
0
}
{
GMSH_FULLRC
,
"NewPhysicalGroup"
,
nullptr
,
0
},
{
GMSH_FULLRC
,
"Debug"
,
nullptr
,
0
}
};
};
extern
"C"
{
extern
"C"
{
...
@@ -86,6 +87,7 @@ PView *GMSH_CrackPlugin::execute(PView *view)
...
@@ -86,6 +87,7 @@ PView *GMSH_CrackPlugin::execute(PView *view)
SVector3
normal1d
(
CrackOptions_Number
[
3
].
def
,
CrackOptions_Number
[
4
].
def
,
SVector3
normal1d
(
CrackOptions_Number
[
3
].
def
,
CrackOptions_Number
[
4
].
def
,
CrackOptions_Number
[
5
].
def
);
CrackOptions_Number
[
5
].
def
);
int
newPhysical
=
(
int
)
CrackOptions_Number
[
6
].
def
;
int
newPhysical
=
(
int
)
CrackOptions_Number
[
6
].
def
;
int
debug
=
(
int
)
CrackOptions_Number
[
7
].
def
;
if
(
dim
!=
1
&&
dim
!=
2
)
{
if
(
dim
!=
1
&&
dim
!=
2
)
{
Msg
::
Error
(
"Crack dimension should be 1 or 2"
);
Msg
::
Error
(
"Crack dimension should be 1 or 2"
);
...
@@ -122,13 +124,19 @@ PView *GMSH_CrackPlugin::execute(PView *view)
...
@@ -122,13 +124,19 @@ PView *GMSH_CrackPlugin::execute(PView *view)
for
(
std
::
size_t
j
=
0
;
j
<
entities
[
i
]
->
getNumMeshElements
();
j
++
)
for
(
std
::
size_t
j
=
0
;
j
<
entities
[
i
]
->
getNumMeshElements
();
j
++
)
crackElements
.
push_back
(
entities
[
i
]
->
getMeshElement
(
j
));
crackElements
.
push_back
(
entities
[
i
]
->
getMeshElement
(
j
));
// get internal crack nodes and boundary nodes
// get internal crack nodes (and list of connected crack elements), as well as
std
::
set
<
MVertex
*>
crackVertices
,
bndVertices
;
// and boundary nodes
std
::
map
<
MVertex
*
,
std
::
vector
<
MElement
*>
>
crackVertices
;
std
::
set
<
MVertex
*>
bndVertices
;
if
(
dim
==
1
)
{
if
(
dim
==
1
)
{
for
(
std
::
size_t
i
=
0
;
i
<
crackElements
.
size
();
i
++
)
{
for
(
std
::
size_t
i
=
0
;
i
<
crackElements
.
size
();
i
++
)
{
for
(
std
::
size_t
j
=
0
;
j
<
crackElements
[
i
]
->
getNumVertices
();
j
++
)
{
for
(
std
::
size_t
j
=
0
;
j
<
crackElements
[
i
]
->
getNumVertices
();
j
++
)
{
MVertex
*
v
=
crackElements
[
i
]
->
getVertex
(
j
);
MVertex
*
v
=
crackElements
[
i
]
->
getVertex
(
j
);
crackVertices
.
insert
(
v
);
auto
it
=
crackVertices
.
find
(
v
);
if
(
it
==
crackVertices
.
end
())
crackVertices
[
v
]
=
{
crackElements
[
i
]};
else
it
->
second
.
push_back
(
crackElements
[
i
]);
}
}
for
(
std
::
size_t
j
=
0
;
j
<
crackElements
[
i
]
->
getNumPrimaryVertices
();
for
(
std
::
size_t
j
=
0
;
j
<
crackElements
[
i
]
->
getNumPrimaryVertices
();
j
++
)
{
j
++
)
{
...
@@ -145,7 +153,11 @@ PView *GMSH_CrackPlugin::execute(PView *view)
...
@@ -145,7 +153,11 @@ PView *GMSH_CrackPlugin::execute(PView *view)
for
(
std
::
size_t
i
=
0
;
i
<
crackElements
.
size
();
i
++
)
{
for
(
std
::
size_t
i
=
0
;
i
<
crackElements
.
size
();
i
++
)
{
for
(
std
::
size_t
j
=
0
;
j
<
crackElements
[
i
]
->
getNumVertices
();
j
++
)
{
for
(
std
::
size_t
j
=
0
;
j
<
crackElements
[
i
]
->
getNumVertices
();
j
++
)
{
MVertex
*
v
=
crackElements
[
i
]
->
getVertex
(
j
);
MVertex
*
v
=
crackElements
[
i
]
->
getVertex
(
j
);
crackVertices
.
insert
(
v
);
auto
it
=
crackVertices
.
find
(
v
);
if
(
it
==
crackVertices
.
end
())
crackVertices
[
v
]
=
{
crackElements
[
i
]};
else
it
->
second
.
push_back
(
crackElements
[
i
]);
}
}
for
(
int
j
=
0
;
j
<
crackElements
[
i
]
->
getNumEdges
();
j
++
)
{
for
(
int
j
=
0
;
j
<
crackElements
[
i
]
->
getNumEdges
();
j
++
)
{
EdgeData
ed
(
crackElements
[
i
]
->
getEdge
(
j
));
EdgeData
ed
(
crackElements
[
i
]
->
getEdge
(
j
));
...
@@ -208,40 +220,46 @@ PView *GMSH_CrackPlugin::execute(PView *view)
...
@@ -208,40 +220,46 @@ PView *GMSH_CrackPlugin::execute(PView *view)
for
(
std
::
size_t
i
=
0
;
i
<
allentities
[
ent
]
->
getNumMeshElements
();
i
++
)
{
for
(
std
::
size_t
i
=
0
;
i
<
allentities
[
ent
]
->
getNumMeshElements
();
i
++
)
{
MElement
*
e
=
allentities
[
ent
]
->
getMeshElement
(
i
);
MElement
*
e
=
allentities
[
ent
]
->
getMeshElement
(
i
);
for
(
std
::
size_t
j
=
0
;
j
<
e
->
getNumVertices
();
j
++
)
{
for
(
std
::
size_t
j
=
0
;
j
<
e
->
getNumVertices
();
j
++
)
{
if
(
crackVertices
.
find
(
e
->
getVertex
(
j
))
!=
crackVertices
.
end
())
{
auto
it
=
crackVertices
.
find
(
e
->
getVertex
(
j
));
// element touches the crack: find the closest crack element
if
(
it
==
crackVertices
.
end
())
continue
;
SPoint3
b
=
e
->
barycenter
();
// the element touches the crack by at least one node: determine if the
double
d
=
1e200
;
// vector joining its barycenter to the barycenter of one of the
MElement
*
ce
=
nullptr
;
// connected crack elements is not in the same direction as the normal
for
(
std
::
size_t
k
=
0
;
k
<
crackElements
.
size
();
k
++
)
{
// to the crack element; if the condition is fulfilled for one of the
double
d2
=
b
.
distance
(
crackElements
[
k
]
->
barycenter
());
// connected crack elements, we consider the element lies on the
if
(
d2
<
d
)
{
// "positive side" of the crack
d
=
d2
;
SPoint3
b
=
e
->
barycenter
();
ce
=
crackElements
[
k
];
bool
found
=
false
;
}
for
(
auto
ce
:
it
->
second
)
{
}
SVector3
dv
=
SVector3
(
b
,
ce
->
barycenter
());
SVector3
dv
=
SVector3
(
e
->
barycenter
(),
ce
->
barycenter
());
SVector3
n
;
SVector3
n
;
if
(
dim
==
1
)
if
(
dim
==
1
)
n
=
crossprod
(
normal1d
,
ce
->
getEdge
(
0
).
tangent
());
n
=
crossprod
(
normal1d
,
ce
->
getEdge
(
0
).
tangent
());
else
else
n
=
ce
->
getFace
(
0
).
normal
();
n
=
ce
->
getFace
(
0
).
normal
();
if
(
dot
(
n
,
dv
)
<
0
)
{
oneside
.
insert
(
e
);
}
if
(
dot
(
n
,
dv
)
<
0
)
{
oneside
.
insert
(
e
);
found
=
true
;
break
;
}
}
}
if
(
found
)
break
;
// we're done for the element
}
}
}
}
}
}
/*
if
(
debug
)
{
FILE *fp = fopen("debug.pos", "w");
Msg
::
Info
(
"Writing 'debug.pos' file with elements detected on one side "
if(fp){
"of the crack"
);
fprintf(fp, "View \"Ele < 0\" {\n");
FILE
*
fp
=
fopen
(
"debug.pos"
,
"w"
);
for(auto it = oneside.begin(); it != oneside.end(); it++)
if
(
fp
){
(*it)->writePOS(fp, false, true, false, false, false, false);
fprintf
(
fp
,
"View
\"
Elements on one side
\"
{
\n
"
);
fprintf(fp, "};\n");
for
(
auto
it
=
oneside
.
begin
();
it
!=
oneside
.
end
();
it
++
)
fclose(fp);
(
*
it
)
->
writePOS
(
fp
,
false
,
true
,
false
,
false
,
false
,
false
);
fprintf
(
fp
,
"};
\n
"
);
fclose
(
fp
);
}
}
}
*/
// create new crack entity
// create new crack entity
...
@@ -278,7 +296,7 @@ PView *GMSH_CrackPlugin::execute(PView *view)
...
@@ -278,7 +296,7 @@ PView *GMSH_CrackPlugin::execute(PView *view)
// duplicate internal crack nodes
// duplicate internal crack nodes
std
::
map
<
MVertex
*
,
MVertex
*>
vxv
;
std
::
map
<
MVertex
*
,
MVertex
*>
vxv
;
for
(
auto
it
=
crackVertices
.
begin
();
it
!=
crackVertices
.
end
();
it
++
)
{
for
(
auto
it
=
crackVertices
.
begin
();
it
!=
crackVertices
.
end
();
it
++
)
{
MVertex
*
v
=
*
it
;
MVertex
*
v
=
i
t
->
firs
t
;
MVertex
*
newv
=
new
MVertex
(
v
->
x
(),
v
->
y
(),
v
->
z
(),
crackEntity
);
MVertex
*
newv
=
new
MVertex
(
v
->
x
(),
v
->
y
(),
v
->
z
(),
crackEntity
);
crackEntity
->
mesh_vertices
.
push_back
(
newv
);
crackEntity
->
mesh_vertices
.
push_back
(
newv
);
vxv
[
v
]
=
newv
;
vxv
[
v
]
=
newv
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment