23template <
typename CalculateNorm>
26 CalculateNorm calculate_norm)
29 x.setLocalAccessibleVector();
40 res = calculate_norm(res, value);
45double norm1(
GlobalVector const& x,
unsigned const global_component,
49 norm(x, global_component, dof_table,
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,
63 [](
double res,
double value) {
return res + value * value; });
69 return std::sqrt(res);
76 norm(x, global_component, dof_table, [](
double res,
double value)
77 {
return std::max(res, std::abs(value)); });
89 std::size_t
const global_component_id)
91 auto const index = dof_table.
getGlobalIndex(location, global_component_id);
104 std::size_t
const global_component_id)
106 auto const index = dof_table.
getGlobalIndex(location, global_component_id);
113 std::size_t
const mesh_item_id,
116 assert(dof_table.
size() > mesh_item_id);
117 std::vector<GlobalIndexType> indices;
123 auto const& idcs = dof_table(mesh_item_id, c).rows;
124 indices.reserve(indices.size() + idcs.size());
125 indices.insert(indices.end(), idcs.begin(), idcs.end());
132 std::size_t
const id,
134 std::vector<GlobalIndexType>& indices)
136 assert(dof_table.
size() >
id);
143 auto const& idcs = dof_table(
id, c).rows;
144 indices.reserve(indices.size() + idcs.size());
145 indices.insert(indices.end(), idcs.begin(), idcs.end());
158 return norm1(x, global_component, dof_table);
160 return norm2(x, global_component, dof_table);
162 return normInfinity(x, global_component, dof_table);
164 OGS_FATAL(
"An invalid norm type has been passed.");
169 std::size_t
const mesh_item_id,
170 std::vector<NumLib::LocalToGlobalIndexMap const*>
const& dof_tables,
171 std::vector<GlobalVector*>
const& x)
173 Eigen::VectorXd local_x_vec;
175 auto const n_processes = x.size();
176 for (std::size_t process_id = 0; process_id < n_processes; ++process_id)
180 assert(!indices.empty());
181 auto const last = local_x_vec.size();
182 local_x_vec.conservativeResize(last + indices.size());
183 auto const local_solution = x[process_id]->get(indices);
184 assert(indices.size() == local_solution.size());
185 local_x_vec.tail(local_solution.size()).noalias() =
Global vector based on Eigen vector.
double get(IndexType rowId) const
get entry
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.
auto meshLocations(Mesh const &mesh, MeshItemType const item_type)
double normInfinity(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)