16template <
typename CalculateNorm>
19 CalculateNorm calculate_norm)
22 x.setLocalAccessibleVector();
33 res = calculate_norm(res, value);
42 norm(x, global_component, dof_table,
43 [](
double res,
double value) {
return res + std::abs(value); });
55 norm(x, global_component, dof_table,
56 [](
double res,
double value) {
return res + value * value; });
62 return std::sqrt(res);
69 norm(x, global_component, dof_table, [](
double res,
double value)
70 {
return std::max(res, std::abs(value)); });
82 std::size_t
const global_component_id)
84 auto const index = dof_table.
getGlobalIndex(location, global_component_id);
97 std::size_t
const global_component_id)
99 auto const index = dof_table.
getGlobalIndex(location, global_component_id);
106 std::size_t
const mesh_item_id,
109 assert(dof_table.
size() > mesh_item_id);
110 std::vector<GlobalIndexType> indices;
116 auto const& idcs = dof_table(mesh_item_id, c).rows;
117 indices.reserve(indices.size() + idcs.size());
118 indices.insert(indices.end(), idcs.begin(), idcs.end());
125 std::size_t
const variable_id,
126 std::size_t
const component_id,
127 std::size_t
const bulk_element_id,
132 std::vector<GlobalIndexType> indices;
133 auto const& bulk_element = ms.
getElement(bulk_element_id);
134 auto const global_component =
136 auto const mesh_id = ms.getID();
144 indices.push_back(dof_table.
getGlobalIndex(loc, global_component));
150 std::size_t
const id,
152 std::vector<GlobalIndexType>& indices)
154 assert(dof_table.
size() >
id);
161 auto const& idcs = dof_table(
id, c).rows;
162 indices.reserve(indices.size() + idcs.size());
163 indices.insert(indices.end(), idcs.begin(), idcs.end());
176 return norm1(x, global_component, dof_table);
178 return norm2(x, global_component, dof_table);
180 return normInfinity(x, global_component, dof_table);
182 OGS_FATAL(
"An invalid norm type has been passed.");
187 std::size_t
const mesh_item_id,
188 std::vector<NumLib::LocalToGlobalIndexMap const*>
const& dof_tables,
189 std::vector<GlobalVector*>
const& x)
191 Eigen::VectorXd local_x_vec;
193 auto const n_processes = x.size();
194 for (std::size_t process_id = 0; process_id < n_processes; ++process_id)
198 assert(!indices.empty());
199 auto const last = local_x_vec.size();
200 local_x_vec.conservativeResize(last + indices.size());
201 auto const local_solution = x[process_id]->get(indices);
202 assert(indices.size() == local_solution.size());
203 local_x_vec.tail(local_solution.size()).noalias() =
MathLib::EigenVector GlobalVector
double get(IndexType rowId) const
get entry
Mesh const & getMesh() const
const Element * getElement(std::size_t idx) const
Get the element with the given index.
int getGlobalComponent(int const variable_id, int const component_id) const
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 constexpr NUMLIB_EXPORT GlobalIndexType const nop
static T allreduce(T const &value, MPI_Op const &mpi_op, Mpi const &mpi)
Eigen::Map< const Vector > toVector(std::vector< double > const &data, Eigen::VectorXd::Index size)
Creates an Eigen mapped vector from the given data vector.
constexpr ranges::views::view_closure ids
For an element of a range view return its id.
auto meshLocations(Mesh const &mesh, MeshItemType const item_type)
double normInfinity(GlobalVector const &x, unsigned const global_component, LocalToGlobalIndexMap const &dof_table)
double norm1(GlobalVector const &x, unsigned const global_component, LocalToGlobalIndexMap const &dof_table)
double norm2(GlobalVector const &x, unsigned const global_component, LocalToGlobalIndexMap const &dof_table)
double getNodalValue(GlobalVector const &x, MeshLib::Location const &location, NumLib::LocalToGlobalIndexMap const &dof_table, 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)
Eigen::VectorXd getLocalX(std::size_t const mesh_item_id, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_tables, std::vector< GlobalVector * > const &x)
double getNonGhostNodalValue(GlobalVector const &x, MeshLib::Location const &location, NumLib::LocalToGlobalIndexMap const &dof_table, std::size_t const global_component_id)
double norm(GlobalVector const &x, unsigned const global_component, MathLib::VecNormType norm_type, LocalToGlobalIndexMap const &dof_table)