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

clang-format

parent d81d6c23
No related branches found
No related tags found
No related merge requests found
......@@ -166,4 +166,4 @@ private:
std::size_t _n_active_nodes;
};
} // namespace MeshLib
} // namespace MeshLib
......@@ -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
......@@ -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
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