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

[AsmL] Add variable_id to LocalToGlobalIdxMap.

Update the constructors, getGlobalIndex(), and meshGetSubsets()
to include the variable_id.

The global component offsets for each variable are
stored in the _variable_component_offset.
parent ac990b1a
No related branches found
No related tags found
No related merge requests found
......@@ -53,27 +53,40 @@ LocalToGlobalIndexMap::LocalToGlobalIndexMap(
// For all MeshSubsets and each of their MeshSubset's and each element
// of that MeshSubset save a line of global indices.
unsigned comp_id = 0;
for (auto const& mss : _mesh_subsets)
_variable_component_offsets.reserve(_mesh_subsets.size());
std::size_t offset = 0;
for (int variable_id = 0; variable_id < _mesh_subsets.size();
++variable_id)
{
for (MeshLib::MeshSubset const* const ms : *mss)
_variable_component_offsets.push_back(offset);
auto const& mss = *_mesh_subsets[variable_id];
for (int component_id = 0; component_id < mss.size();
++component_id)
{
std::size_t const mesh_id = ms->getMeshID();
MeshLib::MeshSubset const& ms = mss.getMeshSubset(component_id);
std::size_t const mesh_id = ms.getMeshID();
auto const global_component_id =
getGlobalComponent(variable_id, component_id);
findGlobalIndices(ms->elementsBegin(), ms->elementsEnd(), mesh_id,
comp_id, comp_id);
findGlobalIndices(ms.elementsBegin(), ms.elementsEnd(), mesh_id,
global_component_id, global_component_id);
}
++comp_id;
// increase by number of components of that variable
offset += mss.size();
}
}
LocalToGlobalIndexMap::LocalToGlobalIndexMap(
std::vector<std::unique_ptr<MeshLib::MeshSubsets>>&& mesh_subsets,
std::size_t const component_id,
int const component_id,
std::vector<MeshLib::Element*> const& elements,
NumLib::MeshComponentMap&& mesh_component_map)
: _mesh_subsets(std::move(mesh_subsets)),
_mesh_component_map(std::move(mesh_component_map))
_mesh_component_map(std::move(mesh_component_map)),
_variable_component_offsets(1, 0) // Single variable only.
{
// There is only on mesh_subsets in the vector _mesh_subsets.
assert(_mesh_subsets.size() == 1);
......@@ -93,22 +106,24 @@ LocalToGlobalIndexMap::LocalToGlobalIndexMap(
}
LocalToGlobalIndexMap* LocalToGlobalIndexMap::deriveBoundaryConstrainedMap(
std::size_t const variable_id,
std::size_t const component_id,
int const variable_id,
int const component_id,
std::unique_ptr<MeshLib::MeshSubsets>&& mesh_subsets,
std::vector<MeshLib::Element*> const& elements) const
{
DBUG("Construct reduced local to global index map.");
// Create a subset of the current mesh component map.
// TODO Lookup the (global) component id for given variable and component
// ids.
auto const global_component_id =
getGlobalComponent(variable_id, component_id);
auto mesh_component_map =
_mesh_component_map.getSubset(component_id, *mesh_subsets);
_mesh_component_map.getSubset(global_component_id, *mesh_subsets);
std::vector<std::unique_ptr<MeshLib::MeshSubsets>> all_mesh_subsets;
all_mesh_subsets.emplace_back(std::move(mesh_subsets));
return new LocalToGlobalIndexMap(std::move(all_mesh_subsets), component_id,
elements, std::move(mesh_component_map));
return new LocalToGlobalIndexMap(std::move(all_mesh_subsets),
global_component_id, elements,
std::move(mesh_component_map));
}
std::size_t
......
......@@ -54,8 +54,8 @@ public:
///
/// \note The elements are not necessarily those used in the mesh_subsets.
LocalToGlobalIndexMap* deriveBoundaryConstrainedMap(
std::size_t const variable_id,
std::size_t const component_id,
int const variable_id,
int const component_id,
std::unique_ptr<MeshLib::MeshSubsets>&& mesh_subsets,
std::vector<MeshLib::Element*> const& elements) const;
......@@ -80,8 +80,10 @@ public:
std::size_t getNumElementDOF(std::size_t const mesh_item_id) const;
GlobalIndexType getGlobalIndex(MeshLib::Location const& l,
std::size_t const c) const
int const variable_id,
int const component_id) const
{
auto const c = getGlobalComponent(variable_id, component_id);
return _mesh_component_map.getGlobalIndex(l, c);
}
......@@ -107,12 +109,10 @@ public:
range_end);
}
MeshLib::MeshSubsets const& getMeshSubsets(std::size_t const /* variable_id */,
std::size_t const component_id) const
MeshLib::MeshSubsets const& getMeshSubsets(int const variable_id,
int const component_id) const
{
// TODO The (global) component_id should be calculated (looked up) from
// variable_id and component_id.
return *_mesh_subsets[component_id];
return *_mesh_subsets[getGlobalComponent(variable_id, component_id)];
}
private:
......@@ -123,7 +123,7 @@ private:
/// this construtor.
explicit LocalToGlobalIndexMap(
std::vector<std::unique_ptr<MeshLib::MeshSubsets>>&& mesh_subsets,
std::size_t const component_id,
int const component_id,
std::vector<MeshLib::Element*> const& elements,
NumLib::MeshComponentMap&& mesh_component_map);
......@@ -133,6 +133,14 @@ private:
std::size_t const mesh_id,
const unsigned component_id, const unsigned comp_id_write);
/// The global component id for the specific variable (like velocity) and a
/// component (like x, or y, or z).
std::size_t getGlobalComponent(int const variable_id,
int const component_id) const
{
return _variable_component_offsets[variable_id] + component_id;
}
private:
/// A vector of mesh subsets for each process variables' components.
std::vector<std::unique_ptr<MeshLib::MeshSubsets>> const _mesh_subsets;
......@@ -147,6 +155,7 @@ private:
/// \see _rows
Table const& _columns = _rows;
std::vector<int> _variable_component_offsets;
#ifndef NDEBUG
/// Prints first rows of the table, every line, and the mesh component map.
friend std::ostream& operator<<(std::ostream& os, LocalToGlobalIndexMap const& map);
......
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