libMesh
Loading...
Searching...
No Matches
Functions
meshnorm.C File Reference

Go to the source code of this file.

Functions

void output_norms (const System &sys, const NumericVector< Number > &vec, const std::string &vecname)
 
int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 52 of file meshnorm.C.

53{
54 LibMeshInit init (argc, argv);
55
56 Mesh mesh(init.comm());
58
59 libMesh::out << "Usage: " << argv[0]
60 << " mesh solution" << std::endl;
61
62 libMesh::out << "Loading..." << std::endl;
63
64 mesh.read(argv[1]);
65 libMesh::out << "Loaded mesh " << argv[1] << std::endl;
67
68 es.read(argv[2], EquationSystems::READ_HEADER |
72 libMesh::out << "Loaded solution " << argv[2] << std::endl;
73 es.print_info();
74
76
77 for (unsigned int i = 0; i != es.n_systems(); ++i)
78 {
79 System & sys = es.get_system(i);
80
81 output_norms(sys, *sys.solution, std::string("solution"));
82 for (unsigned int j = 0; j != sys.n_vectors(); ++j)
83 output_norms(sys, sys.get_vector(j), sys.vector_name(j));
84 }
85}
std::streamsize precision() const
Get the associated write precision.
This is the EquationSystems class.
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
Definition libmesh.h:92
virtual void read(const std::string &name, void *mesh_data=nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false, bool skip_detect_interior_parents=false)=0
Interfaces for reading/writing a mesh to/from a file.
void print_info(std::ostream &os=libMesh::out, const unsigned int verbosity=0, const bool global=true) const
Prints relevant information about the mesh.
Definition mesh_base.C:1755
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition mesh.h:51
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition system.h:100
unsigned int n_vectors() const
Definition system.h:2499
const std::string & vector_name(const unsigned int vec_num) const
Definition system.C:971
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition system.h:1655
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition system.C:931
MeshBase & mesh
void output_norms(const System &sys, const NumericVector< Number > &vec, const std::string &vecname)
Definition meshnorm.C:29
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
OStreamProxy out

References libMesh::EquationSystems::get_system(), libMesh::System::get_vector(), main(), mesh, libMesh::EquationSystems::n_systems(), libMesh::System::n_vectors(), libMesh::out, output_norms(), libMesh::BasicOStreamProxy< charT, traits >::precision(), libMesh::EquationSystems::print_info(), libMesh::MeshBase::print_info(), libMesh::MeshBase::read(), libMesh::EquationSystems::read(), libMesh::EquationSystems::READ_ADDITIONAL_DATA, libMesh::EquationSystems::READ_BASIC_ONLY, libMesh::EquationSystems::READ_DATA, libMesh::EquationSystems::READ_HEADER, libMesh::System::solution, and libMesh::System::vector_name().

◆ output_norms()

void output_norms ( const System sys,
const NumericVector< Number > &  vec,
const std::string &  vecname 
)

Definition at line 29 of file meshnorm.C.

30{
31 for (unsigned int k = 0; k != sys.n_vars(); ++k)
32 {
33 libMesh::out << "Norms in system " << sys.name() <<
34 ", vector " << vecname <<
35 ", variable " << sys.variable_name(k) << ":" << std::endl;
36 Real l1_vecnorm = sys.calculate_norm(vec, k, DISCRETE_L1);
37 libMesh::out << "l1 norm: " << l1_vecnorm << std::endl;
38 if (l1_vecnorm)
39 {
40 libMesh::out << "l2 norm: " << sys.calculate_norm(vec, k, DISCRETE_L2) << std::endl;
41 libMesh::out << "linf norm: " << sys.calculate_norm(vec, k, DISCRETE_L_INF) << std::endl;
42 libMesh::out << "H1 norm: " << sys.calculate_norm(vec, k, H1) << std::endl;
43 libMesh::out << "L1 norm: " << sys.calculate_norm(vec, k, L1) << std::endl;
44 libMesh::out << "L2 norm: " << sys.calculate_norm(vec, k, L2) << std::endl;
45 libMesh::out << "Linf norm: " << sys.calculate_norm(vec, k, L_INF) << std::endl;
46 libMesh::out << "H1 seminorm: " << sys.calculate_norm(vec, k, H1_SEMINORM) << std::endl;
47 libMesh::out << "H1 norm: " << sys.calculate_norm(vec, k, H1) << std::endl;
48 }
49 }
50}
const std::string & name() const
Definition system.h:2385
const std::string & variable_name(const unsigned int i) const
Definition system.C:2679
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
Definition system.C:1511
unsigned int n_vars() const
Definition system.C:2674
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

References libMesh::System::calculate_norm(), libMesh::DISCRETE_L1, libMesh::DISCRETE_L2, libMesh::DISCRETE_L_INF, libMesh::H1, libMesh::H1_SEMINORM, libMesh::L1, libMesh::L2, libMesh::L_INF, libMesh::System::n_vars(), libMesh::System::name(), libMesh::out, libMesh::Real, and libMesh::System::variable_name().

Referenced by main().