libMesh
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Attributes | Friends | List of all members
Biharmonic Class Reference

The Biharmonic class encapsulates most of the data structures necessary to calculate the biharmonic residual and Jacobian, auxiliary quantities, to take a timestep, and to output the state – biharmonic solution and vectors of auxiliary quantities. More...

#include <biharmonic.h>

Inheritance diagram for Biharmonic:
[legend]

Classes

class  JR
 Biharmonic's friend class definition. More...
 

Public Types

enum  InitialStateEnum { STRIP = 0, ROD = 1, BALL = 2 }
 
enum  FreeEnergyEnum { DOUBLE_WELL = 1, DOUBLE_OBSTACLE = 2, LOG_DOUBLE_WELL = 3, LOG_DOUBLE_OBSTACLE = 4 }
 
enum  ReadFlags {
  READ_HEADER = 1, READ_DATA = 2, READ_ADDITIONAL_DATA = 4, READ_LEGACY_FORMAT = 8,
  TRY_READ_IFEMS = 16, READ_BASIC_ONLY = 32
}
 Define enumeration to set properties in EquationSystems::read() More...
 
enum  WriteFlags { WRITE_DATA = 1, WRITE_ADDITIONAL_DATA = 2, WRITE_PARALLEL_FILES = 4, WRITE_SERIAL_FILES = 8 }
 Define enumeration to set properties in EquationSystems::write() More...
 

Public Member Functions

 Biharmonic (ReplicatedMesh &mesh)
 Constructor retrieves command-line options, setting defaults, if necessary. More...
 
 ~Biharmonic ()
 Destructor. More...
 
bool verbose ()
 
Real dt0 ()
 
Real dt ()
 
void viewParameters ()
 
void init ()
 Initialize all the systems. More...
 
void step (const Real &dt=-1.0)
 
void output (int timestep, const Real &t, Real &o_t, bool force=false)
 
void run ()
 
virtual void clear ()
 Restores the data structure to a pristine state. More...
 
virtual void reinit ()
 Handle any mesh changes and reinitialize all the systems on the updated mesh. More...
 
virtual void reinit_mesh ()
 Handle the association of a completely new mesh with the EquationSystem and all the Systems assigned to it. More...
 
virtual void enable_default_ghosting (bool enable)
 Enable or disable default ghosting functors on the Mesh and on all Systems. More...
 
void update ()
 Updates local values for all the systems. More...
 
unsigned int n_systems () const
 
bool has_system (std::string_view name) const
 
template<typename T_sys >
const T_sys & get_system (std::string_view name) const
 
template<typename T_sys >
T_sys & get_system (std::string_view name)
 
template<typename T_sys >
const T_sys & get_system (const unsigned int num) const
 
template<typename T_sys >
T_sys & get_system (const unsigned int num)
 
const System & get_system (std::string_view name) const
 
System & get_system (std::string_view name)
 
const System & get_system (const unsigned int num) const
 
System & get_system (const unsigned int num)
 
virtual System & add_system (std::string_view system_type, std::string_view name)
 Add the system of type system_type named name to the systems array. More...
 
template<typename T_sys >
T_sys & add_system (std::string_view name)
 Add the system named name to the systems array. More...
 
unsigned int n_vars () const
 
std::size_t n_dofs () const
 
std::size_t n_active_dofs () const
 
virtual void solve ()
 Call solve on all the individual equation systems. More...
 
virtual void adjoint_solve (const QoISet &qoi_indices=QoISet())
 Call adjoint_solve on all the individual equation systems. More...
 
virtual void sensitivity_solve (const ParameterVector &parameters)
 Call sensitivity_solve on all the individual equation systems. More...
 
void build_variable_names (std::vector< std::string > &var_names, const FEType *type=nullptr, const std::set< std::string > *system_names=nullptr) const
 Fill the input vector var_names with the names of the variables for each system. More...
 
void build_solution_vector (std::vector< Number > &soln, std::string_view system_name, std::string_view variable_name="all_vars") const
 Fill the input vector soln with the solution values for the system named name. More...
 
void build_solution_vector (std::vector< Number > &soln, const std::set< std::string > *system_names=nullptr, bool add_sides=false) const
 Fill the input vector soln with solution values. More...
 
std::unique_ptr< NumericVector< Number > > build_parallel_solution_vector (const std::set< std::string > *system_names=nullptr, bool add_sides=false) const
 A version of build_solution_vector which is appropriate for "parallel" output formats like Nemesis. More...
 
void get_vars_active_subdomains (const std::vector< std::string > &names, std::vector< std::set< subdomain_id_type >> &vars_active_subdomains) const
 Retrieve vars_active_subdomains, which indicates the active subdomains for each variable in names. More...
 
void build_elemental_solution_vector (std::vector< Number > &soln, std::vector< std::string > &names) const
 Retrieve the solution data for CONSTANT MONOMIALs and/or components of CONSTANT MONOMIAL_VECs. More...
 
std::vector< std::pair< unsigned int, unsigned int > > find_variable_numbers (std::vector< std::string > &names, const FEType *type=nullptr, const std::vector< FEType > *types=nullptr) const
 Finds system and variable numbers for any variables of 'type' or of 'types' corresponding to the entries in the input 'names' vector. More...
 
std::unique_ptr< NumericVector< Number > > build_parallel_elemental_solution_vector (std::vector< std::string > &names) const
 Builds a parallel vector of CONSTANT MONOMIAL and/or components of CONSTANT MONOMIAL_VEC solution values corresponding to the entries in the input 'names' vector. More...
 
void build_discontinuous_solution_vector (std::vector< Number > &soln, const std::set< std::string > *system_names=nullptr, const std::vector< std::string > *var_names=nullptr, bool vertices_only=false, bool add_sides=false) const
 Fill the input vector soln with solution values. More...
 
template<typename InValType = Number>
void read (std::string_view name, const XdrMODE, const unsigned int read_flags=(READ_HEADER|READ_DATA), bool partition_agnostic=true)
 Read & initialize the systems from disk using the XDR data format. More...
 
template<typename InValType = Number>
void read (std::string_view name, const unsigned int read_flags=(READ_HEADER|READ_DATA), bool partition_agnostic=true)
 
template<typename InValType = Number>
void read (Xdr &io, std::function< std::unique_ptr< Xdr >()> &local_io_functor, const unsigned int read_flags=(READ_HEADER|READ_DATA), bool partition_agnostic=true)
 
void write (std::string_view name, const XdrMODE, const unsigned int write_flags=(WRITE_DATA), bool partition_agnostic=true) const
 Write the systems to disk using the XDR data format. More...
 
void write (std::string_view name, const unsigned int write_flags=(WRITE_DATA), bool partition_agnostic=true) const
 
void write (std::ostream name, const unsigned int write_flags=(WRITE_DATA), bool partition_agnostic=true) const
 
void write (Xdr &io, const unsigned int write_flags=(WRITE_DATA), bool partition_agnostic=true, Xdr *const local_io=nullptr) const
 
virtual bool compare (const EquationSystems &other_es, const Real threshold, const bool verbose) const
 
virtual std::string get_info () const
 
void print_info (std::ostream &os=libMesh::out) const
 Prints information about the equation systems, by default to libMesh::out. More...
 
const MeshBase & get_mesh () const
 
MeshBase & get_mesh ()
 
void allgather ()
 Serializes a distributed mesh and its associated degree of freedom numbering for all systems. More...
 
void enable_refine_in_reinit ()
 Calls to reinit() will also do two-step coarsen-then-refine. More...
 
void disable_refine_in_reinit ()
 Calls to reinit() will not try to coarsen or refine the mesh. More...
 
bool refine_in_reinit_flag ()
 
bool reinit_solutions ()
 Handle any mesh changes and project any solutions onto the updated mesh. More...
 
virtual void reinit_systems ()
 Reinitialize all systems on the current mesh. More...
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static bool redundant_added_side (const Elem &elem, unsigned int side)
 
static std::string get_info ()
 Gets a string containing the reference information. More...
 
static void print_info (std::ostream &out_stream=libMesh::out)
 Prints the reference information, by default to libMesh::out. More...
 
static unsigned int n_objects ()
 Prints the number of outstanding (created, but not yet destroyed) objects. More...
 
static void enable_print_counter_info ()
 Methods to enable/disable the reference counter output from print_info(). More...
 
static void disable_print_counter_info ()
 

Public Attributes

Parameters parameters
 Data structure holding arbitrary parameters. More...
 

Protected Types

typedef std::map< std::string, std::pair< unsigned int, unsigned int > > Counts
 Data structure to log the information. More...
 

Protected Member Functions

void increment_constructor_count (const std::string &name) noexcept
 Increments the construction counter. More...
 
void increment_destructor_count (const std::string &name) noexcept
 Increments the destruction counter. More...
 

Protected Attributes

std::map< std::string, std::unique_ptr< System >, std::less<> > _systems
 Data structure holding the systems. More...
 
bool _refine_in_reinit
 Flag for whether to call coarsen/refine in reinit(). More...
 
bool _enable_default_ghosting
 Flag for whether to enable default ghosting on newly added Systems. More...
 
const Parallel::Communicator & _communicator
 

Static Protected Attributes

static Counts _counts
 Actually holds the data. More...
 
static Threads::atomic< unsigned int_n_objects
 The number of objects. More...
 
static Threads::spin_mutex _mutex
 Mutual exclusion object to enable thread-safe reference counting. More...
 
static bool _enable_print_counter = true
 Flag to control whether reference count information is printed when print_info is called. More...
 

Private Attributes

unsigned int _dim
 
unsigned int _N
 
Real _kappa
 
Real _theta
 
Real _theta_c
 
Real _tol
 
bool _growth
 
bool _degenerate
 
bool _cahn_hillard
 
bool _netforce
 
FreeEnergyEnum _energy
 
int _log_truncation
 
bool _verbose
 
InitialStateEnum _initialState
 
Point _initialCenter
 
Real _initialWidth
 
Real _dt0
 
Real _dt
 
Real _t0
 
Real _T
 
Real _t1
 
Real _cnWeight
 
std::string _ofile_base
 
std::string _ofile
 
std::unique_ptr< ExodusII_IO_exio
 
Real _o_dt
 
int _o_count
 
ReplicatedMesh_mesh
 
JR_jr
 

Friends

class JR
 

Detailed Description

The Biharmonic class encapsulates most of the data structures necessary to calculate the biharmonic residual and Jacobian, auxiliary quantities, to take a timestep, and to output the state – biharmonic solution and vectors of auxiliary quantities.

The main reason for this design is to have a data structure that has all of the necessary data in one place, where all of the calculation subroutines can access these data. Currently these data are split up among several interdependent objects with no clear hierarchy between them: mesh, equation system, equation system bundle, residual/Jacobian calculator.

Since no object contains all others and the data are distributed among many objects, the natural control and data flow resides outside of these objects and is typically implemented in main(). We, however, would like to split the calculation into natural chunks – subroutines – while retaining these subroutines access to the common necessary data – biharmonic parameters, mesh and time interval sizes, etc. Thus, class Biharmonic. Finally, making Biharmonic inherit from EquationSystems makes it possible to include it in the most common callbacks that do not pass back a user context, but only an EquationSystems object.

Definition at line 45 of file biharmonic.h.

Member Typedef Documentation

◆ Counts

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts
protectedinherited

Data structure to log the information.

The log is identified by the class name.

Definition at line 119 of file reference_counter.h.

Member Enumeration Documentation

◆ FreeEnergyEnum

Enumerator
DOUBLE_WELL 
DOUBLE_OBSTACLE 
LOG_DOUBLE_WELL 
LOG_DOUBLE_OBSTACLE 

Definition at line 54 of file biharmonic.h.

◆ InitialStateEnum

Enumerator
STRIP 
ROD 
BALL 

Definition at line 49 of file biharmonic.h.

49  {STRIP = 0,
50  ROD = 1,
51  BALL = 2};

◆ ReadFlags

Define enumeration to set properties in EquationSystems::read()

Enumerator
READ_HEADER 
READ_DATA 
READ_ADDITIONAL_DATA 
READ_LEGACY_FORMAT 
TRY_READ_IFEMS 
READ_BASIC_ONLY 

Definition at line 77 of file equation_systems.h.

◆ WriteFlags

Define enumeration to set properties in EquationSystems::write()

Enumerator
WRITE_DATA 
WRITE_ADDITIONAL_DATA 
WRITE_PARALLEL_FILES 
WRITE_SERIAL_FILES 

Definition at line 87 of file equation_systems.h.

Constructor & Destructor Documentation

◆ Biharmonic()

Biharmonic::Biharmonic ( ReplicatedMesh mesh)

Constructor retrieves command-line options, setting defaults, if necessary.

It then builds the mesh using these options, then the equations systems around it, and, finally, sets up the output. We recommend that this be used through the factory Create function, which allocates the mesh. In that case don't forget to call Destroy at the end, to free the mesh up.

Definition at line 16 of file biharmonic.C.

References _cahn_hillard, _cnWeight, _degenerate, _dim, _dt0, _energy, _exio, _growth, _initialCenter, _initialState, _initialWidth, _kappa, _log_truncation, _mesh, _N, _netforce, _o_dt, _ofile, _ofile_base, _T, _t0, _t1, _theta, _theta_c, _tol, _verbose, BALL, libMesh::MeshTools::Generation::build_cube(), libMesh::MeshTools::Generation::build_line(), libMesh::MeshTools::Generation::build_square(), libMesh::command_line_value(), libMesh::command_line_vector(), DOUBLE_OBSTACLE, DOUBLE_WELL, libMesh::EDGE2, libMesh::HEX8, LOG_DOUBLE_OBSTACLE, LOG_DOUBLE_WELL, libMesh::on_command_line(), libMesh::out, libMesh::QUAD4, ROD, and STRIP.

