Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Karsten Rink
ogs
Commits
32d1c339
Commit
32d1c339
authored
6 years ago
by
Tom Fischer
Browse files
Options
Downloads
Patches
Plain Diff
[A/U] Restrict the reset of the property to a material id.
parent
a58322cc
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp
+43
-12
43 additions, 12 deletions
...tions/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp
with
43 additions
and
12 deletions
Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp
+
43
−
12
View file @
32d1c339
...
@@ -76,8 +76,11 @@ static std::vector<bool> markNodesOutSideOfPolygon(
...
@@ -76,8 +76,11 @@ static std::vector<bool> markNodesOutSideOfPolygon(
}
}
template
<
typename
PT
>
template
<
typename
PT
>
void
resetMeshElementProperty
(
MeshLib
::
Mesh
&
mesh
,
GeoLib
::
Polygon
const
&
polygon
,
void
resetMeshElementProperty
(
MeshLib
::
Mesh
&
mesh
,
std
::
string
const
&
property_name
,
PT
new_property_value
)
GeoLib
::
Polygon
const
&
polygon
,
std
::
string
const
&
property_name
,
PT
new_property_value
,
int
restrict_to_material_id
)
{
{
auto
*
const
pv
=
MeshLib
::
getOrCreateMeshProperty
<
PT
>
(
auto
*
const
pv
=
MeshLib
::
getOrCreateMeshProperty
<
PT
>
(
mesh
,
property_name
,
MeshLib
::
MeshItemType
::
Cell
,
1
);
mesh
,
property_name
,
MeshLib
::
MeshItemType
::
Cell
,
1
);
...
@@ -88,20 +91,40 @@ void resetMeshElementProperty(MeshLib::Mesh &mesh, GeoLib::Polygon const& polygo
...
@@ -88,20 +91,40 @@ void resetMeshElementProperty(MeshLib::Mesh &mesh, GeoLib::Polygon const& polygo
return
;
return
;
}
}
std
::
vector
<
bool
>
outside
(
markNodesOutSideOfPolygon
(
mesh
.
getNodes
(),
std
::
vector
<
bool
>
outside
(
polygon
));
markNodesOutSideOfPolygon
(
mesh
.
getNodes
(),
polygon
));
for
(
std
::
size_t
j
(
0
);
j
<
mesh
.
getElements
().
size
();
++
j
)
{
auto
const
*
material_ids
=
mesh
.
getProperties
().
getPropertyVector
<
int
>
(
"MaterialIDs"
);
auto
hasElementRequiredMaterialID
=
[
&
](
int
const
element_id
)
{
if
(
restrict_to_material_id
==
-
1
)
return
true
;
if
(
!
material_ids
)
{
OGS_FATAL
(
"Restriction of reseting a property in a polygonal region "
"requires that a MaterialIDs data array is available in the "
"mesh."
);
}
return
(
*
material_ids
)[
element_id
]
==
restrict_to_material_id
;
};
for
(
std
::
size_t
j
(
0
);
j
<
mesh
.
getElements
().
size
();
++
j
)
{
bool
elem_out
(
true
);
bool
elem_out
(
true
);
MeshLib
::
Element
const
*
const
elem
(
mesh
.
getElements
()[
j
]);
MeshLib
::
Element
const
*
const
elem
(
mesh
.
getElements
()[
j
]);
for
(
auto
k
=
decltype
(
elem
->
getNumberOfNodes
()){
0
};
for
(
auto
k
=
decltype
(
elem
->
getNumberOfNodes
()){
0
};
k
<
elem
->
getNumberOfNodes
()
&&
elem_out
;
++
k
)
k
<
elem
->
getNumberOfNodes
()
&&
elem_out
;
++
k
)
{
{
if
(
!
outside
[
elem
->
getNode
(
k
)
->
getID
()])
{
if
(
!
outside
[
elem
->
getNode
(
k
)
->
getID
()])
{
elem_out
=
false
;
elem_out
=
false
;
}
}
}
}
if
(
!
elem_out
)
{
if
(
!
elem_out
&&
hasElementRequiredMaterialID
(
elem
->
getID
()))
{
(
*
pv
)[
j
]
=
new_property_value
;
(
*
pv
)[
j
]
=
new_property_value
;
}
}
}
}
...
@@ -140,6 +163,11 @@ int main (int argc, char* argv[])
...
@@ -140,6 +163,11 @@ int main (int argc, char* argv[])
TCLAP
::
ValueArg
<
std
::
string
>
property_name_arg
(
"n"
,
"property-name"
,
TCLAP
::
ValueArg
<
std
::
string
>
property_name_arg
(
"n"
,
"property-name"
,
"name of property in the mesh"
,
false
,
"MaterialIDs"
,
"string"
);
"name of property in the mesh"
,
false
,
"MaterialIDs"
,
"string"
);
cmd
.
add
(
property_name_arg
);
cmd
.
add
(
property_name_arg
);
TCLAP
::
ValueArg
<
int
>
restrict_arg
(
"r"
,
"restrict-to-MaterialID"
,
"Restrict reseting the property to the material id"
,
false
,
-
1
,
"MaterialID"
);
cmd
.
add
(
restrict_arg
);
TCLAP
::
ValueArg
<
std
::
string
>
mesh_in
(
"m"
,
"mesh-input-file"
,
TCLAP
::
ValueArg
<
std
::
string
>
mesh_in
(
"m"
,
"mesh-input-file"
,
"the name of the file containing the input mesh"
,
true
,
"the name of the file containing the input mesh"
,
true
,
""
,
"file name"
);
""
,
"file name"
);
...
@@ -193,17 +221,20 @@ int main (int argc, char* argv[])
...
@@ -193,17 +221,20 @@ int main (int argc, char* argv[])
if
(
char_property_arg
.
isSet
())
{
if
(
char_property_arg
.
isSet
())
{
resetMeshElementProperty
(
*
mesh
,
polygon
,
property_name
,
resetMeshElementProperty
(
*
mesh
,
polygon
,
property_name
,
char_property_arg
.
getValue
());
char_property_arg
.
getValue
(),
restrict_arg
.
getValue
());
}
}
if
(
int_property_arg
.
isSet
())
{
if
(
int_property_arg
.
isSet
())
{
resetMeshElementProperty
(
*
mesh
,
polygon
,
property_name
,
resetMeshElementProperty
(
*
mesh
,
polygon
,
property_name
,
int_property_arg
.
getValue
());
int_property_arg
.
getValue
(),
restrict_arg
.
getValue
());
}
}
if
(
bool_property_arg
.
isSet
())
{
if
(
bool_property_arg
.
isSet
())
{
resetMeshElementProperty
(
*
mesh
,
polygon
,
property_name
,
resetMeshElementProperty
(
*
mesh
,
polygon
,
property_name
,
bool_property_arg
.
getValue
());
bool_property_arg
.
getValue
(),
restrict_arg
.
getValue
());
}
}
std
::
vector
<
std
::
string
>
property_names
(
std
::
vector
<
std
::
string
>
property_names
(
...
...
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