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
Model registry
Operate
Environments
Monitor
Incidents
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
Larry Price
gmsh
Commits
deacf2fa
Commit
deacf2fa
authored
15 years ago
by
Laurent Van Migroet
Browse files
Options
Downloads
Patches
Plain Diff
Add createGModel
parent
fa09e8a5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Geo/GModel.h
+6
-0
6 additions, 0 deletions
Geo/GModel.h
Geo/GModelIO_Mesh.cpp
+105
-0
105 additions, 0 deletions
Geo/GModelIO_Mesh.cpp
with
111 additions
and
0 deletions
Geo/GModel.h
+
6
−
0
View file @
deacf2fa
...
@@ -328,6 +328,12 @@ class GModel
...
@@ -328,6 +328,12 @@ class GModel
// build a new GModel by cutting the elements crossed by the levelset ls
// build a new GModel by cutting the elements crossed by the levelset ls
GModel
*
buildCutGModel
(
gLevelset
*
ls
);
GModel
*
buildCutGModel
(
gLevelset
*
ls
);
// create GModel by importing mesh and vertices, vertexMap has a dim equal to the number
// of vertices and all std::vector have a dim equal to the number of elements
static
GModel
*
createGModel
(
std
::
map
<
int
,
MVertex
*>&
vertexMap
,
std
::
vector
<
int
>
&
numElement
,
std
::
vector
<
std
::
vector
<
int
>>
&
vertexIndices
,
std
::
vector
<
int
>
&
elementType
,
std
::
vector
<
int
>
&
physical
,
std
::
vector
<
int
>
&
elementary
,
std
::
vector
<
int
>
&
partition
);
// Gmsh native CAD format (readGEO is static, since it can create
// Gmsh native CAD format (readGEO is static, since it can create
// multiple models)
// multiple models)
...
...
This diff is collapsed.
Click to expand it.
Geo/GModelIO_Mesh.cpp
+
105
−
0
View file @
deacf2fa
...
@@ -2911,3 +2911,108 @@ int GModel::writeDIFF(const std::string &name, bool binary, bool saveAll,
...
@@ -2911,3 +2911,108 @@ int GModel::writeDIFF(const std::string &name, bool binary, bool saveAll,
fclose
(
fp
);
fclose
(
fp
);
return
1
;
return
1
;
}
}
GModel
*
GModel
::
createGModel
(
std
::
map
<
int
,
MVertex
*>&
vertexMap
,
std
::
vector
<
int
>
&
elementNum
,
std
::
vector
<
std
::
vector
<
int
>>
&
vertexIndices
,
std
::
vector
<
int
>
&
elementType
,
std
::
vector
<
int
>
&
physical
,
std
::
vector
<
int
>
&
elementary
,
std
::
vector
<
int
>
&
partition
)
{
GModel
*
gm
=
new
GModel
();
std
::
map
<
int
,
std
::
vector
<
MElement
*>
>
elements
[
10
];
std
::
map
<
int
,
std
::
map
<
int
,
std
::
string
>
>
physicals
[
4
];
std
::
vector
<
MVertex
*>
vertexVector
;
int
numVertices
=
(
int
)
vertexMap
.
size
();
int
numElement
=
(
int
)
elementNum
.
size
();
if
(
numElement
!=
(
int
)
vertexIndices
.
size
())
Msg
::
Error
(
"Dimension in vertices numbers"
);
if
(
numElement
!=
(
int
)
elementType
.
size
())
Msg
::
Error
(
"Dimension in elementType numbers"
);
if
(
numElement
!=
(
int
)
physical
.
size
())
Msg
::
Error
(
"Dimension in physical numbers"
);
if
(
numElement
!=
(
int
)
elementary
.
size
())
Msg
::
Error
(
"Dimension in elementary numbers"
);
if
(
numElement
!=
(
int
)
partition
.
size
())
Msg
::
Error
(
"Dimension in partition numbers"
);
std
::
map
<
int
,
MVertex
*>::
const_iterator
it
=
vertexMap
.
begin
();
std
::
map
<
int
,
MVertex
*>::
const_iterator
end
=
vertexMap
.
end
();
int
maxVertex
=
INT_MIN
;
int
minVertex
=
INT_MAX
;
int
num
;
for
(
it
;
it
!=
end
;
++
it
){
num
=
it
->
first
;
minVertex
=
std
::
min
(
minVertex
,
num
);
maxVertex
=
std
::
max
(
maxVertex
,
num
);
}
if
(
minVertex
==
INT_MAX
)
Msg
::
Error
(
"Could not determine the min index of vertices"
);
// If the vertex numbering is dense, tranfer the map into a
// vector to speed up element creation
if
((
minVertex
==
1
&&
maxVertex
==
numVertices
)
||
(
minVertex
==
0
&&
maxVertex
==
numVertices
-
1
)){
Msg
::
Info
(
"Vertex numbering is dense"
);
vertexVector
.
resize
(
vertexMap
.
size
()
+
1
);
if
(
minVertex
==
1
)
vertexVector
[
0
]
=
0
;
else
vertexVector
[
numVertices
]
=
0
;
std
::
map
<
int
,
MVertex
*>::
const_iterator
it
=
vertexMap
.
begin
();
for
(;
it
!=
vertexMap
.
end
();
++
it
)
vertexVector
[
it
->
first
]
=
it
->
second
;
vertexMap
.
clear
();
}
int
*
indices
;
int
nbVertices
;
for
(
int
i
=
0
;
i
<
numElement
;
++
i
){
num
=
elementNum
[
i
];
std
::
vector
<
MVertex
*>
vertices
;
nbVertices
=
(
int
)
vertexIndices
[
i
].
size
();
indices
=
&
vertexIndices
[
i
][
0
];
if
(
vertexVector
.
size
()){
Msg
::
Error
(
"Vertex not found aborting"
);
if
(
!
getVertices
(
nbVertices
,
indices
,
vertexVector
,
vertices
)){
delete
gm
;
return
0
;
}
}
else
{
Msg
::
Error
(
"Vertex not found aborting"
);
if
(
!
getVertices
(
nbVertices
,
indices
,
vertexMap
,
vertices
)){
delete
gm
;
return
0
;
}
}
createElementMSH
(
gm
,
num
,
elementType
[
i
],
physical
[
i
],
elementary
[
i
],
partition
[
i
],
vertices
,
elements
,
physicals
);
}
// store the elements in their associated elementary entity. If the
// entity does not exist, create a new (discrete) one.
for
(
int
i
=
0
;
i
<
(
int
)(
sizeof
(
elements
)
/
sizeof
(
elements
[
0
]));
i
++
)
gm
->
_storeElementsInEntities
(
elements
[
i
]);
// associate the correct geometrical entity with each mesh vertex
gm
->
_associateEntityWithMeshVertices
();
// store the vertices in their associated geometrical entity
if
(
vertexVector
.
size
())
gm
->
_storeVerticesInEntities
(
vertexVector
);
else
gm
->
_storeVerticesInEntities
(
vertexMap
);
// store the physical tags
for
(
int
i
=
0
;
i
<
4
;
i
++
)
gm
->
_storePhysicalTagsInEntities
(
i
,
physicals
[
i
]);
return
gm
;
}
\ No newline at end of file
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