https://mooseframework.inl.gov
MeshInfo.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "GeneralReporter.h"
13 
14 namespace libMesh
15 {
16 class EquationSystems;
17 class System;
18 class MeshBase;
19 }
20 
24 class MeshInfo : public GeneralReporter
25 {
26 public:
29  virtual void initialize() override {}
30  virtual void finalize() override {}
31  virtual void execute() override;
32 
36  struct SidesetInfo
37  {
39  std::string name;
40  std::vector<std::pair<dof_id_type, unsigned int>> sides;
41  };
42 
47  {
49  std::string name;
50  std::vector<dof_id_type> elems;
51  };
52 
53 protected:
55 
56  // Reporter values to return
57  unsigned int & _num_dofs;
58  unsigned int & _num_dofs_nl;
59  unsigned int & _num_dofs_aux;
60  unsigned int & _num_dofs_constrained;
61  unsigned int & _num_elem;
62  unsigned int & _num_node;
63  unsigned int & _num_local_dofs;
64  unsigned int & _num_local_dofs_nl;
65  unsigned int & _num_local_dofs_aux;
66  unsigned int & _num_local_elem;
67  unsigned int & _num_local_node;
68  std::map<BoundaryID, SidesetInfo> & _local_sidesets;
69  std::map<BoundaryID, SidesetInfo> & _local_sideset_elems;
70  std::map<BoundaryID, SidesetInfo> & _sidesets;
71  std::map<BoundaryID, SidesetInfo> & _sideset_elems;
72  std::map<SubdomainID, SubdomainInfo> & _local_subdomains;
73  std::map<SubdomainID, SubdomainInfo> & _local_subdomain_elems;
74  std::map<SubdomainID, SubdomainInfo> & _subdomains;
75  std::map<SubdomainID, SubdomainInfo> & _subdomain_elems;
76 
77  // Helper to perform optional declaration based on "_items"
78  template <typename T>
79  T & declareHelper(const std::string & item_name, const ReporterMode mode);
80 
81 private:
86 
91 };
92 
93 template <typename T>
94 T &
95 MeshInfo::declareHelper(const std::string & item_name, const ReporterMode mode)
96 {
97  return (!_items.isValid() || _items.isValueSet(item_name))
98  ? declareValueByName<T>(item_name, mode)
99  : declareUnusedValue<T>();
100 }
101 
102 void to_json(nlohmann::json & json, const std::map<BoundaryID, MeshInfo::SidesetInfo> & sidesets);
103 void dataStore(std::ostream & stream, MeshInfo::SidesetInfo & sideset_info, void * context);
104 void dataLoad(std::istream & stream, MeshInfo::SidesetInfo & sideset_info, void * context);
105 
106 void to_json(nlohmann::json & json, const std::map<BoundaryID, MeshInfo::SubdomainInfo> & sidesets);
107 void dataStore(std::ostream & stream, MeshInfo::SubdomainInfo & sideset_info, void * context);
108 void dataLoad(std::istream & stream, MeshInfo::SubdomainInfo & sideset_info, void * context);
void dataStore(std::ostream &stream, MeshInfo::SidesetInfo &sideset_info, void *context)
Definition: MeshInfo.C:238
Helper struct for defining information about a single sideset.
Definition: MeshInfo.h:36
std::vector< dof_id_type > elems
Definition: MeshInfo.h:50
std::string name
Definition: MeshInfo.h:39
std::string name
Definition: MeshInfo.h:49
static InputParameters validParams()
Definition: MeshInfo.C:19
unsigned int & _num_local_elem
Definition: MeshInfo.h:66
void possiblyAddSidesetInfo()
Possibly add to _local_sidesets, _local_sideset_elems, _sidesets, and _sideset_elems.
Definition: MeshInfo.C:103
const libMesh::MeshBase & _mesh
Definition: MeshInfo.h:90
unsigned int & _num_dofs_constrained
Definition: MeshInfo.h:60
Reporter object that has a single execution of the "execute" method for for each execute flag...
virtual void execute() override
Execute method.
Definition: MeshInfo.C:81
virtual bool isValid() const override
IsValid.
std::map< SubdomainID, SubdomainInfo > & _subdomains
Definition: MeshInfo.h:74
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
Definition: MeshInfo.h:29
unsigned int & _num_dofs_aux
Definition: MeshInfo.h:59
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
std::map< BoundaryID, SidesetInfo > & _sideset_elems
Definition: MeshInfo.h:71
void dataLoad(std::istream &stream, MeshInfo::SidesetInfo &sideset_info, void *context)
Definition: MeshInfo.C:246
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
void to_json(nlohmann::json &json, const std::map< BoundaryID, MeshInfo::SidesetInfo > &sidesets)
Definition: MeshInfo.C:210
unsigned int & _num_local_dofs_aux
Definition: MeshInfo.h:65
unsigned int & _num_local_node
Definition: MeshInfo.h:67
MeshInfo(const InputParameters &parameters)
Definition: MeshInfo.C:38
unsigned int & _num_dofs_nl
Definition: MeshInfo.h:58
Report mesh information, such as the number of elements, nodes, and degrees of freedom.
Definition: MeshInfo.h:24
T & declareHelper(const std::string &item_name, const ReporterMode mode)
Definition: MeshInfo.h:95
const libMesh::EquationSystems & _equation_systems
Definition: MeshInfo.h:87
boundary_id_type BoundaryID
std::vector< std::pair< dof_id_type, unsigned int > > sides
Definition: MeshInfo.h:40
void possiblyAddSubdomainInfo()
Possibly add to _local_subdomains, _local_subdomain_elems, _subdomains, and _subdomain_elems.
Definition: MeshInfo.C:254
std::map< BoundaryID, SidesetInfo > & _local_sidesets
Definition: MeshInfo.h:68
bool isValueSet(const std::string &value) const
Methods for seeing if a value is set in the MultiMooseEnum.
unsigned int & _num_node
Definition: MeshInfo.h:62
Helper struct for defining information about a single subdomain.
Definition: MeshInfo.h:46
const libMesh::System & _aux_system
Definition: MeshInfo.h:89
std::map< BoundaryID, SidesetInfo > & _sidesets
Definition: MeshInfo.h:70
std::map< SubdomainID, SubdomainInfo > & _local_subdomain_elems
Definition: MeshInfo.h:73
const InputParameters & parameters() const
Get the parameters of the object.
std::map< SubdomainID, SubdomainInfo > & _local_subdomains
Definition: MeshInfo.h:72
unsigned int & _num_local_dofs
Definition: MeshInfo.h:63
unsigned int & _num_dofs
Definition: MeshInfo.h:57
std::map< SubdomainID, SubdomainInfo > & _subdomain_elems
Definition: MeshInfo.h:75
virtual void finalize() override
Finalize.
Definition: MeshInfo.h:30
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type...
const MultiMooseEnum & _items
Definition: MeshInfo.h:54
unsigned int & _num_local_dofs_nl
Definition: MeshInfo.h:64
std::map< BoundaryID, SidesetInfo > & _local_sideset_elems
Definition: MeshInfo.h:69
unsigned int & _num_elem
Definition: MeshInfo.h:61
MooseEnumItem that automatically creates the ID and doesn&#39;t allow the ID to be assigned.
Definition: ReporterMode.h:44
const libMesh::System & _nonlinear_system
Definition: MeshInfo.h:88