16  :
17  EquationSystems(mesh),
18  _mesh(mesh)
19 {
20  // Retrieve parameters and set defaults
21  _verbose = false;
22  _growth = false;
23  _degenerate = false;
24  _cahn_hillard = false;
25  _netforce = false;
26 
27  if (on_command_line("--verbose"))
28  _verbose = true;
29  if (on_command_line("--growth"))
30  _growth = true;
31  if (on_command_line("--degenerate"))
32  _degenerate = true;
33  if (on_command_line("--cahn_hillard"))
34  _cahn_hillard = true;
35  if (on_command_line("--netforce"))
36  _netforce = true;
37 
38  _kappa = command_line_value("kappa", 1.0);
39 
40  // "type of energy (double well, double obstacle, logarithmic+double well, logarithmic+double obstacle)"
41  std::string energy = command_line_value("energy", std::string("double_well"));
42 
43  if (energy == "double_well")
45  else if (energy == "double_obstacle")
47  else if (energy == "log_double_well")
49  else if (energy == "log_double_obstacle")
51  else
52  libmesh_error_msg("Unknown energy type: " << energy);
53 
54  _tol = command_line_value("tol", 1.0e-8);
55  _theta = command_line_value("theta", .001);
56  _theta_c = command_line_value("theta_c", 1.0);
57 
58  // "order of log truncation (0=none, 2=quadratic, 3=cubic)"
59  _log_truncation = command_line_value("log_truncation", 2);
60 
61  if (!_log_truncation)
62  libMesh::out << "WARNING: no truncation is being used for the logarithmic free energy term.\nWARNING: division by zero possible!\n";
63 
64 
65  // Dimension
66  _dim = command_line_value("dim", 1);
67 
68  libmesh_assert_msg((_dim <= 3) && (_dim > 0), "Invalid mesh dimension");
69 
70  // Build the mesh
71  // Yes, it's better to make a coarse mesh and then refine it. We'll get to it later.
72  _N = command_line_value("N", 8);
73  libmesh_assert_msg(_N > 0, "Invalid mesh size");
74 
75  switch (_dim)
76  {
77  case 1:
79  break;
80  case 2:
81  MeshTools::Generation::build_square(_mesh, _N, _N, 0.0, 1.0, 0.0, 1.0, QUAD4);
82  break;
83  case 3:
84  MeshTools::Generation::build_cube(_mesh, _N, _N, _N, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, HEX8);
85  break;
86  default:
87  libmesh_assert_msg((_dim <= 3) && (_dim > 0), "Invalid mesh dimension");
88  break;
89  }
90 
91  // Determine the initial timestep size
92  _dt0 = command_line_value("dt", 1.0/(10*_kappa*_N*_N*_N*_N));
93  libmesh_assert_msg(_dt0>=0, "Negative initial timestep");
94 
95  _t0 = command_line_value("min_time", 0.0);
96  _t1 = command_line_value("max_time", _t0 + 50.0*_dt0);
97  libmesh_assert_msg(_t1 >= _t0, "Final time less than initial time");
98  _T = _t1 - _t0;
99 
100  _cnWeight = command_line_value("crank_nicholson_weight", 1.0);
101  libmesh_assert_msg(_cnWeight <= 1 && _cnWeight >= 0, "Crank-Nicholson weight must be between 0 and 1");
102 
103  // Initial state
105  std::string initialState = command_line_value("initial_state", std::string("strip"));
106 
107  if (initialState == std::string("ball"))
109  else if (initialState == std::string("strip"))
111  else if (initialState == std::string("rod"))
112  _initialState = ROD;
113  else
114  libmesh_error_msg("Unknown initial state: neither ball nor rod nor strip");
115 
116  std::vector<Real> icenter;
117  command_line_vector("initial_center", icenter);
118 
119  // Check that the point defining the center was in the right spatial dimension
120  if (icenter.size() > _dim)
121  libmesh_assert_msg(icenter.size() > _dim, "Invalid dimension for the initial state center of mass");
122 
123  // Pad
124  icenter.resize(3);
125  for (std::size_t i = icenter.size(); i < _dim; ++i)
126  icenter[i] = 0.5;
127 
128  for (unsigned int i = _dim; i < 3; ++i)
129  icenter[i] = 0.0;
130 
131  _initialCenter = Point(icenter[0], icenter[1], icenter[2]);
132  _initialWidth = command_line_value("initial_width", 0.125);
133 
134  // Output options
135 #ifdef LIBMESH_HAVE_EXODUS_API
136  if (on_command_line("output_base"))
137  _ofile_base = command_line_value("output_base", std::string("bih"));
138 
139  else
140  {
141  switch(_dim)
142  {
143  case 1:
144  _ofile_base = std::string("bih.1");
145  break;
146  case 2:
147  _ofile_base = std::string("bih.2");
148  break;
149  case 3:
150  _ofile_base = std::string("bih.3");
151  break;
152  default:
153  _ofile_base = std::string("bih");
154  break;
155  }
156  }
157  _ofile = _ofile_base + ".e";
158  _exio = std::make_unique<ExodusII_IO>(_mesh);
159  _o_dt = command_line_value("output_dt", 0.0);
160 #endif // #ifdef LIBMESH_HAVE_EXODUS_API
161 } // constructor
EquationSystems(MeshBase &mesh)
Constructor.
std::string _ofile
Definition: biharmonic.h:105
std::unique_ptr< ExodusII_IO > _exio
Definition: biharmonic.h:106
bool _verbose
Definition: biharmonic.h:98
Real _cnWeight
Definition: biharmonic.h:103
MeshBase & mesh
Real _kappa
Definition: biharmonic.h:93
Real _theta_c
Definition: biharmonic.h:93
void build_square(UnstructuredMesh &mesh, const unsigned int nx, const unsigned int ny, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 2D meshes.
Point _initialCenter
Definition: biharmonic.h:100
Real _tol
Definition: biharmonic.h:94
bool _netforce
Definition: biharmonic.h:95
bool _cahn_hillard
Definition: biharmonic.h:95
T command_line_value(const std::string &, T)
Definition: libmesh.C:971
FreeEnergyEnum _energy
Definition: biharmonic.h:96
int _log_truncation
Definition: biharmonic.h:97
unsigned int _dim
Definition: biharmonic.h:92
Real _initialWidth
Definition: biharmonic.h:101
void command_line_vector(const std::string &, std::vector< T > &)
Definition: libmesh.C:1044
OStreamProxy out
bool _growth
Definition: biharmonic.h:95
void build_line(UnstructuredMesh &mesh, const unsigned int nx, const Real xmin=0., const Real xmax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 1D meshes.
bool on_command_line(std::string arg)
Definition: libmesh.C:934
Real _o_dt
Definition: biharmonic.h:107
unsigned int _N
Definition: biharmonic.h:92
ReplicatedMesh & _mesh
Definition: biharmonic.h:111
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:39
std::string _ofile_base
Definition: biharmonic.h:105
InitialStateEnum _initialState
Definition: biharmonic.h:99
void build_cube(UnstructuredMesh &mesh, const unsigned int nx=0, const unsigned int ny=0, const unsigned int nz=0, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const Real zmin=0., const Real zmax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
Builds a (elements) cube.
Real _theta
Definition: biharmonic.h:93
bool _degenerate
Definition: biharmonic.h:95

◆ ~Biharmonic()

Biharmonic::~Biharmonic ( )
inline

Destructor.

Definition at line 72 of file biharmonic.h.

73  {
74  // delete _meshRefinement;
75  }

Member Function Documentation

◆ add_system() [1/2]

System & libMesh::EquationSystems::add_system ( std::string_view  system_type,
std::string_view  name 
)
virtualinherited

Add the system of type system_type named name to the systems array.

Definition at line 353 of file equation_systems.C.

References libMesh::EquationSystems::_systems, libMesh::EquationSystems::get_system(), and libMesh::Quality::name().

Referenced by assemble_and_solve(), build_system(), main(), libMesh::ErrorVector::plot_error(), libMesh::EquationSystems::read(), libMesh::StaticCondensationDofMap::reinit(), TimeSolverTestImplementation< NewmarkSolver >::run_test_with_exact_soln(), libMesh::PetscPreconditioner< T >::set_hypre_ads_data(), libMesh::PetscPreconditioner< T >::set_hypre_ams_data(), setup(), WriteVecAndScalar::setupTests(), SystemsTest::simpleSetup(), MultiEvaluablePredTest::test(), SystemsTest::test100KVariables(), ConstraintOperatorTest::test1DCoarseningNewNodes(), ConstraintOperatorTest::test1DCoarseningOperator(), SystemsTest::test2DProjectVectorFE(), SystemsTest::test3DProjectVectorFE(), MeshFunctionTest::test_bad_gradient_var_with_out_of_mesh_value(), MeshFunctionTest::test_bad_hessian_var_with_out_of_mesh_value(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), ProjectSolutionTest::test_partial_project_solution(), MeshFunctionTest::test_subdomain_id_sets(), EquationSystemsTest::testAddSystem(), DofMapTest::testArrayDofIndicesWithType(), SystemsTest::testAssemblyWithDgFemContext(), DofMapTest::testBadElemFECombo(), EquationSystemsTest::testBadVarNames(), SystemsTest::testBlockRestrictedVarNDofs(), SystemsTest::testBoundaryProjectCube(), DofMapTest::testConstraintLoopDetection(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyElementVectorImpl(), MeshInputTest::testCopyNodalSolutionImpl(), ConstraintOperatorTest::testCoreform(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), EquationSystemsTest::testDisableDefaultGhosting(), SystemsTest::testDofCouplingWithVarGroups(), MixedDimensionMeshTest::testDofOrdering(), MixedDimensionRefinedMeshTest::testDofOrdering(), MixedDimensionNonUniformRefinement::testDofOrdering(), MixedDimensionNonUniformRefinementTriangle::testDofOrdering(), MixedDimensionNonUniformRefinement3D::testDofOrdering(), DofMapTest::testDofOwner(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), SystemsTest::testFirstScalarNumber(), EquationSystemsTest::testInit(), MeshAssignTest::testMeshMoveAssign(), PeriodicBCTest::testPeriodicBC(), EquationSystemsTest::testPostInitAddElem(), EquationSystemsTest::testPostInitAddRealSystem(), EquationSystemsTest::testPostInitAddSystem(), SystemsTest::testProjectCube(), SystemsTest::testProjectCubeWithMeshFunction(), MeshInputTest::testProjectionRegression(), SystemsTest::testProjectLine(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), SystemsTest::testProjectSquare(), InfFERadialTest::testRefinement(), EquationSystemsTest::testRefineThenReinitPreserveFlags(), EquationSystemsTest::testReinitWithNodeElem(), EquationSystemsTest::testRepartitionThenReinit(), EquationSystemsTest::testSelectivePRefine(), SystemsTest::testSetSystemParameterOverEquationSystem(), MeshInputTest::testSingleElementImpl(), DisjointNeighborTest::testTempJump(), DisjointNeighborTest::testTempJumpRefine(), WriteVecAndScalar::testWriteExodus(), and WriteVecAndScalar::testWriteNemesis().

355 {
356  // If the user already built a system with this name, we'll
357  // trust them and we'll use it. That way they can pre-add
358  // non-standard derived system classes, and if their restart file
359  // has some non-standard sys_type we won't throw an error.
360  if (_systems.count(name))
361  {
362  return this->get_system(name);
363  }
364  // Build a basic System
365  else if (sys_type == "Basic")
366  this->add_system<System> (name);
367 
368  // Build a Newmark system
369  else if (sys_type == "Newmark")
370  this->add_system<NewmarkSystem> (name);
371 
372  // Build an Explicit system
373  else if ((sys_type == "Explicit"))
374  this->add_system<ExplicitSystem> (name);
375 
376  // Build an Implicit system
377  else if ((sys_type == "Implicit") ||
378  (sys_type == "Steady" ))
379  this->add_system<ImplicitSystem> (name);
380 
381  // build a transient implicit linear system
382  else if ((sys_type == "Transient") ||
383  (sys_type == "TransientImplicit") ||
384  (sys_type == "TransientLinearImplicit"))
385  this->add_system<TransientLinearImplicitSystem> (name);
386 
387  // build a transient implicit nonlinear system
388  else if (sys_type == "TransientNonlinearImplicit")
389  this->add_system<TransientNonlinearImplicitSystem> (name);
390 
391  // build a transient explicit system
392  else if (sys_type == "TransientExplicit")
393  this->add_system<TransientExplicitSystem> (name);
394 
395  // build a linear implicit system
396  else if (sys_type == "LinearImplicit")
397  this->add_system<LinearImplicitSystem> (name);
398 
399  // build a nonlinear implicit system
400  else if (sys_type == "NonlinearImplicit")
401  this->add_system<NonlinearImplicitSystem> (name);
402 
403  // build a Reduced Basis Construction system
404  else if (sys_type == "RBConstruction")
405  this->add_system<RBConstruction> (name);
406 
407  // build a transient Reduced Basis Construction system
408  else if (sys_type == "TransientRBConstruction")
409  this->add_system<TransientRBConstruction> (name);
410 
411 #ifdef LIBMESH_HAVE_SLEPC
412  // build an eigen system
413  else if (sys_type == "Eigen")
414  this->add_system<EigenSystem> (name);
415  else if (sys_type == "TransientEigenSystem")
416  this->add_system<TransientEigenSystem> (name);
417 #endif
418 
419 #if defined(LIBMESH_USE_COMPLEX_NUMBERS)
420  // build a frequency system
421  else if (sys_type == "Frequency")
422  this->add_system<FrequencySystem> (name);
423 #endif
424 
425  else
426  libmesh_error_msg("ERROR: Unknown system type: " << sys_type);
427 
428  // Return a reference to the new system
429  //return (*this)(name);
430  return this->get_system(name);
431 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
const T_sys & get_system(std::string_view name) const
std::map< std::string, std::unique_ptr< System >, std::less<> > _systems
Data structure holding the systems.

◆ add_system() [2/2]

template<typename T_sys >
T_sys & libMesh::EquationSystems::add_system ( std::string_view  name)
inlineinherited

Add the system named name to the systems array.

Definition at line 657 of file equation_systems.h.

References libMesh::EquationSystems::_add_system_to_nodes_and_elems(), libMesh::EquationSystems::_enable_default_ghosting, libMesh::EquationSystems::_remove_default_ghosting(), libMesh::EquationSystems::_systems, libMesh::EquationSystems::n_systems(), and libMesh::Quality::name().

658 {
659  if (!_systems.count(name))
660  {
661  const unsigned int sys_num = this->n_systems();
662 
663  auto result = _systems.emplace
664  (name, std::make_unique<T_sys>(*this, std::string(name),
665  sys_num));
666 
668  this->_remove_default_ghosting(sys_num);
669 
670  // Tell all the \p DofObject entities to add a system.
672 
673  // Return reference to newly added item
674  auto it = result.first;
675  auto & sys_ptr = it->second;
676  return cast_ref<T_sys &>(*sys_ptr);
677  }
678  else
679  {
680  // We now allow redundant add_system calls, to make it
681  // easier to load data from files for user-derived system
682  // subclasses
683  return this->get_system<T_sys>(name);
684  }
685 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
unsigned int n_systems() const
bool _enable_default_ghosting
Flag for whether to enable default ghosting on newly added Systems.
void _remove_default_ghosting(unsigned int sys_num)
This just calls DofMap::remove_default_ghosting() but using a shim lets us forward-declare DofMap...
void _add_system_to_nodes_and_elems()
This function is used in the implementation of add_system, it loops over the nodes and elements of th...
std::map< std::string, std::unique_ptr< System >, std::less<> > _systems
Data structure holding the systems.

◆ adjoint_solve()

void libMesh::EquationSystems::adjoint_solve ( const QoISet qoi_indices = QoISet())
virtualinherited

Call adjoint_solve on all the individual equation systems.

By default this function solves each system's adjoint once, in the reverse order from that in which they were added. For more sophisticated decoupled problems the user may with to override this behavior in a derived class.

Definition at line 455 of file equation_systems.C.

References libMesh::EquationSystems::get_system(), libMesh::libmesh_assert(), and libMesh::EquationSystems::n_systems().

Referenced by libMesh::UniformRefinementEstimator::_estimate_error().

456 {
457  libmesh_assert (this->n_systems());
458 
459  for (unsigned int i=this->n_systems(); i != 0; --i)
460  this->get_system(i-1).adjoint_solve(qoi_indices);
461 }
unsigned int n_systems() const
const T_sys & get_system(std::string_view name) const
libmesh_assert(ctx)

◆ allgather()

void libMesh::EquationSystems::allgather ( )
inherited

Serializes a distributed mesh and its associated degree of freedom numbering for all systems.

Definition at line 275 of file equation_systems.C.

References libMesh::EquationSystems::_mesh, libMesh::MeshBase::allgather(), libMesh::DofMap::distribute_dofs(), libMesh::MeshBase::element_stored_range(), libMesh::System::get_dof_map(), libMesh::EquationSystems::get_system(), libMesh::MeshBase::is_serial(), libMesh::make_range(), libMesh::EquationSystems::n_systems(), libMesh::Threads::parallel_for(), and libMesh::System::reinit_constraints().

276 {
277  // A serial mesh means nothing needs to be done
278  if (_mesh.is_serial())
279  return;
280 
281  const unsigned int n_sys = this->n_systems();
282 
283  libmesh_assert_not_equal_to (n_sys, 0);
284 
285  // Gather the mesh
286  _mesh.allgather();
287 
288  // Tell all the \p DofObject entities how many systems
289  // there are.
290  for (auto & node : _mesh.node_ptr_range())
291  node->set_n_systems(n_sys);
292 
295  [n_sys](const ElemRange & range)
296  {
297  for (Elem * elem : range)
298  elem->set_n_systems(n_sys);
299  });
300 
301  // And distribute each system's dofs
302  for (auto i : make_range(this->n_systems()))
303  {
304  System & sys = this->get_system(i);
305  DofMap & dof_map = sys.get_dof_map();
306  dof_map.distribute_dofs(_mesh);
307 
308  // The user probably won't need constraint equations or the
309  // send_list after an allgather, but let's keep it in consistent
310  // shape just in case.
311  sys.reinit_constraints();
312 
313  // Even if there weren't any constraint changes,
314  // reinit_constraints() did prepare_send_list() for us.
315  }
316 }
void parallel_for(const Range &range, const Body &body, unsigned int n_threads=libMesh::n_threads())
Execute the provided function object in parallel on the specified range.
Definition: threads_none.h:73
StoredRange< MeshBase::element_iterator, Elem * > ElemRange
Definition: elem_range.h:31
unsigned int n_systems() const
virtual void allgather()
Gathers all elements and nodes of the mesh onto every processor.
Definition: mesh_base.h:376
const T_sys & get_system(std::string_view name) const
MeshBase & _mesh
The mesh data structure.
virtual bool is_serial() const
Definition: mesh_base.h:347
const ElemRange & element_stored_range()
Definition: mesh_base.C:1913
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:176

◆ build_discontinuous_solution_vector()

void libMesh::EquationSystems::build_discontinuous_solution_vector ( std::vector< Number > &  soln,
const std::set< std::string > *  system_names = nullptr,
const std::vector< std::string > *  var_names = nullptr,
bool  vertices_only = false,
bool  add_sides = false 
) const
inherited

Fill the input vector soln with solution values.

The entries will be in variable-major format (corresponding to the names from build_variable_names()).

If systems_names!=nullptr, only include data from the specified systems.

If vertices_only == true, then for higher-order elements only the solution at the vertices is computed. This can be useful when plotting discontinuous solutions on higher-order elements and only a lower-order representation is required.

If add_sides == true, append data for plotting on "side elements" too.

Definition at line 1273 of file equation_systems.C.

References libMesh::Variable::active_on_subdomain(), libMesh::DISCONTINUOUS, libMesh::FEInterface::get_continuity(), libMesh::H_CURL, libMesh::H_DIV, libMesh::index_range(), libMesh::Elem::level(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::FEInterface::n_vec_dim(), libMesh::Elem::neighbor_ptr(), libMesh::FEInterface::nodal_soln(), libMesh::Elem::node_ptr(), libMesh::Elem::nodes_on_side(), libMesh::FEType::p_refinement, libMesh::FEInterface::side_nodal_soln(), libMesh::Elem::subdomain_id(), and libMesh::Elem::which_neighbor_am_i().

Referenced by libMesh::MeshOutput< MeshBase >::write_discontinuous_equation_systems(), libMesh::ExodusII_IO::write_discontinuous_exodusII(), libMesh::GMVIO::write_discontinuous_gmv(), and libMesh::ExodusII_IO::write_element_data_from_discontinuous_nodal_data().

1278 {
1279  LOG_SCOPE("build_discontinuous_solution_vector()", "EquationSystems");
1280 
1281  libmesh_assert (this->n_systems());
1282 
1283  // Get the number of variables (nv) by counting the number of variables
1284  // in each system listed in system_names
1285  unsigned int nv = 0;
1286 
1287  for (const auto & [sys_name, sys_ptr] : _systems)
1288  {
1289  // Check current system is listed in system_names, and skip pos if not
1290  bool use_current_system = (system_names == nullptr);
1291  if (!use_current_system)
1292  use_current_system = system_names->count(sys_name);
1293  if (!use_current_system || sys_ptr->hide_output())
1294  continue;
1295 
1296  // Loop over all variables in this System and check whether we
1297  // are supposed to use each one.
1298  for (auto var_id : make_range(sys_ptr->n_vars()))
1299  {
1300  bool use_current_var = (var_names == nullptr);
1301  if (!use_current_var)
1302  use_current_var = std::count(var_names->begin(),
1303  var_names->end(),
1304  sys_ptr->variable_name(var_id));
1305 
1306  // Only increment the total number of vars if we are
1307  // supposed to use this one.
1308  if (use_current_var)
1309  nv++;
1310  }
1311  }
1312 
1313  // get the total "weight" - the number of nodal values to write for
1314  // each variable.
1315  unsigned int tw=0;
1316  for (const auto & elem : _mesh.active_element_ptr_range())
1317  {
1318  tw += vertices_only ? elem->n_vertices() : elem->n_nodes();
1319 
1320  if (add_sides)
1321  {
1322  for (auto s : elem->side_index_range())
1323  {
1324  if (redundant_added_side(*elem,s))
1325  continue;
1326 
1327  const std::vector<unsigned int> side_nodes =
1328  elem->nodes_on_side(s);
1329 
1330  if (!vertices_only)
1331  tw += side_nodes.size();
1332  else
1333  for (auto n : index_range(side_nodes))
1334  if (elem->is_vertex(side_nodes[n]))
1335  ++tw;
1336  }
1337  }
1338  }
1339 
1340  // Only if we are on processor zero, allocate the storage
1341  // to hold (number_of_nodes)*(number_of_variables) entries.
1342  if (_mesh.processor_id() == 0)
1343  soln.resize(tw*nv);
1344 
1345  std::vector<Number> sys_soln;
1346 
1347  // Keep track of the variable "offset". This is used for indexing
1348  // into the global solution vector.
1349  unsigned int var_offset = 0;
1350 
1351  // For each system in this EquationSystems object,
1352  // update the global solution and if we are on processor 0,
1353  // loop over the elements and build the nodal solution
1354  // from the element solution. Then insert this nodal solution
1355  // into the vector passed to build_solution_vector.
1356  for (const auto & [sys_name, system] : _systems)
1357  {
1358  // Check current system is listed in system_names, and skip pos if not
1359  bool use_current_system = (system_names == nullptr);
1360  if (!use_current_system)
1361  use_current_system = system_names->count(sys_name);
1362  if (!use_current_system || system->hide_output())
1363  continue;
1364 
1365  const unsigned int nv_sys = system->n_vars();
1366  const auto & dof_map = system->get_dof_map();
1367 
1368  system->update_global_solution (sys_soln, 0);
1369 
1370  // Keep track of the number of vars actually written.
1371  unsigned int n_vars_written_current_system = 0;
1372 
1373  if (_mesh.processor_id() == 0)
1374  {
1375  std::vector<Number> soln_coeffs; // The finite element solution coeffs
1376  std::vector<Number> nodal_soln; // The FE solution interpolated to the nodes
1377  std::vector<dof_id_type> dof_indices; // The DOF indices for the finite element
1378 
1379  // For each variable, determine if we are supposed to
1380  // write it, then loop over the active elements, compute
1381  // the nodal_soln and store it to the "soln" vector. We
1382  // store zeros for subdomain-restricted variables on
1383  // elements where they are not active.
1384  for (unsigned int var=0; var<nv_sys; var++)
1385  {
1386  bool use_current_var = (var_names == nullptr);
1387  if (!use_current_var)
1388  use_current_var = std::count(var_names->begin(),
1389  var_names->end(),
1390  system->variable_name(var));
1391 
1392  // If we aren't supposed to write this var, go to the
1393  // next loop iteration.
1394  if (!use_current_var)
1395  continue;
1396 
1397  const FEType & fe_type = system->variable_type(var);
1398  const Variable & var_description = system->variable(var);
1399  const bool add_p_level = fe_type.p_refinement;
1400 
1401  unsigned int nn=0;
1402 
1403  for (auto & elem : _mesh.active_element_ptr_range())
1404  {
1405  if (var_description.active_on_subdomain(elem->subdomain_id()))
1406  {
1407  dof_map.dof_indices (elem, dof_indices, var);
1408 
1409  soln_coeffs.resize(dof_indices.size());
1410 
1411  for (auto i : index_range(dof_indices))
1412  soln_coeffs[i] = sys_soln[dof_indices[i]];
1413 
1414  // Compute the FE solution at all the nodes, but
1415  // only use the first n_vertices() entries if
1416  // vertices_only == true.
1417  FEInterface::nodal_soln (elem->dim(),
1418  fe_type,
1419  elem,
1420  soln_coeffs,
1421  nodal_soln,
1422  add_p_level,
1423  FEInterface::n_vec_dim(_mesh, fe_type));
1424 
1425  // infinite elements should be skipped...
1426  if (!elem->infinite())
1427  {
1428  libmesh_assert_equal_to (nodal_soln.size(), elem->n_nodes());
1429 
1430  const unsigned int n_vals =
1431  vertices_only ? elem->n_vertices() : elem->n_nodes();
1432 
1433  for (unsigned int n=0; n<n_vals; n++)
1434  {
1435  // Compute index into global solution vector.
1436  std::size_t index =
1437  nv * (nn++) + (n_vars_written_current_system + var_offset);
1438 
1439  soln[index] += nodal_soln[n];
1440  }
1441  }
1442  }
1443  else
1444  nn += vertices_only ? elem->n_vertices() : elem->n_nodes();
1445  } // end loop over active elements writing interiors
1446 
1447  // Loop writing "fake" sides, if requested
1448  if (add_sides)
1449  {
1450  // We don't build discontinuous solution vectors in
1451  // parallel yet, but we'll do ordering of fake side
1452  // values as if we did, for consistency with the
1453  // parallel continuous ordering and for future
1454  // compatibility.
1455  std::vector<std::vector<const Elem *>>
1456  elems_by_pid(_mesh.n_processors());
1457 
1458  for (const auto & elem : _mesh.active_element_ptr_range())
1459  elems_by_pid[elem->processor_id()].push_back(elem);
1460 
1461  for (auto p : index_range(elems_by_pid))
1462  for (const Elem * elem : elems_by_pid[p])
1463  {
1464  if (var_description.active_on_subdomain(elem->subdomain_id()))
1465  {
1466  dof_map.dof_indices (elem, dof_indices, var);
1467 
1468  soln_coeffs.resize(dof_indices.size());
1469 
1470  for (auto i : index_range(dof_indices))
1471  soln_coeffs[i] = sys_soln[dof_indices[i]];
1472 
1473  for (auto s : elem->side_index_range())
1474  {
1475  if (redundant_added_side(*elem,s))
1476  continue;
1477 
1478  const std::vector<unsigned int> side_nodes =
1479  elem->nodes_on_side(s);
1480 
1481  // Compute the FE solution at all the
1482  // side nodes, but only use those for
1483  // which is_vertex() == true if
1484  // vertices_only == true.
1486  (fe_type, elem, s, soln_coeffs,
1487  nodal_soln, add_p_level,
1488  FEInterface::n_vec_dim(_mesh, fe_type));
1489 
1490  libmesh_assert_equal_to
1491  (nodal_soln.size(),
1492  side_nodes.size());
1493 
1494  // If we don't have a continuous FE
1495  // then we want to average between
1496  // sides, at least in the equal-level
1497  // case where it's easy. This is
1498  // analogous to our repeat_count
1499  // behavior elsewhere.
1500  const FEContinuity cont =
1501  FEInterface::get_continuity(fe_type);
1502  const Elem * const neigh = elem->neighbor_ptr(s);
1503 
1504  if ((cont == DISCONTINUOUS || cont == H_CURL || cont == H_DIV) &&
1505  neigh &&
1506  neigh->level() == elem->level() &&
1507  var_description.active_on_subdomain(neigh->subdomain_id()))
1508  {
1509  std::vector<dof_id_type> neigh_indices;
1510  dof_map.dof_indices (neigh, neigh_indices, var);
1511  std::vector<Number> neigh_coeffs(neigh_indices.size());
1512 
1513  for (auto i : index_range(neigh_indices))
1514  neigh_coeffs[i] = sys_soln[neigh_indices[i]];
1515 
1516  const unsigned int s_neigh =
1517  neigh->which_neighbor_am_i(elem);
1518  std::vector<Number> neigh_soln;
1520  (fe_type, neigh, s_neigh,
1521  neigh_coeffs, neigh_soln, add_p_level,
1522  FEInterface::n_vec_dim(_mesh, fe_type));
1523 
1524  const std::vector<unsigned int> neigh_nodes =
1525  neigh->nodes_on_side(s_neigh);
1526  for (auto n : index_range(side_nodes))
1527  for (auto neigh_n : index_range(neigh_nodes))
1528  if (neigh->node_ptr(neigh_nodes[neigh_n])
1529  == elem->node_ptr(side_nodes[n]))
1530  {
1531  nodal_soln[n] += neigh_soln[neigh_n];
1532  nodal_soln[n] /= 2;
1533  }
1534  }
1535 
1536  for (auto n : index_range(side_nodes))
1537  {
1538  if (vertices_only &&
1539  !elem->is_vertex(n))
1540  continue;
1541 
1542  // Compute index into global solution vector.
1543  std::size_t index =
1544  nv * (nn++) + (n_vars_written_current_system + var_offset);
1545 
1546  soln[index] += nodal_soln[n];
1547  }
1548  }
1549  }
1550  else
1551  {
1552  nn += vertices_only ? elem->n_vertices() : elem->n_nodes();
1553 
1554  for (auto s : elem->side_index_range())
1555  {
1556  if (redundant_added_side(*elem,s))
1557  continue;
1558 
1559  const std::vector<unsigned int> side_nodes =
1560  elem->nodes_on_side(s);
1561 
1562  for (auto n : index_range(side_nodes))
1563  {
1564  if (vertices_only &&
1565  !elem->is_vertex(n))
1566  continue;
1567  nn++;
1568  }
1569  }
1570  }
1571  } // end loop over active elements, writing "fake" sides
1572  }
1573  // If we made it here, we actually wrote a variable, so increment
1574  // the number of variables actually written for the current system.
1575  n_vars_written_current_system++;
1576 
1577  } // end loop over vars
1578  } // end if proc 0
1579 
1580  // Update offset for next loop iteration.
1581  var_offset += n_vars_written_current_system;
1582  } // end loop over systems
1583 }
unsigned int n_systems() const
static void side_nodal_soln(const FEType &fe_t, const Elem *elem, const unsigned int side, const std::vector< Number > &elem_soln, std::vector< Number > &nodal_soln, const bool add_p_level=true, const unsigned int vdim=1)
Build the nodal soln on one side from the (full) element soln.
Definition: fe_interface.C:651
MeshBase & _mesh
The mesh data structure.
processor_id_type n_processors() const
libmesh_assert(ctx)
static unsigned int n_vec_dim(const MeshBase &mesh, const FEType &fe_type)
static FEContinuity get_continuity(const FEType &fe_type)
Returns the input FEType&#39;s FEContinuity based on the underlying FEFamily and potentially the Order...
FEContinuity
defines an enum for finite element types to libmesh_assert a certain level (or type? Hcurl?) of continuity.
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:176
processor_id_type processor_id() const
static void nodal_soln(const unsigned int dim, const FEType &fe_t, const Elem *elem, const std::vector< Number > &elem_soln, std::vector< Number > &nodal_soln, const bool add_p_level=true, const unsigned int vdim=1)
Build the nodal soln from the element soln.
Definition: fe_interface.C:626
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:153
std::map< std::string, std::unique_ptr< System >, std::less<> > _systems
Data structure holding the systems.
static bool redundant_added_side(const Elem &elem, unsigned int side)

◆ build_elemental_solution_vector()

void libMesh::EquationSystems::build_elemental_solution_vector ( std::vector< Number > &  soln,
std::vector< std::string > &  names 
) const
inherited

Retrieve the solution data for CONSTANT MONOMIALs and/or components of CONSTANT MONOMIAL_VECs.

If 'names' is populated, only the variables corresponding to those names will be retrieved. This can be used to filter which variables are retrieved.

This is the more appropriately-named replacement for the get_solution() function defined above.

Definition at line 1030 of file equation_systems.C.

References libMesh::EquationSystems::build_parallel_elemental_solution_vector().

Referenced by libMesh::ExodusII_IO::write_element_data().

1032 {
1033  // Call the parallel version of this function
1034  std::unique_ptr<NumericVector<Number>> parallel_soln =
1036 
1037  // Localize into 'soln', provided that parallel_soln is not empty.
1038  // Note: parallel_soln will be empty in the event that none of the
1039  // input names were CONSTANT, MONOMIAL nor components of CONSTANT,
1040  // MONOMIAL_VEC variables, or there were simply none of these in
1041  // the EquationSystems object.
1042  soln.clear();
1043  if (parallel_soln)
1044  parallel_soln->localize_to_one(soln);
1045 }
std::unique_ptr< NumericVector< Number > > build_parallel_elemental_solution_vector(std::vector< std::string > &names) const
Builds a parallel vector of CONSTANT MONOMIAL and/or components of CONSTANT MONOMIAL_VEC solution val...

◆ build_parallel_elemental_solution_vector()

std::unique_ptr< NumericVector< Number > > libMesh::EquationSystems::build_parallel_elemental_solution_vector ( std::vector< std::string > &  names) const
inherited

Builds a parallel vector of CONSTANT MONOMIAL and/or components of CONSTANT MONOMIAL_VEC solution values corresponding to the entries in the input 'names' vector.

This vector is approximately uniformly distributed across all of the available processors.

The related function build_elemental_solution_vector() is implemented by calling this function and then calling localize_to_one() on the resulting vector.

Returns a nullptr if no CONSTANT, MONOMIAL/MONOMIAL_VEC variables exist in the 'names' vector (if it is empty, then it will return all variables in the system of this type if any) or a std::unique_ptr to a var-major numeric vector of total length n_elem * n_vars, where n_vars includes all components of vectors, ordered according to: [u0, u1, ... uN, v0, v1, ... vN, w0, w1, ... wN] for constant monomial variables (u, v, w) on a mesh with N elements.

Definition at line 1154 of file equation_systems.C.

References libMesh::ParallelObject::_communicator, libMesh::EquationSystems::_mesh, libMesh::MeshBase::active_local_element_stored_range(), libMesh::NumericVector< T >::build(), libMesh::NumericVector< T >::close(), libMesh::ParallelObject::comm(), libMesh::CONSTANT, libMesh::System::current_local_solution, libMesh::DofMap::dof_indices(), libMesh::EquationSystems::find_variable_numbers(), libMesh::System::get_dof_map(), libMesh::EquationSystems::get_system(), libMesh::index_range(), libMesh::NumericVector< T >::init(), libMesh::libmesh_assert(), libMesh::MeshBase::max_elem_id(), libMesh::MONOMIAL, libMesh::MONOMIAL_VEC, libMesh::MeshBase::n_elem(), libMesh::ParallelObject::n_processors(), libMesh::PARALLEL, libMesh::Threads::parallel_for(), libMesh::ParallelObject::processor_id(), libMesh::System::solution, libMesh::MeshBase::spatial_dimension(), libMesh::System::update(), libMesh::System::variable(), and libMesh::System::variable_type().

Referenced by libMesh::EquationSystems::build_elemental_solution_vector().

1155 {
1156  // Filter any names that aren't elemental variables and get the system indices for those that are.
1157  // Note that it's probably fine if the names vector is empty since we'll still at least filter
1158  // out all non-monomials. If there are no monomials, then nothing is output here.
1159  std::vector<FEType> type = {FEType(CONSTANT, MONOMIAL), FEType(CONSTANT, MONOMIAL_VEC)};
1160  std::vector<std::pair<unsigned int, unsigned int>> var_nums =
1161  this->find_variable_numbers(names, /*type=*/nullptr, &type);
1162 
1163  const std::size_t nv = names.size(); /*total number of vars including vector components*/
1164  const dof_id_type ne = _mesh.n_elem();
1165  libmesh_assert_equal_to (ne, _mesh.max_elem_id());
1166 
1167  // If there are no variables to write out don't do anything...
1168  if (!nv)
1169  return std::unique_ptr<NumericVector<Number>>(nullptr);
1170 
1171  // We can handle the case where there are nullptrs in the Elem vector
1172  // by just having extra zeros in the solution vector.
1173  numeric_index_type parallel_soln_global_size = ne*nv;
1174 
1175  numeric_index_type div = parallel_soln_global_size / this->n_processors();
1176  numeric_index_type mod = parallel_soln_global_size % this->n_processors();
1177 
1178  // Initialize all processors to the average size.
1179  numeric_index_type parallel_soln_local_size = div;
1180 
1181  // The first "mod" processors get an extra entry.
1182  if (this->processor_id() < mod)
1183  parallel_soln_local_size = div+1;
1184 
1185  // Create a NumericVector to hold the parallel solution
1186  std::unique_ptr<NumericVector<Number>> parallel_soln_ptr = NumericVector<Number>::build(_communicator);
1187  NumericVector<Number> & parallel_soln = *parallel_soln_ptr;
1188  parallel_soln.init(parallel_soln_global_size,
1189  parallel_soln_local_size,
1190  /*fast=*/false,
1191  /*ParallelType=*/PARALLEL);
1192 
1193  unsigned int sys_ctr = 0;
1194  unsigned int var_ctr = 0;
1195  for (auto i : index_range(var_nums))
1196  {
1197  std::pair<unsigned int, unsigned int> var_num = var_nums[i];
1198  const System & system = this->get_system(var_num.first);
1199 
1200  // Update the current_local_solution if necessary
1201  if (sys_ctr != var_num.first)
1202  {
1203  System & non_const_sys = const_cast<System &>(system);
1204  // We used to simply call non_const_sys.solution->close()
1205  // here, but that is not allowed when the solution vector is
1206  // locked read-only, for example when printing the solution
1207  // during during the middle of a solve... So try to be a bit
1208  // more careful about calling close() unnecessarily.
1209  libmesh_assert(this->comm().verify(non_const_sys.solution->closed()));
1210  if (!non_const_sys.solution->closed())
1211  non_const_sys.solution->close();
1212  non_const_sys.update();
1213  sys_ctr = var_num.first;
1214  }
1215 
1216  NumericVector<Number> & sys_soln(*system.current_local_solution);
1217 
1218  const unsigned int var = var_num.second;
1219 
1220  const Variable & variable = system.variable(var);
1221  const DofMap & dof_map = system.get_dof_map();
1222 
1223  // We need to check if the constant monomial is a scalar or a vector and set the number of
1224  // components as the mesh spatial dimension for the latter as per es.find_variable_numbers().
1225  // Even for the case where a variable is not active on any subdomain belonging to the
1226  // processor, we still need to know this number to update 'var_ctr'.
1227  const unsigned int n_comps =
1228  (system.variable_type(var) == type[1]) ? _mesh.spatial_dimension() : 1;
1229 
1230  // Loop over all elements in the mesh and index all components of the variable if it's active
1233  [&dof_map, &variable, ne, var, var_ctr, n_comps,
1234  &parallel_soln, &sys_soln](const ConstElemRange & range)
1235  {
1236  // The DOF indices for the finite element
1237  std::vector<dof_id_type> dof_indices;
1238 
1239  for (const Elem * elem : range)
1240  {
1241  if (variable.active_on_subdomain(elem->subdomain_id()))
1242  {
1243  dof_map.dof_indices(elem, dof_indices, var);
1244 
1245  // The number of DOF components needs to be equal to the expected number so that we know
1246  // where to store data to correctly correspond to variable names.
1247  libmesh_assert_equal_to(dof_indices.size(), n_comps);
1248 
1249  for (unsigned int comp = 0; comp < n_comps; comp++)
1250  parallel_soln.set(ne * (var_ctr + comp) + elem->id(), sys_soln(dof_indices[comp]));
1251  }
1252  }
1253  });
1254 
1255  var_ctr += n_comps;
1256  } // end loop over var_nums
1257 
1258  // NOTE: number of output names might not be equal to the number passed to this function. Any that
1259  // aren't CONSTANT MONOMIALS or components of CONSTANT MONOMIAL_VECS have been filtered out (see
1260  // EquationSystems::find_variable_numbers).
1261  //
1262  // But, if everything is accounted for properly, then names.size() == var_ctr
1263  libmesh_assert_equal_to(names.size(), var_ctr);
1264 
1265  parallel_soln.close();
1266  return parallel_soln_ptr;
1267 }
void parallel_for(const Range &range, const Body &body, unsigned int n_threads=libMesh::n_threads())
Execute the provided function object in parallel on the specified range.
Definition: threads_none.h:73
const Parallel::Communicator & comm() const
const Parallel::Communicator & _communicator
const T_sys & get_system(std::string_view name) const
StoredRange< MeshBase::const_element_iterator, const Elem * > ConstElemRange
Definition: elem_range.h:34
MeshBase & _mesh
The mesh data structure.
processor_id_type n_processors() const
dof_id_type numeric_index_type
Definition: id_types.h:99
virtual dof_id_type max_elem_id() const =0
libmesh_assert(ctx)
const ConstElemRange & active_local_element_stored_range() const
Definition: mesh_base.C:1928
unsigned int spatial_dimension() const
Definition: mesh_base.C:606
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, SolverPackage solver_package=libMesh::default_solver_package(), ParallelType parallel_type=AUTOMATIC)
Builds a NumericVector on the processors in communicator comm using the linear solver package specifi...
std::vector< std::pair< unsigned int, unsigned int > > find_variable_numbers(std::vector< std::string > &names, const FEType *type=nullptr, const std::vector< FEType > *types=nullptr) const
Finds system and variable numbers for any variables of &#39;type&#39; or of &#39;types&#39; corresponding to the entr...
virtual dof_id_type n_elem() const =0
processor_id_type processor_id() const
template class LIBMESH_EXPORT NumericVector< Number >
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:153
uint8_t dof_id_type
Definition: id_types.h:67

◆ build_parallel_solution_vector()

std::unique_ptr< NumericVector< Number > > libMesh::EquationSystems::build_parallel_solution_vector ( const std::set< std::string > *  system_names = nullptr,
bool  add_sides = false 
) const
inherited

A version of build_solution_vector which is appropriate for "parallel" output formats like Nemesis.

Returns
A std::unique_ptr to a node-major NumericVector of total length n_nodes*n_vars that various I/O classes can then use to get the local values they need to write on each processor.

Definition at line 596 of file equation_systems.C.

References libMesh::ParallelObject::_communicator, libMesh::EquationSystems::_mesh, libMesh::EquationSystems::_systems, libMesh::Variable::active_on_subdomain(), libMesh::NumericVector< T >::add(), TIMPI::Communicator::allgather(), libMesh::NumericVector< T >::build(), libMesh::NumericVector< T >::close(), libMesh::ParallelObject::comm(), libMesh::System::current_local_solution, dim, distance(), libMesh::DofMap::dof_indices(), libMesh::FEInterface::field_type(), libMesh::NumericVector< T >::first_local_index(), libMesh::NumericVector< T >::get(), libMesh::System::get_dof_map(), libMesh::DofObject::id(), libMesh::index_range(), libMesh::NumericVector< T >::init(), libMesh::NumericVector< T >::last_local_index(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::MeshBase::max_node_id(), libMesh::DofObject::n_dofs(), libMesh::System::n_vars(), libMesh::FEInterface::n_vec_dim(), libMesh::FEInterface::nodal_soln(), libMesh::System::number(), libMesh::FEType::p_refinement, libMesh::PARALLEL, libMesh::ParallelObject::processor_id(), TIMPI::Communicator::rank(), libMesh::EquationSystems::redundant_added_side(), libMesh::NumericVector< T >::set(), libMesh::FEInterface::side_nodal_soln(), TIMPI::Communicator::size(), libMesh::System::solution, libMesh::MeshBase::spatial_dimension(), TIMPI::Communicator::sum(), libMesh::TOLERANCE, libMesh::TYPE_VECTOR, libMesh::System::update(), libMesh::System::variable(), and libMesh::System::variable_type().

Referenced by libMesh::EquationSystems::build_solution_vector(), and libMesh::MeshOutput< MeshBase >::write_nodal_data().

598 {
599  LOG_SCOPE("build_parallel_solution_vector()", "EquationSystems");
600 
601  // This function must be run on all processors at once
602  parallel_object_only();
603 
604  const unsigned int dim = _mesh.spatial_dimension();
605  const dof_id_type max_nn = _mesh.max_node_id();
606 
607  // allocate vector storage to hold
608  // (max_node_id)*(number_of_variables) entries.
609  //
610  // If node renumbering is disabled and adaptive coarsening has
611  // created gaps between node numbers, then this vector will be
612  // sparse.
613  //
614  // We have to differentiate between between scalar and vector
615  // variables. We intercept vector variables and treat each
616  // component as a scalar variable (consistently with build_solution_names).
617 
618  unsigned int nv = 0;
619 
620  //Could this be replaced by a/some convenience methods?[PB]
621  {
622  unsigned int n_scalar_vars = 0;
623  unsigned int n_vector_vars = 0;
624  for (const auto & [sys_name, sys_ptr] : _systems)
625  {
626  // Check current system is listed in system_names, and skip pos if not
627  bool use_current_system = (system_names == nullptr);
628  if (!use_current_system)
629  use_current_system = system_names->count(sys_name);
630  if (!use_current_system || sys_ptr->hide_output())
631  continue;
632 
633  for (auto vn : make_range(sys_ptr->n_vars()))
634  {
635  if (FEInterface::field_type(sys_ptr->variable_type(vn)) == TYPE_VECTOR)
636  n_vector_vars++;
637  else
638  n_scalar_vars++;
639  }
640  }
641  // Here, we're assuming the number of vector components is the same
642  // as the mesh spatial dimension.
643  nv = n_scalar_vars + dim*n_vector_vars;
644  }
645 
646  // Get the number of nodes to store locally.
647  dof_id_type n_local_nodes = cast_int<dof_id_type>
648  (std::distance(_mesh.local_nodes_begin(),
649  _mesh.local_nodes_end()));
650 
651  // If node renumbering has been disabled, nodes may not be numbered
652  // contiguously, and the number of nodes might not match the
653  // max_node_id. In this case we just do our best.
654  dof_id_type n_total_nodes = n_local_nodes;
655  _mesh.comm().sum(n_total_nodes);
656 
657  const processor_id_type n_proc = _mesh.comm().size();
658  const processor_id_type my_pid = _mesh.comm().rank();
659  const dof_id_type n_gaps = max_nn - n_total_nodes;
660  const dof_id_type gaps_per_processor = n_gaps / n_proc;
661  const dof_id_type remainder_gaps = n_gaps % n_proc;
662 
663  n_local_nodes = n_local_nodes + // Actual nodes
664  gaps_per_processor + // Our even share of gaps
665  (my_pid < remainder_gaps); // Leftovers
666 
667  // If we've been asked to build added sides' data, we need space to
668  // add it. Keep track of how much space.
669  dof_id_type local_added_side_nodes = 0,
670  added_side_nodes = 0;
671 
672  // others_added_side_nodes[p]: local_added_side_nodes on rank p
673  std::vector<dof_id_type> others_added_side_nodes;
674 
675  // A map of (element_id, side, side_node) pairs to the corresponding
676  // added side node index.
677  std::map<std::tuple<dof_id_type, unsigned short, unsigned short>,
678  dof_id_type> discontinuous_node_indices;
679 
680  // If we don't have any added side nodes, we'll have no offsets from
681  // them, and we won't care about which offsets apply to which node
682  // ids either.
683 
684  // Number of true nodes on processors [0,p]
685  std::vector<dof_id_type> true_node_offsets;
686  // Number of added (fake) nodes on processors [0,p)
687  std::vector<dof_id_type> added_node_offsets;
688 
689  auto node_id_to_vec_id =
690  [&true_node_offsets, &added_node_offsets]
691  (const dof_id_type node_id)
692  {
693  if (true_node_offsets.empty())
694  return node_id; // O(1) in the common !add_sides case
695 
696  // Find the processor id that has node_id in the parallel vec
697  const auto lb = std::upper_bound(true_node_offsets.begin(),
698  true_node_offsets.end(), node_id);
699  libmesh_assert(lb != true_node_offsets.end());
700  const processor_id_type p = lb - true_node_offsets.begin();
701 
702  return node_id + added_node_offsets[p];
703  };
704 
705  if (add_sides)
706  {
707  true_node_offsets.resize(n_proc);
708  added_node_offsets.resize(n_proc);
709 
710  // One loop to count everyone's new side nodes
711  for (const auto & elem : _mesh.active_element_ptr_range())
712  {
713  for (auto s : elem->side_index_range())
714  {
715  if (redundant_added_side(*elem,s))
716  continue;
717 
718  const std::vector<unsigned int> side_nodes =
719  elem->nodes_on_side(s);
720 
721  if (elem->processor_id() == this->processor_id())
722  local_added_side_nodes += side_nodes.size();
723  }
724  }
725 
726  others_added_side_nodes.resize(n_proc);
727  _mesh.comm().allgather(local_added_side_nodes,
728  others_added_side_nodes);
729 
730  added_side_nodes = std::accumulate(others_added_side_nodes.begin(),
731  others_added_side_nodes.end(), 0,
732  std::plus<>());
733 
734  _mesh.comm().allgather(n_local_nodes, true_node_offsets);
735  for (auto p : make_range(n_proc-1))
736  true_node_offsets[p+1] += true_node_offsets[p];
737  libmesh_assert_equal_to(true_node_offsets[n_proc-1], _mesh.max_node_id());
738 
739  // For nodes that exist in the mesh, we just need an offset to
740  // tell where to put their solutions.
741  added_node_offsets[0] = 0;
742  for (auto p : make_range(n_proc-1))
743  added_node_offsets[p+1] =
744  added_node_offsets[p] + others_added_side_nodes[p];
745 
746  // For added side nodes, we need to fill a map. Start after all
747  // the true node for our pid plus all the side nodes for
748  // previous pids
749  dof_id_type node_counter = true_node_offsets[my_pid];
750  for (auto p : make_range(my_pid))
751  node_counter += others_added_side_nodes[p];
752 
753  // One loop to figure out whose added side nodes get which index
754  for (const auto & elem : _mesh.active_local_element_ptr_range())
755  {
756  for (auto s : elem->side_index_range())
757  {
758  if (redundant_added_side(*elem,s))
759  continue;
760 
761  const std::vector<unsigned int> side_nodes =
762  elem->nodes_on_side(s);
763 
764  for (auto n : index_range(side_nodes))
765  discontinuous_node_indices
766  [std::make_tuple(elem->id(),s,n)] = node_counter++;
767  }
768  }
769  }
770 
771  const dof_id_type
772  n_global_vals = (max_nn + added_side_nodes) * nv,
773  n_local_vals = (n_local_nodes + local_added_side_nodes) * nv;
774 
775  // Create a NumericVector to hold the parallel solution
776  std::unique_ptr<NumericVector<Number>> parallel_soln_ptr = NumericVector<Number>::build(_communicator);
777  NumericVector<Number> & parallel_soln = *parallel_soln_ptr;
778  parallel_soln.init(n_global_vals, n_local_vals, false, PARALLEL);
779 
780  // Create a NumericVector to hold the "repeat_count" for each node - this is essentially
781  // the number of elements contributing to that node's value
782  std::unique_ptr<NumericVector<Number>> repeat_count_ptr = NumericVector<Number>::build(_communicator);
783  NumericVector<Number> & repeat_count = *repeat_count_ptr;
784  repeat_count.init(n_global_vals, n_local_vals, false, PARALLEL);
785 
786  repeat_count.close();
787 
788  unsigned int var_num=0;
789 
790  // For each system in this EquationSystems object,
791  // update the global solution and if we are on processor 0,
792  // loop over the elements and build the nodal solution
793  // from the element solution. Then insert this nodal solution
794  // into the vector passed to build_solution_vector.
795  for (const auto & [sys_name, sys_ptr] : _systems)
796  {
797  // Check current system is listed in system_names, and skip pos if not
798  bool use_current_system = (system_names == nullptr);
799  if (!use_current_system)
800  use_current_system = system_names->count(sys_name);
801  if (!use_current_system || sys_ptr->hide_output())
802  continue;
803 
804  const System & system = *sys_ptr;
805  const unsigned int nv_sys = system.n_vars();
806  const unsigned int sys_num = system.number();
807 
808  //Could this be replaced by a/some convenience methods?[PB]
809  unsigned int n_scalar_vars = 0;
810  unsigned int n_vector_vars = 0;
811  for (auto vn : make_range(sys_ptr->n_vars()))
812  {
813  if (FEInterface::field_type(sys_ptr->variable_type(vn)) == TYPE_VECTOR)
814  n_vector_vars++;
815  else
816  n_scalar_vars++;
817  }
818 
819  // Here, we're assuming the number of vector components is the same
820  // as the mesh spatial dimension.
821  unsigned int nv_sys_split = n_scalar_vars + dim*n_vector_vars;
822 
823  // Update the current_local_solution
824  {
825  System & non_const_sys = const_cast<System &>(system);
826  // We used to simply call non_const_sys.solution->close()
827  // here, but that is not allowed when the solution vector is
828  // locked read-only, for example when printing the solution
829  // during the middle of a solve... So try to be a bit
830  // more careful about calling close() unnecessarily.
831  libmesh_assert(this->comm().verify(non_const_sys.solution->closed()));
832  if (!non_const_sys.solution->closed())
833  non_const_sys.solution->close();
834  non_const_sys.update();
835  }
836 
837  NumericVector<Number> & sys_soln(*system.current_local_solution);
838 
839  const DofMap & dof_map = system.get_dof_map();
840 
841  std::vector<Number> elem_soln; // The finite element solution
842  std::vector<Number> nodal_soln; // The FE solution interpolated to the nodes
843  std::vector<dof_id_type> dof_indices; // The DOF indices for the finite element
844 
845  unsigned var_inc = 0;
846  for (unsigned int var=0; var<nv_sys; var++)
847  {
848  const FEType & fe_type = system.variable_type(var);
849  const Variable & var_description = system.variable(var);
850  unsigned int n_vec_dim = FEInterface::n_vec_dim( sys_ptr->get_mesh(), fe_type );
851  const bool add_p_level = fe_type.p_refinement;
852 
853  for (const auto & elem : _mesh.active_local_element_ptr_range())
854  {
855  if (var_description.active_on_subdomain(elem->subdomain_id()))
856  {
857  dof_map.dof_indices (elem, dof_indices, var);
858  sys_soln.get(dof_indices, elem_soln);
859 
860  FEInterface::nodal_soln (elem->dim(),
861  fe_type,
862  elem,
863  elem_soln,
864  nodal_soln,
865  add_p_level,
866  n_vec_dim);
867 
868  // infinite elements should be skipped...
869  if (!elem->infinite())
870  {
871  libmesh_assert_equal_to (nodal_soln.size(), n_vec_dim*elem->n_nodes());
872 
873  for (auto n : elem->node_index_range())
874  {
875  const Node & node = elem->node_ref(n);
876 
877  const dof_id_type node_idx =
878  nv * node_id_to_vec_id(node.id());
879 
880  for (unsigned int d=0; d < n_vec_dim; d++)
881  {
882  // For vector-valued elements, all components are in nodal_soln. For each
883  // node, the components are stored in order, i.e. node_0 -> s0_x, s0_y, s0_z
884  parallel_soln.add(node_idx + (var_inc+d + var_num), nodal_soln[n_vec_dim*n+d]);
885 
886  // Increment the repeat count for this position
887  repeat_count.add(node_idx + (var_inc+d + var_num), 1);
888  }
889  }
890 
891  if (add_sides)
892  {
893  for (auto s : elem->side_index_range())
894  {
895  if (redundant_added_side(*elem,s))
896  continue;
897 
898  // Compute the FE solution at all the
899  // side nodes
901  (fe_type, elem, s, elem_soln,
902  nodal_soln, add_p_level, n_vec_dim);
903 
904 #ifdef DEBUG
905  const std::vector<unsigned int> side_nodes =
906  elem->nodes_on_side(s);
907 
908  libmesh_assert_equal_to
909  (nodal_soln.size(),
910  side_nodes.size());
911 #endif
912 
913  for (auto n : index_range(nodal_soln))
914  {
915  // Retrieve index into global solution vector.
916  std::size_t node_index =
917  nv * libmesh_map_find(discontinuous_node_indices,
918  std::make_tuple(elem->id(), s, n));
919 
920  for (unsigned int d=0; d < n_vec_dim; d++)
921  {
922  parallel_soln.add(node_index + (var_inc+d + var_num), nodal_soln[n_vec_dim*n+d]);
923  repeat_count.add(node_index + (var_inc+d + var_num), 1);
924  }
925  }
926  }
927  }
928  }
929  }
930  else // If this variable doesn't exist on this subdomain we have to still increment repeat_count so that we won't divide by 0 later:
931  for (auto n : elem->node_index_range())
932  {
933  const Node & node = elem->node_ref(n);
934  // Only do this if this variable has NO DoFs at
935  // this node... it might have some from an
936  // adjoining element...
937  if (!node.n_dofs(sys_num, var))
938  {
939  const dof_id_type node_idx =
940  nv * node_id_to_vec_id(node.id());
941 
942  for (unsigned int d=0; d < n_vec_dim; d++)
943  repeat_count.add(node_idx + (var_inc+d + var_num), 1);
944  }
945  }
946 
947  } // end loop over elements
948  var_inc += n_vec_dim;
949  } // end loop on variables in this system
950 
951  var_num += nv_sys_split;
952  } // end loop over systems
953 
954  // Sum the nodal solution values and repeat counts.
955  parallel_soln.close();
956  repeat_count.close();
957 
958  // If there were gaps in the node numbering, there will be
959  // corresponding zeros in the parallel_soln and repeat_count
960  // vectors. We need to set those repeat_count entries to 1
961  // in order to avoid dividing by zero.
962  if (n_gaps)
963  {
964  for (numeric_index_type i=repeat_count.first_local_index();
965  i<repeat_count.last_local_index(); ++i)
966  {
967  // repeat_count entries are integral values but let's avoid a
968  // direct floating point comparison with 0 just in case some
969  // roundoff noise crept in during vector assembly?
970  if (std::abs(repeat_count(i)) < TOLERANCE)
971  repeat_count.set(i, 1.);
972  }
973 
974  // Make sure the repeat_count vector is up-to-date on all
975  // processors.
976  repeat_count.close();
977  }
978 
979  // Divide to get the average value at the nodes
980  parallel_soln /= repeat_count;
981 
982  return parallel_soln_ptr;
983 }
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
static constexpr Real TOLERANCE
unsigned int dim
void sum(T &r) const
static FEFieldType field_type(const FEType &fe_type)
processor_id_type rank() const
const Parallel::Communicator & comm() const
const Parallel::Communicator & _communicator
Real distance(const Point &p)
static void side_nodal_soln(const FEType &fe_t, const Elem *elem, const unsigned int side, const std::vector< Number > &elem_soln, std::vector< Number > &nodal_soln, const bool add_p_level=true, const unsigned int vdim=1)
Build the nodal soln on one side from the (full) element soln.
Definition: fe_interface.C:651
MeshBase & _mesh
The mesh data structure.
processor_id_type size() const
uint8_t processor_id_type
dof_id_type numeric_index_type
Definition: id_types.h:99
libmesh_assert(ctx)
static unsigned int n_vec_dim(const MeshBase &mesh, const FEType &fe_type)
unsigned int spatial_dimension() const
Definition: mesh_base.C:606
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:176
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, SolverPackage solver_package=libMesh::default_solver_package(), ParallelType parallel_type=AUTOMATIC)
Builds a NumericVector on the processors in communicator comm using the linear solver package specifi...
virtual dof_id_type max_node_id() const =0
processor_id_type processor_id() const
static void nodal_soln(const unsigned int dim, const FEType &fe_t, const Elem *elem, const std::vector< Number > &elem_soln, std::vector< Number > &nodal_soln, const bool add_p_level=true, const unsigned int vdim=1)
Build the nodal soln from the element soln.
Definition: fe_interface.C:626
template class LIBMESH_EXPORT NumericVector< Number >
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:153
uint8_t dof_id_type
Definition: id_types.h:67
std::map< std::string, std::unique_ptr< System >, std::less<> > _systems
Data structure holding the systems.
static bool redundant_added_side(const Elem &elem, unsigned int side)

◆ build_solution_vector() [1/2]

void libMesh::EquationSystems::build_solution_vector ( std::vector< Number > &  soln,
std::string_view  system_name,
std::string_view  variable_name = "all_vars" 
) const
inherited

Fill the input vector soln with the solution values for the system named name.

Note
The input vector soln will only be assembled on processor 0, so this method is only applicable to outputting plot files from processor 0.

Definition at line 584 of file equation_systems.C.

Referenced by libMesh::MeshOutput< MeshBase >::write_equation_systems().

587 {
588  // TODO:[BSK] re-implement this from the method below
589  libmesh_not_implemented();
590 }

◆ build_solution_vector() [2/2]

void libMesh::EquationSystems::build_solution_vector ( std::vector< Number > &  soln,
const std::set< std::string > *  system_names = nullptr,
bool  add_sides = false 
) const
inherited

Fill the input vector soln with solution values.

The entries will be in variable-major format (corresponding to the names from build_variable_names()).

If systems_names!=nullptr, only include data from the specified systems.

If add_sides is true, append data for plotting on "side elements" too.

Definition at line 987 of file equation_systems.C.

References libMesh::EquationSystems::build_parallel_solution_vector().

990 {
991  LOG_SCOPE("build_solution_vector()", "EquationSystems");
992 
993  // Call the parallel implementation
994  std::unique_ptr<NumericVector<Number>> parallel_soln =
995  this->build_parallel_solution_vector(system_names, add_sides);
996 
997  // Localize the NumericVector into the provided std::vector.
998  parallel_soln->localize_to_one(soln);
999 }
std::unique_ptr< NumericVector< Number > > build_parallel_solution_vector(const std::set< std::string > *system_names=nullptr, bool add_sides=false) const
A version of build_solution_vector which is appropriate for "parallel" output formats like Nemesis...

◆ build_variable_names()

void libMesh::EquationSystems::build_variable_names ( std::vector< std::string > &  var_names,
const FEType type = nullptr,
const std::set< std::string > *  system_names = nullptr 
) const
inherited

Fill the input vector var_names with the names of the variables for each system.

If type is passed, only variables of the specified type will be populated. If systems_names!=nullptr, only include names from the specified systems.

Definition at line 465 of file equation_systems.C.

References libMesh::EquationSystems::_systems, dim, libMesh::FEInterface::field_type(), libMesh::EquationSystems::get_mesh(), libMesh::make_range(), libMesh::EquationSystems::n_vars(), libMesh::FEInterface::n_vec_dim(), libMesh::MeshBase::spatial_dimension(), and libMesh::TYPE_VECTOR.

Referenced by main(), EquationSystemsTest::testBadVarNames(), libMesh::MeshOutput< MeshBase >::write_discontinuous_equation_systems(), libMesh::ExodusII_IO::write_discontinuous_exodusII(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::Nemesis_IO::write_element_data(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO::write_element_data_from_discontinuous_nodal_data(), libMesh::MeshOutput< MeshBase >::write_equation_systems(), libMesh::Nemesis_IO::write_nodal_data(), and libMesh::MeshOutput< MeshBase >::write_nodal_data().

468 {
469  // start indexing at end of possibly non-empty vector of variable names to avoid overwriting them
470  unsigned int var_num = var_names.size();
471 
472  // We'll want to double-check that we don't have any naming
473  // conflicts; this API causes problems down the line if so.
474  std::unordered_multiset<std::string> seen_names;
475 
476  // Need to size var_names by scalar variables plus all the
477  // vector components for all the vector variables
478  //Could this be replaced by a/some convenience methods?[PB]
479  {
480  unsigned int n_scalar_vars = 0;
481  unsigned int n_vector_vars = 0;
482 
483  for (const auto & [sys_name, sys_ptr] : _systems)
484  {
485  // Check current system is listed in system_names, and skip pos if not
486  bool use_current_system = (system_names == nullptr);
487  if (!use_current_system)
488  use_current_system = system_names->count(sys_name);
489  if (!use_current_system || sys_ptr->hide_output())
490  {
491  for (auto vn : make_range(sys_ptr->n_vars()))
492  seen_names.insert(sys_ptr->variable_name(vn));
493  continue;
494  }
495 
496  for (auto vn : make_range(sys_ptr->n_vars()))
497  {
498  seen_names.insert(sys_ptr->variable_name(vn));
499  if (FEInterface::field_type(sys_ptr->variable_type(vn)) == TYPE_VECTOR)
500  n_vector_vars++;
501  else
502  n_scalar_vars++;
503  }
504  }
505 
506  // Here, we're assuming the number of vector components is the same
507  // as the mesh spatial dimension.
508  unsigned int dim = this->get_mesh().spatial_dimension();
509  unsigned int nv = n_scalar_vars + dim*n_vector_vars;
510 
511  // We'd better not have more than dim*this->n_vars() (all vector variables)
512  // Treat the NodeElem-only mesh case as dim=1
513  libmesh_assert_less_equal ( nv, (dim > 0 ? dim : 1)*this->n_vars() );
514 
515  // 'nv' represents the max possible number of output variables, so allocate enough memory for
516  // all variables in the system to be populated here. When this is called more than once on a
517  // single 'var_names' vector, different filters should be used such that duplicates don't occur.
518  var_names.resize( nv );
519  }
520 
521  for (const auto & [sys_name, sys_ptr] : _systems)
522  {
523  // Check current system is listed in system_names, and skip pos if not
524  bool use_current_system = (system_names == nullptr);
525  if (!use_current_system)
526  use_current_system = system_names->count(sys_name);
527  if (!use_current_system || sys_ptr->hide_output())
528  continue;
529 
530  for (auto vn : make_range(sys_ptr->n_vars()))
531  {
532  const std::string & var_name = sys_ptr->variable_name(vn);
533  const FEType & fe_type = sys_ptr->variable_type(vn);
534 
535  unsigned int n_vec_dim = FEInterface::n_vec_dim( sys_ptr->get_mesh(), fe_type);
536 
537  // Filter on the type if requested
538  if (type == nullptr || (type && *type == fe_type))
539  {
540  if (FEInterface::field_type(fe_type) == TYPE_VECTOR)
541  {
542  switch(n_vec_dim)
543  {
544  case 0:
545  case 1:
546  var_names[var_num++] = var_name;
547  libmesh_error_msg_if(seen_names.count(var_name) > 1,
548  "Duplicate variable name "+var_name);
549  break;
550  case 2:
551  var_names[var_num++] = var_name+"_x";
552  var_names[var_num++] = var_name+"_y";
553  libmesh_error_msg_if(seen_names.count(var_name+"_x"),
554  "Duplicate variable name "+var_name+"_x");
555  libmesh_error_msg_if(seen_names.count(var_name+"_y"),
556  "Duplicate variable name "+var_name+"_y");
557  break;
558  case 3:
559  var_names[var_num++] = var_name+"_x";
560  var_names[var_num++] = var_name+"_y";
561  var_names[var_num++] = var_name+"_z";
562  libmesh_error_msg_if(seen_names.count(var_name+"_x"),
563  "Duplicate variable name "+var_name+"_x");
564  libmesh_error_msg_if(seen_names.count(var_name+"_y"),
565  "Duplicate variable name "+var_name+"_y");
566  libmesh_error_msg_if(seen_names.count(var_name+"_z"),
567  "Duplicate variable name "+var_name+"_z");
568  break;
569  default:
570  libmesh_error_msg("Invalid dim in build_variable_names");
571  }
572  }
573  else
574  var_names[var_num++] = var_name;
575  }
576  }
577  }
578  // Now resize again in case we filtered any names
579  var_names.resize(var_num);
580 }
unsigned int n_vars() const
unsigned int dim
static FEFieldType field_type(const FEType &fe_type)
static unsigned int n_vec_dim(const MeshBase &mesh, const FEType &fe_type)
unsigned int spatial_dimension() const
Definition: mesh_base.C:606
const MeshBase & get_mesh() const
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:176
std::map< std::string, std::unique_ptr< System >, std::less<> > _systems
Data structure holding the systems.

◆ clear()

void libMesh::EquationSystems::clear ( )
virtualinherited

Restores the data structure to a pristine state.

Definition at line 69 of file equation_systems.C.

References libMesh::EquationSystems::_systems, libMesh::Parameters::clear(), and libMesh::EquationSystems::parameters.

Referenced by main().

70 {
71  // Clear any additional parameters
72  parameters.clear ();
73 
74  // Clear the systems.
75  _systems.clear();
76 }
virtual void clear()
Clears internal data structures & frees any allocated memory.
Definition: parameters.h:349
Parameters parameters
Data structure holding arbitrary parameters.
std::map< std::string, std::unique_ptr< System >, std::less<> > _systems
Data structure holding the systems.

◆ comm()

const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inlineinherited
Returns
A reference to the Parallel::Communicator object used by this mesh.

Definition at line 97 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_tao_equality_constraints(), libMesh::__libmesh_tao_equality_constraints_jacobian(), libMesh::__libmesh_tao_gradient(), libMesh::__libmesh_tao_hessian(), libMesh::__libmesh_tao_inequality_constraints(), libMesh::__libmesh_tao_inequality_constraints_jacobian(), libMesh::__libmesh_tao_objective(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult_add(), libMesh::MeshRefinement::_refine_elements(), libMesh::MeshRefinement::_smooth_flags(), libMesh::DofMap::add_constraints_to_send_list(), add_cube_convex_hull_to_mesh(), libMesh::PetscDMWrapper::add_dofs_helper(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::RBEIMEvaluation::add_interpolation_data(), libMesh::CondensedEigenSystem::add_matrices(), libMesh::EigenSystem::add_matrices(), libMesh::System::add_matrix(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::DofMap::add_variable(), libMesh::DofMap::add_variables(), libMesh::System::add_vector(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::AdvectionSystem::assemble_claw_rhs(), libMesh::FEMSystem::assemble_qoi(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::MeshCommunication::assign_global_indices(), libMesh::Partitioner::assign_partitioning(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::Partitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_section(), libMesh::PetscDMWrapper::build_sf(), libMesh::MeshBase::cache_elem_data(), libMesh::System::calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::MeshTetInterface::check_hull_integrity(), libMesh::MeshBase::complete_preparation(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::RBSCMConstruction::compute_SCM_bounds_on_training_set(), libMesh::DofMap::computed_sparsity_already(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ContinuationSystem::ContinuationSystem(), libMesh::MeshBase::copy_constraint_rows(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::CondensedEigenSystem::copy_super_to_sub(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshTools::create_bounding_box(), libMesh::DofMap::create_dof_constraints(), libMesh::MeshTools::create_nodal_bounding_box(), libMesh::MeshRefinement::create_parent_error_vector(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::MeshTools::create_subdomain_bounding_box(), libMesh::PetscMatrix< T >::create_submatrix_nosort(), create_wrapped_function(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::RBEIMEvaluation::distribute_bfs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), DMVariableBounds_libMesh(), libMesh::DTKSolutionTransfer::DTKSolutionTransfer(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_nodes(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::EpetraVector< T >::EpetraVector(), AssembleOptimization::equality_constraints(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::SmoothnessEstimator::estimate_smoothness(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_error_tolerance(), libMesh::MeshRefinement::flag_elements_by_mean_stddev(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::DofMap::gather_constraints(), libMesh::MeshfreeInterpolation::gather_remote_data(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::RBEIMEvaluation::get_eim_basis_function_node_value(), libMesh::RBEIMEvaluation::get_eim_basis_function_side_value(), libMesh::RBEIMEvaluation::get_eim_basis_function_value(), libMesh::System::get_info(), libMesh::MeshBase::get_info(), libMesh::DofMap::get_info(), libMesh::RBEIMEvaluation::get_interior_basis_functions_as_vecs(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::RBEIMConstruction::get_max_abs_value(), libMesh::RBEIMConstruction::get_node_max_abs_value(), libMesh::RBEIMEvaluation::get_parametrized_function_node_value(), libMesh::RBEIMEvaluation::get_parametrized_function_side_value(), libMesh::RBEIMEvaluation::get_parametrized_function_value(), libMesh::RBEIMConstruction::get_random_point(), libMesh::MeshTetInterface::improve_hull_integrity(), AssembleOptimization::inequality_constraints(), AssembleOptimization::inequality_constraints_jacobian(), libMesh::LocationMap< T >::init(), libMesh::TimeSolver::init(), libMesh::StaticCondensation::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::AdvectionSystem::init_data(), libMesh::ClawSystem::init_data(), libMesh::PetscDMWrapper::init_petscdm(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set(), libMesh::RBEIMConstruction::inner_product(), integrate_function(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_equal_connectivity(), libMesh::MeshTools::libmesh_assert_equal_points(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_constraint_rows(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_flags(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_p_levels(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshTools::libmesh_assert_valid_unique_ids(), libMesh::libmesh_petsc_linesearch_shellfunc(), libMesh::libmesh_petsc_preconditioner_apply(), libMesh::libmesh_petsc_recalculate_monitor(), libMesh::libmesh_petsc_snes_fd_residual(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_mffd_interface(), libMesh::libmesh_petsc_snes_mffd_residual(), libMesh::libmesh_petsc_snes_postcheck(), libMesh::libmesh_petsc_snes_precheck(), libMesh::libmesh_petsc_snes_residual(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::limit_overrefined_boundary(), libMesh::MeshRefinement::limit_underrefined_boundary(), libMesh::LinearImplicitSystem::LinearImplicitSystem(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_new_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_new_nodes_parallel_consistent(), libMesh::MeshCommunication::make_node_bcids_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_unique_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshCommunication::make_p_levels_parallel_consistent(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), libMesh::FEMSystem::mesh_position_set(), libMesh::TriangulatorInterface::MeshedHole::MeshedHole(), LinearElasticityWithContact::move_mesh(), libMesh::DistributedMesh::n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::MeshTools::n_connected_components(), libMesh::DofMap::n_constrained_dofs(), libMesh::MeshBase::n_constraint_rows(), libMesh::DofMap::n_dofs(), libMesh::DofMap::n_dofs_per_processor(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::MeshTools::n_levels(), MixedOrderTest::n_neighbor_links(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::SparsityPattern::Build::n_nonzeros(), libMesh::MeshTools::n_p_levels(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::RBEIMEvaluation::node_distribute_bfs(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::RBEIMConstruction::node_inner_product(), libMesh::PetscVector< libMesh::Number >::operator=(), libMesh::MeshBase::operator==(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), libMesh::ReplicatedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_n_elem(), libMesh::DistributedMesh::parallel_n_nodes(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::BoundaryInfo::parallel_sync_node_ids(), libMesh::BoundaryInfo::parallel_sync_side_ids(), libMesh::MeshTools::paranoid_n_levels(), libMesh::Partitioner::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::print_constraint_rows(), libMesh::DofMap::print_dof_constraints(), libMesh::DofMap::process_mesh_constraint_rows(), libMesh::Partitioner::processor_pairs_to_interface_nodes(), libMesh::InterMeshProjection::project_system_vectors(), FEMParameters::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::EquationSystems::read(), libMesh::ExodusII_IO::read_header(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::RBEIMEvaluation::read_in_interior_basis_functions(), libMesh::RBEIMEvaluation::read_in_node_basis_functions(), libMesh::RBEIMEvaluation::read_in_side_basis_functions(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::Nemesis_IO_Helper::read_var_names_impl(), MeshFunctionTest::read_variable_info_from_output_data(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::SimplexRefiner::refine_via_edges(), libMesh::StaticCondensationDofMap::reinit(), libMesh::BoundaryInfo::remove_edge_id(), libMesh::BoundaryInfo::remove_node_id(), libMesh::BoundaryInfo::remove_shellface_id(), libMesh::BoundaryInfo::remove_side_id(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::DistributedMesh::renumber_nodes_and_elements(), LinearElasticityWithContact::residual_and_jacobian(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), scale_mesh_and_plot(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::send_and_insert_dof_values(), libMesh::TransientRBConstruction::set_error_temporal_data(), libMesh::Partitioner::set_interface_node_processor_ids_BFS(), libMesh::Partitioner::set_interface_node_processor_ids_linear(), libMesh::Partitioner::set_interface_node_processor_ids_petscpartitioner(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::PetscDiffSolver::setup_petsc_data(), libMesh::RBEIMEvaluation::side_distribute_bfs(), libMesh::RBEIMEvaluation::side_gather_bfs(), libMesh::RBEIMConstruction::side_inner_product(), libMesh::Partitioner::single_partition(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::VariationalMeshSmoother::smooth(), libMesh::ClawSystem::solve_conservation_law(), libMesh::split_mesh(), libMesh::RBEIMConstruction::store_eim_solutions_for_training_set(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::MeshBase::sync_subdomain_name_map(), ConstraintOperatorTest::test1DCoarseningNewNodes(), ConstraintOperatorTest::test1DCoarseningOperator(), MeshFunctionTest::test_bad_gradient_var_with_out_of_mesh_value(), MeshFunctionTest::test_bad_hessian_var_with_out_of_mesh_value(), libMesh::MeshRefinement::test_level_one(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), libMesh::MeshRefinement::test_unflagged(), DofMapTest::testBadElemFECombo(), SystemsTest::testBlockRestrictedVarNDofs(), BoundaryInfoTest::testBoundaryOnChildrenErrors(), VolumeTest::testC0PolygonMethods(), VolumeTest::testC0PolyhedronMethods(), ConstraintOperatorTest::testCoreform(), ConnectedComponentsTest::testEdge(), MeshInputTest::testExodusIGASidesets(), MeshTriangulationTest::testFoundCenters(), PointLocatorTest::testLocator(), BoundaryInfoTest::testMesh(), PointLocatorTest::testPlanar(), MeshTriangulationTest::testPoly2TriRefinementBase(), SystemsTest::testProjectCubeWithMeshFunction(), BoundaryInfoTest::testRenumber(), BoundaryInfoTest::testSelectiveRenumber(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), MeshTriangulationTest::testTriangulatorInterp(), MeshTriangulationTest::testTriangulatorMeshedHoles(), MeshTriangulationTest::testTriangulatorRoundHole(), MeshSmootherTest::testVariationalSmoother(), libMesh::MeshTools::total_weight(), libMesh::RBConstruction::train_reduced_basis_with_POD(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::Poly2TriTriangulator::triangulate(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::MeshRefinement::uniformly_coarsen(), update_current_local_solution(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::MeshTools::volume(), libMesh::STLIO::write(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::VTKIO::write_nodal_data(), libMesh::RBEIMEvaluation::write_out_interior_basis_functions(), libMesh::RBEIMEvaluation::write_out_node_basis_functions(), libMesh::RBEIMEvaluation::write_out_side_basis_functions(), libMesh::RBEvaluation::write_out_vectors(), libMesh::TransientRBConstruction::write_riesz_representors_to_files(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::RBDataSerialization::RBEvaluationSerialization::write_to_file(), libMesh::RBDataSerialization::TransientRBEvaluationSerialization::write_to_file(), libMesh::RBDataSerialization::RBEIMEvaluationSerialization::write_to_file(), and libMesh::RBDataSerialization::RBSCMEvaluationSerialization::write_to_file().

98  { return _communicator; }
const Parallel::Communicator & _communicator

◆ compare()

bool libMesh::EquationSystems::compare ( const EquationSystems other_es,
const Real  threshold,
const bool  verbose 
) const
virtualinherited
Returns
true when this equation system contains identical data, up to the given threshold. Delegates most of the comparisons to perform to the responsible systems

Definition at line 1612 of file equation_systems.C.

References libMesh::EquationSystems::_systems, libMesh::EquationSystems::get_system(), libMesh::EquationSystems::n_systems(), and libMesh::out.

Referenced by do_compare().

1615 {
1616  // safety check, whether we handle at least the same number
1617  // of systems
1618  std::vector<bool> os_result;
1619 
1620  if (this->n_systems() != other_es.n_systems())
1621  {
1622  if (verbose)
1623  {
1624  libMesh::out << " Fatal difference. This system handles "
1625  << this->n_systems() << " systems," << std::endl
1626  << " while the other system handles "
1627  << other_es.n_systems()
1628  << " systems." << std::endl
1629  << " Aborting comparison." << std::endl;
1630  }
1631  return false;
1632  }
1633  else
1634  {
1635  // start comparing each system
1636  for (const auto & [sys_name, sys_ptr] : _systems)
1637  {
1638  // get the other system
1639  const System & other_system = other_es.get_system (sys_name);
1640 
1641  os_result.push_back (sys_ptr->compare (other_system, threshold, verbose));
1642 
1643  }
1644 
1645  }
1646 
1647 
1648  // sum up the results
1649  if (os_result.size()==0)
1650  return true;
1651  else
1652  {
1653  bool os_identical;
1654  unsigned int n = 0;
1655  do
1656  {
1657  os_identical = os_result[n];
1658  n++;
1659  }
1660  while (os_identical && n<os_result.size());
1661  return os_identical;
1662  }
1663 }
unsigned int n_systems() const
OStreamProxy out
std::map< std::string, std::unique_ptr< System >, std::less<> > _systems
Data structure holding the systems.

◆ disable_print_counter_info()

void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 100 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

101 {
102  _enable_print_counter = false;
103  return;
104 }
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...

◆ disable_refine_in_reinit()

void libMesh::EquationSystems::disable_refine_in_reinit ( )
inlineinherited

Calls to reinit() will not try to coarsen or refine the mesh.

Definition at line 560 of file equation_systems.h.

References libMesh::EquationSystems::_refine_in_reinit.

Referenced by EquationSystemsTest::testRefineThenReinitPreserveFlags(), and EquationSystemsTest::testSelectivePRefine().

560 { this->_refine_in_reinit = false; }
bool _refine_in_reinit
Flag for whether to call coarsen/refine in reinit().

◆ dt()

Real Biharmonic::dt ( )
inline

Definition at line 81 of file biharmonic.h.

References _dt.

81 { return _dt; }

◆ dt0()

Real Biharmonic::dt0 ( )
inline

Definition at line 80 of file biharmonic.h.

References _dt0.

80 { return _dt0; }

◆ enable_default_ghosting()

void libMesh::EquationSystems::enable_default_ghosting ( bool  enable)
virtualinherited

Enable or disable default ghosting functors on the Mesh and on all Systems.

Standard ghosting is enabled by default. If disabled, default ghosting will also be disabled on any later added systems.

Unless other equivalent ghosting functors have been added, removing the default coupling functor is only safe for explicit solves, and removing the default algebraic ghosting functor is only safe for codes where no evaluations on neighbor cells (e.g. no jump error estimators) are done.

Definition at line 320 of file equation_systems.C.

References libMesh::EquationSystems::_enable_default_ghosting, libMesh::DofMap::add_default_ghosting(), libMesh::EquationSystems::get_mesh(), libMesh::EquationSystems::get_system(), libMesh::make_range(), mesh, libMesh::EquationSystems::n_systems(), and libMesh::DofMap::remove_default_ghosting().

Referenced by EquationSystemsTest::testDisableDefaultGhosting().

321 {
322  _enable_default_ghosting = enable;
323  MeshBase &mesh = this->get_mesh();
324 
325  if (enable)
326  mesh.add_ghosting_functor(mesh.default_ghosting());
327  else
328  mesh.remove_ghosting_functor(mesh.default_ghosting());
329 
330  for (auto i : make_range(this->n_systems()))
331  {
332  DofMap & dof_map = this->get_system(i).get_dof_map();
333  if (enable)
334  dof_map.add_default_ghosting();
335  else
336  dof_map.remove_default_ghosting();
337  }
338 }
unsigned int n_systems() const
bool _enable_default_ghosting
Flag for whether to enable default ghosting on newly added Systems.
MeshBase & mesh
const T_sys & get_system(std::string_view name) const
const MeshBase & get_mesh() const
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:176

◆ enable_print_counter_info()

void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

Methods to enable/disable the reference counter output from print_info().

Enabled by default.

Definition at line 94 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

Referenced by libMesh::LibMeshInit::~LibMeshInit().

95 {
96  _enable_print_counter = true;
97  return;
98 }
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...

◆ enable_refine_in_reinit()

void libMesh::EquationSystems::enable_refine_in_reinit ( )
inlineinherited

Calls to reinit() will also do two-step coarsen-then-refine.

Definition at line 555 of file equation_systems.h.

References libMesh::EquationSystems::_refine_in_reinit.

555 { this->_refine_in_reinit = true; }
bool _refine_in_reinit
Flag for whether to call coarsen/refine in reinit().

◆ find_variable_numbers()

std::vector< std::pair< unsigned int, unsigned int > > libMesh::EquationSystems::find_variable_numbers ( std::vector< std::string > &  names,
const FEType type = nullptr,
const std::vector< FEType > *  types = nullptr 
) const
inherited

Finds system and variable numbers for any variables of 'type' or of 'types' corresponding to the entries in the input 'names' vector.

If 'names' is empty, this returns all variables of the type. The names of vector variables are decomposed into individual ones suffixed with their cartesian component, but there will still be a single pair of system numbers for such vector variables. Thus, the size of the 'names' vector modified by this function may not be equal to that of the returned vector of pairs. Nevertheless, both should be sorted in accordance with ExodusII format, and so the developer just needs to know to separate dof_indices when accessing the system solution for vector variables.

This function is designed to work for either a single type or a vector of types, but not both. This is because it can't simply be called a second time with another type as it filters (deletes) the names of those on the first call that used a different type. Thus, the 'types' argument is for the case where variables of multiple types are allowed to pass through.

TODO: find a more generic way to handle this whole procedure.

Definition at line 1049 of file equation_systems.C.

References dim, libMesh::FEInterface::field_type(), libMesh::index_range(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::System::n_vars(), libMesh::Quality::name(), libMesh::System::number(), libMesh::TYPE_VECTOR, libMesh::System::variable_name(), and libMesh::System::variable_type().

Referenced by libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::Nemesis_IO::write_element_data(), and libMesh::Nemesis_IO::write_nodal_data().

1050 {
1051  // This function must be run on all processors at once
1052  parallel_object_only();
1053 
1054  libmesh_assert (this->n_systems());
1055 
1056  // Resolve class of type input and assert that at least one of them is null
1057  libmesh_assert_msg(!type || !types,
1058  "Input 'type', 'types', or neither in find_variable_numbers, but not both.");
1059 
1060  std::vector<FEType> type_filter;
1061  if (type)
1062  type_filter.push_back(*type);
1063  else if (types)
1064  type_filter = *types;
1065 
1066  // Store a copy of the valid variable names, if any. The names vector will be repopulated with any
1067  // valid names (or all if 'is_names_empty') in the system that passes through the type filter. If
1068  // the variable is a vector, its name will be decomposed into its separate components in
1069  // accordance with build_variable_names().
1070  std::vector<std::string> name_filter = names;
1071  bool is_names_empty = name_filter.empty();
1072  names.clear();
1073 
1074  // initialize convenience variables
1075  FEType var_type;
1076  std::string name;
1077 
1078  const std::vector<std::string> component_suffix = {"_x", "_y", "_z"};
1079  unsigned int dim = _mesh.spatial_dimension();
1080  libmesh_error_msg_if(dim > 3, "Invalid dim in find_variable_numbers");
1081 
1082  // Now filter through the variables in each system and store the system index and their index
1083  // within that system. This way, we know where to find their data even after we sort them.
1084  std::vector<std::pair<unsigned int, unsigned int>> var_nums;
1085 
1086  for (const auto & pr : _systems)
1087  {
1088  const System & system = *(pr.second);
1089 
1090  for (auto var : make_range(system.n_vars()))
1091  {
1092  // apply the type filter
1093  var_type = system.variable_type(var);
1094  if (type_filter.size() &&
1095  std::find(type_filter.begin(), type_filter.end(), var_type) == type_filter.end())
1096  continue;
1097 
1098  // apply the name filter (note that all variables pass if it is empty)
1099  if (FEInterface::field_type(var_type) == TYPE_VECTOR)
1100  {
1101  std::vector<std::string> component_names;
1102  for (unsigned int comp = 0; comp < dim; ++comp)
1103  {
1104  name = system.variable_name(var) + component_suffix[comp];
1105  if (is_names_empty ||
1106  (std::find(name_filter.begin(), name_filter.end(), name) != name_filter.end()))
1107  component_names.push_back(name);
1108  }
1109 
1110  if (! component_names.empty())
1111  names.insert(names.end(), component_names.begin(), component_names.end());
1112  else
1113  continue;
1114  }
1115  else /*scalar-valued variable*/
1116  {
1117  name = system.variable_name(var);
1118  if (is_names_empty ||
1119  (std::find(name_filter.begin(), name_filter.end(), name) != name_filter.end()))
1120  names.push_back(name);
1121  else
1122  continue;
1123  }
1124 
1125  // if the variable made it through both filters get its system indices
1126  var_nums.emplace_back(system.number(), var);
1127  }
1128  }
1129 
1130  // Sort the var_nums vector pairs alphabetically based on the variable name
1131  std::vector<unsigned int> sort_index(var_nums.size());
1132  std::iota(sort_index.begin(), sort_index.end(), 0);
1133  std::sort(sort_index.begin(), sort_index.end(),
1134  [&](const unsigned int & lhs, const unsigned int & rhs)
1135  {return this->get_system(var_nums[lhs].first).variable_name(var_nums[lhs].second) <
1136  this->get_system(var_nums[rhs].first).variable_name(var_nums[rhs].second);});
1137 
1138  std::vector<std::pair<unsigned int, unsigned int>> var_nums_sorted(var_nums.size());
1139  for (auto i : index_range(var_nums_sorted))
1140  {
1141  var_nums_sorted[i].first = var_nums[sort_index[i]].first;
1142  var_nums_sorted[i].second = var_nums[sort_index[i]].second;
1143  }
1144 
1145  // Also sort the names vector
1146  std::sort(names.begin(), names.end());
1147 
1148  // Return the sorted vector pairs
1149  return var_nums_sorted;
1150 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
unsigned int n_systems() const
unsigned int dim
static FEFieldType field_type(const FEType &fe_type)
const T_sys & get_system(std::string_view name) const
MeshBase & _mesh
The mesh data structure.
libmesh_assert(ctx)
unsigned int spatial_dimension() const
Definition: mesh_base.C:606
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:176
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:153
std::map< std::string, std::unique_ptr< System >, std::less<> > _systems
Data structure holding the systems.

◆ get_info() [1/2]

std::string libMesh::ReferenceCounter::get_info ( )
staticinherited

Gets a string containing the reference information.

Definition at line 47 of file reference_counter.C.

References libMesh::ReferenceCounter::_counts, and libMesh::Quality::name().

Referenced by libMesh::ReferenceCounter::print_info().

48 {
49 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
50 
51  std::ostringstream oss;
52 
53  oss << '\n'
54  << " ---------------------------------------------------------------------------- \n"
55  << "| Reference count information |\n"
56  << " ---------------------------------------------------------------------------- \n";
57 
58  for (const auto & [name, cd] : _counts)
59  oss << "| " << name << " reference count information:\n"
60  << "| Creations: " << cd.first << '\n'
61  << "| Destructions: " << cd.second << '\n';
62 
63  oss << " ---------------------------------------------------------------------------- \n";
64 
65  return oss.str();
66 
67 #else
68 
69  return "";
70 
71 #endif
72 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
static Counts _counts
Actually holds the data.

◆ get_info() [2/2]

std::string libMesh::EquationSystems::get_info ( ) const
virtualinherited
Returns
A string containing information about the systems, flags, and parameters.

Definition at line 1667 of file equation_systems.C.

References libMesh::EquationSystems::_systems, and libMesh::EquationSystems::n_systems().

Referenced by libMesh::EquationSystems::print_info().

1668 {
1669  std::ostringstream oss;
1670 
1671  unsigned int n_hidden_sys = 0;
1672  for (auto & pr : _systems)
1673  n_hidden_sys += pr.second->hide_output();
1674 
1675  oss << " EquationSystems\n"
1676  << " n_systems()=" << this->n_systems()
1677  << (n_hidden_sys ? " (hidden: " + std::to_string(n_hidden_sys) + ")" : "")
1678  << "\n";
1679 
1680  // Print the info for the individual systems
1681  for (const auto & pr : _systems)
1682  if (!pr.second->hide_output())
1683  oss << pr.second->get_info();
1684 
1685 
1686  // // Possibly print the parameters
1687  // if (!this->parameters.empty())
1688  // {
1689  // oss << " n_parameters()=" << this->n_parameters() << '\n';
1690  // oss << " Parameters:\n";
1691 
1692  // for (const auto & [key, val] : _parameters)
1693  // oss << " "
1694  // << "\""
1695  // << key
1696  // << "\""
1697  // << "="
1698  // << val
1699  // << '\n';
1700  // }
1701 
1702  return oss.str();
1703 }
unsigned int n_systems() const
std::map< std::string, std::unique_ptr< System >, std::less<> > _systems
Data structure holding the systems.

◆ get_mesh() [1/2]

const MeshBase & libMesh::EquationSystems::get_mesh ( ) const
inlineinherited
Returns
A constant reference to the mesh

Definition at line 632 of file equation_systems.h.

References libMesh::EquationSystems::_mesh.

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), alternative_fe_assembly(), assemble(), LinearElasticity::assemble(), assemble_1D(), assemble_biharmonic(), assemble_cd(), assemble_divgrad(), assemble_elasticity(), assemble_ellipticdg(), assemble_func(), assemble_graddiv(), assemble_helmholtz(), assemble_laplace(), assemble_mass(), assemble_matrices(), assemble_matrix_and_rhs(), assemble_poisson(), assemble_SchroedingerEquation(), assemble_shell(), assemble_stokes(), assemble_temperature_jump(), assemble_wave(), assembly_with_dg_fem_context(), libMesh::EquationSystems::build_variable_names(), compute_stresses(), LinearElasticity::compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::EquationSystems::enable_default_ghosting(), libMesh::AdjointRefinementEstimator::estimate_error(), fe_assembly(), fill_dirichlet_bc(), libMesh::MeshFunction::init(), LaplaceYoung::jacobian(), LargeDeformationElasticity::jacobian(), periodic_bc_test_poisson(), libMesh::EquationSystems::read(), libMesh::EquationSystems::reinit_solutions(), LaplaceYoung::residual(), LargeDeformationElasticity::residual(), run_timestepping(), scale_mesh_and_plot(), libMesh::DirectSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::DTKSolutionTransfer::transfer(), transform_mesh_and_plot(), libMesh::EquationSystems::write(), libMesh::MeshOutput< MeshBase >::write_discontinuous_equation_systems(), libMesh::MeshOutput< MeshBase >::write_equation_systems(), libMesh::Nemesis_IO_Helper::write_nodal_solution(), write_output(), and write_output_solvedata().

633 {
634  return _mesh;
635 }
MeshBase & _mesh
The mesh data structure.

◆ get_mesh() [2/2]

MeshBase & libMesh::EquationSystems::get_mesh ( )
inlineinherited
Returns
A reference to the mesh

Definition at line 640 of file equation_systems.h.

References libMesh::EquationSystems::_mesh.

641 {
642  return _mesh;
643 }
MeshBase & _mesh
The mesh data structure.

◆ get_system() [1/8]

template<typename T_sys >
const T_sys & libMesh::EquationSystems::get_system ( std::string_view  name) const
inlineinherited
Returns
A constant reference to the system named name. The template argument defines the return type. For example, const SteadySystem & sys = eq.get_system<SteadySystem> ("sys"); is an example of how the method might be used

Definition at line 743 of file equation_systems.h.

References libMesh::EquationSystems::_systems, and libMesh::Quality::name().

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::EquationSystems::_remove_default_ghosting(), add_M_C_K_helmholtz(), libMesh::EnsightIO::add_scalar(), libMesh::RBSCMConstruction::add_scaled_symm_Aq(), libMesh::EquationSystems::add_system(), libMesh::EnsightIO::add_vector(), libMesh::EquationSystems::adjoint_solve(), libMesh::EquationSystems::allgather(), alternative_fe_assembly(), apply_initial(), assemble(), LinearElasticity::assemble(), assemble_1D(), assemble_biharmonic(), assemble_cd(), assemble_divgrad(), assemble_elasticity(), assemble_ellipticdg(), assemble_func(), assemble_graddiv(), assemble_helmholtz(), assemble_laplace(), assemble_mass(), assemble_matrices(), assemble_matrix_and_rhs(), assemble_poisson(), assemble_SchroedingerEquation(), assemble_shell(), assemble_stokes(), assemble_temperature_jump(), assemble_wave(), assembly_with_dg_fem_context(), libMesh::ExactSolution::attach_exact_deriv(), libMesh::ExactSolution::attach_exact_hessian(), libMesh::ExactSolution::attach_exact_value(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::compare(), libMesh::ExactSolution::compute_error(), compute_stresses(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::GMVIO::copy_nodal_solution(), SolidSystem::element_time_derivative(), libMesh::EquationSystems::enable_default_ghosting(), libMesh::ExactSolution::error_norm(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::ErrorEstimator::estimate_errors(), libMesh::ExactSolution::ExactSolution(), fe_assembly(), fill_dirichlet_bc(), libMesh::DTKAdapter::find_sys(), form_functionA(), form_functionB(), form_matrixA(), libMesh::EquationSystems::init(), init_cd(), SolidSystem::init_data(), init_sys(), initialize(), LaplaceYoung::jacobian(), LargeDeformationElasticity::jacobian(), line_print(), libMesh::RBSCMConstruction::load_matrix_B(), main(), libMesh::RBSCMConstruction::perform_SCM_greedy(), periodic_bc_test_poisson(), libMesh::EquationSystems::read(), MeshFunctionTest::read_variable_info_from_output_data(), libMesh::EquationSystems::reinit_mesh(), libMesh::EquationSystems::reinit_solutions(), libMesh::EquationSystems::reinit_systems(), LaplaceYoung::residual(), LargeDeformationElasticity::residual(), run_timestepping(), SolidSystem::save_initial_mesh(), libMesh::EquationSystems::sensitivity_solve(), set_initial_condition(), SolidSystem::side_time_derivative(), libMesh::EquationSystems::solve(), MixedDimensionMeshTest::testDofOrdering(), MixedDimensionRefinedMeshTest::testDofOrdering(), MixedDimensionNonUniformRefinement::testDofOrdering(), MixedDimensionNonUniformRefinementTriangle::testDofOrdering(), MixedDimensionNonUniformRefinement3D::testDofOrdering(), SlitMeshRefinedSystemTest::testRestart(), libMesh::EquationSystems::update(), libMesh::Nemesis_IO_Helper::write_element_values(), libMesh::Nemesis_IO_Helper::write_nodal_solution(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().

744 {
745  auto pos = _systems.find(name);
746 
747  // Check for errors
748  libmesh_error_msg_if(pos == _systems.end(), "ERROR: no system named \"" << name << "\" found!");
749 
750  // Attempt dynamic cast
751  const auto & sys_ptr = pos->second;
752  return cast_ref<const T_sys &>(*sys_ptr);
753 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
std::map< std::string, std::unique_ptr< System >, std::less<> > _systems
Data structure holding the systems.

◆ get_system() [2/8]

template<typename T_sys >
T_sys & libMesh::EquationSystems::get_system ( std::string_view  name)
inlineinherited
Returns
A writable reference to the system named name. The template argument defines the return type. For example, const SteadySystem & sys = eq.get_system<SteadySystem> ("sys"); is an example of how the method might be used

Definition at line 762 of file equation_systems.h.

References libMesh::EquationSystems::_systems, and libMesh::Quality::name().

763 {
764  auto pos = _systems.find(name);
765 
766  // Check for errors
767  libmesh_error_msg_if(pos == _systems.end(), "ERROR: no system named " << name << " found!");
768 
769  // Attempt dynamic cast
770  auto & sys_ptr = pos->second;
771  return cast_ref<T_sys &>(*sys_ptr);
772 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
std::map< std::string, std::unique_ptr< System >, std::less<> > _systems
Data structure holding the systems.

◆ get_system() [3/8]

template<typename T_sys >
const T_sys & libMesh::EquationSystems::get_system ( const unsigned int  num) const
inlineinherited
Returns
A constant reference to system number num. The template argument defines the return type. For example, const SteadySystem & sys = eq.get_system<SteadySystem> (0); is an example of how the method might be used

Definition at line 702 of file equation_systems.h.

References libMesh::EquationSystems::_systems, and libMesh::EquationSystems::n_systems().

703 {
704  libmesh_assert_less (num, this->n_systems());
705 
706  for (auto & pr : _systems)
707  {
708  const auto & sys_ptr = pr.second;
709  if (sys_ptr->number() == num)
710  return cast_ref<const T_sys &>(*sys_ptr);
711  }
712  // Error if we made it here
713  libmesh_error_msg("ERROR: no system number " << num << " found!");
714 }
unsigned int n_systems() const
std::map< std::string, std::unique_ptr< System >, std::less<> > _systems
Data structure holding the systems.

◆ get_system() [4/8]

template<typename T_sys >
T_sys & libMesh::EquationSystems::get_system ( const unsigned int  num)
inlineinherited
Returns
A writable reference to the system number num. The template argument defines the return type. For example, const SteadySystem & sys = eq.get_system<SteadySystem> (0); is an example of how the method might be used

Definition at line 721 of file equation_systems.h.

References libMesh::EquationSystems::_systems, and libMesh::EquationSystems::n_systems().

722 {
723  libmesh_assert_less (num, this->n_systems());
724 
725  for (auto & pr : _systems)
726  {
727  auto & sys_ptr = pr.second;
728  if (sys_ptr->number() == num)
729  return cast_ref<T_sys &>(*sys_ptr);
730  }
731 
732  // Error if we made it here
733  libmesh_error_msg("ERROR: no system number " << num << " found!");
734 }
unsigned int n_systems() const
std::map< std::string, std::unique_ptr< System >, std::less<> > _systems
Data structure holding the systems.

◆ get_system() [5/8]

const System & libMesh::EquationSystems::get_system ( std::string_view  name) const
inlineinherited
Returns
A constant reference to the system named name.

Definition at line 781 of file equation_systems.h.

References libMesh::Quality::name().

782 {
783  return this->get_system<System>(name);
784 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42

◆ get_system() [6/8]

System & libMesh::EquationSystems::get_system ( std::string_view  name)
inlineinherited
Returns
A writable reference to the system named name.

Definition at line 789 of file equation_systems.h.

References libMesh::Quality::name().

790 {
791  return this->get_system<System>(name);
792 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42

◆ get_system() [7/8]

const System & libMesh::EquationSystems::get_system ( const unsigned int  num) const
inlineinherited
Returns
A constant reference to system number num.

Definition at line 797 of file equation_systems.h.

798 {
799  return this->get_system<System>(num);
800 }

◆ get_system() [8/8]

System & libMesh::EquationSystems::get_system ( const unsigned int  num)
inlineinherited
Returns
A writable reference to the system number num.

Definition at line 805 of file equation_systems.h.

806 {
807  return this->get_system<System>(num);
808 }

◆ get_vars_active_subdomains()

void libMesh::EquationSystems::get_vars_active_subdomains ( const std::vector< std::string > &  names,
std::vector< std::set< subdomain_id_type >> &  vars_active_subdomains 
) const
inherited

Retrieve vars_active_subdomains, which indicates the active subdomains for each variable in names.

Definition at line 1003 of file equation_systems.C.

References libMesh::EquationSystems::_systems, libMesh::Variable::active_subdomains(), distance(), and libMesh::make_range().

Referenced by libMesh::Nemesis_IO::write_element_data(), libMesh::ExodusII_IO::write_element_data(), and libMesh::ExodusII_IO::write_element_data_from_discontinuous_nodal_data().

1005 {
1006  vars_active_subdomains.clear();
1007  vars_active_subdomains.resize(names.size());
1008 
1009  for (const auto & pr : _systems)
1010  {
1011  const auto & sys_ptr = pr.second;
1012  for (auto vn : make_range(sys_ptr->n_vars()))
1013  {
1014  const std::string & var_name = sys_ptr->variable_name(vn);
1015 
1016  auto names_it = std::find(names.begin(), names.end(), var_name);
1017  if(names_it != names.end())
1018  {
1019  const Variable & variable = sys_ptr->variable(vn);
1020  const std::set<subdomain_id_type> & active_subdomains = variable.active_subdomains();
1021  vars_active_subdomains[std::distance(names.begin(), names_it)] = active_subdomains;
1022  }
1023  }
1024  }
1025 }
Real distance(const Point &p)
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:176
std::map< std::string, std::unique_ptr< System >, std::less<> > _systems
Data structure holding the systems.

◆ has_system()

bool libMesh::EquationSystems::has_system ( std::string_view  name) const
inlineinherited
Returns
true if the system named name exists within this EquationSystems object.

Definition at line 690 of file equation_systems.h.

References libMesh::EquationSystems::_systems, and libMesh::Quality::name().

Referenced by libMesh::EnsightIO::add_scalar(), libMesh::EnsightIO::add_vector(), libMesh::ExactSolution::compute_error(), libMesh::ExactSolution::error_norm(), and main().

691 {
692  if (_systems.find(name) == _systems.end())
693  return false;
694  return true;
695 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
std::map< std::string, std::unique_ptr< System >, std::less<> > _systems
Data structure holding the systems.

◆ increment_constructor_count()

void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name)
inlineprotectednoexceptinherited

Increments the construction counter.

Should be called in the constructor of any derived class that will be reference counted.

Definition at line 183 of file reference_counter.h.

References libMesh::err, libMesh::BasicOStreamProxy< charT, traits >::get(), libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().

184 {
185  libmesh_try
186  {
187  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
188  std::pair<unsigned int, unsigned int> & p = _counts[name];
189  p.first++;
190  }
191  libmesh_catch (...)
192  {
193  auto stream = libMesh::err.get();
194  stream->exceptions(stream->goodbit); // stream must not throw
195  libMesh::err << "Encountered unrecoverable error while calling "
196  << "ReferenceCounter::increment_constructor_count() "
197  << "for a(n) " << name << " object." << std::endl;
198  std::terminate();
199  }
200 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
OStreamProxy err
static Counts _counts
Actually holds the data.
streamT * get()
Rather than implement every ostream/ios/ios_base function, we&#39;ll be lazy and make esoteric uses go th...
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.
Definition: threads.C:30

◆ increment_destructor_count()

void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name)
inlineprotectednoexceptinherited

Increments the destruction counter.

Should be called in the destructor of any derived class that will be reference counted.

Definition at line 207 of file reference_counter.h.

References libMesh::err, libMesh::BasicOStreamProxy< charT, traits >::get(), libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().

208 {
209  libmesh_try
210  {
211  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
212  std::pair<unsigned int, unsigned int> & p = _counts[name];
213  p.second++;
214  }
215  libmesh_catch (...)
216  {
217  auto stream = libMesh::err.get();
218  stream->exceptions(stream->goodbit); // stream must not throw
219  libMesh::err << "Encountered unrecoverable error while calling "
220  << "ReferenceCounter::increment_destructor_count() "
221  << "for a(n) " << name << " object." << std::endl;
222  std::terminate();
223  }
224 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
OStreamProxy err
static Counts _counts
Actually holds the data.
streamT * get()
Rather than implement every ostream/ios/ios_base function, we&#39;ll be lazy and make esoteric uses go th...
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.
Definition: threads.C:30

◆ init()

void Biharmonic::init ( )
virtual

Initialize all the systems.

Reimplemented from libMesh::EquationSystems.

Definition at line 212 of file biharmonic.C.

References _dt, _jr, _o_count, _verbose, libMesh::TriangleWrapper::init(), and libMesh::out.

213 {
214  // Build the main equation encapsulated in the JR (Jacobian-Residual or J(R) "jet of R") object
215  _jr = &(add_system<Biharmonic::JR>(std::string("Biharmonic::JR")));
216 
217  if (_verbose)
218  libMesh::out << ">>> Initializing Biharmonic\n";
219 
220  _dt = 0;
221  _o_count = 0;
223 
224  if (_verbose)
225  libMesh::out << "<<< Initializing Biharmonic\n";
226 }
bool _verbose
Definition: biharmonic.h:98
int _o_count
Definition: biharmonic.h:108
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
OStreamProxy out

◆ n_active_dofs()

std::size_t libMesh::EquationSystems::n_active_dofs ( ) const
inherited
Returns
The number of active degrees of freedom for the EquationSystems object.

Definition at line 1749 of file equation_systems.C.

References libMesh::EquationSystems::_systems.

Referenced by main(), and write_output_solvedata().

1750 {
1751  std::size_t tot=0;
1752 
1753  for (const auto & pr : _systems)
1754  tot += pr.second->n_active_dofs();
1755 
1756  return tot;
1757 }
std::map< std::string, std::unique_ptr< System >, std::less<> > _systems
Data structure holding the systems.

◆ n_dofs()

std::size_t libMesh::EquationSystems::n_dofs ( ) const
inherited
Returns
The total number of degrees of freedom in all systems.

Definition at line 1736 of file equation_systems.C.

References libMesh::EquationSystems::_systems.

Referenced by Biharmonic::JR::bounds(), and Biharmonic::JR::residual_and_jacobian().

1737 {
1738  std::size_t tot=0;
1739 
1740  for (const auto & pr : _systems)
1741  tot += pr.second->n_dofs();
1742 
1743  return tot;
1744 }
std::map< std::string, std::unique_ptr< System >, std::less<> > _systems
Data structure holding the systems.

◆ n_objects()

static unsigned int libMesh::ReferenceCounter::n_objects ( )
inlinestaticinherited

Prints the number of outstanding (created, but not yet destroyed) objects.

Definition at line 85 of file reference_counter.h.

References libMesh::ReferenceCounter::_n_objects.

Referenced by libMesh::LibMeshInit::~LibMeshInit().

86  { return _n_objects; }
static Threads::atomic< unsigned int > _n_objects
The number of objects.

◆ n_processors()

processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
Returns
The number of processors in the group.

Definition at line 103 of file parallel_object.h.

References libMesh::ParallelObject::_communicator, libMesh::libmesh_assert(), and TIMPI::Communicator::size().

Referenced by libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::DofMap::add_constraints_to_send_list(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::System::add_vector(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::Partitioner::assign_partitioning(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::Partitioner::build_graph(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::DistributedMesh::clear(), libMesh::DistributedMesh::clear_elems(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::UnstructuredMesh::copy_nodes_and_elements(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_scalar_dofs(), libMesh::DistributedMesh::DistributedMesh(), libMesh::EnsightIO::EnsightIO(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::MeshBase::get_info(), libMesh::StaticCondensation::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_petscdm(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), libMesh::NumericVector< Number >::is_effectively_ghosted(), libMesh::NumericVector< Number >::is_effectively_serial(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::DofMap::n_dofs_per_processor(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::Partitioner::partition(), libMesh::MeshBase::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::DofMap::prepare_send_list(), libMesh::MeshBase::print_constraint_rows(), libMesh::DofMap::print_dof_constraints(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::XdrIO::read_header(), libMesh::CheckpointIO::read_nodes(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::Partitioner::repartition(), OverlappingFunctorTest::run_partitioner_test(), libMesh::DofMap::scatter_constraints(), libMesh::DistributedMesh::set_next_unique_id(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), WriteVecAndScalar::setupTests(), libMesh::RBEIMEvaluation::side_gather_bfs(), DistributedMeshTest::testRemoteElemError(), CheckpointIOTest::testSplitter(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::VTKIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

104  {
105  processor_id_type returnval =
106  cast_int<processor_id_type>(_communicator.size());
107  libmesh_assert(returnval); // We never have an empty comm
108  return returnval;
109  }
const Parallel::Communicator & _communicator
processor_id_type size() const
uint8_t processor_id_type
libmesh_assert(ctx)

◆ n_systems()

unsigned int libMesh::EquationSystems::n_systems ( ) const
inlineinherited

◆ n_vars()

unsigned int libMesh::EquationSystems::n_vars ( ) const
inherited
Returns
The total number of variables in all systems.

Definition at line 1724 of file equation_systems.C.

References libMesh::EquationSystems::_systems.

Referenced by libMesh::EquationSystems::build_variable_names().

1725 {
1726  unsigned int tot=0;
1727 
1728  for (const auto & pr : _systems)
1729  tot += pr.second->n_vars();
1730 
1731  return tot;
1732 }
std::map< std::string, std::unique_ptr< System >, std::less<> > _systems
Data structure holding the systems.

◆ output()

void Biharmonic::output ( int  timestep,
const Real &  t,
Real &  o_t,
bool  force = false 
)

Definition at line 253 of file biharmonic.C.

References _exio, _o_count, _o_dt, _ofile, _verbose, and libMesh::out.

Referenced by run().

257 {
258  if (!force && t - o_t < _o_dt)
259  return;
260 
261  ++_o_count;
262 
263  if (_verbose)
264  libMesh::out << "Writing state "
265  << timestep
266  << " at time "
267  << t
268  << " to file "
269  << _ofile
270  << "; output a total of "
271  << _o_count
272  << " states so far\n";
273 
274  _exio->write_timestep(_ofile, *this, timestep, t);
275 
276  if (!force)
277  o_t = t;
278 }
std::string _ofile
Definition: biharmonic.h:105
std::unique_ptr< ExodusII_IO > _exio
Definition: biharmonic.h:106
bool _verbose
Definition: biharmonic.h:98
int _o_count
Definition: biharmonic.h:108
OStreamProxy out
Real _o_dt
Definition: biharmonic.h:107

◆ print_info() [1/2]

void libMesh::ReferenceCounter::print_info ( std::ostream &  out_stream = libMesh::out)
staticinherited

Prints the reference information, by default to libMesh::out.

Definition at line 81 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter, and libMesh::ReferenceCounter::get_info().

Referenced by libMesh::LibMeshInit::~LibMeshInit().

82 {
84  out_stream << ReferenceCounter::get_info();
85 }
static std::string get_info()
Gets a string containing the reference information.
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...

◆ print_info() [2/2]

void libMesh::EquationSystems::print_info ( std::ostream &  os = libMesh::out) const
inherited

Prints information about the equation systems, by default to libMesh::out.

Definition at line 1707 of file equation_systems.C.

References libMesh::EquationSystems::get_info().

Referenced by assemble_and_solve(), do_compare(), main(), and libMesh::operator<<().

1708 {
1709  os << this->get_info()
1710  << std::endl;
1711 }
virtual std::string get_info() const

◆ processor_id()

processor_id_type libMesh::ParallelObject::processor_id ( ) const
inlineinherited
Returns
The rank of this processor in the group.

Definition at line 114 of file parallel_object.h.

References libMesh::ParallelObject::_communicator, and TIMPI::Communicator::rank().

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::MeshTools::Modification::all_tri(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::Partitioner::assign_partitioning(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::Partitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::MeshFunction::check_found_elem(), libMesh::DistributedMesh::clear(), libMesh::DistributedMesh::clear_elems(), libMesh::ExodusII_IO_Helper::close(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::compute_communication_map_parameters(), libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::Nemesis_IO_Helper::compute_node_communication_maps(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::ExodusII_IO_Helper::create(), libMesh::DistributedMesh::delete_elem(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_scalar_dofs(), libMesh::DistributedMesh::DistributedMesh(), libMesh::DofMapBase::end_dof(), libMesh::DofMapBase::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::find_dofs_to_send(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMapBase::first_dof(), libMesh::DofMapBase::first_old_dof(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::MeshBase::get_info(), libMesh::DofMap::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::RBEIMEvaluation::get_interior_basis_functions_as_vecs(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::DofMap::get_local_constraints(), libMesh::MeshBase::get_local_constraints(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::SparsityPattern::Build::handle_vi_vj(), libMesh::LaplaceMeshSmoother::init(), libMesh::SystemSubsetBySubdomain::init(), HeatSystem::init_data(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::DistributedMesh::insert_elem(), libMesh::DofMap::is_evaluable(), libMesh::SparsityPattern::Build::join(), libMesh::TransientRBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEvaluation::legacy_write_offline_data_to_files(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DofMap::local_variable_indices(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), AugmentSparsityOnInterface::mesh_reinit(), libMesh::TriangulatorInterface::MeshedHole::MeshedHole(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::MeshTools::n_connected_components(), libMesh::MeshBase::n_constraint_rows(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMapBase::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::DistributedMesh::own_node(), libMesh::BoundaryInfo::parallel_sync_node_ids(), libMesh::BoundaryInfo::parallel_sync_side_ids(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::print_constraint_rows(), libMesh::DofMap::print_dof_constraints(), libMesh::DofMap::process_mesh_constraint_rows(), libMesh::Nemesis_IO_Helper::put_cmap_params(), libMesh::Nemesis_IO_Helper::put_elem_cmap(), libMesh::Nemesis_IO_Helper::put_elem_map(), libMesh::Nemesis_IO_Helper::put_loadbal_param(), libMesh::Nemesis_IO_Helper::put_node_cmap(), libMesh::Nemesis_IO_Helper::put_node_map(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read(), libMesh::EquationSystems::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_global_values(), libMesh::ExodusII_IO::read_header(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::DynaIO::read_mesh(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::System::read_parallel_data(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::System::read_serialized_data(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::Nemesis_IO_Helper::read_var_names_impl(), libMesh::SimplexRefiner::refine_via_edges(), libMesh::StaticCondensationDofMap::reinit(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::DistributedMesh::renumber_nodes_and_elements(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::DistributedMesh::set_next_unique_id(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::RBEIMEvaluation::side_gather_bfs(), MeshFunctionTest::test_bad_gradient_var_with_out_of_mesh_value(), MeshFunctionTest::test_bad_hessian_var_with_out_of_mesh_value(), ExodusTest< elem_type >::test_read_gold(), ExodusTest< elem_type >::test_write(), MeshInputTest::testAbaqusRead(), MeshInputTest::testBadGmsh(), BoundaryInfoTest::testBoundaryIDs(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyElementVectorImpl(), MeshInputTest::testCopyNodalSolutionImpl(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testDynaFileMappings(), MeshInputTest::testDynaNoSplines(), MeshInputTest::testDynaReadElem(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusFileMappings(), MeshInputTest::testExodusIGASidesets(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), MeshInputTest::testGmshBCIDOverlap(), MeshInputTest::testGoodGmsh(), MeshInputTest::testGoodSTL(), MeshInputTest::testGoodSTLBinary(), BoundaryInfoTest::testInternalBoundary(), MeshInputTest::testLowOrderEdgeBlocks(), SystemsTest::testProjectMatrix3D(), BoundaryInfoTest::testShellFaceConstraints(), MeshInputTest::testSingleElementImpl(), WriteVecAndScalar::testSolution(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), MeshSmootherTest::testVariationalSmoother(), libMesh::MeshTools::total_weight(), libMesh::NetGenMeshInterface::triangulate(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::DTKAdapter::update_variable_values(), libMesh::MeshTools::volume(), libMesh::STLIO::write(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::CheckpointIO::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_element_values_element_major(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO_Helper::write_elemset_data(), libMesh::ExodusII_IO_Helper::write_elemsets(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::System::write_header(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::UCDIO::write_nodal_data(), libMesh::VTKIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_common(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::ExodusII_IO_Helper::write_nodeset_data(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::RBEIMEvaluation::write_out_interior_basis_functions(), libMesh::RBEIMEvaluation::write_out_node_basis_functions(), libMesh::RBEIMEvaluation::write_out_side_basis_functions(), write_output_solvedata(), libMesh::System::write_parallel_data(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::System::write_serialized_data(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), libMesh::ExodusII_IO_Helper::write_sideset_data(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), libMesh::ExodusII_IO_Helper::write_timestep(), and libMesh::ExodusII_IO::write_timestep_discontinuous().

115  { return cast_int<processor_id_type>(_communicator.rank()); }
processor_id_type rank() const
const Parallel::Communicator & _communicator

◆ read() [1/3]

template<typename InValType >
void libMesh::EquationSystems::read ( std::string_view  name,
const XdrMODE  mode,
const unsigned int  read_flags = (READ_HEADER | READ_DATA),
bool  partition_agnostic = true 
)
inherited

Read & initialize the systems from disk using the XDR data format.

This format allows for machine-independent binary output.

Set which sections of the file to read by bitwise OR'ing the EquationSystems::ReadFlags enumeration together. For example, to read all sections of the file, set read_flags to: (READ_HEADER | READ_DATA | READ_ADDITIONAL_DATA)

Note
The equation system can be defined without initializing the data vectors to any solution values. This can be done by omitting READ_DATA in the read_flags parameter.

If XdrMODE is omitted, it will be inferred as READ for filenames containing .xda or as DECODE for filenames containing .xdr

Parameters
nameName of the file to be read.
read_flagsSingle flag created by bitwise-OR'ing several flags together.
modeControls whether reading is done in binary or ascii mode.
partition_agnosticIf true then the mesh and degrees of freedom will be temporarily renumbered in a partition agnostic way so that files written using "n" mpi processes can be re-read on "m" mpi processes. This renumbering is not compatible with meshes that have two nodes in exactly the same position!

Definition at line 90 of file equation_systems_io.C.

References libMesh::Quality::name(), and libMesh::ParallelObject::processor_id().

Referenced by main(), libMesh::EquationSystems::read(), MeshFunctionTest::read_variable_info_from_output_data(), libMesh::FileHistoryData::retrieve_adjoint_solution(), libMesh::FileHistoryData::retrieve_primal_solution(), and SlitMeshRefinedSystemTest::testRestart().

94 {
95  // This will unzip a file with .bz2 as the extension, otherwise it
96  // simply returns the name if the file need not be unzipped.
97  Xdr io ((this->processor_id() == 0) ? std::string(name) : "", mode);
98 
99  std::function<std::unique_ptr<Xdr>()> local_io_functor;
100  local_io_functor = [this,&name,&mode]() {
101  return std::make_unique<Xdr>(local_file_name(this->processor_id(), name), mode); };
102 
103  this->read(io, local_io_functor, read_flags, partition_agnostic);
104 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
void read(std::string_view name, const XdrMODE, const unsigned int read_flags=(READ_HEADER|READ_DATA), bool partition_agnostic=true)
Read & initialize the systems from disk using the XDR data format.
processor_id_type processor_id() const

◆ read() [2/3]

template<typename InValType >
void libMesh::EquationSystems::read ( std::string_view  name,
const unsigned int  read_flags = (READ_HEADER | READ_DATA),
bool  partition_agnostic = true 
)
inherited

Definition at line 77 of file equation_systems_io.C.

References libMesh::DECODE, libMesh::Quality::name(), libMesh::READ, and libMesh::EquationSystems::read().

80 {
81  XdrMODE mode = READ;
82  if (name.find(".xdr") != std::string::npos)
83  mode = DECODE;
84  this->read(name, mode, read_flags, partition_agnostic);
85 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
XdrMODE
Defines an enum for read/write mode in Xdr format.
Definition: enum_xdr_mode.h:35
void read(std::string_view name, const XdrMODE, const unsigned int read_flags=(READ_HEADER|READ_DATA), bool partition_agnostic=true)
Read & initialize the systems from disk using the XDR data format.

◆ read() [3/3]

template<typename InValType >
void libMesh::EquationSystems::read ( Xdr io,
std::function< std::unique_ptr< Xdr >()> &  local_io_functor,
const unsigned int  read_flags = (READ_HEADER | READ_DATA),
bool  partition_agnostic = true 
)
inherited


This program implements the input of an EquationSystems object. This warrants some documentation. The output file essentially consists of 11 sections:

1.) A version header (for non-'legacy' formats, libMesh-0.7.0 and greater).
2.) The number of individual equation systems (unsigned int)

for each system

3.)  The name of the system (string)
4.)  The type of the system (string)

handled through System::read():

+-------------------------------------------------------------+
|  5.) The number of variables in the system (unsigned int)   |
|                                                             |
|   for each variable in the system                           |
|                                                             |
|    6.) The name of the variable (string)                    |
|                                                             |
|    7.) Combined in an FEType:                               |
|         - The approximation order(s) of the variable (Order |
|           Enum, cast to int/s)                              |
|         - The finite element family/ies of the variable     |
|           (FEFamily Enum, cast to int/s)                    |
|                                                             |
|   end variable loop                                         |
|                                                             |
| 8.) The number of additional vectors (unsigned int),        |
|                                                             |
|    for each additional vector in the equation system object |
|                                                             |
|    9.) the name of the additional vector  (string)          |
+-------------------------------------------------------------+

end system loop


for each system, handled through System::read_{serialized,parallel}_data():

+--------------------------------------------------------------+
| 10.) The global solution vector, re-ordered to be node-major |
|     (More on this later.)                                    |
|                                                              |
|    for each additional vector in the equation system object  |
|                                                              |
|    11.) The global additional vector, re-ordered to be       |
|         node-major (More on this later.)                     |
+--------------------------------------------------------------+

end system loop

Note that the actual IO is handled through the Xdr class (to be renamed later?) which provides a uniform interface to both the XDR (eXternal Data Representation) interface and standard ASCII output. Thus this one section of code will read XDR or ASCII files with no changes.

Definition at line 109 of file equation_systems_io.C.

References libMesh::EquationSystems::_mesh, libMesh::EquationSystems::add_system(), TIMPI::Communicator::broadcast(), libMesh::MeshRefinement::clean_refinement_flags(), libMesh::Xdr::close(), libMesh::ParallelObject::comm(), libMesh::Utility::contains(), libMesh::Xdr::data(), libMesh::MeshBase::fix_broken_node_and_element_numbering(), libMesh::EquationSystems::get_mesh(), libMesh::EquationSystems::get_system(), libMesh::MeshTools::Private::globally_renumber_nodes_and_elements(), libMesh::EquationSystems::init(), libMesh::libmesh_assert(), mesh, libMesh::ParallelObject::processor_id(), libMesh::EquationSystems::read(), libMesh::EquationSystems::READ_ADDITIONAL_DATA, libMesh::EquationSystems::READ_BASIC_ONLY, libMesh::EquationSystems::READ_DATA, libMesh::EquationSystems::READ_HEADER, libMesh::System::read_header(), libMesh::EquationSystems::READ_LEGACY_FORMAT, libMesh::Xdr::reading(), libMesh::System::set_basic_system_only(), libMesh::Xdr::set_version(), libMesh::EquationSystems::TRY_READ_IFEMS, and libMesh::EquationSystems::update().

113 {
177  // Set booleans from the read_flags argument
178  const bool read_header = read_flags & EquationSystems::READ_HEADER;
179  const bool read_data = read_flags & EquationSystems::READ_DATA;
180  const bool read_additional_data = read_flags & EquationSystems::READ_ADDITIONAL_DATA;
181  const bool read_legacy_format = read_flags & EquationSystems::READ_LEGACY_FORMAT;
182  const bool try_read_ifems = read_flags & EquationSystems::TRY_READ_IFEMS;
183  const bool read_basic_only = read_flags & EquationSystems::READ_BASIC_ONLY;
184  bool read_parallel_files = false;
185 
186  std::vector<std::pair<std::string, System *>> xda_systems;
187 
188  libmesh_assert (io.reading());
189 
190  {
191  // 1.)
192  // Read the version header.
193  std::string version = "legacy";
194  if (!read_legacy_format)
195  {
196  if (this->processor_id() == 0) io.data(version);
197  this->comm().broadcast(version);
198 
199  // All processors have the version header, if it does not contain
200  // the libMesh_label string then it is a legacy file.
201  const std::string libMesh_label = "libMesh-";
202  std::string::size_type lm_pos = version.find(libMesh_label);
203  if (lm_pos==std::string::npos)
204  {
205  io.close();
206 
207  // Recursively call this read() function but with the
208  // EquationSystems::READ_LEGACY_FORMAT bit set.
209  this->read (io, local_io_functor, (read_flags | EquationSystems::READ_LEGACY_FORMAT), partition_agnostic);
210  return;
211  }
212 
213  // Figure out the libMesh version that created this file
214  std::istringstream iss(version.substr(lm_pos + libMesh_label.size()));
215  int ver_major = 0, ver_minor = 0, ver_patch = 0;
216  char dot;
217  iss >> ver_major >> dot >> ver_minor >> dot >> ver_patch;
218  io.set_version(LIBMESH_VERSION_ID(ver_major, ver_minor, ver_patch));
219 
220 
221  read_parallel_files = Utility::contains(version, " parallel");
222 
223  // If requested that we try to read infinite element information,
224  // and the string " with infinite elements" is not in the version,
225  // then tack it on. This is for compatibility reading ifem
226  // files written prior to 11/10/2008 - BSK
227  if (try_read_ifems)
228  if (!Utility::contains(version, " with infinite elements"))
229  version += " with infinite elements";
230 
231  }
232  else
233  libmesh_deprecated();
234 
235  LOG_SCOPE("read()", "EquationSystems");
236 
237  // 2.)
238  // Read the number of systems
239  unsigned int n_sys=0;
240  if (this->processor_id() == 0) io.data (n_sys);
241  this->comm().broadcast(n_sys);
242 
243  for (unsigned int sys=0; sys<n_sys; sys++)
244  {
245  // 3.)
246  // Read the name of the sys-th equation system
247  std::string sys_name;
248  if (this->processor_id() == 0) io.data (sys_name);
249  this->comm().broadcast(sys_name);
250 
251  // 4.)
252  // Read the type of the sys-th equation system
253  std::string sys_type;
254  if (this->processor_id() == 0) io.data (sys_type);
255  this->comm().broadcast(sys_type);
256 
257  if (read_header)
258  this->add_system (sys_type, sys_name);
259 
260  // 5.) - 9.)
261  // Let System::read_header() do the job
262  System & new_system = this->get_system(sys_name);
263  new_system.read_header (io,
264  version,
265  read_header,
266  read_additional_data,
267  read_legacy_format);
268 
269  xda_systems.emplace_back(sys_name, &new_system);
270 
271  // If we're only creating "basic" systems, we need to tell
272  // each system that before we call init() later.
273  if (read_basic_only)
274  new_system.set_basic_system_only();
275  }
276  }
277 
278 
279 
280  // Now we are ready to initialize the underlying data
281  // structures. This will initialize the vectors for
282  // storage, the dof_map, etc...
283  if (read_header)
284  this->init();
285 
286  // 10.) & 11.)
287  // Read and set the numeric vector values
288  if (read_data)
289  {
290  std::unique_ptr<Xdr> local_io;
291 
292  // the EquationSystems::read() method should look constant from the mesh
293  // perspective, but we need to assign a temporary numbering to the nodes
294  // and elements in the mesh, which requires that we abuse const_cast
295  if (!read_legacy_format && partition_agnostic)
296  {
297  MeshBase & mesh = const_cast<MeshBase &>(this->get_mesh());
299  }
300 
301  for (auto & pr : xda_systems)
302  {
303  libmesh_error_msg_if(read_legacy_format,
304  "Reading legacy format XDR files is officially no longer supported.");
305 
306  if (read_parallel_files)
307  {
308  if (!local_io)
309  {
310  local_io = local_io_functor();
311  libmesh_assert(local_io->reading());
312  }
313  pr.second->read_parallel_data<InValType> (*local_io, read_additional_data);
314  }
315  else
316  pr.second->read_serialized_data<InValType> (io, read_additional_data);
317  }
318 
319  // Undo the temporary numbering.
320  if (!read_legacy_format && partition_agnostic)
322  }
323 
324  // Localize each system's data
325  this->update();
326 
327  #ifdef LIBMESH_ENABLE_AMR
328  MeshRefinement mesh_refine(_mesh);
329  mesh_refine.clean_refinement_flags();
330  #endif
331 }
MeshBase & mesh
const Parallel::Communicator & comm() const
virtual void fix_broken_node_and_element_numbering()=0
There is no reason for a user to ever call this function.
const T_sys & get_system(std::string_view name) const
MeshBase & _mesh
The mesh data structure.
libmesh_assert(ctx)
void read(std::string_view name, const XdrMODE, const unsigned int read_flags=(READ_HEADER|READ_DATA), bool partition_agnostic=true)
Read & initialize the systems from disk using the XDR data format.
bool contains(std::string_view superstring, std::string_view substring)
Look for a substring within a string.
Definition: utility.C:205
void globally_renumber_nodes_and_elements(MeshBase &)
There is no reason for a user to ever call this function.
Definition: mesh_tools.C:2657
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
const MeshBase & get_mesh() const
virtual void init()
Initialize all the systems.
virtual System & add_system(std::string_view system_type, std::string_view name)
Add the system of type system_type named name to the systems array.
processor_id_type processor_id() const
void update()
Updates local values for all the systems.

◆ redundant_added_side()

bool libMesh::EquationSystems::redundant_added_side ( const Elem elem,
unsigned int  side 
)
staticinherited

Definition at line 1587 of file equation_systems.C.

References libMesh::Elem::active(), libMesh::DofObject::id(), libMesh::libmesh_assert(), libMesh::Elem::neighbor_ptr(), and libMesh::remote_elem.

Referenced by libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), and libMesh::ExodusII_IO::write_nodal_data().

1588 {
1589  libmesh_assert(elem.active());
1590 
1591  const Elem * neigh = elem.neighbor_ptr(side);
1592 
1593  // Write boundary sides.
1594  if (!neigh)
1595  return false;
1596 
1597  // Write ghost sides in Nemesis
1598  if (neigh == remote_elem)
1599  return false;
1600 
1601  // Don't write a coarser side if a finer side exists
1602  if (!neigh->active())
1603  return true;
1604 
1605  // Don't write a side redundantly from both of the
1606  // elements sharing it. We'll disambiguate with id().
1607  return (neigh->id() < elem.id());
1608 }
libmesh_assert(ctx)
const RemoteElem * remote_elem
Definition: remote_elem.C:57

◆ refine_in_reinit_flag()

bool libMesh::EquationSystems::refine_in_reinit_flag ( )
inlineinherited
Returns
Whether or not calls to reinit() will try to coarsen/refine the mesh

Definition at line 565 of file equation_systems.h.

References libMesh::EquationSystems::_refine_in_reinit.

565 { return this->_refine_in_reinit; }
bool _refine_in_reinit
Flag for whether to call coarsen/refine in reinit().

◆ reinit()

void libMesh::EquationSystems::reinit ( )
virtualinherited

Handle any mesh changes and reinitialize all the systems on the updated mesh.

Definition at line 92 of file equation_systems.C.

References libMesh::EquationSystems::reinit_solutions(), and libMesh::EquationSystems::reinit_systems().

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), assemble_and_solve(), libMesh::AdjointRefinementEstimator::estimate_error(), main(), run_timestepping(), SystemsTest::test2DProjectVectorFE(), SystemsTest::test3DProjectVectorFE(), EquationSystemsTest::testBadVarNames(), MeshAssignTest::testMeshMoveAssign(), EquationSystemsTest::testPostInitAddElem(), EquationSystemsTest::testPostInitAddRealSystem(), EquationSystemsTest::testPostInitAddSystem(), SystemsTest::testProjectCube(), SystemsTest::testProjectLine(), SystemsTest::testProjectSquare(), InfFERadialTest::testRefinement(), EquationSystemsTest::testRefineThenReinitPreserveFlags(), EquationSystemsTest::testReinitWithNodeElem(), EquationSystemsTest::testRepartitionThenReinit(), and EquationSystemsTest::testSelectivePRefine().

93 {
94  const bool mesh_changed = this->reinit_solutions();
95 
96  // If the mesh has changed, systems will need to reinitialize their
97  // own data on the new mesh.
98  if (mesh_changed)
99  this->reinit_systems();
100 }
bool reinit_solutions()
Handle any mesh changes and project any solutions onto the updated mesh.
virtual void reinit_systems()
Reinitialize all systems on the current mesh.

◆ reinit_mesh()

void libMesh::EquationSystems::reinit_mesh ( )
virtualinherited

Handle the association of a completely new mesh with the EquationSystem and all the Systems assigned to it.

Definition at line 102 of file equation_systems.C.

References libMesh::EquationSystems::_mesh, libMesh::MeshBase::element_stored_range(), libMesh::EquationSystems::get_system(), libMesh::make_range(), libMesh::EquationSystems::n_systems(), and libMesh::Threads::parallel_for().

Referenced by libMesh::EquationSystems::init(), and MeshAssignTest::testMeshMoveAssign().

103 {
104  const unsigned int n_sys = this->n_systems();
105 
106  libmesh_assert_not_equal_to (n_sys, 0);
107 
108  // Tell all the \p DofObject entities how many systems
109  // there are.
110  for (auto & node : _mesh.node_ptr_range())
111  node->set_n_systems(n_sys);
112 
115  [n_sys](const ElemRange & range)
116  {
117  for (Elem * elem : range)
118  elem->set_n_systems(n_sys);
119  });
120 
121  //for (auto i : make_range(this->n_systems()))
122  //this->get_system(i).init();
123 
124 #ifdef LIBMESH_ENABLE_AMR
125  MeshRefinement mesh_refine(_mesh);
126  mesh_refine.clean_refinement_flags();
127 #endif
128 
129  // Now loop over all the systems belonging to this ES
130  // and call reinit_mesh for each system
131  for (auto i : make_range(this->n_systems()))
132  this->get_system(i).reinit_mesh();
133 
134 }
void parallel_for(const Range &range, const Body &body, unsigned int n_threads=libMesh::n_threads())
Execute the provided function object in parallel on the specified range.
Definition: threads_none.h:73
StoredRange< MeshBase::element_iterator, Elem * > ElemRange
Definition: elem_range.h:31
unsigned int n_systems() const
const T_sys & get_system(std::string_view name) const
MeshBase & _mesh
The mesh data structure.
const ElemRange & element_stored_range()
Definition: mesh_base.C:1913
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:176

◆ reinit_solutions()

bool libMesh::EquationSystems::reinit_solutions ( )
inherited

Handle any mesh changes and project any solutions onto the updated mesh.

Returns
Whether or not the mesh may have changed.

Definition at line 136 of file equation_systems.C.

References libMesh::EquationSystems::_mesh, libMesh::EquationSystems::_refine_in_reinit, libMesh::MeshRefinement::coarsen_elements(), libMesh::MeshBase::contract(), libMesh::DofMap::distribute_dofs(), libMesh::MeshBase::element_stored_range(), libMesh::MeshRefinement::face_level_mismatch_limit(), libMesh::System::get_dof_map(), libMesh::EquationSystems::get_mesh(), libMesh::EquationSystems::get_system(), libMesh::make_range(), libMesh::EquationSystems::n_systems(), libMesh::MeshRefinement::overrefined_boundary_limit(), libMesh::Threads::parallel_for(), libMesh::System::prolong_vectors(), libMesh::MeshRefinement::refine_elements(), libMesh::System::reinit_constraints(), libMesh::System::restrict_vectors(), and libMesh::MeshRefinement::underrefined_boundary_limit().

Referenced by libMesh::EquationSystems::reinit().

137 {
138  parallel_object_only();
139 
140  const unsigned int n_sys = this->n_systems();
141  libmesh_assert_not_equal_to (n_sys, 0);
142 
143  // And any new systems will need initialization
144  for (unsigned int i=0; i != n_sys; ++i)
145  if (!this->get_system(i).is_initialized())
146  this->get_system(i).init();
147 
148  // We used to assert that all nodes and elements *already* had
149  // n_systems() properly set; however this is false in the case where
150  // user code has manually added nodes and/or elements to an
151  // already-initialized system.
152 
153  // Make sure all the \p DofObject entities know how many systems
154  // there are.
155  {
156  // All the nodes
157  for (auto & node : _mesh.node_ptr_range())
158  node->set_n_systems(n_sys);
159 
160  // All the elements
163  [n_sys](const ElemRange & range)
164  {
165  for (Elem * elem : range)
166  elem->set_n_systems(n_sys);
167  });
168  }
169 
170  // Localize each system's vectors
171  for (unsigned int i=0; i != n_sys; ++i)
172  this->get_system(i).re_update();
173 
174 #ifdef LIBMESH_ENABLE_AMR
175 
176  bool mesh_changed = false;
177 
178  // FIXME: For backwards compatibility, assume
179  // refine_and_coarsen_elements or refine_uniformly have already
180  // been called
181  {
182  for (unsigned int i=0; i != n_sys; ++i)
183  {
184  System & sys = this->get_system(i);
185 
186  // Even if the system doesn't have any variables in it we want
187  // consistent behavior; e.g. distribute_dofs should have the
188  // opportunity to count up zero dofs on each processor.
189  //
190  // Who's been adding zero-var systems anyway, outside of my
191  // unit tests? - RHS
192  // if (!sys.n_vars())
193  // continue;
194 
195  sys.get_dof_map().distribute_dofs(_mesh);
196 
197  // Recreate any user or internal constraints
198  sys.reinit_constraints();
199 
200  // Even if there weren't any constraint changes,
201  // reinit_constraints() did prepare_send_list() for us.
202 
203  sys.prolong_vectors();
204  }
205  mesh_changed = true;
206  }
207 
208  if (this->_refine_in_reinit)
209  {
210  // Don't override any user refinement settings
211  MeshRefinement mesh_refine(_mesh);
212  mesh_refine.face_level_mismatch_limit() = 0; // unlimited
213  mesh_refine.overrefined_boundary_limit() = -1; // unlimited
214  mesh_refine.underrefined_boundary_limit() = -1; // unlimited
215 
216  // Try to coarsen the mesh, then restrict each system's vectors
217  // if necessary
218  if (mesh_refine.coarsen_elements())
219  {
220  for (auto i : make_range(this->n_systems()))
221  {
222  System & sys = this->get_system(i);
223  sys.get_dof_map().distribute_dofs(_mesh);
224  sys.reinit_constraints();
225 
226  // Even if there weren't any constraint changes,
227  // reinit_constraints() did prepare_send_list() for us.
228 
229  sys.restrict_vectors();
230  }
231  mesh_changed = true;
232  }
233 
234  // Once vectors are all restricted, we can delete
235  // children of coarsened elements
236  if (mesh_changed)
237  this->get_mesh().contract();
238 
239  // Try to refine the mesh, then prolong each system's vectors
240  // if necessary
241  if (mesh_refine.refine_elements())
242  {
243  for (auto i : make_range(this->n_systems()))
244  {
245  System & sys = this->get_system(i);
246  sys.get_dof_map().distribute_dofs(_mesh);
247  sys.reinit_constraints();
248 
249  // Even if there weren't any constraint changes,
250  // reinit_constraints() did prepare_send_list() for us.
251 
252  sys.prolong_vectors();
253  }
254  mesh_changed = true;
255  }
256  }
257 
258  return mesh_changed;
259 
260 #endif // #ifdef LIBMESH_ENABLE_AMR
261 
262  return false;
263 }
void parallel_for(const Range &range, const Body &body, unsigned int n_threads=libMesh::n_threads())
Execute the provided function object in parallel on the specified range.
Definition: threads_none.h:73
StoredRange< MeshBase::element_iterator, Elem * > ElemRange
Definition: elem_range.h:31
unsigned int n_systems() const
const T_sys & get_system(std::string_view name) const
MeshBase & _mesh
The mesh data structure.
const ElemRange & element_stored_range()
Definition: mesh_base.C:1913
bool _refine_in_reinit
Flag for whether to call coarsen/refine in reinit().
virtual bool contract()=0
Delete subactive (i.e.
const MeshBase & get_mesh() const
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:176

◆ reinit_systems()

void libMesh::EquationSystems::reinit_systems ( )
virtualinherited

Reinitialize all systems on the current mesh.

Definition at line 267 of file equation_systems.C.

References libMesh::EquationSystems::get_system(), libMesh::make_range(), and libMesh::EquationSystems::n_systems().

Referenced by libMesh::EquationSystems::reinit().

268 {
269  for (auto i : make_range(this->n_systems()))
270  this->get_system(i).reinit();
271 }
unsigned int n_systems() const
const T_sys & get_system(std::string_view name) const
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:176

◆ run()

void Biharmonic::run ( )

Definition at line 289 of file biharmonic.C.

References _dt, _t0, _t1, _verbose, libMesh::out, output(), libMesh::Real, and step().

290 {
291  Real t = _t0, o_t = 0.0;
292  int timestep = 1;
293 
294  // Force-write the initial timestep
295  output(timestep, t, o_t, true);
296 
297  while (t < _t1)
298  {
299  ++timestep;
300 
301  // A pretty update message
302  if (_verbose)
303  libMesh::out << "Solving for state " << timestep << ", time " << t << "\n";
304 
305  // Move biharmonic one timestep forward
306  step();
307 
308  // Keep track of time and timestep
309  t += _dt;
310 
311  // Output
312  output(timestep, t, o_t);
313  } // while(t < _t1)
314 
315  // Force-write the final timestep
316  output(timestep, t, o_t, true);
317 }
bool _verbose
Definition: biharmonic.h:98
void output(int timestep, const Real &t, Real &o_t, bool force=false)
Definition: biharmonic.C:253
void step(const Real &dt=-1.0)
Definition: biharmonic.C:232
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
OStreamProxy out

◆ sensitivity_solve()

void libMesh::EquationSystems::sensitivity_solve ( const ParameterVector parameters)
virtualinherited

Call sensitivity_solve on all the individual equation systems.

By default this function solves each sensitivity system once, in the order in which in which they were added. For more sophisticated decoupled problems the user may with to override this behavior in a derived class.

Definition at line 445 of file equation_systems.C.

References libMesh::EquationSystems::get_system(), libMesh::libmesh_assert(), libMesh::make_range(), and libMesh::EquationSystems::n_systems().

446 {
447  libmesh_assert (this->n_systems());
448 
449  for (auto i : make_range(this->n_systems()))
450  this->get_system(i).sensitivity_solve(parameters_in);
451 }
unsigned int n_systems() const
const T_sys & get_system(std::string_view name) const
libmesh_assert(ctx)
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:176

◆ solve()

void libMesh::EquationSystems::solve ( )
virtualinherited

Call solve on all the individual equation systems.

By default this function solves each equation system once, in the order they were added. For more sophisticated decoupled problems the user may with to override this behavior in a derived class.

Definition at line 435 of file equation_systems.C.

References libMesh::EquationSystems::get_system(), libMesh::libmesh_assert(), libMesh::make_range(), and libMesh::EquationSystems::n_systems().

Referenced by libMesh::UniformRefinementEstimator::_estimate_error().

436 {
437  libmesh_assert (this->n_systems());
438 
439  for (auto i : make_range(this->n_systems()))
440  this->get_system(i).solve();
441 }
unsigned int n_systems() const
const T_sys & get_system(std::string_view name) const
libmesh_assert(ctx)
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:176

◆ step()

void Biharmonic::step ( const Real &  dt = -1.0)

Definition at line 232 of file biharmonic.C.

References _dt, _dt0, and _jr.

Referenced by run().

233 {
234  // We need to update the old solution vector.
235  // The old solution vector will be the current solution vector from the
236  // previous time step. We use vector assignment. Only TransientSystems
237  // (and systems derived from them) contain old solutions.
238  if (dt_in < 0)
239  _dt = _dt0;
240  else
241  _dt = dt_in;
242 
243  *(_jr->old_local_solution) = *(_jr->current_local_solution);
244 
245  // this will localize the current solution, resulting in a
246  // current_local_solution with correct ghost values
247  _jr->solve();
248 }

◆ update()

void libMesh::EquationSystems::update ( )
inherited

Updates local values for all the systems.

Definition at line 342 of file equation_systems.C.

References libMesh::EquationSystems::get_system(), libMesh::make_range(), and libMesh::EquationSystems::n_systems().

Referenced by main(), libMesh::EquationSystems::read(), and MeshFunctionTest::read_variable_info_from_output_data().

343 {
344  LOG_SCOPE("update()", "EquationSystems");
345 
346  // Localize each system's vectors
347  for (auto i : make_range(this->n_systems()))
348  this->get_system(i).update();
349 }
unsigned int n_systems() const
const T_sys & get_system(std::string_view name) const
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:176

◆ verbose()

bool Biharmonic::verbose ( )
inline

Definition at line 79 of file biharmonic.h.

References _verbose.

79 { return _verbose; }
bool _verbose
Definition: biharmonic.h:98

◆ viewParameters()

void Biharmonic::viewParameters ( )

Definition at line 165 of file biharmonic.C.

References _cahn_hillard, _cnWeight, _degenerate, _dim, _dt0, _energy, _growth, _initialCenter, _initialState, _initialWidth, _kappa, _log_truncation, _N, _netforce, _o_dt, _ofile_base, _T, _t0, _t1, _theta, _theta_c, _tol, _verbose, BALL, int, libMesh::out, ROD, and STRIP.

166 {
167  libMesh::out << "Biharmonic parameters:\n";
168 
169  // Print verbosity status
170  if (_verbose)
171  libMesh::out << "verbose mode is on\n";
172  else
173  libMesh::out << "verbose mode is off\n";
174 
175  // Print parameters
176  libMesh::out << "mesh dimension = " << _dim << "\n";
177  libMesh::out << "initial linear mesh size = " << _N << "\n";
178  libMesh::out << "kappa = " << _kappa << "\n";
179  libMesh::out << "growth = " << (int)_growth << "\n";
180  libMesh::out << "degenerate = " << (int)_degenerate << "\n";
181  libMesh::out << "Cahn-Hillard = " << (int)_cahn_hillard << "\n";
182  libMesh::out << "netforce = " << (int)_netforce << "\n";
183  libMesh::out << "energy = " << _energy << "\n";
184  libMesh::out << "tol = " << _tol << "\n";
185  libMesh::out << "theta = " << _theta << "\n";
186  libMesh::out << "theta_c = " << _theta_c << "\n";
187  libMesh::out << "log truncation = " << _log_truncation << "\n";
188  libMesh::out << "initial timestep size = " << _dt0 << "\n";
189 
190  if (_initialState == STRIP)
191  libMesh::out << "initial state: strip\n";
192 
193  if (_initialState == ROD)
194  libMesh::out << "initial state: rod\n";
195 
196  if (_initialState == BALL)
197  libMesh::out << "initial state: ball\n";
198 
199  libMesh::out << "initial state center = " << _initialCenter(0) << "\n";
200  libMesh::out << "initial state width = " << _initialWidth << "\n";
201  libMesh::out << "initial time (min_time) = " << _t0 << "\n";
202  libMesh::out << "integration time = " << _T << "\n";
203  libMesh::out << "final time (max_time) = " << _t1 << "\n";
204  libMesh::out << "Crank-Nicholson weight = " << _cnWeight << "\n";
205  libMesh::out << "Output timestep = " << _o_dt << "\n";
206  libMesh::out << "Output filename base: " << _ofile_base << "\n";
207 }
bool _verbose
Definition: biharmonic.h:98
Real _cnWeight
Definition: biharmonic.h:103
Real _kappa
Definition: biharmonic.h:93
Real _theta_c
Definition: biharmonic.h:93
Point _initialCenter
Definition: biharmonic.h:100
Real _tol
Definition: biharmonic.h:94
bool _netforce
Definition: biharmonic.h:95
bool _cahn_hillard
Definition: biharmonic.h:95
FreeEnergyEnum _energy
Definition: biharmonic.h:96
int _log_truncation
Definition: biharmonic.h:97
unsigned int _dim
Definition: biharmonic.h:92
Real _initialWidth
Definition: biharmonic.h:101
OStreamProxy out
bool _growth
Definition: biharmonic.h:95
Real _o_dt
Definition: biharmonic.h:107
unsigned int _N
Definition: biharmonic.h:92
std::string _ofile_base
Definition: biharmonic.h:105
InitialStateEnum _initialState
Definition: biharmonic.h:99
void ErrorVector unsigned int
Definition: adjoints_ex3.C:360
Real _theta
Definition: biharmonic.h:93
bool _degenerate
Definition: biharmonic.h:95

◆ write() [1/4]

void libMesh::EquationSystems::write ( std::string_view  name,
const XdrMODE  mode,
const unsigned int  write_flags = (WRITE_DATA),
bool  partition_agnostic = true 
) const
inherited

Write the systems to disk using the XDR data format.

This format allows for machine-independent binary output.

Set the writing properties using the EquationSystems::WriteFlags enumeration. Set which sections to write out by bitwise OR'ing the enumeration values. Write everything by setting write_flags to: (WRITE_DATA | WRITE_ADDITIONAL_DATA)

Note
The solution data can be omitted by calling this routine with WRITE_DATA omitted in the write_flags argument.

If XdrMODE is omitted, it will be inferred as WRITE for filenames containing .xda or as ENCODE for filenames containing .xdr

Parameters
nameName of the file to be read.
write_flagsSingle flag created by bitwise-OR'ing several flags together.
modeControls whether reading is done in binary or ascii mode.
partition_agnosticIf true then the mesh and degrees of freedom will be temporarily renumbered in a partition agnostic way so that files written using "n" mpi processes can be re-read on "m" mpi processes. This renumbering is not compatible with meshes that have two nodes in exactly the same position!

Definition at line 347 of file equation_systems_io.C.

References libMesh::Quality::name(), libMesh::ParallelObject::processor_id(), libMesh::EquationSystems::WRITE_DATA, and libMesh::EquationSystems::WRITE_PARALLEL_FILES.

Referenced by main(), libMesh::ErrorVector::plot_error(), libMesh::FileHistoryData::rewrite_stored_solution(), libMesh::FileHistoryData::store_adjoint_solution(), libMesh::FileHistoryData::store_initial_solution(), libMesh::FileHistoryData::store_primal_solution(), libMesh::EquationSystems::write(), libMesh::NameBasedIO::write_equation_systems(), and write_output().

351 {
352  Xdr io((this->processor_id()==0) ? std::string(name) : "", mode);
353 
354  std::unique_ptr<Xdr> local_io;
355  // open a parallel buffer if warranted
356  if (write_flags & EquationSystems::WRITE_PARALLEL_FILES && write_flags & EquationSystems::WRITE_DATA)
357  local_io = std::make_unique<Xdr>(local_file_name(this->processor_id(),name), mode);
358 
359  this->write(io, write_flags, partition_agnostic, local_io.get());
360 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
void write(std::string_view name, const XdrMODE, const unsigned int write_flags=(WRITE_DATA), bool partition_agnostic=true) const
Write the systems to disk using the XDR data format.
processor_id_type processor_id() const

◆ write() [2/4]

void libMesh::EquationSystems::write ( std::string_view  name,
const unsigned int  write_flags = (WRITE_DATA),
bool  partition_agnostic = true 
) const
inherited

Definition at line 335 of file equation_systems_io.C.

References libMesh::ENCODE, libMesh::Quality::name(), libMesh::WRITE, and libMesh::EquationSystems::write().

338 {
339  XdrMODE mode = WRITE;
340  if (name.find(".xdr") != std::string::npos)
341  mode = ENCODE;
342  this->write(name, mode, write_flags, partition_agnostic);
343 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
void write(std::string_view name, const XdrMODE, const unsigned int write_flags=(WRITE_DATA), bool partition_agnostic=true) const
Write the systems to disk using the XDR data format.
XdrMODE
Defines an enum for read/write mode in Xdr format.
Definition: enum_xdr_mode.h:35

◆ write() [3/4]

void libMesh::EquationSystems::write ( std::ostream  name,
const unsigned int  write_flags = (WRITE_DATA),
bool  partition_agnostic = true 
) const
inherited

◆ write() [4/4]

void libMesh::EquationSystems::write ( Xdr io,
const unsigned int  write_flags = (WRITE_DATA),
bool  partition_agnostic = true,
Xdr *const  local_io = nullptr 
) const
inherited


This program implements the output of an EquationSystems object. This warrants some documentation. The output file essentially consists of 11 sections:

1.) The version header.
2.) The number of individual equation systems (unsigned int)

for each system

3.)  The name of the system (string)
4.)  The type of the system (string)

handled through System::read():

+-------------------------------------------------------------+
|  5.) The number of variables in the system (unsigned int)   |
|                                                             |
|   for each variable in the system                           |
|                                                             |
|    6.) The name of the variable (string)                    |
|                                                             |
|    7.) Combined in an FEType:                               |
|         - The approximation order(s) of the variable (Order |
|           Enum, cast to int/s)                              |
|         - The finite element family/ies of the variable     |
|           (FEFamily Enum, cast to int/s)                    |
|                                                             |
|   end variable loop                                         |
|                                                             |
| 8.) The number of additional vectors (unsigned int),        |
|                                                             |
|    for each additional vector in the equation system object |
|                                                             |
|    9.) the name of the additional vector  (string)          |
+-------------------------------------------------------------+

end system loop


for each system, handled through System::write_{serialized,parallel}_data():

+--------------------------------------------------------------+
| 10.) The global solution vector, re-ordered to be node-major |
|     (More on this later.)                                    |
|                                                              |
|    for each additional vector in the equation system object  |
|                                                              |
|    11.) The global additional vector, re-ordered to be       |
|         node-major (More on this later.)                     |
+--------------------------------------------------------------+

end system loop

Note that the actual IO is handled through the Xdr class (to be renamed later?) which provides a uniform interface to both the XDR (eXternal Data Representation) interface and standard ASCII output. Thus this one section of code will write XDR or ASCII files with no changes.

Definition at line 364 of file equation_systems_io.C.

References libMesh::EquationSystems::_mesh, libMesh::EquationSystems::_systems, libMesh::Xdr::close(), libMesh::Xdr::data(), libMesh::get_io_compatibility_version(), libMesh::EquationSystems::get_mesh(), libMesh::MeshTools::Private::globally_renumber_nodes_and_elements(), libMesh::libmesh_assert(), mesh, libMesh::ParallelObject::processor_id(), libMesh::Xdr::set_version(), libMesh::EquationSystems::WRITE_ADDITIONAL_DATA, libMesh::EquationSystems::WRITE_DATA, libMesh::EquationSystems::WRITE_PARALLEL_FILES, and libMesh::Xdr::writing().

368 {
432  // the EquationSystems::write() method should look constant,
433  // but we need to assign a temporary numbering to the nodes
434  // and elements in the mesh, which requires that we abuse const_cast
435  if (partition_agnostic)
436  {
437  MeshBase & mesh = const_cast<MeshBase &>(this->get_mesh());
439  }
440 
441  // set booleans from write_flags argument
442  const bool write_data = write_flags & EquationSystems::WRITE_DATA;
443  const bool write_additional_data = write_flags & EquationSystems::WRITE_ADDITIONAL_DATA;
444 
445  // always write parallel files if we're instructed to write in
446  // parallel
447  const bool write_parallel_files =
449  // Even if we're on a distributed mesh, we may or may not have a
450  // consistent way of reconstructing the same mesh partitioning
451  // later, but we need the same mesh partitioning if we want to
452  // reread the parallel solution safely, so let's write a serial file
453  // unless specifically requested not to.
454  // ||
455  // // but also write parallel files if we haven't been instructed to
456  // // write in serial and we're on a distributed mesh
457  // (!(write_flags & EquationSystems::WRITE_SERIAL_FILES) &&
458  // !this->get_mesh().is_serial())
459  ;
460 
461  if (write_parallel_files && write_data)
462  libmesh_assert(local_io);
463 
464  {
465  libmesh_assert (io.writing());
466 
467  LOG_SCOPE("write()", "EquationSystems");
468 
469  const unsigned int proc_id = this->processor_id();
470 
471  unsigned int n_sys = 0;
472  for (auto & pr : _systems)
473  if (!pr.second->hide_output())
474  n_sys++;
475 
476  // set the version number in the Xdr object
477  io.set_version(LIBMESH_VERSION_ID(LIBMESH_MAJOR_VERSION,
478  LIBMESH_MINOR_VERSION,
479  LIBMESH_MICRO_VERSION));
480 
481  // Only write the header information
482  // if we are processor 0.
483  if (proc_id == 0)
484  {
485  std::string comment;
486 
487  // 1.)
488  // Write the version header
489  std::string version("libMesh-" + libMesh::get_io_compatibility_version());
490  if (write_parallel_files) version += " parallel";
491 
492 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
493  version += " with infinite elements";
494 #endif
495  io.data (version, "# File Format Identifier");
496 
497  // 2.)
498  // Write the number of equation systems
499  io.data (n_sys, "# No. of Equation Systems");
500 
501  for (auto & [sys_name, sys] : _systems)
502  {
503  // Ignore this system if it has been marked as hidden
504  if (sys->hide_output()) continue;
505 
506  // 3.)
507  // Write the name of the sys_num-th system
508  {
509  const unsigned int sys_num = sys->number();
510 
511  comment = "# Name, System No. ";
512  comment += std::to_string(sys_num);
513 
514  // Note: There is no Xdr::data overload taking a "const
515  // std::string &" so we need to make a copy.
516  std::string copy = sys_name;
517  io.data (copy, comment);
518  }
519 
520  // 4.)
521  // Write the type of system handled
522  {
523  const unsigned int sys_num = sys->number();
524  std::string sys_type = sys->system_type();
525 
526  comment = "# Type, System No. ";
527  comment += std::to_string(sys_num);
528 
529  io.data (sys_type, comment);
530  }
531 
532  // 5.) - 9.)
533  // Let System::write_header() do the job
534  sys->write_header (io, version, write_additional_data);
535  }
536  }
537 
538  // Start from the first system, again,
539  // to write vectors to disk, if wanted
540  if (write_data)
541  {
542  for (auto & pr : _systems)
543  {
544  // Ignore this system if it has been marked as hidden
545  if (pr.second->hide_output()) continue;
546 
547  // 10.) + 11.)
548  if (write_parallel_files)
549  pr.second->write_parallel_data (*local_io,write_additional_data);
550  else
551  pr.second->write_serialized_data (io,write_additional_data);
552  }
553 
554  if (local_io)
555  local_io->close();
556  }
557 
558  io.close();
559  }
560 
561  // the EquationSystems::write() method should look constant,
562  // but we need to undo the temporary numbering of the nodes
563  // and elements in the mesh, which requires that we abuse const_cast
564  if (partition_agnostic)
565  const_cast<MeshBase &>(_mesh).fix_broken_node_and_element_numbering();
566 }
MeshBase & mesh
MeshBase & _mesh
The mesh data structure.
std::string get_io_compatibility_version()
Specifier for I/O file compatibility features.
libmesh_assert(ctx)
void globally_renumber_nodes_and_elements(MeshBase &)
There is no reason for a user to ever call this function.
Definition: mesh_tools.C:2657
const MeshBase & get_mesh() const
processor_id_type processor_id() const
std::map< std::string, std::unique_ptr< System >, std::less<> > _systems
Data structure holding the systems.

Friends And Related Function Documentation

◆ JR

friend class JR
friend

Definition at line 110 of file biharmonic.h.

Member Data Documentation

◆ _cahn_hillard

bool Biharmonic::_cahn_hillard
private

Definition at line 95 of file biharmonic.h.

Referenced by Biharmonic(), and viewParameters().

◆ _cnWeight

Real Biharmonic::_cnWeight
private

Definition at line 103 of file biharmonic.h.

Referenced by Biharmonic(), and viewParameters().

◆ _communicator

const Parallel::Communicator& libMesh::ParallelObject::_communicator
protectedinherited

◆ _counts

ReferenceCounter::Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited

Actually holds the data.

Definition at line 124 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::get_info().

◆ _degenerate

bool Biharmonic::_degenerate
private

Definition at line 95 of file biharmonic.h.

Referenced by Biharmonic(), and viewParameters().

◆ _dim

unsigned int Biharmonic::_dim
private

Definition at line 92 of file biharmonic.h.

Referenced by Biharmonic(), Biharmonic::JR::JR(), and viewParameters().

◆ _dt

Real Biharmonic::_dt
private

Definition at line 102 of file biharmonic.h.

Referenced by dt(), init(), run(), and step().

◆ _dt0

Real Biharmonic::_dt0
private

Definition at line 102 of file biharmonic.h.

Referenced by Biharmonic(), dt0(), step(), and viewParameters().

◆ _enable_default_ghosting

bool libMesh::EquationSystems::_enable_default_ghosting
protectedinherited

Flag for whether to enable default ghosting on newly added Systems.

Default value: true

Definition at line 609 of file equation_systems.h.

Referenced by libMesh::EquationSystems::add_system(), and libMesh::EquationSystems::enable_default_ghosting().

◆ _enable_print_counter

bool libMesh::ReferenceCounter::_enable_print_counter = true
staticprotectedinherited

Flag to control whether reference count information is printed when print_info is called.

Definition at line 143 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().

◆ _energy

FreeEnergyEnum Biharmonic::_energy
private

Definition at line 96 of file biharmonic.h.

Referenced by Biharmonic(), and viewParameters().

◆ _exio

std::unique_ptr<ExodusII_IO> Biharmonic::_exio
private

Definition at line 106 of file biharmonic.h.

Referenced by Biharmonic(), and output().

◆ _growth

bool Biharmonic::_growth
private

Definition at line 95 of file biharmonic.h.

Referenced by Biharmonic(), and viewParameters().

◆ _initialCenter

Point Biharmonic::_initialCenter
private

Definition at line 100 of file biharmonic.h.

Referenced by Biharmonic(), and viewParameters().

◆ _initialState

InitialStateEnum Biharmonic::_initialState
private

Definition at line 99 of file biharmonic.h.

Referenced by Biharmonic(), and viewParameters().

◆ _initialWidth

Real Biharmonic::_initialWidth
private

Definition at line 101 of file biharmonic.h.

Referenced by Biharmonic(), and viewParameters().

◆ _jr

JR* Biharmonic::_jr
private

Definition at line 113 of file biharmonic.h.

Referenced by init(), and step().

◆ _kappa

Real Biharmonic::_kappa
private

Definition at line 93 of file biharmonic.h.

Referenced by Biharmonic(), and viewParameters().

◆ _log_truncation

int Biharmonic::_log_truncation
private

Definition at line 97 of file biharmonic.h.

Referenced by Biharmonic(), and viewParameters().

◆ _mesh

ReplicatedMesh& Biharmonic::_mesh
private

Definition at line 111 of file biharmonic.h.

Referenced by Biharmonic().

◆ _mutex

Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 137 of file reference_counter.h.

◆ _N

unsigned int Biharmonic::_N
private

Definition at line 92 of file biharmonic.h.

Referenced by Biharmonic(), and viewParameters().

◆ _n_objects

Threads::atomic< unsigned int > libMesh::ReferenceCounter::_n_objects
staticprotectedinherited

The number of objects.

Print the reference count information when the number returns to 0.

Definition at line 132 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter(), and libMesh::ReferenceCounter::~ReferenceCounter().

◆ _netforce

bool Biharmonic::_netforce
private

Definition at line 95 of file biharmonic.h.

Referenced by Biharmonic(), and viewParameters().

◆ _o_count

int Biharmonic::_o_count
private

Definition at line 108 of file biharmonic.h.

Referenced by init(), and output().

◆ _o_dt

Real Biharmonic::_o_dt
private

Definition at line 107 of file biharmonic.h.

Referenced by Biharmonic(), output(), and viewParameters().

◆ _ofile

std::string Biharmonic::_ofile
private

Definition at line 105 of file biharmonic.h.

Referenced by Biharmonic(), and output().

◆ _ofile_base

std::string Biharmonic::_ofile_base
private

Definition at line 105 of file biharmonic.h.

Referenced by Biharmonic(), and viewParameters().

◆ _refine_in_reinit

bool libMesh::EquationSystems::_refine_in_reinit
protectedinherited

◆ _systems

std::map<std::string, std::unique_ptr<System>, std::less<> > libMesh::EquationSystems::_systems
protectedinherited

◆ _T

Real Biharmonic::_T
private

Definition at line 102 of file biharmonic.h.

Referenced by Biharmonic(), and viewParameters().

◆ _t0

Real Biharmonic::_t0
private

Definition at line 102 of file biharmonic.h.

Referenced by Biharmonic(), run(), and viewParameters().

◆ _t1

Real Biharmonic::_t1
private

Definition at line 102 of file biharmonic.h.

Referenced by Biharmonic(), run(), and viewParameters().

◆ _theta

Real Biharmonic::_theta
private

Definition at line 93 of file biharmonic.h.

Referenced by Biharmonic(), and viewParameters().

◆ _theta_c

Real Biharmonic::_theta_c
private

Definition at line 93 of file biharmonic.h.

Referenced by Biharmonic(), and viewParameters().

◆ _tol

Real Biharmonic::_tol
private

Definition at line 94 of file biharmonic.h.

Referenced by Biharmonic(), and viewParameters().

◆ _verbose

bool Biharmonic::_verbose
private

Definition at line 98 of file biharmonic.h.

Referenced by Biharmonic(), init(), output(), run(), verbose(), and viewParameters().

◆ parameters

Parameters libMesh::EquationSystems::parameters
inherited

Data structure holding arbitrary parameters.

Definition at line 583 of file equation_systems.h.

Referenced by add_M_C_K_helmholtz(), assemble_biharmonic(), assemble_cd(), assemble_divgrad(), assemble_ellipticdg(), assemble_func(), assemble_helmholtz(), assemble_poisson(), assemble_SchroedingerEquation(), assemble_shell(), assemble_stokes(), assemble_wave(), libMesh::ExactSolution::attach_exact_deriv(), libMesh::ExactSolution::attach_exact_hessian(), libMesh::ExactSolution::attach_exact_value(), libMesh::NewmarkSystem::clear(), libMesh::EquationSystems::clear(), libMesh::FrequencySystem::clear_all(), compute_jacobian(), compute_residual(), LinearElasticityWithContact::compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::EquationSystems::EquationSystems(), fe_assembly(), fill_dirichlet_bc(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::ImplicitSystem::get_linear_solve_parameters(), libMesh::FEComputeData::init(), init_cd(), HeatSystem::init_data(), libMesh::FrequencySystem::init_data(), init_sys(), initialize(), LargeDeformationElasticity::jacobian(), line_print(), main(), libMesh::FrequencySystem::n_frequencies(), libMesh::NewmarkSystem::NewmarkSystem(), libMesh::NonlinearImplicitSystem::NonlinearImplicitSystem(), LargeDeformationElasticity::residual(), LinearElasticityWithContact::residual_and_jacobian(), run_timestepping(), libMesh::FrequencySystem::set_current_frequency(), libMesh::FrequencySystem::set_frequencies(), libMesh::FrequencySystem::set_frequencies_by_range(), libMesh::FrequencySystem::set_frequencies_by_steps(), set_initial_condition(), libMesh::NewmarkSystem::set_newmark_parameters(), libMesh::NonlinearImplicitSystem::set_solver_parameters(), setup(), SolidSystem::side_time_derivative(), libMesh::RBConstruction::solve_for_matrix_and_rhs(), libMesh::EigenSystem::solve_helper(), MeshFunctionTest::test_bad_gradient_var_with_out_of_mesh_value(), MeshFunctionTest::test_bad_hessian_var_with_out_of_mesh_value(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), ProjectSolutionTest::test_partial_project_solution(), MeshFunctionTest::test_subdomain_id_sets(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyNodalSolutionImpl(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), SystemsTest::testProjectCube(), SystemsTest::testProjectCubeWithMeshFunction(), MeshInputTest::testProjectionRegression(), SystemsTest::testProjectLine(), SystemsTest::testProjectSquare(), EquationSystemsTest::testRepartitionThenReinit(), SystemsTest::testSetSystemParameterOverEquationSystem(), MeshInputTest::testSingleElementImpl(), and libMesh::WrappedFunction< Output >::WrappedFunction().


The documentation for this class was generated from the following files: