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 23 of file DOFTableUtil.cpp.

26{
27#ifdef USE_PETSC
28 x.setLocalAccessibleVector();
29#endif
30
31 double res = 0.0;
32 auto const& ms = dof_table.getMeshSubset(global_component);
33
34 assert(ms.getMeshID() == mesh.getID());
35 for (MeshLib::Node const* node : ms.getNodes())
36 {
37 auto const value = getNonGhostNodalValue(
38 x, mesh, dof_table, node->getID(), global_component);
39 res = calculate_norm(res, value);
40 }
41 return res;
42}
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 44 of file DOFTableUtil.cpp.

46{
47 double res =
48 norm(x, global_component, dof_table, mesh,
49 [](double res, double value) { return res + std::abs(value); });
50
51#ifdef USE_PETSC
52 double global_result = 0.0;
53 MPI_Allreduce(&res, &global_result, 1, MPI_DOUBLE, MPI_SUM,
54 PETSC_COMM_WORLD);
55 res = global_result;
56#endif
57 return res;
58}

References 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 60 of file DOFTableUtil.cpp.

62{
63 double res =
64 norm(x, global_component, dof_table, mesh,
65 [](double res, double value) { return res + value * value; });
66
67#ifdef USE_PETSC
68 double global_result = 0.0;
69 MPI_Allreduce(&res, &global_result, 1, MPI_DOUBLE, MPI_SUM,
70 PETSC_COMM_WORLD);
71 res = global_result;
72#endif
73 return std::sqrt(res);
74}

References 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 76 of file DOFTableUtil.cpp.

79{
80 double res = norm(x, global_component, dof_table, mesh,
81 [](double res, double value)
82 { return std::max(res, std::abs(value)); });
83
84#ifdef USE_PETSC
85 double global_result = 0.0;
86 MPI_Allreduce(&res, &global_result, 1, MPI_DOUBLE, MPI_MAX,
87 PETSC_COMM_WORLD);
88 res = global_result;
89#endif
90 return res;
91}

References NumLib::norm(), and normInfinity().

Referenced by normInfinity().