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
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
Yuhao Liu
ogs
Commits
d1ff5530
Commit
d1ff5530
authored
3 years ago
by
Tom Fischer
Committed by
Dmitri Naumov
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[NL/DOF] Move code to its own method.
Move the code for creating parallel MeshComponentMap to its own method.
parent
c9a93be4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
NumLib/DOF/MeshComponentMap.cpp
+69
-59
69 additions, 59 deletions
NumLib/DOF/MeshComponentMap.cpp
NumLib/DOF/MeshComponentMap.h
+8
-0
8 additions, 0 deletions
NumLib/DOF/MeshComponentMap.h
with
77 additions
and
59 deletions
NumLib/DOF/MeshComponentMap.cpp
+
69
−
59
View file @
d1ff5530
...
...
@@ -39,66 +39,9 @@ MeshComponentMap::MeshComponentMap(
createSerialMeshComponentMap
(
components
,
order
);
return
;
}
// Use PETSc with multi-thread
// get number of unknowns
GlobalIndexType
num_unknowns
=
0
;
for
(
auto
const
&
c
:
components
)
else
{
// PETSc always works with MeshLib::NodePartitionedMesh.
const
MeshLib
::
NodePartitionedMesh
&
p_mesh
=
static_cast
<
const
MeshLib
::
NodePartitionedMesh
&>
(
c
.
getMesh
());
num_unknowns
+=
p_mesh
.
getNumberOfGlobalNodes
();
}
// construct dict (and here we number global_index by component type)
int
comp_id
=
0
;
_num_global_dof
=
0
;
_num_local_dof
=
0
;
for
(
auto
const
&
c
:
components
)
{
assert
(
dynamic_cast
<
MeshLib
::
NodePartitionedMesh
const
*>
(
&
c
.
getMesh
())
!=
nullptr
);
std
::
size_t
const
mesh_id
=
c
.
getMeshID
();
const
MeshLib
::
NodePartitionedMesh
&
p_mesh
=
static_cast
<
const
MeshLib
::
NodePartitionedMesh
&>
(
c
.
getMesh
());
// mesh items are ordered first by node, cell, ....
for
(
std
::
size_t
j
=
0
;
j
<
c
.
getNumberOfNodes
();
j
++
)
{
GlobalIndexType
global_id
=
0
;
if
(
order
!=
ComponentOrder
::
BY_LOCATION
)
{
// Deactivated since this case is not suitable to
// arrange non ghost entries of a partition within
// a rank in the parallel computing.
OGS_FATAL
(
"Global index in the system of equations"
" can only be numbered by the order type of "
"ComponentOrder::BY_LOCATION"
);
}
global_id
=
static_cast
<
GlobalIndexType
>
(
components
.
size
()
*
p_mesh
.
getGlobalNodeID
(
j
)
+
comp_id
);
const
bool
is_ghost
=
p_mesh
.
isGhostNode
(
p_mesh
.
getNode
(
j
)
->
getID
());
if
(
is_ghost
)
{
_ghosts_indices
.
push_back
(
global_id
);
global_id
=
-
global_id
;
// If the ghost entry has an index of 0,
// its index is set to the negative value of unknowns.
if
(
global_id
==
0
)
global_id
=
-
num_unknowns
;
}
else
_num_local_dof
++
;
_dict
.
insert
(
Line
(
Location
(
mesh_id
,
MeshLib
::
MeshItemType
::
Node
,
j
),
comp_id
,
global_id
));
}
_num_global_dof
+=
p_mesh
.
getNumberOfGlobalNodes
();
comp_id
++
;
createParallelMeshComponentMap
(
components
,
order
);
}
}
#else
...
...
@@ -378,4 +321,71 @@ void MeshComponentMap::createSerialMeshComponentMap(
}
}
#ifdef USE_PETSC
void
MeshComponentMap
::
createParallelMeshComponentMap
(
std
::
vector
<
MeshLib
::
MeshSubset
>
const
&
components
,
ComponentOrder
order
)
{
// Use PETSc with multi-thread
// get number of unknowns
GlobalIndexType
num_unknowns
=
0
;
for
(
auto
const
&
c
:
components
)
{
// PETSc always works with MeshLib::NodePartitionedMesh.
const
MeshLib
::
NodePartitionedMesh
&
p_mesh
=
static_cast
<
const
MeshLib
::
NodePartitionedMesh
&>
(
c
.
getMesh
());
num_unknowns
+=
p_mesh
.
getNumberOfGlobalNodes
();
}
// construct dict (and here we number global_index by component type)
int
comp_id
=
0
;
_num_global_dof
=
0
;
_num_local_dof
=
0
;
for
(
auto
const
&
c
:
components
)
{
assert
(
dynamic_cast
<
MeshLib
::
NodePartitionedMesh
const
*>
(
&
c
.
getMesh
())
!=
nullptr
);
std
::
size_t
const
mesh_id
=
c
.
getMeshID
();
const
MeshLib
::
NodePartitionedMesh
&
p_mesh
=
static_cast
<
const
MeshLib
::
NodePartitionedMesh
&>
(
c
.
getMesh
());
// mesh items are ordered first by node, cell, ....
for
(
std
::
size_t
j
=
0
;
j
<
c
.
getNumberOfNodes
();
j
++
)
{
GlobalIndexType
global_id
=
0
;
if
(
order
!=
ComponentOrder
::
BY_LOCATION
)
{
// Deactivated since this case is not suitable to
// arrange non ghost entries of a partition within
// a rank in the parallel computing.
OGS_FATAL
(
"Global index in the system of equations"
" can only be numbered by the order type of "
"ComponentOrder::BY_LOCATION"
);
}
global_id
=
static_cast
<
GlobalIndexType
>
(
components
.
size
()
*
p_mesh
.
getGlobalNodeID
(
j
)
+
comp_id
);
const
bool
is_ghost
=
p_mesh
.
isGhostNode
(
p_mesh
.
getNode
(
j
)
->
getID
());
if
(
is_ghost
)
{
_ghosts_indices
.
push_back
(
global_id
);
global_id
=
-
global_id
;
// If the ghost entry has an index of 0,
// its index is set to the negative value of unknowns.
if
(
global_id
==
0
)
global_id
=
-
num_unknowns
;
}
else
_num_local_dof
++
;
_dict
.
insert
(
Line
(
Location
(
mesh_id
,
MeshLib
::
MeshItemType
::
Node
,
j
),
comp_id
,
global_id
));
}
_num_global_dof
+=
p_mesh
.
getNumberOfGlobalNodes
();
comp_id
++
;
}
}
#endif
}
// namespace NumLib
This diff is collapsed.
Click to expand it.
NumLib/DOF/MeshComponentMap.h
+
8
−
0
View file @
d1ff5530
...
...
@@ -188,6 +188,14 @@ private:
void
createSerialMeshComponentMap
(
std
::
vector
<
MeshLib
::
MeshSubset
>
const
&
components
,
ComponentOrder
order
);
#ifdef USE_PETSC
/// \param components a vector of components
/// \param order type of ordering values in a vector
void
createParallelMeshComponentMap
(
std
::
vector
<
MeshLib
::
MeshSubset
>
const
&
components
,
ComponentOrder
order
);
#endif
};
}
// namespace NumLib
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