19 template <
typename CalculateNorm>
22 CalculateNorm calculate_norm)
25 x.setLocalAccessibleVector();
31 assert(ms.getMeshID() == mesh.
getID());
35 x, mesh, dof_table, node->getID(), global_component);
36 res = calculate_norm(res, value);
45 norm(x, global_component, dof_table, mesh,
46 [](
double res,
double value) {
return res + std::abs(value); });
49 double global_result = 0.0;
50 MPI_Allreduce(&res, &global_result, 1, MPI_DOUBLE, MPI_SUM,
61 norm(x, global_component, dof_table, mesh,
62 [](
double res,
double value) {
return res + value * value; });
65 double global_result = 0.0;
66 MPI_Allreduce(&res, &global_result, 1, MPI_DOUBLE, MPI_SUM,
70 return std::sqrt(res);
77 double res =
norm(x, global_component, dof_table, mesh,
78 [](
double res,
double value)
79 {
return std::max(res, std::abs(value)); });
82 double global_result = 0.0;
83 MPI_Allreduce(&res, &global_result, 1, MPI_DOUBLE, MPI_MAX,
93 std::size_t
const node_id,
94 std::size_t
const global_component_id)
99 auto const index = dof_table.
getGlobalIndex(l, global_component_id);
112 std::size_t
const node_id,
113 std::size_t
const global_component_id)
118 auto const index = dof_table.
getGlobalIndex(l, global_component_id);
125 std::size_t
const mesh_item_id,
128 assert(dof_table.
size() > mesh_item_id);
129 std::vector<GlobalIndexType> indices;
135 auto const& idcs = dof_table(mesh_item_id,
c).rows;
136 indices.reserve(indices.size() + idcs.size());
137 indices.insert(indices.end(), idcs.begin(), idcs.end());
144 std::size_t
const id,
146 std::vector<GlobalIndexType>& indices)
148 assert(dof_table.
size() >
id);
155 auto const& idcs = dof_table(
id,
c).rows;
156 indices.reserve(indices.size() + idcs.size());
157 indices.insert(indices.end(), idcs.begin(), idcs.end());
170 return norm1(x, global_component, dof_table, mesh);
172 return norm2(x, global_component, dof_table, mesh);
174 return normInfinity(x, global_component, dof_table, mesh);
176 OGS_FATAL(
"An invalid norm type has been passed.");
Global vector based on Eigen vector.
double get(IndexType rowId) const
get entry
std::size_t getID() const
Get id of the mesh.
MathLib::RowColumnIndices< GlobalIndexType > RowColumnIndices
GlobalIndexType getGlobalIndex(MeshLib::Location const &l, int const variable_id, int const component_id) const
MeshLib::MeshSubset const & getMeshSubset(int const variable_id, int const component_id) const
int getNumberOfGlobalComponents() const
static NUMLIB_EXPORT GlobalIndexType const nop
VecNormType
Norm type. Not declared as class type in order to use the members as integers.
double norm1(GlobalVector const &x, unsigned const global_component, LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh)
double normInfinity(GlobalVector const &x, unsigned const global_component, LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh)
double norm2(GlobalVector const &x, unsigned const global_component, LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh)
double getNodalValue(GlobalVector const &x, MeshLib::Mesh const &mesh, NumLib::LocalToGlobalIndexMap const &dof_table, std::size_t const node_id, std::size_t const global_component_id)
double norm(GlobalVector const &x, unsigned const global_component, MathLib::VecNormType norm_type, LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh)
double getNonGhostNodalValue(GlobalVector const &x, MeshLib::Mesh const &mesh, NumLib::LocalToGlobalIndexMap const &dof_table, std::size_t const node_id, std::size_t const global_component_id)
std::vector< GlobalIndexType > getIndices(std::size_t const mesh_item_id, NumLib::LocalToGlobalIndexMap const &dof_table)
NumLib::LocalToGlobalIndexMap::RowColumnIndices getRowColumnIndices(std::size_t const id, NumLib::LocalToGlobalIndexMap const &dof_table, std::vector< GlobalIndexType > &indices)