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
Dmitri Naumov
ogs
Commits
6fa8fd99
Commit
6fa8fd99
authored
5 years ago
by
Dmitri Naumov
Browse files
Options
Downloads
Patches
Plain Diff
clang-format
parent
d81d6c23
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
MeshLib/NodePartitionedMesh.h
+1
-1
1 addition, 1 deletion
MeshLib/NodePartitionedMesh.h
NumLib/DOF/MeshComponentMap.cpp
+28
-29
28 additions, 29 deletions
NumLib/DOF/MeshComponentMap.cpp
NumLib/DOF/MeshComponentMap.h
+12
-20
12 additions, 20 deletions
NumLib/DOF/MeshComponentMap.h
with
41 additions
and
50 deletions
MeshLib/NodePartitionedMesh.h
+
1
−
1
View file @
6fa8fd99
...
...
@@ -166,4 +166,4 @@ private:
std
::
size_t
_n_active_nodes
;
};
}
// namespace MeshLib
}
// namespace MeshLib
This diff is collapsed.
Click to expand it.
NumLib/DOF/MeshComponentMap.cpp
+
28
−
29
View file @
6fa8fd99
...
...
@@ -21,7 +21,6 @@
namespace
NumLib
{
using
namespace
detail
;
GlobalIndexType
const
MeshComponentMap
::
nop
=
...
...
@@ -35,10 +34,10 @@ MeshComponentMap::MeshComponentMap(
GlobalIndexType
num_unknowns
=
0
;
for
(
auto
const
&
c
:
components
)
{
// PETSc always works with MeshLib::NodePartitionedMesh.
const
MeshLib
::
NodePartitionedMesh
&
mesh
=
static_cast
<
const
MeshLib
::
NodePartitionedMesh
&>
(
c
.
getMesh
());
num_unknowns
+=
mesh
.
getNumberOfGlobalNodes
();
// PETSc always works with MeshLib::NodePartitionedMesh.
const
MeshLib
::
NodePartitionedMesh
&
mesh
=
static_cast
<
const
MeshLib
::
NodePartitionedMesh
&>
(
c
.
getMesh
());
num_unknowns
+=
mesh
.
getNumberOfGlobalNodes
();
}
// construct dict (and here we number global_index by component type)
...
...
@@ -116,7 +115,7 @@ MeshComponentMap::MeshComponentMap(
renumberByLocation
();
}
}
#endif // end of USE_PETSC
#endif
// end of USE_PETSC
MeshComponentMap
MeshComponentMap
::
getSubset
(
std
::
vector
<
MeshLib
::
MeshSubset
>
const
&
bulk_mesh_subsets
,
...
...
@@ -207,8 +206,9 @@ void MeshComponentMap::renumberByLocation(GlobalIndexType offset)
{
GlobalIndexType
global_index
=
offset
;
auto
&
m
=
_dict
.
get
<
ByLocation
>
();
// view as sorted by mesh item
for
(
auto
itr_mesh_item
=
m
.
begin
();
itr_mesh_item
!=
m
.
end
();
++
itr_mesh_item
)
auto
&
m
=
_dict
.
get
<
ByLocation
>
();
// view as sorted by mesh item
for
(
auto
itr_mesh_item
=
m
.
begin
();
itr_mesh_item
!=
m
.
end
();
++
itr_mesh_item
)
{
Line
pos
=
*
itr_mesh_item
;
pos
.
global_index
=
global_index
++
;
...
...
@@ -218,7 +218,7 @@ void MeshComponentMap::renumberByLocation(GlobalIndexType offset)
std
::
vector
<
int
>
MeshComponentMap
::
getComponentIDs
(
const
Location
&
l
)
const
{
auto
const
&
m
=
_dict
.
get
<
ByLocation
>
();
auto
const
&
m
=
_dict
.
get
<
ByLocation
>
();
auto
const
p
=
m
.
equal_range
(
Line
(
l
));
std
::
vector
<
int
>
vec_compID
;
for
(
auto
itr
=
p
.
first
;
itr
!=
p
.
second
;
++
itr
)
...
...
@@ -230,23 +230,24 @@ std::vector<int> MeshComponentMap::getComponentIDs(const Location& l) const
Line
MeshComponentMap
::
getLine
(
Location
const
&
l
,
int
const
comp_id
)
const
{
auto
const
&
m
=
_dict
.
get
<
ByLocationAndComponent
>
();
auto
const
&
m
=
_dict
.
get
<
ByLocationAndComponent
>
();
auto
const
itr
=
m
.
find
(
Line
(
l
,
comp_id
));
assert
(
itr
!=
m
.
end
());
// The line must exist in the current dictionary.
assert
(
itr
!=
m
.
end
());
// The line must exist in the current dictionary.
return
*
itr
;
}
GlobalIndexType
MeshComponentMap
::
getGlobalIndex
(
Location
const
&
l
,
int
const
comp_id
)
const
{
auto
const
&
m
=
_dict
.
get
<
ByLocationAndComponent
>
();
auto
const
&
m
=
_dict
.
get
<
ByLocationAndComponent
>
();
auto
const
itr
=
m
.
find
(
Line
(
l
,
comp_id
));
return
itr
!=
m
.
end
()
?
itr
->
global_index
:
nop
;
return
itr
!=
m
.
end
()
?
itr
->
global_index
:
nop
;
}
std
::
vector
<
GlobalIndexType
>
MeshComponentMap
::
getGlobalIndices
(
const
Location
&
l
)
const
std
::
vector
<
GlobalIndexType
>
MeshComponentMap
::
getGlobalIndices
(
const
Location
&
l
)
const
{
auto
const
&
m
=
_dict
.
get
<
ByLocation
>
();
auto
const
&
m
=
_dict
.
get
<
ByLocation
>
();
auto
const
p
=
m
.
equal_range
(
Line
(
l
));
std
::
vector
<
GlobalIndexType
>
global_indices
;
for
(
auto
itr
=
p
.
first
;
itr
!=
p
.
second
;
++
itr
)
...
...
@@ -265,7 +266,7 @@ std::vector<GlobalIndexType> MeshComponentMap::getGlobalIndicesByLocation(
std
::
vector
<
GlobalIndexType
>
global_indices
;
global_indices
.
reserve
(
ls
.
size
());
auto
const
&
m
=
_dict
.
get
<
ByLocation
>
();
auto
const
&
m
=
_dict
.
get
<
ByLocation
>
();
for
(
const
auto
&
l
:
ls
)
{
auto
const
p
=
m
.
equal_range
(
Line
(
l
));
...
...
@@ -287,7 +288,7 @@ std::vector<GlobalIndexType> MeshComponentMap::getGlobalIndicesByComponent(
pairs
.
reserve
(
ls
.
size
());
// Create a sub dictionary containing all lines with location from ls.
auto
const
&
m
=
_dict
.
get
<
ByLocation
>
();
auto
const
&
m
=
_dict
.
get
<
ByLocation
>
();
for
(
const
auto
&
l
:
ls
)
{
auto
const
p
=
m
.
equal_range
(
Line
(
l
));
...
...
@@ -297,10 +298,9 @@ std::vector<GlobalIndexType> MeshComponentMap::getGlobalIndicesByComponent(
}
}
auto
CIPairLess
=
[](
CIPair
const
&
a
,
CIPair
const
&
b
)
{
return
a
.
first
<
b
.
first
;
};
auto
CIPairLess
=
[](
CIPair
const
&
a
,
CIPair
const
&
b
)
{
return
a
.
first
<
b
.
first
;
};
// Create vector of global indices from sub dictionary sorting by component.
if
(
!
std
::
is_sorted
(
pairs
.
begin
(),
pairs
.
end
(),
CIPairLess
))
...
...
@@ -330,7 +330,7 @@ GlobalIndexType MeshComponentMap::getLocalIndex(
(
void
)
range_end
;
return
global_index
;
#else
if
(
global_index
>=
0
)
// non-ghost location.
if
(
global_index
>=
0
)
// non-ghost location.
return
global_index
-
range_begin
;
//
...
...
@@ -341,17 +341,16 @@ GlobalIndexType MeshComponentMap::getLocalIndex(
// of the local vector:
GlobalIndexType
const
real_global_index
=
(
-
global_index
==
static_cast
<
GlobalIndexType
>
(
_num_global_dof
))
?
0
:
-
global_index
;
?
0
:
-
global_index
;
// TODO Find in ghost indices is O(n^2/2) for n being the length of
// _ghosts_indices. Providing an inverted table would be faster.
auto
const
ghost_index_it
=
std
::
find
(
_ghosts_indices
.
begin
(),
_ghosts_indices
.
end
(),
real_global_index
);
auto
const
ghost_index_it
=
std
::
find
(
_ghosts_indices
.
begin
(),
_ghosts_indices
.
end
(),
real_global_index
);
if
(
ghost_index_it
==
_ghosts_indices
.
end
())
{
OGS_FATAL
(
"index %d not found in ghost_indices"
,
real_global_index
);
OGS_FATAL
(
"index %d not found in ghost_indices"
,
real_global_index
);
}
// Using std::distance on a std::vector is O(1). As long as _ghost_indices
...
...
@@ -362,4 +361,4 @@ GlobalIndexType MeshComponentMap::getLocalIndex(
#endif
}
}
// namespace NumLib
}
// namespace NumLib
This diff is collapsed.
Click to expand it.
NumLib/DOF/MeshComponentMap.h
+
12
−
20
View file @
6fa8fd99
...
...
@@ -12,20 +12,17 @@
#pragma once
#include
"numlib_export.h"
#include
"MeshLib/MeshSubset.h"
#include
"ComponentGlobalIndexDict.h"
#include
"MeshLib/MeshSubset.h"
#include
"numlib_export.h"
namespace
NumLib
{
/// Ordering of components in global matrix/vector.
enum
class
ComponentOrder
{
BY_COMPONENT
,
///< Ordering data by component type
BY_LOCATION
///< Ordering data by spatial location
BY_COMPONENT
,
///< Ordering data by component type
BY_LOCATION
///< Ordering data by spatial location
};
/// Multidirectional mapping between mesh entities and degrees of freedom.
...
...
@@ -58,10 +55,7 @@ public:
std
::
vector
<
int
>
const
&
new_global_component_ids
)
const
;
/// The number of dofs including the those located in the ghost nodes.
std
::
size_t
dofSizeWithGhosts
()
const
{
return
_dict
.
size
();
}
std
::
size_t
dofSizeWithGhosts
()
const
{
return
_dict
.
size
();
}
/// Component ids at given location \c l.
///
...
...
@@ -89,7 +83,7 @@ public:
/// | l | comp_id_1 | gi23 |
/// | ... | ... | ... |
/// | l | comp_id_k | gi45 |
std
::
vector
<
GlobalIndexType
>
getGlobalIndices
(
const
Location
&
l
)
const
;
std
::
vector
<
GlobalIndexType
>
getGlobalIndices
(
const
Location
&
l
)
const
;
/// Global indices for all components at all given locations \c ls ordered
/// by location. The return list is sorted first by location.
...
...
@@ -124,10 +118,7 @@ public:
/// Get the number of local unknowns excluding those associated
/// with ghost nodes (for DDC with node-wise mesh partitioning).
std
::
size_t
dofSizeWithoutGhosts
()
const
{
return
_num_local_dof
;
}
std
::
size_t
dofSizeWithoutGhosts
()
const
{
return
_num_local_dof
;
}
/// Get ghost indices (for DDC).
std
::
vector
<
GlobalIndexType
>
const
&
getGhostIndices
()
const
...
...
@@ -167,7 +158,8 @@ private:
/// Private constructor used by internally created mesh component maps.
explicit
MeshComponentMap
(
detail
::
ComponentGlobalIndexDict
&
dict
)
:
_dict
(
dict
)
{
}
{
}
/// Looks up if a line is already stored in the dictionary.
/// \attention The line for the location l and component id must exist,
...
...
@@ -175,13 +167,13 @@ private:
/// \return a copy of the line.
detail
::
Line
getLine
(
Location
const
&
l
,
int
const
comp_id
)
const
;
void
renumberByLocation
(
GlobalIndexType
offset
=
0
);
void
renumberByLocation
(
GlobalIndexType
offset
=
0
);
detail
::
ComponentGlobalIndexDict
_dict
;
/// Number of local unknowns excluding those associated
/// with ghost nodes (for domain decomposition).
std
::
size_t
_num_local_dof
=
0
;
std
::
size_t
_num_local_dof
=
0
;
#ifdef USE_PETSC
/// Number of global unknowns. Used internally only.
...
...
@@ -192,4 +184,4 @@ private:
std
::
vector
<
GlobalIndexType
>
_ghosts_indices
;
};
}
// namespace NumLib
}
// 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