Line data Source code
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 : 21 : /** 22 : * Report mesh information, such as the number of elements, nodes, and degrees of freedom. 23 : */ 24 : class MeshInfo : public GeneralReporter 25 : { 26 : public: 27 : static InputParameters validParams(); 28 : MeshInfo(const InputParameters & parameters); 29 313 : virtual void initialize() override {} 30 313 : virtual void finalize() override {} 31 : virtual void execute() override; 32 : 33 : /** 34 : * Helper struct for defining information about a single sideset. 35 : */ 36 : struct SidesetInfo 37 : { 38 : BoundaryID id; 39 : std::string name; 40 : std::vector<std::pair<dof_id_type, unsigned int>> sides; 41 : }; 42 : 43 : /** 44 : * Helper struct for defining information about a single subdomain. 45 : */ 46 : struct SubdomainInfo 47 : { 48 : BoundaryID id; 49 : std::string name; 50 : std::vector<dof_id_type> elems; 51 : }; 52 : 53 : protected: 54 : const MultiMooseEnum & _items; 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: 82 : /// Possibly add to _local_sidesets, _local_sideset_elems, _sidesets, and _sideset_elems 83 : void possiblyAddSidesetInfo(); 84 : /// Possibly add to _local_subdomains, _local_subdomain_elems, _subdomains, and _subdomain_elems 85 : void possiblyAddSubdomainInfo(); 86 : 87 : const libMesh::EquationSystems & _equation_systems; 88 : const libMesh::System & _nonlinear_system; 89 : const libMesh::System & _aux_system; 90 : const libMesh::MeshBase & _mesh; 91 : }; 92 : 93 : template <typename T> 94 : T & 95 6460 : MeshInfo::declareHelper(const std::string & item_name, const ReporterMode mode) 96 : { 97 5434 : return (!_items.isValid() || _items.isValueSet(item_name)) 98 13226 : ? declareValueByName<T>(item_name, mode) 99 12920 : : 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);