23template <
typename CalculateNorm>
26 CalculateNorm calculate_norm)
29 x.setLocalAccessibleVector();
35 assert(ms.getMeshID() == mesh.
getID());
39 x, mesh, dof_table, node->getID(), global_component);
40 res = calculate_norm(res, value);
45double norm1(
GlobalVector const& x,
unsigned const global_component,
49 norm(x, global_component, dof_table, mesh,
50 [](
double res,
double value) {
return res + std::abs(value); });
58double norm2(
GlobalVector const& x,
unsigned const global_component,
62 norm(x, global_component, dof_table, mesh,
63 [](
double res,
double value) {
return res + value * value; });
69 return std::sqrt(res);
77 norm(x, global_component, dof_table, mesh, [](
double res,
double value)
78 {
return std::max(res, std::abs(value)); });
89 std::size_t
const node_id,
90 std::size_t
const global_component_id)
95 auto const index = dof_table.
getGlobalIndex(l, global_component_id);
108 std::size_t
const node_id,
109 std::size_t
const global_component_id)
114 auto const index = dof_table.
getGlobalIndex(l, global_component_id);
121 std::size_t
const mesh_item_id,
124 assert(dof_table.
size() > mesh_item_id);
125 std::vector<GlobalIndexType> indices;
131 auto const& idcs = dof_table(mesh_item_id, c).rows;
132 indices.reserve(indices.size() + idcs.size());
133 indices.insert(indices.end(), idcs.begin(), idcs.end());
140 std::size_t
const id,
142 std::vector<GlobalIndexType>& indices)
144 assert(dof_table.
size() >
id);
151 auto const& idcs = dof_table(
id, c).rows;
152 indices.reserve(indices.size() + idcs.size());
153 indices.insert(indices.end(), idcs.begin(), idcs.end());
166 return norm1(x, global_component, dof_table, mesh);
168 return norm2(x, global_component, dof_table, mesh);
170 return normInfinity(x, global_component, dof_table, mesh);
172 OGS_FATAL(
"An invalid norm type has been passed.");
177 std::size_t
const mesh_item_id,
178 std::vector<NumLib::LocalToGlobalIndexMap const*>
const& dof_tables,
179 std::vector<GlobalVector*>
const& x)
181 Eigen::VectorXd local_x_vec;
183 auto const n_processes = x.size();
184 for (std::size_t process_id = 0; process_id < n_processes; ++process_id)
188 assert(!indices.empty());
189 auto const last = local_x_vec.size();
190 local_x_vec.conservativeResize(last + indices.size());
191 auto const local_solution = x[process_id]->get(indices);
192 assert(indices.size() == local_solution.size());
193 local_x_vec.tail(local_solution.size()).noalias() =
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 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.
double normInfinity(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)
Eigen::VectorXd getLocalX(std::size_t const mesh_item_id, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_tables, std::vector< GlobalVector * > const &x)