Skip to content
Snippets Groups Projects
Commit 34712f95 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[NL] Add multicomponent MeshComponentMap::getSubset().

parent 4a99140b
No related branches found
No related tags found
No related merge requests found
......@@ -176,6 +176,36 @@ MeshComponentMap MeshComponentMap::getSubset(
return MeshComponentMap(subset_dict, 1);
}
MeshComponentMap MeshComponentMap::getSubset(
std::vector<std::size_t> const& component_ids,
MeshLib::MeshSubsets const& mesh_subsets) const
{
assert(component_ids.size() <= _num_components);
// New dictionary for the subset.
ComponentGlobalIndexDict subset_dict;
for (auto const& mesh_subset : mesh_subsets)
{
std::size_t const mesh_id = mesh_subset->getMeshID();
// Lookup the locations in the current mesh component map and
// insert the full lines into the subset dictionary.
for (std::size_t j = 0; j < mesh_subset->getNumberOfNodes(); j++)
for (std::size_t component_id : component_ids)
subset_dict.insert(
getLine(Location(mesh_id, MeshLib::MeshItemType::Node,
mesh_subset->getNodeID(j)),
component_id));
for (std::size_t j = 0; j < mesh_subset->getNumberOfElements(); j++)
for (std::size_t component_id : component_ids)
subset_dict.insert(
getLine(Location(mesh_id, MeshLib::MeshItemType::Cell,
mesh_subset->getElementID(j)),
component_id));
}
return MeshComponentMap(subset_dict, 1);
}
void MeshComponentMap::renumberByLocation(GlobalIndexType offset)
{
GlobalIndexType global_index = offset;
......
......@@ -45,9 +45,24 @@ public:
/// The order (BY_LOCATION/BY_COMPONENT) of components is the same as of the
/// current map.
///
/// This is single-component version.
///
/// \param component_id The global components id.
/// \param components components that should remain in the created subset
MeshComponentMap getSubset(std::size_t const component_id,
MeshComponentMap getSubset(std::size_t const component_ids,
MeshLib::MeshSubsets const& components) const;
/// Creates a multi-component subset of the current mesh component map.
/// The order (BY_LOCATION/BY_COMPONENT) of components is the same as of the
/// current map.
///
/// This is multi-component version.
///
/// \note For each component the same mesh subset will be used.
///
/// \param component_ids The vector of global components id.
/// \param components components that should remain in the created subset
MeshComponentMap getSubset(std::vector<std::size_t> const& component_ids,
MeshLib::MeshSubsets const& components) const;
/// The number of dofs including the those located in the ghost nodes.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment