OGS
NumLib::anonymous_namespace{DOFTableUtil.cpp} Namespace Reference

Functions

template<typename CalculateNorm >
double norm (GlobalVector const &x, unsigned const global_component, LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh, CalculateNorm calculate_norm)
 
double norm1 (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 normInfinity (GlobalVector const &x, unsigned const global_component, LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh)
 

Function Documentation

◆ norm()

template<typename CalculateNorm >
double NumLib::anonymous_namespace{DOFTableUtil.cpp}::norm ( GlobalVector const & x,
unsigned const global_component,
LocalToGlobalIndexMap const & dof_table,
MeshLib::Mesh const & mesh,
CalculateNorm calculate_norm )

Definition at line 24 of file DOFTableUtil.cpp.

27{
28#ifdef USE_PETSC
29 x.setLocalAccessibleVector();
30#endif
31
32 double res = 0.0;
33 auto const& ms = dof_table.getMeshSubset(global_component);
34
35 assert(ms.getMeshID() == mesh.getID());
36 for (MeshLib::Node const* node : ms.getNodes())
37 {
38 auto const value = getNonGhostNodalValue(
39 x, mesh, dof_table, node->getID(), global_component);
40 res = calculate_norm(res, value);
41 }
42 return res;
43}
std::vector< std::size_t > getNodes(GeoLib::Point const &pnt, std::vector< MeshLib::Node * > const &nodes, MeshLib::PropertyVector< int > const &mat_ids, std::pair< int, int > const &mat_limits, std::pair< double, double > const &elevation_limits, 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)

References MeshLib::Mesh::getID(), NumLib::LocalToGlobalIndexMap::getMeshSubset(), and NumLib::getNonGhostNodalValue().

◆ norm1()

double NumLib::anonymous_namespace{DOFTableUtil.cpp}::norm1 ( GlobalVector const & x,
unsigned const global_component,
LocalToGlobalIndexMap const & dof_table,
MeshLib::Mesh const & mesh )

Definition at line 45 of file DOFTableUtil.cpp.

47{
48 double const res =
49 norm(x, global_component, dof_table, mesh,
50 [](double res, double value) { return res + std::abs(value); });
51
52#ifdef USE_PETSC
53 return BaseLib::MPI::allreduce(res, MPI_SUM, BaseLib::MPI::Mpi{});
54#endif
55 return res;
56}
static T allreduce(T const &value, MPI_Op const &mpi_op, Mpi const &mpi)
Definition MPI.h:128

References BaseLib::MPI::allreduce(), and NumLib::norm().

◆ norm2()

double NumLib::anonymous_namespace{DOFTableUtil.cpp}::norm2 ( GlobalVector const & x,
unsigned const global_component,
LocalToGlobalIndexMap const & dof_table,
MeshLib::Mesh const & mesh )

Definition at line 58 of file DOFTableUtil.cpp.

60{
61 double const res =
62 norm(x, global_component, dof_table, mesh,
63 [](double res, double value) { return res + value * value; });
64
65#ifdef USE_PETSC
66 return std::sqrt(
68#endif
69 return std::sqrt(res);
70}

References BaseLib::MPI::allreduce(), and NumLib::norm().

◆ normInfinity()

double NumLib::anonymous_namespace{DOFTableUtil.cpp}::normInfinity ( GlobalVector const & x,
unsigned const global_component,
LocalToGlobalIndexMap const & dof_table,
MeshLib::Mesh const & mesh )

Definition at line 72 of file DOFTableUtil.cpp.

75{
76 double const res =
77 norm(x, global_component, dof_table, mesh, [](double res, double value)
78 { return std::max(res, std::abs(value)); });
79
80#ifdef USE_PETSC
81 return BaseLib::MPI::allreduce(res, MPI_MAX, BaseLib::MPI::Mpi{});
82#endif
83 return res;
84}

References BaseLib::MPI::allreduce(), NumLib::norm(), and normInfinity().

Referenced by normInfinity().