29 std::vector<MeshLib::MeshSubset>
const& components,
ComponentOrder order)
34 components[0].getMesh());
47 std::vector<MeshLib::MeshSubset>
const& components,
ComponentOrder order)
54 std::vector<MeshLib::MeshSubset>
const& bulk_mesh_subsets,
56 std::vector<int>
const& new_global_component_ids)
const
60 auto const first_mismatch =
61 std::adjacent_find(begin(bulk_mesh_subsets), end(bulk_mesh_subsets),
62 [](
auto const& a,
auto const& b)
63 {
return a.getMeshID() != b.getMeshID(); });
64 if (first_mismatch != end(bulk_mesh_subsets))
67 "Assumption in the MeshComponentMap violated. Expecting all of "
68 "mesh ids to be the same, but it is not true for "
69 "the mesh '{:s}' with id {:d}.",
70 first_mismatch->getMesh().getName(),
71 first_mismatch->getMeshID());
76 auto bulk_node_ids = [](
auto const& mesh)
79 if (bulk_node_ids_ptr ==
nullptr)
82 "Bulk node ids map expected in the construction of the mesh "
85 return *bulk_node_ids_ptr;
87 auto const& bulk_node_ids_map = bulk_node_ids(new_mesh_subset.
getMesh());
92 std::size_t
const new_mesh_id = new_mesh_subset.
getMeshID();
95 for (
auto*
const node : new_mesh_subset.
getNodes())
97 auto const node_id = node->getID();
108 bulk_node_ids_map[node_id]};
110 for (
auto component_id : new_global_component_ids)
112 auto const global_index =
114 if (global_index ==
nop)
119 "Could not find a global index for global component "
120 "{:d} for the mesh '{:s}', node {:d}, in the "
121 "corresponding bulk mesh '{:s}' and node {:d}. This "
122 "happens because the boundary mesh is larger than the "
123 "definition region of the bulk component, usually "
124 "because the geometry for the boundary condition is "
129 bulk_mesh_subsets.front().getMesh().getName(),
130 bulk_node_ids_map[node_id]);
134 subset_dict.insert({new_location, component_id, global_index});
146 for (
auto itr_mesh_item = m.begin(); itr_mesh_item != m.end();
149 Line pos = *itr_mesh_item;
151 m.replace(itr_mesh_item, pos);
158 auto const p = m.equal_range(
Line(l));
159 std::vector<int> vec_compID;
160 for (
auto itr = p.first; itr != p.second; ++itr)
162 vec_compID.push_back(itr->comp_id);
168 int const comp_id)
const
171 auto const itr = m.find(
Line(l, comp_id));
172 return itr != m.end() ? itr->global_index :
nop;
179 auto const p = m.equal_range(
Line(l));
180 std::vector<GlobalIndexType> global_indices;
181 for (
auto itr = p.first; itr != p.second; ++itr)
183 global_indices.push_back(itr->global_index);
185 return global_indices;
189 std::vector<Location>
const& ls)
const
194 std::vector<GlobalIndexType> global_indices;
195 global_indices.reserve(ls.size());
198 for (
const auto& l : ls)
200 auto const p = m.equal_range(
Line(l));
201 for (
auto itr = p.first; itr != p.second; ++itr)
203 global_indices.push_back(itr->global_index);
207 return global_indices;
211 std::vector<Location>
const& ls)
const
214 using CIPair = std::pair<int, GlobalIndexType>;
215 std::vector<CIPair> pairs;
216 pairs.reserve(ls.size());
220 for (
const auto& l : ls)
222 auto const p = m.equal_range(
Line(l));
223 for (
auto itr = p.first; itr != p.second; ++itr)
225 pairs.emplace_back(itr->comp_id, itr->global_index);
229 auto CIPairLess = [](CIPair
const& a, CIPair
const& b)
230 {
return a.first < b.first; };
233 if (!std::is_sorted(pairs.begin(), pairs.end(), CIPairLess))
235 std::stable_sort(pairs.begin(), pairs.end(), CIPairLess);
238 std::vector<GlobalIndexType> global_indices;
239 global_indices.reserve(pairs.size());
240 transform(cbegin(pairs), cend(pairs), back_inserter(global_indices),
241 [&](
const auto& pair) {
return pair.second; });
243 return global_indices;
249 std::size_t
const range_begin,
250 std::size_t
const range_end)
const
256 if (global_index ==
nop)
265 if (global_index >= 0)
266 return global_index - range_begin;
281 auto const ghost_index_it = std::find(
285 OGS_FATAL(
"index {:d} not found in ghost_indices", real_global_index);
290 return range_end - range_begin +
297 std::vector<MeshLib::MeshSubset>
const& components,
ComponentOrder order)
302 for (
auto const& c : components)
304 std::size_t
const mesh_id = c.getMeshID();
305 auto const& mesh_subset_nodes = c.getNodes();
307 for (std::size_t j = 0; j < mesh_subset_nodes.size(); j++)
309 auto const node_id = mesh_subset_nodes[j]->getID();
312 comp_id, global_index++));
328 std::size_t
const global_node_id,
329 int const number_of_components_at_base_node,
330 int const number_of_components_at_high_order_node,
331 int const component_id_at_base_node,
332 int const component_id_at_high_order_node,
333 bool const is_base_node)
335 int const partition_id = partitioned_mesh.
getPartitionID(global_node_id);
337 auto const n_total_active_base_nodes_before_this_rank =
340 auto const n_total_active_high_order_nodes_before_this_rank =
343 auto const node_id_offset =
344 n_total_active_base_nodes_before_this_rank +
345 n_total_active_high_order_nodes_before_this_rank;
347 auto const index_offset = n_total_active_base_nodes_before_this_rank *
348 number_of_components_at_base_node +
349 n_total_active_high_order_nodes_before_this_rank *
350 number_of_components_at_high_order_node;
355 index_offset + (global_node_id - node_id_offset) *
356 number_of_components_at_base_node) +
357 component_id_at_base_node;
360 int const n_active_base_nodes_of_this_partition =
362 n_total_active_base_nodes_before_this_rank;
379 n_active_base_nodes_of_this_partition *
380 number_of_components_at_base_node +
381 (global_node_id - node_id_offset -
382 n_active_base_nodes_of_this_partition) *
383 number_of_components_at_high_order_node) +
384 component_id_at_high_order_node;
388 std::vector<MeshLib::MeshSubset>
const& components,
ComponentOrder order)
396 "Global index in the system of equations can only be numbered by "
397 "the order type of ComponentOrder::BY_LOCATION");
402 components[0].getMesh());
408 int components_at_high_order_nodes = 0;
409 for (
auto const& c : components)
413 components_at_high_order_nodes++;
424 int const n_components = components.size();
427 int comp_id_at_high_order_node = 0;
430 for (
auto const& c : components)
433 &c.getMesh()) !=
nullptr);
434 std::size_t
const mesh_id = c.getMeshID();
437 const auto& sub_mesh_nodes = c.getNodes();
440 for (std::size_t j = 0; j < sub_mesh_nodes.size(); j++)
442 const auto node_id = sub_mesh_nodes[j]->getID();
443 const bool is_base_node =
446 *sub_mesh_nodes[j]));
448 const auto global_node_id =
451 (!c.useTaylorHoodElements())
453 n_components * global_node_id + comp_id)
455 partitioned_mesh, global_node_id, n_components,
456 components_at_high_order_nodes, comp_id,
457 comp_id_at_high_order_node, is_base_node);
458 const bool is_ghost = partitioned_mesh.
isGhostNode(node_id);
462 global_index = -global_index;
465 if (global_index == 0)
467 global_index = -num_unknowns;
477 comp_id, global_index));
480 bool const use_whole_nodes =
485 comp_id_at_high_order_node++;
GlobalMatrix::IndexType GlobalIndexType
Definition of mesh class for partitioned mesh (by node) for parallel computing within the framework o...
Definition of the Node class.
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.
std::size_t getNumberOfNodes() const
Get the number of nodes.
std::vector< Element const * > const & getElementsConnectedToNode(std::size_t node_id) const
std::size_t getPartitionID(const std::size_t global_node_id) const
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 getNumberOfRegularHighOrderNodesAtRank(int const partition_id) const
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
std::size_t getNumberOfGlobalBaseNodes() const
Get the number of nodes of the global mesh for linear elements.
std::size_t getNumberOfRegularBaseNodesAtRank(int const partition_id) 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
MeshLib::Location Location
std::size_t _num_global_dof
Number of global unknowns. Used internally only.
MeshComponentMap(std::vector< MeshLib::MeshSubset > const &components, ComponentOrder order)
GlobalIndexType getGlobalIndex(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
static constexpr NUMLIB_EXPORT GlobalIndexType const nop
detail::ComponentGlobalIndexDict _dict
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)
std::size_t _num_local_dof
std::vector< GlobalIndexType > _ghosts_indices
Global ID for ghost entries.
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
bool isBaseNode(Node const &node, std::vector< Element const * > const &elements_connected_to_node)
PropertyVector< std::size_t > const * bulkNodeIDs(Mesh const &mesh)
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
GlobalIndexType getGlobalIndexWithTaylorHoodElement(MeshLib::NodePartitionedMesh const &partitioned_mesh, std::size_t const global_node_id, int const number_of_components_at_base_node, int const number_of_components_at_high_order_node, int const component_id_at_base_node, int const component_id_at_high_order_node, bool const is_base_node)
ComponentOrder
Ordering of components in global matrix/vector.
@ BY_LOCATION
Ordering data by spatial location.
GlobalIndexType global_index