27 std::numeric_limits<GlobalIndexType>::max();
31 std::vector<MeshLib::MeshSubset>
const& components,
ComponentOrder order)
36 components[0].getMesh());
39 createSerialMeshComponentMap(components, order);
44 createParallelMeshComponentMap(components, order);
49 std::vector<MeshLib::MeshSubset>
const& components,
ComponentOrder order)
51 createSerialMeshComponentMap(components, order);
56 std::vector<MeshLib::MeshSubset>
const& bulk_mesh_subsets,
58 std::vector<int>
const& new_global_component_ids)
const
62 auto const first_mismatch =
63 std::adjacent_find(begin(bulk_mesh_subsets), end(bulk_mesh_subsets),
64 [](
auto const& a,
auto const& b)
65 {
return a.getMeshID() != b.getMeshID(); });
66 if (first_mismatch != end(bulk_mesh_subsets))
69 "Assumption in the MeshComponentMap violated. Expecting all of "
70 "mesh ids to be the same, but it is not true for "
71 "the mesh '{:s}' with id {:d}.",
72 first_mismatch->getMesh().getName(),
73 first_mismatch->getMeshID());
79 if (!new_mesh_properties.template existsPropertyVector<std::size_t>(
83 "Bulk node ids map expected in the construction of the mesh "
86 auto const& bulk_node_ids_map =
87 *new_mesh_properties.template getPropertyVector<std::size_t>(
93 std::size_t
const new_mesh_id = new_mesh_subset.
getMeshID();
96 for (
auto*
const node : new_mesh_subset.
getNodes())
98 auto const node_id = node->getID();
109 bulk_node_ids_map[node_id]};
111 for (
auto component_id : new_global_component_ids)
113 auto const global_index =
114 getGlobalIndex(bulk_location, component_id);
115 if (global_index == nop)
120 "Could not find a global index for global component "
121 "{:d} for the mesh '{:s}', node {:d}, in the "
122 "corresponding bulk mesh '{:s}' and node {:d}. This "
123 "happens because the boundary mesh is larger then the "
124 "definition region of the bulk component, usually "
125 "because the geometry for the boundary condition is "
130 bulk_mesh_subsets.front().getMesh().getName(),
131 bulk_node_ids_map[node_id]);
135 subset_dict.insert({new_location, component_id, global_index});
147 for (
auto itr_mesh_item = m.begin(); itr_mesh_item != m.end();
150 Line pos = *itr_mesh_item;
152 m.replace(itr_mesh_item, pos);
159 auto const p = m.equal_range(
Line(l));
160 std::vector<int> vec_compID;
161 for (
auto itr = p.first; itr != p.second; ++itr)
163 vec_compID.push_back(itr->comp_id);
171 auto const itr = m.find(
Line(l, comp_id));
172 assert(itr != m.end());
177 int const comp_id)
const
180 auto const itr = m.find(
Line(l, comp_id));
181 return itr != m.end() ? itr->global_index : nop;
188 auto const p = m.equal_range(
Line(l));
189 std::vector<GlobalIndexType> global_indices;
190 for (
auto itr = p.first; itr != p.second; ++itr)
192 global_indices.push_back(itr->global_index);
194 return global_indices;
198 std::vector<Location>
const& ls)
const
203 std::vector<GlobalIndexType> global_indices;
204 global_indices.reserve(ls.size());
207 for (
const auto& l : ls)
209 auto const p = m.equal_range(
Line(l));
210 for (
auto itr = p.first; itr != p.second; ++itr)
212 global_indices.push_back(itr->global_index);
216 return global_indices;
220 std::vector<Location>
const& ls)
const
223 using CIPair = std::pair<int, GlobalIndexType>;
224 std::vector<CIPair> pairs;
225 pairs.reserve(ls.size());
229 for (
const auto& l : ls)
231 auto const p = m.equal_range(
Line(l));
232 for (
auto itr = p.first; itr != p.second; ++itr)
234 pairs.emplace_back(itr->comp_id, itr->global_index);
238 auto CIPairLess = [](CIPair
const& a, CIPair
const& b)
239 {
return a.first < b.first; };
242 if (!std::is_sorted(pairs.begin(), pairs.end(), CIPairLess))
244 std::stable_sort(pairs.begin(), pairs.end(), CIPairLess);
247 std::vector<GlobalIndexType> global_indices;
248 global_indices.reserve(pairs.size());
249 transform(cbegin(pairs), cend(pairs), back_inserter(global_indices),
250 [&](
const auto& pair) {
return pair.second; });
252 return global_indices;
258 std::size_t
const range_begin,
259 std::size_t
const range_end)
const
267 if (global_index >= 0)
268 return global_index - range_begin;
283 auto const ghost_index_it = std::find(
284 _ghosts_indices.begin(), _ghosts_indices.end(), real_global_index);
285 if (ghost_index_it == _ghosts_indices.end())
287 OGS_FATAL(
"index {:d} not found in ghost_indices", real_global_index);
292 return range_end - range_begin +
293 std::distance(_ghosts_indices.begin(), ghost_index_it);
299 std::vector<MeshLib::MeshSubset>
const& components,
ComponentOrder order)
304 for (
auto const&
c : components)
306 std::size_t
const mesh_id =
c.getMeshID();
308 for (std::size_t j = 0; j <
c.getNumberOfNodes(); j++)
312 comp_id, global_index++));
316 _num_local_dof = _dict.size();
320 renumberByLocation();
326 std::vector<MeshLib::MeshSubset>
const& components,
ComponentOrder order)
334 "Global index in the system of equations can only be numbered by "
335 "the order type of ComponentOrder::BY_LOCATION");
340 for (
auto const&
c : components)
351 for (
auto const&
c : components)
354 &
c.getMesh()) !=
nullptr);
355 std::size_t
const mesh_id =
c.getMeshID();
360 for (std::size_t j = 0; j <
c.getNumberOfNodes(); j++)
365 const bool is_ghost = partitioned_mesh.
isGhostNode(
369 _ghosts_indices.push_back(global_index);
370 global_index = -global_index;
373 if (global_index == 0)
375 global_index = -num_unknowns;
384 comp_id, global_index));
GlobalMatrix::IndexType GlobalIndexType
Definition of mesh class for partitioned mesh (by node) for parallel computing within the framework o...
std::size_t getID() const
A subset of nodes on a single mesh.
Mesh const & getMesh() const
std::size_t getMeshID() const
return this mesh ID
std::vector< Node * > const & getNodes() const
const std::string getName() const
Get name of the mesh.
Properties & getProperties()
std::vector< Element const * > const & getElementsConnectedToNode(std::size_t node_id) const
const Node * getNode(std::size_t idx) const
Get the node with the given index.
bool isGhostNode(const std::size_t node_id) const
Check whether a node with ID of node_id is a ghost node.
std::size_t getGlobalNodeID(const std::size_t node_id) const
Get the global node ID of a node with its local ID.
std::size_t getNumberOfGlobalNodes() const
Get the number of all nodes of the global mesh.
bool isForSingleThread() const
Multidirectional mapping between mesh entities and degrees of freedom.
void createParallelMeshComponentMap(std::vector< MeshLib::MeshSubset > const &components, ComponentOrder order)
std::vector< int > getComponentIDs(const Location &l) const
MeshComponentMap(std::vector< MeshLib::MeshSubset > const &components, ComponentOrder order)
GlobalIndexType getGlobalIndex(Location const &l, int const comp_id) const
detail::Line getLine(Location const &l, int const comp_id) const
GlobalIndexType getLocalIndex(Location const &l, int const comp_id, std::size_t const range_begin, std::size_t const range_end) const
std::vector< GlobalIndexType > getGlobalIndices(const Location &l) const
MeshComponentMap getSubset(std::vector< MeshLib::MeshSubset > const &bulk_mesh_subsets, MeshLib::MeshSubset const &new_mesh_subset, std::vector< int > const &new_global_component_ids) const
void renumberByLocation(GlobalIndexType offset=0)
static NUMLIB_EXPORT GlobalIndexType const nop
std::vector< GlobalIndexType > getGlobalIndicesByComponent(const std::vector< Location > &ls) const
void createSerialMeshComponentMap(std::vector< MeshLib::MeshSubset > const &components, ComponentOrder order)
std::vector< GlobalIndexType > getGlobalIndicesByLocation(const std::vector< Location > &ls) const
TemplateElement< MeshLib::LineRule2 > Line
bool isBaseNode(Node const &node, std::vector< Element const * > const &elements_connected_to_node)
boost::multi_index::multi_index_container< Line, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< ByLocationAndComponent >, boost::multi_index::identity< Line >, LineByLocationAndComponentComparator >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< ByLocation >, boost::multi_index::identity< Line >, LineByLocationComparator >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< ByComponent >, boost::multi_index::member< Line, int, &Line::comp_id > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< ByGlobalIndex >, boost::multi_index::member< Line, GlobalIndexType, &Line::global_index > >> > ComponentGlobalIndexDict
ComponentOrder
Ordering of components in global matrix/vector.
@ BY_LOCATION
Ordering data by spatial location.
GlobalIndexType global_index