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
Özgür Ozan Sen
ogs
Commits
917d27da
Commit
917d27da
authored
4 years ago
by
Dmitri Naumov
Browse files
Options
Downloads
Patches
Plain Diff
[PL/DS] Rewrite extraction of inner nodes.
parent
c883eb2d
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
ProcessLib/DeactivatedSubdomain.cpp
+37
-30
37 additions, 30 deletions
ProcessLib/DeactivatedSubdomain.cpp
with
37 additions
and
30 deletions
ProcessLib/DeactivatedSubdomain.cpp
+
37
−
30
View file @
917d27da
...
...
@@ -48,6 +48,41 @@ bool DeactivatedSubdomain::includesTimeOf(double const t) const
return
time_interval
->
contains
(
t
);
}
template
<
typename
IsActive
>
static
std
::
vector
<
MeshLib
::
Node
*>
extractInnerNodes
(
MeshLib
::
Mesh
const
&
mesh
,
MeshLib
::
Mesh
const
&
sub_mesh
,
IsActive
is_active
)
{
auto
*
const
bulk_node_ids
=
sub_mesh
.
getProperties
().
template
getPropertyVector
<
std
::
size_t
>(
"bulk_node_ids"
,
MeshLib
::
MeshItemType
::
Node
,
1
);
if
(
bulk_node_ids
==
nullptr
)
{
OGS_FATAL
(
"Bulk node ids map is not available in the deactivate subdomain "
"mesh."
);
}
std
::
vector
<
MeshLib
::
Node
*>
inner_nodes
;
// Reserve for more than needed, but not much, because almost all nodes will
// be found and copied.
inner_nodes
.
reserve
(
sub_mesh
.
getNumberOfNodes
());
std
::
copy_if
(
begin
(
sub_mesh
.
getNodes
()),
end
(
sub_mesh
.
getNodes
()),
back_inserter
(
inner_nodes
),
[
&
](
MeshLib
::
Node
*
const
n
)
{
auto
const
bulk_node
=
mesh
.
getNode
((
*
bulk_node_ids
)[
n
->
getID
()]);
const
auto
&
connected_elements
=
bulk_node
->
getElements
();
// Check whether this node is connected to an active
// element.
return
std
::
all_of
(
begin
(
connected_elements
),
end
(
connected_elements
),
is_active
);
});
return
inner_nodes
;
}
template
<
typename
InputIterator
,
typename
UnaryPredicate
>
std
::
vector
<
std
::
size_t
>
copyIdsIf
(
InputIterator
first
,
InputIterator
last
,
...
...
@@ -95,37 +130,9 @@ static std::unique_ptr<DeactivetedSubdomainMesh> createDeactivatedSubdomainMesh(
"deactivate_subdomain_"
+
std
::
to_string
(
material_id
),
MeshLib
::
cloneElements
(
deactivated_elements
));
auto
const
&
new_mesh_properties
=
sub_mesh
->
getProperties
();
if
(
!
new_mesh_properties
.
template
existsPropertyVector
<
std
::
size_t
>(
"bulk_node_ids"
))
{
OGS_FATAL
(
"Bulk node ids map expected in the construction of the mesh "
"subset."
);
}
auto
const
&
bulk_node_ids_map
=
*
new_mesh_properties
.
template
getPropertyVector
<
std
::
size_t
>(
"bulk_node_ids"
,
MeshLib
::
MeshItemType
::
Node
,
1
);
std
::
vector
<
MeshLib
::
Node
*>
deactivated_nodes
;
auto
const
&
nodes_in_sub_mesh
=
sub_mesh
->
getNodes
();
for
(
std
::
size_t
i
=
0
;
i
<
bulk_node_ids_map
.
size
();
i
++
)
{
auto
const
found_iterator
=
std
::
find
(
deactivated_bulk_node_ids
.
begin
(),
deactivated_bulk_node_ids
.
end
(),
bulk_node_ids_map
[
i
]);
if
(
std
::
end
(
deactivated_bulk_node_ids
)
==
found_iterator
)
{
continue
;
}
deactivated_nodes
.
push_back
(
const_cast
<
MeshLib
::
Node
*>
(
nodes_in_sub_mesh
[
i
]));
deactivated_bulk_node_ids
.
erase
(
found_iterator
);
}
auto
inner_nodes
=
extractInnerNodes
(
mesh
,
*
sub_mesh
,
is_active
);
return
std
::
make_unique
<
DeactivetedSubdomainMesh
>
(
std
::
move
(
sub_mesh
),
std
::
move
(
deactivated
_nodes
));
std
::
move
(
sub_mesh
),
std
::
move
(
inner
_nodes
));
}
std
::
unique_ptr
<
DeactivatedSubdomain
const
>
createDeactivatedSubdomain
(
...
...
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