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

This is the EquationSystems class. More...

#include <equation_systems.h>

Inheritance diagram for libMesh::EquationSystems:
[legend]

Public Types

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

 EquationSystems (MeshBase &mesh)
 Constructor. More...
 
virtual ~EquationSystems ()
 Destructor. More...
 
virtual void clear ()
 Restores the data structure to a pristine state. More...
 
virtual void init ()
 Initialize all the systems. More...
 
virtual void reinit ()
 Reinitialize all the systems. More...
 
void update ()
 Updates local values for all the systems. More...
 
unsigned int n_systems () const
 
bool has_system (const std::string &name) const
 
template<typename T_sys >
const T_sys & get_system (const std::string &name) const
 
template<typename T_sys >
T_sys & get_system (const std::string &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 Systemget_system (const std::string &name) const
 
Systemget_system (const std::string &name)
 
const Systemget_system (const unsigned int num) const
 
Systemget_system (const unsigned int num)
 
virtual Systemadd_system (const std::string &system_type, const std::string &name)
 Add the system of type system_type named name to the systems array. More...
 
template<typename T_sys >
T_sys & add_system (const std::string &name)
 Add the system named name to the systems array. More...
 
void delete_system (const std::string &name)
 Remove the system named name from 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=libmesh_nullptr, const std::set< std::string > *system_names=libmesh_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, const std::string &system_name, const std::string &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=libmesh_nullptr) const
 Fill the input vector soln with solution values. More...
 
UniquePtr< NumericVector< Number > > build_parallel_solution_vector (const std::set< std::string > *system_names=libmesh_nullptr) const
 A version of build_solution_vector which is appropriate for "parallel" output formats like Nemesis. More...
 
void get_solution (std::vector< Number > &soln, std::vector< std::string > &names) const
 Retrieve the solution data for CONSTANT MONOMIALs. More...
 
void build_discontinuous_solution_vector (std::vector< Number > &soln, const std::set< std::string > *system_names=libmesh_nullptr) const
 Fill the input vector soln with solution values. More...
 
template<typename InValType >
void read (const std::string &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...
 
void read (const std::string &name, const XdrMODE mode, const unsigned int read_flags=(READ_HEADER|READ_DATA), bool partition_agnostic=true)
 
template<typename InValType >
void read (const std::string &name, const unsigned int read_flags=(READ_HEADER|READ_DATA), bool partition_agnostic=true)
 
void read (const std::string &name, const unsigned int read_flags=(READ_HEADER|READ_DATA), bool partition_agnostic=true)
 
void write (const std::string &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 (const std::string &name, const unsigned int write_flags=(WRITE_DATA), bool partition_agnostic=true) 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 MeshBaseget_mesh () const
 
MeshBaseget_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 ()
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static std::string get_info ()
 Gets a string containing the reference information. More...
 
static void print_info (std::ostream &out=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, System * >::iterator system_iterator
 Typedef for system iterators. More...
 
typedef std::map< std::string, System * >::const_iterator const_system_iterator
 Typedef for constant system iterators. More...
 
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)
 Increments the construction counter. More...
 
void increment_destructor_count (const std::string &name)
 Increments the destruction counter. More...
 

Protected Attributes

MeshBase_mesh
 The mesh data structure. More...
 
std::map< std::string, System * > _systems
 Data structure holding the systems. More...
 
bool _refine_in_reinit
 Flag for whether to call coarsen/refine in reinit(). 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 Member Functions

template<typename InValType >
void _read_impl (const std::string &name, const XdrMODE, const unsigned int read_flags, bool partition_agnostic=true)
 Actual read implementation. More...
 
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 the Mesh, adding the system to each one. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const EquationSystems &es)
 Same as above, but allows you to also use stream syntax. More...
 

Detailed Description

This is the EquationSystems class.

It is in charge of handling all the various equation systems defined for a MeshBase. It may have multiple systems, which may be active or inactive, so that at different solution stages only a sub-set may be solved for. Also, through the templated access, different types of systems may be handled. Also other features, like flags, parameters, I/O etc are provided.

Author
Benjamin S. Kirk
Date
2002-2007 Manages multiples systems of equations.

Definition at line 66 of file equation_systems.h.

Member Typedef Documentation

typedef std::map<std::string, System *>::const_iterator libMesh::EquationSystems::const_system_iterator
protected

Typedef for constant system iterators.

Definition at line 491 of file equation_systems.h.

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.

typedef std::map<std::string, System *>::iterator libMesh::EquationSystems::system_iterator
protected

Typedef for system iterators.

Definition at line 486 of file equation_systems.h.

Member Enumeration Documentation

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 75 of file equation_systems.h.

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

Enumerator
WRITE_DATA 
WRITE_ADDITIONAL_DATA 
WRITE_PARALLEL_FILES 
WRITE_SERIAL_FILES 

Definition at line 85 of file equation_systems.h.

Constructor & Destructor Documentation

libMesh::EquationSystems::EquationSystems ( MeshBase mesh)

Constructor.

Definition at line 54 of file equation_systems.C.

References _refine_in_reinit, parameters, libMesh::Real, libMesh::Parameters::set(), and libMesh::TOLERANCE.

54  :
55  ParallelObject (m),
56  _mesh (m)
57 {
58  // Set default parameters
59  this->parameters.set<Real> ("linear solver tolerance") = TOLERANCE * TOLERANCE;
60  this->parameters.set<unsigned int>("linear solver maximum iterations") = 5000;
61  this->_refine_in_reinit = true; // default value
62 }
ParallelObject(const Parallel::Communicator &comm_in)
Constructor.
static const Real TOLERANCE
MeshBase & _mesh
The mesh data structure.
bool _refine_in_reinit
Flag for whether to call coarsen/refine in reinit().
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
T & set(const std::string &)
Definition: parameters.h:469
Parameters parameters
Data structure holding arbitrary parameters.
libMesh::EquationSystems::~EquationSystems ( )
virtual

Destructor.

Should be virtual, since the user may want to derive subclasses of EquationSystems.

Definition at line 66 of file equation_systems.C.

References clear().

67 {
68  this->clear ();
69 }
virtual void clear()
Restores the data structure to a pristine state.

Member Function Documentation

void libMesh::EquationSystems::_add_system_to_nodes_and_elems ( )
private

This function is used in the implementation of add_system, it loops over the nodes and elements of the Mesh, adding the system to each one.

The main reason to separate this part is to avoid coupling this header file to mesh.h, and elem.h.

Definition at line 1200 of file equation_systems.C.

References _mesh, libMesh::MeshBase::element_ptr_range(), and libMesh::MeshBase::node_ptr_range().

Referenced by add_system().

1201 {
1202  // All the nodes
1203  for (auto & node : _mesh.node_ptr_range())
1204  node->add_system();
1205 
1206  // All the elements
1207  for (auto & elem : _mesh.element_ptr_range())
1208  elem->add_system();
1209 }
MeshBase & _mesh
The mesh data structure.
virtual SimpleRange< element_iterator > element_ptr_range()=0
virtual SimpleRange< node_iterator > node_ptr_range()=0
template<typename InValType >
template void libMesh::EquationSystems::_read_impl< Real > ( const std::string &  name,
const XdrMODE  ,
const unsigned int  read_flags,
bool  partition_agnostic = true 
)
private

Actual read implementation.

This can be called repeatedly inside a try-catch block in an attempt to read broken files.

Parameters
nameName of the file to be read.
read_flagsSingle flag created by bitwise-OR'ing several flags together.
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.
Note
This renumbering is not compatible with meshes that have two nodes in exactly the same position!

This program implements the output 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 143 of file equation_systems_io.C.

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

147 {
211  // Set booleans from the read_flags argument
212  const bool read_header = read_flags & EquationSystems::READ_HEADER;
213  const bool read_data = read_flags & EquationSystems::READ_DATA;
214  const bool read_additional_data = read_flags & EquationSystems::READ_ADDITIONAL_DATA;
215  const bool read_legacy_format = read_flags & EquationSystems::READ_LEGACY_FORMAT;
216  const bool try_read_ifems = read_flags & EquationSystems::TRY_READ_IFEMS;
217  const bool read_basic_only = read_flags & EquationSystems::READ_BASIC_ONLY;
218  bool read_parallel_files = false;
219 
220  std::vector<std::pair<std::string, System *>> xda_systems;
221 
222  // This will unzip a file with .bz2 as the extension, otherwise it
223  // simply returns the name if the file need not be unzipped.
224  Xdr io ((this->processor_id() == 0) ? name : "", mode);
225  libmesh_assert (io.reading());
226 
227  {
228  // 1.)
229  // Read the version header.
230  std::string version = "legacy";
231  if (!read_legacy_format)
232  {
233  if (this->processor_id() == 0) io.data(version);
234  this->comm().broadcast(version);
235 
236  // All processors have the version header, if it does not contain
237  // the libMesh_label string then it is a legacy file.
238  const std::string libMesh_label = "libMesh-";
239  std::string::size_type lm_pos = version.find(libMesh_label);
240  if (lm_pos==std::string::npos)
241  {
242  io.close();
243 
244  // Recursively call this read() function but with the
245  // EquationSystems::READ_LEGACY_FORMAT bit set.
246  this->read (name, mode, (read_flags | EquationSystems::READ_LEGACY_FORMAT), partition_agnostic);
247  return;
248  }
249 
250  // Figure out the libMesh version that created this file
251  std::istringstream iss(version.substr(lm_pos + libMesh_label.size()));
252  int ver_major = 0, ver_minor = 0, ver_patch = 0;
253  char dot;
254  iss >> ver_major >> dot >> ver_minor >> dot >> ver_patch;
255  io.set_version(LIBMESH_VERSION_ID(ver_major, ver_minor, ver_patch));
256 
257 
258  read_parallel_files = (version.rfind(" parallel") < version.size());
259 
260  // If requested that we try to read infinite element information,
261  // and the string " with infinite elements" is not in the version,
262  // then tack it on. This is for compatibility reading ifem
263  // files written prior to 11/10/2008 - BSK
264  if (try_read_ifems)
265  if (!(version.rfind(" with infinite elements") < version.size()))
266  version += " with infinite elements";
267 
268  }
269  else
270  libmesh_deprecated();
271 
272  START_LOG("read()","EquationSystems");
273 
274  // 2.)
275  // Read the number of equation systems
276  unsigned int n_sys=0;
277  if (this->processor_id() == 0) io.data (n_sys);
278  this->comm().broadcast(n_sys);
279 
280  for (unsigned int sys=0; sys<n_sys; sys++)
281  {
282  // 3.)
283  // Read the name of the sys-th equation system
284  std::string sys_name;
285  if (this->processor_id() == 0) io.data (sys_name);
286  this->comm().broadcast(sys_name);
287 
288  // 4.)
289  // Read the type of the sys-th equation system
290  std::string sys_type;
291  if (this->processor_id() == 0) io.data (sys_type);
292  this->comm().broadcast(sys_type);
293 
294  if (read_header)
295  this->add_system (sys_type, sys_name);
296 
297  // 5.) - 9.)
298  // Let System::read_header() do the job
299  System & new_system = this->get_system(sys_name);
300  new_system.read_header (io,
301  version,
302  read_header,
303  read_additional_data,
304  read_legacy_format);
305 
306  xda_systems.push_back(std::make_pair(sys_name, &new_system));
307 
308  // If we're only creating "basic" systems, we need to tell
309  // each system that before we call init() later.
310  if (read_basic_only)
311  new_system.set_basic_system_only();
312  }
313  }
314 
315 
316 
317  // Now we are ready to initialize the underlying data
318  // structures. This will initialize the vectors for
319  // storage, the dof_map, etc...
320  if (read_header)
321  this->init();
322 
323  // 10.) & 11.)
324  // Read and set the numeric vector values
325  if (read_data)
326  {
327  // the EquationSystems::read() method should look constant from the mesh
328  // perspective, but we need to assign a temporary numbering to the nodes
329  // and elements in the mesh, which requires that we abuse const_cast
330  if (!read_legacy_format && partition_agnostic)
331  {
332  MeshBase & mesh = const_cast<MeshBase &>(this->get_mesh());
334  }
335 
336  Xdr local_io (read_parallel_files ? local_file_name(this->processor_id(),name) : "", mode);
337 
338  std::vector<std::pair<std::string, System *>>::iterator
339  pos = xda_systems.begin();
340 
341  for (; pos != xda_systems.end(); ++pos)
342  if (read_legacy_format)
343  {
344  libmesh_deprecated();
345 #ifdef LIBMESH_ENABLE_DEPRECATED
346  pos->second->read_legacy_data (io, read_additional_data);
347 #endif
348  }
349  else
350  if (read_parallel_files)
351  pos->second->read_parallel_data<InValType> (local_io, read_additional_data);
352  else
353  pos->second->read_serialized_data<InValType> (io, read_additional_data);
354 
355 
356  // Undo the temporary numbering.
357  if (!read_legacy_format && partition_agnostic)
359  }
360 
361  STOP_LOG("read()","EquationSystems");
362 
363  // Localize each system's data
364  this->update();
365 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
ImplicitSystem & sys
MeshBase & mesh
virtual void fix_broken_node_and_element_numbering()=0
There is no reason for a user to ever call this function.
void read(const std::string &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.
MeshBase & _mesh
The mesh data structure.
libmesh_assert(j)
virtual System & add_system(const std::string &system_type, const std::string &name)
Add the system of type system_type named name to the systems array.
void broadcast(T &data, const unsigned int root_id=0) const
Take a local value and broadcast it to all processors.
void globally_renumber_nodes_and_elements(MeshBase &)
There is no reason for a user to ever call this function.
Definition: mesh_tools.C:1968
const Parallel::Communicator & comm() const
const MeshBase & get_mesh() const
const T_sys & get_system(const std::string &name) const
virtual void init()
Initialize all the systems.
void update()
Updates local values for all the systems.
processor_id_type processor_id() const
System & libMesh::EquationSystems::add_system ( const std::string &  system_type,
const std::string &  name 
)
virtual

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

Definition at line 315 of file equation_systems.C.

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

Referenced by _read_impl(), assemble_and_solve(), build_system(), libMesh::RBEIMConstruction::init_data(), main(), libMesh::ErrorVector::plot_error(), TimeSolverTestImplementation< NewmarkSolver >::run_test_with_exact_soln(), setup(), FETest< order, family, elem_type >::setUp(), SlitMeshRefinedSystemTest::setUp(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), EquationSystemsTest::testAddSystem(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MixedDimensionMeshTest::testDofOrdering(), MixedDimensionRefinedMeshTest::testDofOrdering(), MixedDimensionNonUniformRefinement::testDofOrdering(), MixedDimensionNonUniformRefinementTriangle::testDofOrdering(), MixedDimensionNonUniformRefinement3D::testDofOrdering(), DofMapTest::testDofOwner(), EquationSystemsTest::testInit(), EquationSystemsTest::testPostInitAddElem(), EquationSystemsTest::testPostInitAddRealSystem(), EquationSystemsTest::testPostInitAddSystem(), SystemsTest::testProjectCube(), SystemsTest::testProjectCubeWithMeshFunction(), SystemsTest::testProjectLine(), SystemsTest::testProjectSquare(), EquationSystemsTest::testRefineThenReinitPreserveFlags(), and WriteVecAndScalar::testWrite().

317 {
318  // If the user already built a system with this name, we'll
319  // trust them and we'll use it. That way they can pre-add
320  // non-standard derived system classes, and if their restart file
321  // has some non-standard sys_type we won't throw an error.
322  if (_systems.count(name))
323  {
324  return this->get_system(name);
325  }
326  // Build a basic System
327  else if (sys_type == "Basic")
328  this->add_system<System> (name);
329 
330  // Build a Newmark system
331  else if (sys_type == "Newmark")
332  this->add_system<NewmarkSystem> (name);
333 
334  // Build an Explicit system
335  else if ((sys_type == "Explicit"))
336  this->add_system<ExplicitSystem> (name);
337 
338  // Build an Implicit system
339  else if ((sys_type == "Implicit") ||
340  (sys_type == "Steady" ))
341  this->add_system<ImplicitSystem> (name);
342 
343  // build a transient implicit linear system
344  else if ((sys_type == "Transient") ||
345  (sys_type == "TransientImplicit") ||
346  (sys_type == "TransientLinearImplicit"))
347  this->add_system<TransientLinearImplicitSystem> (name);
348 
349  // build a transient implicit nonlinear system
350  else if (sys_type == "TransientNonlinearImplicit")
351  this->add_system<TransientNonlinearImplicitSystem> (name);
352 
353  // build a transient explicit system
354  else if (sys_type == "TransientExplicit")
355  this->add_system<TransientExplicitSystem> (name);
356 
357  // build a linear implicit system
358  else if (sys_type == "LinearImplicit")
359  this->add_system<LinearImplicitSystem> (name);
360 
361  // build a nonlinear implicit system
362  else if (sys_type == "NonlinearImplicit")
363  this->add_system<NonlinearImplicitSystem> (name);
364 
365  // build a Reduced Basis Construction system
366  else if (sys_type == "RBConstruction")
367  this->add_system<RBConstruction> (name);
368 
369  // build a transient Reduced Basis Construction system
370  else if (sys_type == "TransientRBConstruction")
371  this->add_system<TransientRBConstruction> (name);
372 
373 #ifdef LIBMESH_HAVE_SLEPC
374  // build an eigen system
375  else if (sys_type == "Eigen")
376  this->add_system<EigenSystem> (name);
377  else if (sys_type == "TransientEigenSystem")
378  this->add_system<TransientEigenSystem> (name);
379 #endif
380 
381 #if defined(LIBMESH_USE_COMPLEX_NUMBERS)
382  // build a frequency system
383  else if (sys_type == "Frequency")
384  this->add_system<FrequencySystem> (name);
385 #endif
386 
387  else
388  libmesh_error_msg("ERROR: Unknown system type: " << sys_type);
389 
390  // Return a reference to the new system
391  //return (*this)(name);
392  return this->get_system(name);
393 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
const T_sys & get_system(const std::string &name) const
std::map< std::string, System * > _systems
Data structure holding the systems.
template<typename T_sys >
T_sys & libMesh::EquationSystems::add_system ( const std::string &  name)

Add the system named name to the systems array.

Definition at line 560 of file equation_systems.h.

References _add_system_to_nodes_and_elems(), _systems, libmesh_nullptr, n_systems(), and libMesh::Quality::name().

561 {
562  T_sys * ptr = libmesh_nullptr;
563 
564  if (!_systems.count(name))
565  {
566  ptr = new T_sys(*this, name, this->n_systems());
567 
568  _systems.insert (std::make_pair(name, ptr));
569 
570  // Tell all the \p DofObject entities to add a system.
572  }
573  else
574  {
575  // We now allow redundant add_system calls, to make it
576  // easier to load data from files for user-derived system
577  // subclasses
578  ptr = &(this->get_system<T_sys>(name));
579  }
580 
581  // Return a dynamically casted reference to the newly added System.
582  return *ptr;
583 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
const class libmesh_nullptr_t libmesh_nullptr
unsigned int n_systems() const
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, System * > _systems
Data structure holding the systems.
void libMesh::EquationSystems::adjoint_solve ( const QoISet qoi_indices = QoISet())
virtual

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 436 of file equation_systems.C.

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

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

437 {
438  libmesh_assert (this->n_systems());
439 
440  for (unsigned int i=this->n_systems(); i != 0; --i)
441  this->get_system(i-1).adjoint_solve(qoi_indices);
442 }
libmesh_assert(j)
unsigned int n_systems() const
const T_sys & get_system(const std::string &name) const
void libMesh::EquationSystems::allgather ( )

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

Definition at line 265 of file equation_systems.C.

References _mesh, libMesh::MeshBase::allgather(), libMesh::DofMap::distribute_dofs(), libMesh::MeshBase::element_ptr_range(), libMesh::System::get_dof_map(), get_system(), libMesh::MeshBase::is_serial(), n_systems(), libMesh::MeshBase::node_ptr_range(), libMesh::DofMap::prepare_send_list(), libMesh::System::reinit_constraints(), and libMesh::sys.

Referenced by read().

266 {
267  // A serial mesh means nothing needs to be done
268  if (_mesh.is_serial())
269  return;
270 
271  const unsigned int n_sys = this->n_systems();
272 
273  libmesh_assert_not_equal_to (n_sys, 0);
274 
275  // Gather the mesh
276  _mesh.allgather();
277 
278  // Tell all the \p DofObject entities how many systems
279  // there are.
280  for (auto & node : _mesh.node_ptr_range())
281  node->set_n_systems(n_sys);
282 
283  for (auto & elem : _mesh.element_ptr_range())
284  elem->set_n_systems(n_sys);
285 
286  // And distribute each system's dofs
287  for (unsigned int i=0; i != this->n_systems(); ++i)
288  {
289  System & sys = this->get_system(i);
290  DofMap & dof_map = sys.get_dof_map();
291  dof_map.distribute_dofs(_mesh);
292 
293  // The user probably won't need constraint equations or the
294  // send_list after an allgather, but let's keep it in consistent
295  // shape just in case.
296  sys.reinit_constraints();
297  dof_map.prepare_send_list();
298  }
299 }
virtual bool is_serial() const
Definition: mesh_base.h:140
ImplicitSystem & sys
virtual void allgather()
Gathers all elements and nodes of the mesh onto every processor.
Definition: mesh_base.h:169
MeshBase & _mesh
The mesh data structure.
virtual SimpleRange< element_iterator > element_ptr_range()=0
virtual SimpleRange< node_iterator > node_ptr_range()=0
unsigned int n_systems() const
const T_sys & get_system(const std::string &name) const
void libMesh::EquationSystems::build_discontinuous_solution_vector ( std::vector< Number > &  soln,
const std::set< std::string > *  system_names = libmesh_nullptr 
) const

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!=NULL, only include data from the specified systems.

Definition at line 918 of file equation_systems.C.

References _mesh, _systems, libMesh::MeshBase::active_element_ptr_range(), dim, libMesh::DofMap::dof_indices(), end, libMesh::System::get_dof_map(), libMesh::libmesh_assert(), libmesh_nullptr, libMesh::MeshBase::mesh_dimension(), n_systems(), libMesh::System::n_vars(), libMesh::FEInterface::nodal_soln(), libMesh::ParallelObject::processor_id(), libMesh::System::update_global_solution(), and libMesh::System::variable_type().

Referenced by libMesh::ExodusII_IO::write_discontinuous_exodusII(), and libMesh::GMVIO::write_discontinuous_gmv().

920 {
921  LOG_SCOPE("build_discontinuous_solution_vector()", "EquationSystems");
922 
923  libmesh_assert (this->n_systems());
924 
925  const unsigned int dim = _mesh.mesh_dimension();
926 
927  // Get the number of variables (nv) by counting the number of variables
928  // in each system listed in system_names
929  unsigned int nv = 0;
930 
931  {
932  const_system_iterator pos = _systems.begin();
933  const const_system_iterator end = _systems.end();
934 
935  for (; pos != end; ++pos)
936  {
937  // Check current system is listed in system_names, and skip pos if not
938  bool use_current_system = (system_names == libmesh_nullptr);
939  if (!use_current_system)
940  use_current_system = system_names->count(pos->first);
941  if (!use_current_system)
942  continue;
943 
944  const System & system = *(pos->second);
945  nv += system.n_vars();
946  }
947  }
948 
949  unsigned int tw=0;
950 
951  // get the total weight
952  for (const auto & elem : _mesh.active_element_ptr_range())
953  tw += elem->n_nodes();
954 
955  // Only if we are on processor zero, allocate the storage
956  // to hold (number_of_nodes)*(number_of_variables) entries.
957  if (_mesh.processor_id() == 0)
958  soln.resize(tw*nv);
959 
960  std::vector<Number> sys_soln;
961 
962 
963  unsigned int var_num=0;
964 
965  // For each system in this EquationSystems object,
966  // update the global solution and if we are on processor 0,
967  // loop over the elements and build the nodal solution
968  // from the element solution. Then insert this nodal solution
969  // into the vector passed to build_solution_vector.
970  {
971  const_system_iterator pos = _systems.begin();
972  const const_system_iterator end = _systems.end();
973 
974  for (; pos != end; ++pos)
975  {
976  // Check current system is listed in system_names, and skip pos if not
977  bool use_current_system = (system_names == libmesh_nullptr);
978  if (!use_current_system)
979  use_current_system = system_names->count(pos->first);
980  if (!use_current_system)
981  continue;
982 
983  const System & system = *(pos->second);
984  const unsigned int nv_sys = system.n_vars();
985 
986  system.update_global_solution (sys_soln, 0);
987 
988  if (_mesh.processor_id() == 0)
989  {
990  std::vector<Number> elem_soln; // The finite element solution
991  std::vector<Number> nodal_soln; // The FE solution interpolated to the nodes
992  std::vector<dof_id_type> dof_indices; // The DOF indices for the finite element
993 
994  for (unsigned int var=0; var<nv_sys; var++)
995  {
996  const FEType & fe_type = system.variable_type(var);
997 
998  unsigned int nn=0;
999 
1000  for (auto & elem : _mesh.active_element_ptr_range())
1001  {
1002  system.get_dof_map().dof_indices (elem, dof_indices, var);
1003 
1004  elem_soln.resize(dof_indices.size());
1005 
1006  for (std::size_t i=0; i<dof_indices.size(); i++)
1007  elem_soln[i] = sys_soln[dof_indices[i]];
1008 
1010  fe_type,
1011  elem,
1012  elem_soln,
1013  nodal_soln);
1014 
1015 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1016  // infinite elements should be skipped...
1017  if (!elem->infinite())
1018 #endif
1019  {
1020  libmesh_assert_equal_to (nodal_soln.size(), elem->n_nodes());
1021 
1022  for (unsigned int n=0; n<elem->n_nodes(); n++)
1023  {
1024  soln[nv*(nn++) + (var + var_num)] +=
1025  nodal_soln[n];
1026  }
1027  }
1028  }
1029  }
1030  }
1031 
1032  var_num += nv_sys;
1033  }
1034  }
1035 }
unsigned int dim
const class libmesh_nullptr_t libmesh_nullptr
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
virtual SimpleRange< element_iterator > active_element_ptr_range()=0
MeshBase & _mesh
The mesh data structure.
libmesh_assert(j)
std::map< std::string, System * >::const_iterator const_system_iterator
Typedef for constant system iterators.
unsigned int n_systems() const
unsigned int mesh_dimension() const
Definition: mesh_base.C:148
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)
Build the nodal soln from the element soln.
Definition: fe_interface.C:526
processor_id_type processor_id() const
std::map< std::string, System * > _systems
Data structure holding the systems.
UniquePtr< NumericVector< Number > > libMesh::EquationSystems::build_parallel_solution_vector ( const std::set< std::string > *  system_names = libmesh_nullptr) const

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

Returns
A UniquePtr 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 560 of file equation_systems.C.

References libMesh::ParallelObject::_communicator, _mesh, _systems, libMesh::MeshBase::active_local_element_ptr_range(), libMesh::Variable::active_on_subdomain(), libMesh::NumericVector< T >::add(), libMesh::NumericVector< T >::build(), libMesh::NumericVector< T >::close(), libMesh::ParallelObject::comm(), libMesh::System::current_local_solution, dim, distance(), libMesh::DofMap::dof_indices(), end, libMesh::FEInterface::field_type(), libMesh::System::get_dof_map(), libMesh::NumericVector< T >::init(), libMesh::libmesh_assert(), libmesh_nullptr, libMesh::MeshBase::local_nodes_begin(), libMesh::MeshBase::local_nodes_end(), libMesh::MeshBase::max_node_id(), libMesh::MeshBase::mesh_dimension(), libMesh::MeshBase::n_nodes(), libMesh::System::n_vars(), libMesh::FEInterface::n_vec_dim(), libMesh::FEInterface::nodal_soln(), libMesh::System::number(), libMesh::PARALLEL, libMesh::System::solution, libMesh::TYPE_VECTOR, libMesh::System::update(), libMesh::System::variable(), libMesh::System::variable_type(), and libMesh::Parallel::verify().

Referenced by build_solution_vector(), and libMesh::MeshOutput< MT >::write_equation_systems().

561 {
562  LOG_SCOPE("build_parallel_solution_vector()", "EquationSystems");
563 
564  // This function must be run on all processors at once
565  parallel_object_only();
566 
567  const unsigned int dim = _mesh.mesh_dimension();
568  const dof_id_type nn = _mesh.n_nodes();
569 
570  // We'd better have a contiguous node numbering
571  libmesh_assert_equal_to (nn, _mesh.max_node_id());
572 
573  // allocate storage to hold
574  // (number_of_nodes)*(number_of_variables) entries.
575  // We have to differentiate between between scalar and vector
576  // variables. We intercept vector variables and treat each
577  // component as a scalar variable (consistently with build_solution_names).
578 
579  unsigned int nv = 0;
580 
581  //Could this be replaced by a/some convenience methods?[PB]
582  {
583  unsigned int n_scalar_vars = 0;
584  unsigned int n_vector_vars = 0;
585  const_system_iterator pos = _systems.begin();
586  const const_system_iterator end = _systems.end();
587 
588  for (; pos != end; ++pos)
589  {
590  // Check current system is listed in system_names, and skip pos if not
591  bool use_current_system = (system_names == libmesh_nullptr);
592  if (!use_current_system)
593  use_current_system = system_names->count(pos->first);
594  if (!use_current_system)
595  continue;
596 
597  for (unsigned int vn=0; vn<pos->second->n_vars(); vn++)
598  {
599  if (FEInterface::field_type(pos->second->variable_type(vn)) == TYPE_VECTOR)
600  n_vector_vars++;
601  else
602  n_scalar_vars++;
603  }
604  }
605  // Here, we're assuming the number of vector components is the same
606  // as the mesh dimension. Will break for mixed dimension meshes.
607  nv = n_scalar_vars + dim*n_vector_vars;
608  }
609 
610  // Get the number of local nodes
611  dof_id_type n_local_nodes = cast_int<dof_id_type>
614 
615  // Create a NumericVector to hold the parallel solution
616  UniquePtr<NumericVector<Number>> parallel_soln_ptr = NumericVector<Number>::build(_communicator);
617  NumericVector<Number> & parallel_soln = *parallel_soln_ptr;
618  parallel_soln.init(nn*nv, n_local_nodes*nv, false, PARALLEL);
619 
620  // Create a NumericVector to hold the "repeat_count" for each node - this is essentially
621  // the number of elements contributing to that node's value
622  UniquePtr<NumericVector<Number>> repeat_count_ptr = NumericVector<Number>::build(_communicator);
623  NumericVector<Number> & repeat_count = *repeat_count_ptr;
624  repeat_count.init(nn*nv, n_local_nodes*nv, false, PARALLEL);
625 
626  repeat_count.close();
627 
628  unsigned int var_num=0;
629 
630  // For each system in this EquationSystems object,
631  // update the global solution and if we are on processor 0,
632  // loop over the elements and build the nodal solution
633  // from the element solution. Then insert this nodal solution
634  // into the vector passed to build_solution_vector.
635  const_system_iterator pos = _systems.begin();
636  const const_system_iterator end = _systems.end();
637 
638  for (; pos != end; ++pos)
639  {
640  // Check current system is listed in system_names, and skip pos if not
641  bool use_current_system = (system_names == libmesh_nullptr);
642  if (!use_current_system)
643  use_current_system = system_names->count(pos->first);
644  if (!use_current_system)
645  continue;
646 
647  const System & system = *(pos->second);
648  const unsigned int nv_sys = system.n_vars();
649  const unsigned int sys_num = system.number();
650 
651  //Could this be replaced by a/some convenience methods?[PB]
652  unsigned int n_scalar_vars = 0;
653  unsigned int n_vector_vars = 0;
654  for (unsigned int vn=0; vn<pos->second->n_vars(); vn++)
655  {
656  if (FEInterface::field_type(pos->second->variable_type(vn)) == TYPE_VECTOR)
657  n_vector_vars++;
658  else
659  n_scalar_vars++;
660  }
661 
662  // Here, we're assuming the number of vector components is the same
663  // as the mesh dimension. Will break for mixed dimension meshes.
664  unsigned int nv_sys_split = n_scalar_vars + dim*n_vector_vars;
665 
666  // Update the current_local_solution
667  {
668  System & non_const_sys = const_cast<System &>(system);
669  // We used to simply call non_const_sys.solution->close()
670  // here, but that is not allowed when the solution vector is
671  // locked read-only, for example when printing the solution
672  // during the middle of a solve... So try to be a bit
673  // more careful about calling close() unnecessarily.
674  libmesh_assert(this->comm().verify(non_const_sys.solution->closed()));
675  if (!non_const_sys.solution->closed())
676  non_const_sys.solution->close();
677  non_const_sys.update();
678  }
679 
680  NumericVector<Number> & sys_soln(*system.current_local_solution);
681 
682  std::vector<Number> elem_soln; // The finite element solution
683  std::vector<Number> nodal_soln; // The FE solution interpolated to the nodes
684  std::vector<dof_id_type> dof_indices; // The DOF indices for the finite element
685 
686  unsigned var_inc = 0;
687  for (unsigned int var=0; var<nv_sys; var++)
688  {
689  const FEType & fe_type = system.variable_type(var);
690  const Variable & var_description = system.variable(var);
691  const DofMap & dof_map = system.get_dof_map();
692 
693  unsigned int n_vec_dim = FEInterface::n_vec_dim( pos->second->get_mesh(), fe_type );
694 
695  for (const auto & elem : _mesh.active_local_element_ptr_range())
696  {
697  if (var_description.active_on_subdomain(elem->subdomain_id()))
698  {
699  dof_map.dof_indices (elem, dof_indices, var);
700 
701  elem_soln.resize(dof_indices.size());
702 
703  for (std::size_t i=0; i<dof_indices.size(); i++)
704  elem_soln[i] = sys_soln(dof_indices[i]);
705 
707  fe_type,
708  elem,
709  elem_soln,
710  nodal_soln);
711 
712 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
713  // infinite elements should be skipped...
714  if (!elem->infinite())
715 #endif
716  {
717  libmesh_assert_equal_to (nodal_soln.size(), n_vec_dim*elem->n_nodes());
718 
719  for (unsigned int n=0; n<elem->n_nodes(); n++)
720  {
721  for (unsigned int d=0; d < n_vec_dim; d++)
722  {
723  // For vector-valued elements, all components are in nodal_soln. For each
724  // node, the components are stored in order, i.e. node_0 -> s0_x, s0_y, s0_z
725  parallel_soln.add(nv*(elem->node_id(n)) + (var_inc+d + var_num), nodal_soln[n_vec_dim*n+d]);
726 
727  // Increment the repeat count for this position
728  repeat_count.add(nv*(elem->node_id(n)) + (var_inc+d + var_num), 1);
729  }
730  }
731  }
732  }
733  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:
734  for (unsigned int n=0; n<elem->n_nodes(); n++)
735  // Only do this if this variable has NO DoFs at this node... it might have some from an adjoining element...
736  if (!elem->node_ptr(n)->n_dofs(sys_num, var))
737  for (unsigned int d=0; d < n_vec_dim; d++)
738  repeat_count.add(nv*(elem->node_id(n)) + (var+d + var_num), 1);
739 
740  } // end loop over elements
741  var_inc += n_vec_dim;
742  } // end loop on variables in this system
743 
744  var_num += nv_sys_split;
745  } // end loop over systems
746 
747  parallel_soln.close();
748  repeat_count.close();
749 
750  // Divide to get the average value at the nodes
751  parallel_soln /= repeat_count;
752 
753  return UniquePtr<NumericVector<Number>>(parallel_soln_ptr.release());
754 }
unsigned int dim
virtual dof_id_type max_node_id() const =0
static FEFieldType field_type(const FEType &fe_type)
const class libmesh_nullptr_t libmesh_nullptr
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
const Parallel::Communicator & _communicator
Real distance(const Point &p)
MeshBase & _mesh
The mesh data structure.
libmesh_assert(j)
static UniquePtr< NumericVector< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
Builds a NumericVector on the processors in communicator comm using the linear solver package specifi...
virtual SimpleRange< element_iterator > active_local_element_ptr_range()=0
std::map< std::string, System * >::const_iterator const_system_iterator
Typedef for constant system iterators.
virtual node_iterator local_nodes_end()=0
static unsigned int n_vec_dim(const MeshBase &mesh, const FEType &fe_type)
virtual node_iterator local_nodes_begin()=0
Iterate over local nodes (nodes whose processor_id() matches the current processor).
bool verify(const T &r, const Communicator &comm=Communicator_World)
const Parallel::Communicator & comm() const
unsigned int mesh_dimension() const
Definition: mesh_base.C:148
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)
Build the nodal soln from the element soln.
Definition: fe_interface.C:526
virtual dof_id_type n_nodes() const =0
uint8_t dof_id_type
Definition: id_types.h:64
std::map< std::string, System * > _systems
Data structure holding the systems.
void libMesh::EquationSystems::build_solution_vector ( std::vector< Number > &  soln,
const std::string &  system_name,
const std::string &  variable_name = "all_vars" 
) const

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 548 of file equation_systems.C.

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

551 {
552  // TODO:[BSK] re-implement this from the method below
553  libmesh_not_implemented();
554 }
void libMesh::EquationSystems::build_solution_vector ( std::vector< Number > &  soln,
const std::set< std::string > *  system_names = libmesh_nullptr 
) const

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!=NULL, only include data from the specified systems.

Definition at line 758 of file equation_systems.C.

References build_parallel_solution_vector().

760 {
761  LOG_SCOPE("build_solution_vector()", "EquationSystems");
762 
763  // Call the parallel implementation
764  UniquePtr<NumericVector<Number>> parallel_soln =
765  this->build_parallel_solution_vector(system_names);
766 
767  // Localize the NumericVector into the provided std::vector.
768  parallel_soln->localize_to_one(soln);
769 }
UniquePtr< NumericVector< Number > > build_parallel_solution_vector(const std::set< std::string > *system_names=libmesh_nullptr) const
A version of build_solution_vector which is appropriate for "parallel" output formats like Nemesis...
void libMesh::EquationSystems::build_variable_names ( std::vector< std::string > &  var_names,
const FEType type = libmesh_nullptr,
const std::set< std::string > *  system_names = libmesh_nullptr 
) const

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!=NULL, only include names from the specified systems.

Definition at line 446 of file equation_systems.C.

References _systems, dim, end, libMesh::FEInterface::field_type(), get_mesh(), libmesh_nullptr, libMesh::MeshBase::mesh_dimension(), n_vars(), libMesh::FEInterface::n_vec_dim(), and libMesh::TYPE_VECTOR.

Referenced by libMesh::ExodusII_IO::write_discontinuous_exodusII(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), and libMesh::MeshOutput< MT >::write_equation_systems().

449 {
450  unsigned int var_num=0;
451 
452  const_system_iterator pos = _systems.begin();
453  const const_system_iterator end = _systems.end();
454 
455  // Need to size var_names by scalar variables plus all the
456  // vector components for all the vector variables
457  //Could this be replaced by a/some convenience methods?[PB]
458  {
459  unsigned int n_scalar_vars = 0;
460  unsigned int n_vector_vars = 0;
461 
462  for (; pos != end; ++pos)
463  {
464  // Check current system is listed in system_names, and skip pos if not
465  bool use_current_system = (system_names == libmesh_nullptr);
466  if (!use_current_system)
467  use_current_system = system_names->count(pos->first);
468  if (!use_current_system)
469  continue;
470 
471  for (unsigned int vn=0; vn<pos->second->n_vars(); vn++)
472  {
473  if (FEInterface::field_type(pos->second->variable_type(vn)) == TYPE_VECTOR)
474  n_vector_vars++;
475  else
476  n_scalar_vars++;
477  }
478  }
479 
480  // Here, we're assuming the number of vector components is the same
481  // as the mesh dimension. Will break for mixed dimension meshes.
482  unsigned int dim = this->get_mesh().mesh_dimension();
483  unsigned int nv = n_scalar_vars + dim*n_vector_vars;
484 
485  // We'd better not have more than dim*his->n_vars() (all vector variables)
486  libmesh_assert_less_equal ( nv, dim*this->n_vars() );
487 
488  // Here, we're assuming the number of vector components is the same
489  // as the mesh dimension. Will break for mixed dimension meshes.
490 
491  var_names.resize( nv );
492  }
493 
494  // reset
495  pos = _systems.begin();
496 
497  for (; pos != end; ++pos)
498  {
499  // Check current system is listed in system_names, and skip pos if not
500  bool use_current_system = (system_names == libmesh_nullptr);
501  if (!use_current_system)
502  use_current_system = system_names->count(pos->first);
503  if (!use_current_system)
504  continue;
505 
506  for (unsigned int vn=0; vn<pos->second->n_vars(); vn++)
507  {
508  std::string var_name = pos->second->variable_name(vn);
509  FEType fe_type = pos->second->variable_type(vn);
510 
511  unsigned int n_vec_dim = FEInterface::n_vec_dim( pos->second->get_mesh(), fe_type);
512 
513  // Filter on the type if requested
514  if (type == libmesh_nullptr || (type && *type == fe_type))
515  {
516  if (FEInterface::field_type(fe_type) == TYPE_VECTOR)
517  {
518  switch(n_vec_dim)
519  {
520  case 0:
521  case 1:
522  var_names[var_num++] = var_name;
523  break;
524  case 2:
525  var_names[var_num++] = var_name+"_x";
526  var_names[var_num++] = var_name+"_y";
527  break;
528  case 3:
529  var_names[var_num++] = var_name+"_x";
530  var_names[var_num++] = var_name+"_y";
531  var_names[var_num++] = var_name+"_z";
532  break;
533  default:
534  libmesh_error_msg("Invalid dim in build_variable_names");
535  }
536  }
537  else
538  var_names[var_num++] = var_name;
539  }
540  }
541  }
542  // Now resize again in case we filtered any names
543  var_names.resize(var_num);
544 }
unsigned int dim
static FEFieldType field_type(const FEType &fe_type)
const class libmesh_nullptr_t libmesh_nullptr
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
std::map< std::string, System * >::const_iterator const_system_iterator
Typedef for constant system iterators.
static unsigned int n_vec_dim(const MeshBase &mesh, const FEType &fe_type)
unsigned int mesh_dimension() const
Definition: mesh_base.C:148
unsigned int n_vars() const
const MeshBase & get_mesh() const
std::map< std::string, System * > _systems
Data structure holding the systems.
void libMesh::EquationSystems::clear ( )
virtual

Restores the data structure to a pristine state.

Definition at line 73 of file equation_systems.C.

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

Referenced by main(), and ~EquationSystems().

74 {
75  // Clear any additional parameters
76  parameters.clear ();
77 
78  // clear the systems. We must delete them
79  // since we newed them!
80  while (!_systems.empty())
81  {
82  system_iterator pos = _systems.begin();
83 
84  System * sys = pos->second;
85  delete sys;
86  sys = libmesh_nullptr;
87 
88  _systems.erase (pos);
89  }
90 }
ImplicitSystem & sys
const class libmesh_nullptr_t libmesh_nullptr
std::map< std::string, System * >::iterator system_iterator
Typedef for system iterators.
virtual void clear()
Clears internal data structures & frees any allocated memory.
Definition: parameters.h:321
Parameters parameters
Data structure holding arbitrary parameters.
std::map< std::string, System * > _systems
Data structure holding the systems.
const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inherited
Returns
A reference to the Parallel::Communicator object used by this mesh.

Definition at line 87 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_preconditioner_apply(), libMesh::__libmesh_petsc_snes_jacobian(), libMesh::__libmesh_petsc_snes_postcheck(), libMesh::__libmesh_petsc_snes_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::ParmetisPartitioner::_do_repartition(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult_add(), _read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::MeshRefinement::_smooth_flags(), add_cube_convex_hull_to_mesh(), libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::ImplicitSystem::add_matrix(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::System::add_vector(), libMesh::EigenSparseLinearSolver< T >::adjoint_solve(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::DofMap::attach_matrix(), libMesh::Parallel::BinSorter< KeyType, IdxType >::binsort(), libMesh::Parallel::Sort< KeyType, IdxType >::binsort(), libMesh::MeshCommunication::broadcast(), libMesh::SparseMatrix< T >::build(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::Parallel::Histogram< KeyType, IdxType >::build_histogram(), libMesh::PetscNonlinearSolver< T >::build_mat_null_space(), libMesh::BoundaryInfo::build_node_list_from_side_list(), build_parallel_solution_vector(), libMesh::MeshBase::cache_elem_dims(), libMesh::System::calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::Parallel::Sort< KeyType, IdxType >::communicate_bins(), 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::RBSCMConstruction::compute_SCM_bounds_on_training_set(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshTools::create_bounding_box(), 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::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), DMVariableBounds_libMesh(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::RBConstruction::enrich_RB_space(), AssembleOptimization::equality_constraints(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::RBEIMConstruction::evaluate_mesh_function(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::MeshfreeInterpolation::gather_remote_data(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), get_solution(), AssembleOptimization::inequality_constraints(), AssembleOptimization::inequality_constraints_jacobian(), libMesh::LocationMap< T >::init(), libMesh::TopologyMap::init(), libMesh::PetscDiffSolver::init(), libMesh::TimeSolver::init(), libMesh::TaoOptimizationSolver< T >::init(), libMesh::PetscNonlinearSolver< T >::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::EigenSystem::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ParmetisPartitioner::initialize(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_rb_construction(), integrate_function(), 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::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::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::limit_overrefined_boundary(), libMesh::MeshRefinement::limit_underrefined_boundary(), 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_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::MeshSerializer::MeshSerializer(), LinearElasticityWithContact::move_mesh(), libMesh::DistributedMesh::n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::MeshTools::n_levels(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::MeshTools::n_p_levels(), libMesh::BoundaryInfo::n_shellface_conds(), new_function_base(), 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::MeshTools::paranoid_n_levels(), libMesh::Partitioner::partition(), libMesh::MetisPartitioner::partition_range(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::SparseMatrix< T >::print(), FEMParameters::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshCommunication::redistribute(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::DistributedMesh::renumber_dof_objects(), LinearElasticityWithContact::residual_and_jacobian(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::TransientRBConstruction::set_error_temporal_data(), libMesh::RBEIMConstruction::set_explicit_sys_subvector(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::Parallel::Sort< KeyType, IdxType >::sort(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::Parallel::sync_element_data_by_parent_id(), libMesh::Parallel::sync_node_data_by_element_id(), libMesh::MeshRefinement::test_level_one(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), libMesh::MeshRefinement::test_unflagged(), PointLocatorTest::testLocator(), BoundaryInfoTest::testMesh(), SystemsTest::testProjectCubeWithMeshFunction(), libMesh::MeshTools::total_weight(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::RBEIMConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::RBEvaluation::write_out_vectors(), libMesh::TransientRBConstruction::write_riesz_representors_to_files(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::XdrIO::write_serialized_bcs_helper(), 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().

88  { return _communicator; }
const Parallel::Communicator & _communicator
bool libMesh::EquationSystems::compare ( const EquationSystems other_es,
const Real  threshold,
const bool  verbose 
) const
virtual
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 1039 of file equation_systems.C.

References _systems, libMesh::System::compare(), end, get_system(), n_systems(), and libMesh::out.

Referenced by do_compare(), and read().

1042 {
1043  // safety check, whether we handle at least the same number
1044  // of systems
1045  std::vector<bool> os_result;
1046 
1047  if (this->n_systems() != other_es.n_systems())
1048  {
1049  if (verbose)
1050  {
1051  libMesh::out << " Fatal difference. This system handles "
1052  << this->n_systems() << " systems," << std::endl
1053  << " while the other system handles "
1054  << other_es.n_systems()
1055  << " systems." << std::endl
1056  << " Aborting comparison." << std::endl;
1057  }
1058  return false;
1059  }
1060  else
1061  {
1062  // start comparing each system
1063  const_system_iterator pos = _systems.begin();
1064  const const_system_iterator end = _systems.end();
1065 
1066  for (; pos != end; ++pos)
1067  {
1068  const std::string & sys_name = pos->first;
1069  const System & system = *(pos->second);
1070 
1071  // get the other system
1072  const System & other_system = other_es.get_system (sys_name);
1073 
1074  os_result.push_back (system.compare (other_system, threshold, verbose));
1075 
1076  }
1077 
1078  }
1079 
1080 
1081  // sum up the results
1082  if (os_result.size()==0)
1083  return true;
1084  else
1085  {
1086  bool os_identical;
1087  unsigned int n = 0;
1088  do
1089  {
1090  os_identical = os_result[n];
1091  n++;
1092  }
1093  while (os_identical && n<os_result.size());
1094  return os_identical;
1095  }
1096 }
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
std::map< std::string, System * >::const_iterator const_system_iterator
Typedef for constant system iterators.
unsigned int n_systems() const
OStreamProxy out
std::map< std::string, System * > _systems
Data structure holding the systems.
void libMesh::EquationSystems::delete_system ( const std::string &  name)

Remove the system named name from the systems array.

Deprecated:
This function may not work as intended and has not been actively tested over the years. If you need the ability to delete a System from an EquationSystems object, it could probably be added.

Definition at line 401 of file equation_systems.C.

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

402 {
403  libmesh_deprecated();
404 
405  if (!_systems.count(name))
406  libmesh_error_msg("ERROR: no system named " << name);
407 
408  delete _systems[name];
409 
410  _systems.erase (name);
411 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
std::map< std::string, System * > _systems
Data structure holding the systems.
void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 107 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

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

108 {
109  _enable_print_counter = false;
110  return;
111 }
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...
void libMesh::EquationSystems::disable_refine_in_reinit ( )

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

Definition at line 456 of file equation_systems.h.

References _refine_in_reinit.

Referenced by EquationSystemsTest::testRefineThenReinitPreserveFlags().

456 { this->_refine_in_reinit = false; }
bool _refine_in_reinit
Flag for whether to call coarsen/refine in reinit().
void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

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

Definition at line 101 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

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

102 {
103  _enable_print_counter = true;
104  return;
105 }
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...
void libMesh::EquationSystems::enable_refine_in_reinit ( )

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

Definition at line 451 of file equation_systems.h.

References _refine_in_reinit.

451 { this->_refine_in_reinit = true; }
bool _refine_in_reinit
Flag for whether to call coarsen/refine in reinit().
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 (Counts::iterator it = _counts.begin();
59  it != _counts.end(); ++it)
60  {
61  const std::string name(it->first);
62  const unsigned int creations = it->second.first;
63  const unsigned int destructions = it->second.second;
64 
65  oss << "| " << name << " reference count information:\n"
66  << "| Creations: " << creations << '\n'
67  << "| Destructions: " << destructions << '\n';
68  }
69 
70  oss << " ---------------------------------------------------------------------------- \n";
71 
72  return oss.str();
73 
74 #else
75 
76  return "";
77 
78 #endif
79 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
static Counts _counts
Actually holds the data.
std::string libMesh::EquationSystems::get_info ( ) const
virtual
Returns
A string containing information about the systems, flags, and parameters.

Definition at line 1100 of file equation_systems.C.

References _systems, end, and n_systems().

Referenced by print_info(), and read().

1101 {
1102  std::ostringstream oss;
1103 
1104  oss << " EquationSystems\n"
1105  << " n_systems()=" << this->n_systems() << '\n';
1106 
1107  // Print the info for the individual systems
1108  const_system_iterator pos = _systems.begin();
1109  const const_system_iterator end = _systems.end();
1110 
1111  for (; pos != end; ++pos)
1112  oss << pos->second->get_info();
1113 
1114 
1115  // // Possibly print the parameters
1116  // if (!this->parameters.empty())
1117  // {
1118  // oss << " n_parameters()=" << this->n_parameters() << '\n';
1119  // oss << " Parameters:\n";
1120 
1121  // for (std::map<std::string, Real>::const_iterator
1122  // param = _parameters.begin(); param != _parameters.end();
1123  // ++param)
1124  // oss << " "
1125  // << "\""
1126  // << param->first
1127  // << "\""
1128  // << "="
1129  // << param->second
1130  // << '\n';
1131  // }
1132 
1133  return oss.str();
1134 }
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
std::map< std::string, System * >::const_iterator const_system_iterator
Typedef for constant system iterators.
unsigned int n_systems() const
std::map< std::string, System * > _systems
Data structure holding the systems.
const MeshBase & libMesh::EquationSystems::get_mesh ( ) const
MeshBase & libMesh::EquationSystems::get_mesh ( )
Returns
A reference to the mesh

Definition at line 543 of file equation_systems.h.

References _mesh.

544 {
545  return _mesh;
546 }
MeshBase & _mesh
The mesh data structure.
void libMesh::EquationSystems::get_solution ( std::vector< Number > &  soln,
std::vector< std::string > &  names 
) const

Retrieve the solution data for CONSTANT MONOMIALs.

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

Definition at line 773 of file equation_systems.C.

References libMesh::ParallelObject::_communicator, _mesh, _systems, libMesh::MeshBase::active_local_element_ptr_range(), libMesh::Variable::active_on_subdomain(), libMesh::NumericVector< T >::build(), libMesh::NumericVector< T >::close(), libMesh::ParallelObject::comm(), libMesh::CONSTANT, libMesh::System::current_local_solution, libMesh::DofMap::dof_indices(), end, libMesh::System::get_dof_map(), libMesh::NumericVector< T >::init(), libMesh::libmesh_assert(), libMesh::NumericVector< T >::localize_to_one(), libMesh::MeshBase::max_elem_id(), libMesh::MONOMIAL, libMesh::MeshBase::n_elem(), libMesh::ParallelObject::n_processors(), n_systems(), libMesh::System::n_vars(), libMesh::PARALLEL, libMesh::ParallelObject::processor_id(), libMesh::NumericVector< T >::set(), libMesh::System::solution, libMesh::System::update(), libMesh::System::variable(), libMesh::System::variable_name(), libMesh::System::variable_type(), and libMesh::Parallel::verify().

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

775 {
776  // This function must be run on all processors at once
777  parallel_object_only();
778 
779  libmesh_assert (this->n_systems());
780 
781  const dof_id_type ne = _mesh.n_elem();
782 
783  libmesh_assert_equal_to (ne, _mesh.max_elem_id());
784 
785  // If the names vector has entries, we will only populate the soln vector
786  // with names included in that list. Note: The names vector may be
787  // reordered upon exiting this function
788  std::vector<std::string> filter_names = names;
789  bool is_filter_names = !filter_names.empty();
790 
791  soln.clear();
792  names.clear();
793 
794  const FEType type(CONSTANT, MONOMIAL);
795 
796  dof_id_type nv = 0;
797 
798  // Find the total number of variables to output
799  std::vector<std::vector<unsigned>> do_output(_systems.size());
800  {
801  const_system_iterator pos = _systems.begin();
802  const const_system_iterator end = _systems.end();
803  unsigned sys_ctr = 0;
804 
805  for (; pos != end; ++pos, ++sys_ctr)
806  {
807  const System & system = *(pos->second);
808  const unsigned int nv_sys = system.n_vars();
809 
810  do_output[sys_ctr].resize(nv_sys);
811 
812  for (unsigned int var=0; var < nv_sys; ++var)
813  {
814  if (system.variable_type(var) != type ||
815  (is_filter_names && std::find(filter_names.begin(), filter_names.end(), system.variable_name(var)) == filter_names.end()))
816  continue;
817 
818  // Otherwise, this variable should be output
819  nv++;
820  do_output[sys_ctr][var] = 1;
821  }
822  }
823  }
824 
825  // If there are no variables to write out don't do anything...
826  if (!nv)
827  return;
828 
829  // We can handle the case where there are NULLs in the Elem vector
830  // by just having extra zeros in the solution vector.
831  numeric_index_type parallel_soln_global_size = ne*nv;
832 
833  numeric_index_type div = parallel_soln_global_size / this->n_processors();
834  numeric_index_type mod = parallel_soln_global_size % this->n_processors();
835 
836  // Initialize all processors to the average size.
837  numeric_index_type parallel_soln_local_size = div;
838 
839  // The first "mod" processors get an extra entry.
840  if (this->processor_id() < mod)
841  parallel_soln_local_size = div+1;
842 
843  // Create a NumericVector to hold the parallel solution
844  UniquePtr<NumericVector<Number>> parallel_soln_ptr = NumericVector<Number>::build(_communicator);
845  NumericVector<Number> & parallel_soln = *parallel_soln_ptr;
846  parallel_soln.init(parallel_soln_global_size,
847  parallel_soln_local_size,
848  /*fast=*/false,
849  /*ParallelType=*/PARALLEL);
850 
851  dof_id_type var_num = 0;
852 
853  // For each system in this EquationSystems object,
854  // update the global solution and collect the
855  // CONSTANT MONOMIALs. The entries are in variable-major
856  // format.
857  const_system_iterator pos = _systems.begin();
858  const const_system_iterator end = _systems.end();
859  unsigned sys_ctr = 0;
860 
861  for (; pos != end; ++pos, ++sys_ctr)
862  {
863  const System & system = *(pos->second);
864  const unsigned int nv_sys = system.n_vars();
865 
866  // Update the current_local_solution
867  {
868  System & non_const_sys = const_cast<System &>(system);
869  // We used to simply call non_const_sys.solution->close()
870  // here, but that is not allowed when the solution vector is
871  // locked read-only, for example when printing the solution
872  // during during the middle of a solve... So try to be a bit
873  // more careful about calling close() unnecessarily.
874  libmesh_assert(this->comm().verify(non_const_sys.solution->closed()));
875  if (!non_const_sys.solution->closed())
876  non_const_sys.solution->close();
877  non_const_sys.update();
878  }
879 
880  NumericVector<Number> & sys_soln(*system.current_local_solution);
881 
882  // The DOF indices for the finite element
883  std::vector<dof_id_type> dof_indices;
884 
885  // Loop over the variable names and load them in order
886  for (unsigned int var=0; var < nv_sys; ++var)
887  {
888  // Skip this variable if we are not outputting it.
889  if (!do_output[sys_ctr][var])
890  continue;
891 
892  names.push_back(system.variable_name(var));
893 
894  const Variable & variable = system.variable(var);
895  const DofMap & dof_map = system.get_dof_map();
896 
897  for (const auto & elem : _mesh.active_local_element_ptr_range())
898  if (variable.active_on_subdomain(elem->subdomain_id()))
899  {
900  dof_map.dof_indices (elem, dof_indices, var);
901 
902  libmesh_assert_equal_to (1, dof_indices.size());
903 
904  parallel_soln.set((ne*var_num)+elem->id(), sys_soln(dof_indices[0]));
905  }
906 
907  var_num++;
908  } // end loop on variables in this system
909  } // end loop over systems
910 
911  parallel_soln.close();
912 
913  parallel_soln.localize_to_one(soln);
914 }
processor_id_type n_processors() const
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
const Parallel::Communicator & _communicator
MeshBase & _mesh
The mesh data structure.
libmesh_assert(j)
static UniquePtr< NumericVector< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
Builds a NumericVector on the processors in communicator comm using the linear solver package specifi...
virtual SimpleRange< element_iterator > active_local_element_ptr_range()=0
std::map< std::string, System * >::const_iterator const_system_iterator
Typedef for constant system iterators.
virtual dof_id_type max_elem_id() const =0
dof_id_type numeric_index_type
Definition: id_types.h:92
unsigned int n_systems() const
bool verify(const T &r, const Communicator &comm=Communicator_World)
const Parallel::Communicator & comm() const
virtual dof_id_type n_elem() const =0
processor_id_type processor_id() const
uint8_t dof_id_type
Definition: id_types.h:64
std::map< std::string, System * > _systems
Data structure holding the systems.
template<typename T_sys >
const T_sys & libMesh::EquationSystems::get_system ( const std::string &  name) const
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 651 of file equation_systems.h.

References _systems.

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), _read_impl(), add_M_C_K_helmholtz(), libMesh::EnsightIO::add_scalar(), libMesh::RBSCMConstruction::add_scaled_symm_Aq(), add_system(), libMesh::EnsightIO::add_vector(), adjoint_solve(), allgather(), apply_initial(), assemble(), LinearElasticity::assemble(), assemble_1D(), assemble_biharmonic(), assemble_cd(), assemble_elasticity(), assemble_ellipticdg(), assemble_helmholtz(), assemble_laplace(), assemble_mass(), assemble_matrices(), assemble_poisson(), assemble_shell(), assemble_stokes(), assemble_wave(), libMesh::ExactSolution::attach_exact_deriv(), libMesh::ExactSolution::attach_exact_value(), libMesh::ExactSolution::attach_reference_solution(), 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::ExactSolution::error_norm(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::ErrorEstimator::estimate_errors(), libMesh::ExactSolution::ExactSolution(), fill_dirichlet_bc(), libMesh::DTKAdapter::find_sys(), libMesh::RBEIMConstruction::get_explicit_system(), init(), init_cd(), SolidSystem::init_data(), init_sys(), initialize(), LaplaceYoung::jacobian(), LargeDeformationElasticity::jacobian(), libMesh::RBSCMConstruction::load_matrix_B(), main(), libMesh::RBSCMConstruction::perform_SCM_greedy(), reinit(), LaplaceYoung::residual(), LargeDeformationElasticity::residual(), run_timestepping(), SolidSystem::save_initial_mesh(), sensitivity_solve(), SolidSystem::side_time_derivative(), solve(), MixedDimensionMeshTest::testDofOrdering(), MixedDimensionRefinedMeshTest::testDofOrdering(), MixedDimensionNonUniformRefinement::testDofOrdering(), MixedDimensionNonUniformRefinementTriangle::testDofOrdering(), MixedDimensionNonUniformRefinement3D::testDofOrdering(), SlitMeshRefinedSystemTest::testRestart(), update(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().

652 {
653  const_system_iterator pos = _systems.find(name);
654 
655  // Check for errors
656  if (pos == _systems.end())
657  libmesh_error_msg("ERROR: no system named \"" << name << "\" found!");
658 
659  // Attempt dynamic cast
660  return *cast_ptr<T_sys *>(pos->second);
661 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
std::map< std::string, System * >::const_iterator const_system_iterator
Typedef for constant system iterators.
std::map< std::string, System * > _systems
Data structure holding the systems.
template<typename T_sys >
T_sys & libMesh::EquationSystems::get_system ( const std::string &  name)
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 670 of file equation_systems.h.

References _systems.

671 {
672  system_iterator pos = _systems.find(name);
673 
674  // Check for errors
675  if (pos == _systems.end())
676  libmesh_error_msg("ERROR: no system named " << name << " found!");
677 
678  // Attempt dynamic cast
679  return *cast_ptr<T_sys *>(pos->second);
680 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
std::map< std::string, System * >::iterator system_iterator
Typedef for system iterators.
std::map< std::string, System * > _systems
Data structure holding the systems.
template<typename T_sys >
const T_sys & libMesh::EquationSystems::get_system ( const unsigned int  num) const
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 600 of file equation_systems.h.

References _systems, end, and n_systems().

601 {
602  libmesh_assert_less (num, this->n_systems());
603 
604 
605  const_system_iterator pos = _systems.begin();
606  const const_system_iterator end = _systems.end();
607 
608  for (; pos != end; ++pos)
609  if (pos->second->number() == num)
610  break;
611 
612  // Check for errors
613  if (pos == end)
614  libmesh_error_msg("ERROR: no system number " << num << " found!");
615 
616  // Attempt dynamic cast
617  return *cast_ptr<T_sys *>(pos->second);
618 }
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
std::map< std::string, System * >::const_iterator const_system_iterator
Typedef for constant system iterators.
unsigned int n_systems() const
std::map< std::string, System * > _systems
Data structure holding the systems.
template<typename T_sys >
T_sys & libMesh::EquationSystems::get_system ( const unsigned int  num)
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 625 of file equation_systems.h.

References _systems, end, and n_systems().

626 {
627  libmesh_assert_less (num, this->n_systems());
628 
629  const_system_iterator pos = _systems.begin();
630  const const_system_iterator end = _systems.end();
631 
632  for (; pos != end; ++pos)
633  if (pos->second->number() == num)
634  break;
635 
636  // Check for errors
637  if (pos == end)
638  libmesh_error_msg("ERROR: no system number " << num << " found!");
639 
640  // Attempt dynamic cast
641  return *cast_ptr<T_sys *>(pos->second);
642 }
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
std::map< std::string, System * >::const_iterator const_system_iterator
Typedef for constant system iterators.
unsigned int n_systems() const
std::map< std::string, System * > _systems
Data structure holding the systems.
const System & libMesh::EquationSystems::get_system ( const std::string &  name) const
Returns
A constant reference to the system named name.

Definition at line 689 of file equation_systems.h.

References libMesh::Quality::name().

690 {
691  return this->get_system<System>(name);
692 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
System & libMesh::EquationSystems::get_system ( const std::string &  name)
Returns
A writable reference to the system named name.

Definition at line 697 of file equation_systems.h.

References libMesh::Quality::name().

698 {
699  return this->get_system<System>(name);
700 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
const System & libMesh::EquationSystems::get_system ( const unsigned int  num) const
Returns
A constant reference to system number num.

Definition at line 705 of file equation_systems.h.

706 {
707  return this->get_system<System>(num);
708 }
System & libMesh::EquationSystems::get_system ( const unsigned int  num)
Returns
A writable reference to the system number num.

Definition at line 713 of file equation_systems.h.

714 {
715  return this->get_system<System>(num);
716 }
bool libMesh::EquationSystems::has_system ( const std::string &  name) const
Returns
true if the system named name exists within this EquationSystems object.

Definition at line 588 of file equation_systems.h.

References _systems.

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

589 {
590  if (_systems.find(name) == _systems.end())
591  return false;
592  return true;
593 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
std::map< std::string, System * > _systems
Data structure holding the systems.
void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name)
protectedinherited

Increments the construction counter.

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

Definition at line 185 of file reference_counter.h.

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

Referenced by libMesh::ReferenceCounter::n_objects(), and libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().

186 {
187  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
188  std::pair<unsigned int, unsigned int> & p = _counts[name];
189 
190  p.first++;
191 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.
Definition: threads.C:29
static Counts _counts
Actually holds the data.
void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name)
protectedinherited

Increments the destruction counter.

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

Definition at line 198 of file reference_counter.h.

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

Referenced by libMesh::ReferenceCounter::n_objects(), and libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().

199 {
200  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
201  std::pair<unsigned int, unsigned int> & p = _counts[name];
202 
203  p.second++;
204 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.
Definition: threads.C:29
static Counts _counts
Actually holds the data.
void libMesh::EquationSystems::init ( )
virtual

Initialize all the systems.

Reimplemented in Biharmonic.

Definition at line 94 of file equation_systems.C.

References _mesh, libMesh::MeshRefinement::clean_refinement_flags(), libMesh::MeshBase::element_ptr_range(), get_system(), n_systems(), and libMesh::MeshBase::node_ptr_range().

Referenced by _read_impl(), assemble_and_solve(), main(), libMesh::ErrorVector::plot_error(), TimeSolverTestImplementation< NewmarkSolver >::run_test_with_exact_soln(), setup(), FETest< order, family, elem_type >::setUp(), SlitMeshRefinedSystemTest::setUp(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MixedDimensionMeshTest::testDofOrdering(), MixedDimensionRefinedMeshTest::testDofOrdering(), MixedDimensionNonUniformRefinement::testDofOrdering(), MixedDimensionNonUniformRefinementTriangle::testDofOrdering(), MixedDimensionNonUniformRefinement3D::testDofOrdering(), DofMapTest::testDofOwner(), EquationSystemsTest::testInit(), EquationSystemsTest::testPostInitAddElem(), EquationSystemsTest::testPostInitAddRealSystem(), EquationSystemsTest::testPostInitAddSystem(), SystemsTest::testProjectCube(), SystemsTest::testProjectCubeWithMeshFunction(), SystemsTest::testProjectLine(), SystemsTest::testProjectSquare(), EquationSystemsTest::testRefineThenReinitPreserveFlags(), and WriteVecAndScalar::testWrite().

95 {
96  const unsigned int n_sys = this->n_systems();
97 
98  libmesh_assert_not_equal_to (n_sys, 0);
99 
100  // Tell all the \p DofObject entities how many systems
101  // there are.
102  for (auto & node : _mesh.node_ptr_range())
103  node->set_n_systems(n_sys);
104 
105  for (auto & elem : _mesh.element_ptr_range())
106  elem->set_n_systems(n_sys);
107 
108  for (unsigned int i=0; i != this->n_systems(); ++i)
109  this->get_system(i).init();
110 
111 #ifdef LIBMESH_ENABLE_AMR
112  MeshRefinement mesh_refine(_mesh);
113  mesh_refine.clean_refinement_flags();
114 #endif
115 }
MeshBase & _mesh
The mesh data structure.
virtual SimpleRange< element_iterator > element_ptr_range()=0
virtual SimpleRange< node_iterator > node_ptr_range()=0
unsigned int n_systems() const
const T_sys & get_system(const std::string &name) const
std::size_t libMesh::EquationSystems::n_active_dofs ( ) const
Returns
The number of active degrees of freedom for the EquationSystems object.

Definition at line 1186 of file equation_systems.C.

References _systems, and end.

Referenced by main(), and write_output_solvedata().

1187 {
1188  std::size_t tot=0;
1189 
1190  const_system_iterator pos = _systems.begin();
1191  const const_system_iterator end = _systems.end();
1192 
1193  for (; pos != end; ++pos)
1194  tot += pos->second->n_active_dofs();
1195 
1196  return tot;
1197 }
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
std::map< std::string, System * >::const_iterator const_system_iterator
Typedef for constant system iterators.
std::map< std::string, System * > _systems
Data structure holding the systems.
std::size_t libMesh::EquationSystems::n_dofs ( ) const
Returns
The total number of degrees of freedom in all systems.

Definition at line 1170 of file equation_systems.C.

References _systems, and end.

1171 {
1172  std::size_t tot=0;
1173 
1174  const_system_iterator pos = _systems.begin();
1175  const const_system_iterator end = _systems.end();
1176 
1177  for (; pos != end; ++pos)
1178  tot += pos->second->n_dofs();
1179 
1180  return tot;
1181 }
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
std::map< std::string, System * >::const_iterator const_system_iterator
Typedef for constant system iterators.
std::map< std::string, System * > _systems
Data structure holding the systems.
static unsigned int libMesh::ReferenceCounter::n_objects ( )
staticinherited
processor_id_type libMesh::ParallelObject::n_processors ( ) const
inherited
Returns
The number of processors in the group.

Definition at line 93 of file parallel_object.h.

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

Referenced by libMesh::ParmetisPartitioner::_do_repartition(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::DistributedMesh::add_elem(), libMesh::DistributedMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assembly(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::MeshCommunication::broadcast(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::DistributedMesh::clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DistributedMesh::DistributedMesh(), libMesh::EnsightIO::EnsightIO(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::MeshBase::get_info(), get_solution(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), 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::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::Partitioner::partition(), libMesh::MeshBase::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::PetscLinearSolver< T >::PetscLinearSolver(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::SparseMatrix< T >::print(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::XdrIO::read_header(), libMesh::CheckpointIO::read_nodes(), libMesh::MeshCommunication::redistribute(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::Partitioner::repartition(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Parallel::Sort< KeyType, IdxType >::sort(), WriteVecAndScalar::testWrite(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

94  { return cast_int<processor_id_type>(_communicator.size()); }
unsigned int size() const
Definition: parallel.h:726
const Parallel::Communicator & _communicator
unsigned int libMesh::EquationSystems::n_systems ( ) const
unsigned int libMesh::EquationSystems::n_vars ( ) const
Returns
The total number of variables in all systems.

Definition at line 1155 of file equation_systems.C.

References _systems, and end.

Referenced by build_variable_names().

1156 {
1157  unsigned int tot=0;
1158 
1159  const_system_iterator pos = _systems.begin();
1160  const const_system_iterator end = _systems.end();
1161 
1162  for (; pos != end; ++pos)
1163  tot += pos->second->n_vars();
1164 
1165  return tot;
1166 }
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
std::map< std::string, System * >::const_iterator const_system_iterator
Typedef for constant system iterators.
std::map< std::string, System * > _systems
Data structure holding the systems.
void libMesh::ReferenceCounter::print_info ( std::ostream &  out = libMesh::out)
staticinherited

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

Definition at line 88 of file reference_counter.C.

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

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

89 {
91  out_stream << ReferenceCounter::get_info();
92 }
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...
void libMesh::EquationSystems::print_info ( std::ostream &  os = libMesh::out) const

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

Definition at line 1138 of file equation_systems.C.

References get_info().

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

1139 {
1140  os << this->get_info()
1141  << std::endl;
1142 }
virtual std::string get_info() const
processor_id_type libMesh::ParallelObject::processor_id ( ) const
inherited
Returns
The rank of this processor in the group.

Definition at line 99 of file parallel_object.h.

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

Referenced by libMesh::BoundaryInfo::_find_id_maps(), _read_impl(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::MeshRefinement::add_node(), libMesh::MeshTools::Modification::all_tri(), libMesh::FEMSystem::assembly(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::MeshCommunication::broadcast(), build_discontinuous_solution_vector(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::ParmetisPartitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::DofMap::build_sparsity(), libMesh::DistributedMesh::clear(), 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::MeshTools::correct_node_proc_ids(), libMesh::ExodusII_IO_Helper::create(), libMesh::DistributedMesh::delete_elem(), libMesh::DistributedMesh::delete_node(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DistributedMesh::DistributedMesh(), libMesh::EnsightIO::EnsightIO(), libMesh::RBEIMConstruction::evaluate_mesh_function(), libMesh::MeshFunction::find_element(), libMesh::MeshFunction::find_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), 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::Nemesis_IO_Helper::get_loadbal_param(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), get_solution(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::SparsityPattern::Build::handle_vi_vj(), libMesh::SystemSubsetBySubdomain::init(), HeatSystem::init_data(), libMesh::ParmetisPartitioner::initialize(), 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::RBEIMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEIMEvaluation::legacy_write_out_interpolation_points_elem(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), 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::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::System::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::MetisPartitioner::partition_range(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::SparseMatrix< T >::print(), libMesh::NumericVector< T >::print_global(), 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::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::MeshCommunication::redistribute(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), BoundaryInfoTest::testShellFaceConstraints(), WriteVecAndScalar::testWrite(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::Parallel::Packing< Node * >::unpack(), libMesh::Parallel::Packing< Elem * >::unpack(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::DTKAdapter::update_variable_values(), libMesh::MeshTools::weight(), libMesh::NameBasedIO::write(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), 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::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::RBEvaluation::write_out_vectors(), write_output_solvedata(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), and libMesh::ExodusII_IO_Helper::write_timestep().

100  { return cast_int<processor_id_type>(_communicator.rank()); }
const Parallel::Communicator & _communicator
unsigned int rank() const
Definition: parallel.h:724
template<typename InValType >
void libMesh::EquationSystems::read ( const std::string &  name,
const XdrMODE  mode,
const unsigned int  read_flags = (READ_HEADER | READ_DATA),
bool  partition_agnostic = true 
)

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 _mesh, libMesh::MeshRefinement::clean_refinement_flags(), libMesh::Quality::name(), libMesh::out, and TRY_READ_IFEMS.

Referenced by _read_impl(), main(), read(), and SlitMeshRefinedSystemTest::testRestart().

94 {
95  // If we have exceptions enabled we can be considerate and try
96  // to read old restart files which contain infinite element
97  // information but do not have the " with infinite elements"
98  // string in the version information.
99 
100  // First try the read the user requested
101  libmesh_try
102  {
103  this->_read_impl<InValType> (name, mode, read_flags, partition_agnostic);
104  }
105 
106  // If that fails, try it again but explicitly request we look for infinite element info
107  libmesh_catch (...)
108  {
109  libMesh::out << "\n*********************************************************************\n"
110  << "READING THE FILE \"" << name << "\" FAILED.\n"
111  << "It is possible this file contains infinite element information,\n"
112  << "but the version string does not contain \" with infinite elements\"\n"
113  << "Let's try this again, but looking for infinite element information...\n"
114  << "*********************************************************************\n"
115  << std::endl;
116 
117  libmesh_try
118  {
119  this->_read_impl<InValType> (name, mode, read_flags | EquationSystems::TRY_READ_IFEMS, partition_agnostic);
120  }
121 
122  // If all that failed, we are out of ideas here...
123  libmesh_catch (...)
124  {
125  libMesh::out << "\n*********************************************************************\n"
126  << "Well, at least we tried!\n"
127  << "Good Luck!!\n"
128  << "*********************************************************************\n"
129  << std::endl;
130  LIBMESH_THROW();
131  }
132  }
133 
134 #ifdef LIBMESH_ENABLE_AMR
135  MeshRefinement mesh_refine(_mesh);
136  mesh_refine.clean_refinement_flags();
137 #endif
138 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
MeshBase & _mesh
The mesh data structure.
OStreamProxy out
template void libMesh::EquationSystems::read< Real > ( const std::string &  name,
const XdrMODE  mode,
const unsigned int  read_flags = (READ_HEADER|READ_DATA),
bool  partition_agnostic = true 
)

Definition at line 354 of file equation_systems.h.

References libMesh::Quality::name(), read(), READ_DATA, and READ_HEADER.

358  { read<Number>(name, mode, read_flags, partition_agnostic); }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
template<typename InValType >
void libMesh::EquationSystems::read ( const std::string &  name,
const unsigned int  read_flags = (READ_HEADER | READ_DATA),
bool  partition_agnostic = true 
)

Definition at line 72 of file equation_systems_io.C.

References _mesh, libMesh::MeshRefinement::clean_refinement_flags(), libMesh::DECODE, libMesh::READ, and read().

75 {
76  XdrMODE mode = READ;
77  if (name.find(".xdr") != std::string::npos)
78  mode = DECODE;
79  this->read(name, mode, read_flags, partition_agnostic);
80 
81 #ifdef LIBMESH_ENABLE_AMR
82  MeshRefinement mesh_refine(_mesh);
83  mesh_refine.clean_refinement_flags();
84 #endif
85 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
void read(const std::string &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.
MeshBase & _mesh
The mesh data structure.
XdrMODE
Defines an enum for read/write mode in Xdr format.
Definition: enum_xdr_mode.h:32
template void libMesh::EquationSystems::read< Real > ( const std::string &  name,
const unsigned int  read_flags = (READ_HEADER|READ_DATA),
bool  partition_agnostic = true 
)

Definition at line 365 of file equation_systems.h.

References allgather(), compare(), get_info(), get_mesh(), libMesh::Quality::name(), operator<<, libMesh::out, print_info(), libMesh::Real, write(), and WRITE_DATA.

368  { read<Number>(name, read_flags, partition_agnostic); }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
bool libMesh::EquationSystems::refine_in_reinit_flag ( )
Returns
Whether or not calls to reinit() will try to coarsen/refine the mesh

Definition at line 461 of file equation_systems.h.

References _refine_in_reinit.

461 { return this->_refine_in_reinit; }
bool _refine_in_reinit
Flag for whether to call coarsen/refine in reinit().
void libMesh::EquationSystems::reinit ( )
virtual

Reinitialize all the systems.

Definition at line 119 of file equation_systems.C.

References _mesh, _refine_in_reinit, libMesh::MeshRefinement::coarsen_elements(), libMesh::MeshBase::contract(), libMesh::DofMap::distribute_dofs(), libMesh::MeshBase::element_ptr_range(), libMesh::MeshRefinement::face_level_mismatch_limit(), libMesh::System::get_dof_map(), get_mesh(), get_system(), n_systems(), libMesh::MeshBase::node_ptr_range(), libMesh::MeshRefinement::overrefined_boundary_limit(), libMesh::System::prolong_vectors(), libMesh::MeshRefinement::refine_elements(), libMesh::System::reinit_constraints(), libMesh::System::restrict_vectors(), libMesh::sys, and libMesh::MeshRefinement::underrefined_boundary_limit().

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), assemble_and_solve(), libMesh::AdjointRefinementEstimator::estimate_error(), main(), run_timestepping(), SlitMeshRefinedSystemTest::setUp(), EquationSystemsTest::testPostInitAddElem(), EquationSystemsTest::testPostInitAddRealSystem(), EquationSystemsTest::testPostInitAddSystem(), and EquationSystemsTest::testRefineThenReinitPreserveFlags().

120 {
121  parallel_object_only();
122 
123  const unsigned int n_sys = this->n_systems();
124  libmesh_assert_not_equal_to (n_sys, 0);
125 
126  // We may have added new systems since our last
127  // EquationSystems::(re)init call
128  bool _added_new_systems = false;
129  for (unsigned int i=0; i != n_sys; ++i)
130  if (!this->get_system(i).is_initialized())
131  _added_new_systems = true;
132 
133  if (_added_new_systems)
134  {
135  // Our DofObjects will need space for the additional systems
136  for (auto & node : _mesh.node_ptr_range())
137  node->set_n_systems(n_sys);
138 
139  for (auto & elem : _mesh.element_ptr_range())
140  elem->set_n_systems(n_sys);
141 
142  // And any new systems will need initialization
143  for (unsigned int i=0; i != n_sys; ++i)
144  if (!this->get_system(i).is_initialized())
145  this->get_system(i).init();
146  }
147 
148 
149  // We used to assert that all nodes and elements *already* had
150  // n_systems() properly set; however this is false in the case where
151  // user code has manually added nodes and/or elements to an
152  // already-initialized system.
153 
154  // Make sure all the \p DofObject entities know how many systems
155  // there are.
156  {
157  // All the nodes
158  for (auto & node : _mesh.node_ptr_range())
159  node->set_n_systems(this->n_systems());
160 
161  // All the elements
162  for (auto & elem : _mesh.element_ptr_range())
163  elem->set_n_systems(this->n_systems());
164  }
165 
166  // Localize each system's vectors
167  for (unsigned int i=0; i != this->n_systems(); ++i)
168  this->get_system(i).re_update();
169 
170 #ifdef LIBMESH_ENABLE_AMR
171 
172  bool dof_constraints_created = false;
173  bool mesh_changed = false;
174 
175  // FIXME: For backwards compatibility, assume
176  // refine_and_coarsen_elements or refine_uniformly have already
177  // been called
178  {
179  for (unsigned int i=0; i != this->n_systems(); ++i)
180  {
181  System & sys = this->get_system(i);
182 
183  // Even if the system doesn't have any variables in it we want
184  // consistent behavior; e.g. distribute_dofs should have the
185  // opportunity to count up zero dofs on each processor.
186  //
187  // Who's been adding zero-var systems anyway, outside of my
188  // unit tests? - RHS
189  // if (!sys.n_vars())
190  // continue;
191 
192  sys.get_dof_map().distribute_dofs(_mesh);
193 
194  // Recreate any user or internal constraints
195  sys.reinit_constraints();
196 
197  sys.prolong_vectors();
198  }
199  mesh_changed = true;
200  dof_constraints_created = true;
201  }
202 
203  if (this->_refine_in_reinit)
204  {
205  // Don't override any user refinement settings
206  MeshRefinement mesh_refine(_mesh);
207  mesh_refine.face_level_mismatch_limit() = 0; // unlimited
208  mesh_refine.overrefined_boundary_limit() = -1; // unlimited
209  mesh_refine.underrefined_boundary_limit() = -1; // unlimited
210 
211  // Try to coarsen the mesh, then restrict each system's vectors
212  // if necessary
213  if (mesh_refine.coarsen_elements())
214  {
215  for (unsigned int i=0; i != this->n_systems(); ++i)
216  {
217  System & sys = this->get_system(i);
218  if (!dof_constraints_created)
219  {
220  sys.get_dof_map().distribute_dofs(_mesh);
221  sys.reinit_constraints();
222  }
223  sys.restrict_vectors();
224  }
225  mesh_changed = true;
226  dof_constraints_created = true;
227  }
228 
229  // Once vectors are all restricted, we can delete
230  // children of coarsened elements
231  if (mesh_changed)
232  this->get_mesh().contract();
233 
234  // Try to refine the mesh, then prolong each system's vectors
235  // if necessary
236  if (mesh_refine.refine_elements())
237  {
238  for (unsigned int i=0; i != this->n_systems(); ++i)
239  {
240  System & sys = this->get_system(i);
241  if (!dof_constraints_created)
242  {
243  sys.get_dof_map().distribute_dofs(_mesh);
244  sys.reinit_constraints();
245  }
246  sys.prolong_vectors();
247  }
248  mesh_changed = true;
249  // dof_constraints_created = true;
250  }
251  }
252 
253  // If the mesh has changed, systems will need to create new dof
254  // constraints and update their global solution vectors
255  if (mesh_changed)
256  {
257  for (unsigned int i=0; i != this->n_systems(); ++i)
258  this->get_system(i).reinit();
259  }
260 #endif // #ifdef LIBMESH_ENABLE_AMR
261 }
ImplicitSystem & sys
MeshBase & _mesh
The mesh data structure.
virtual SimpleRange< element_iterator > element_ptr_range()=0
virtual SimpleRange< node_iterator > node_ptr_range()=0
bool _refine_in_reinit
Flag for whether to call coarsen/refine in reinit().
unsigned int n_systems() const
virtual bool contract()=0
Delete subactive (i.e.
const MeshBase & get_mesh() const
const T_sys & get_system(const std::string &name) const
void libMesh::EquationSystems::sensitivity_solve ( const ParameterVector parameters)
virtual

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 426 of file equation_systems.C.

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

427 {
428  libmesh_assert (this->n_systems());
429 
430  for (unsigned int i=0; i != this->n_systems(); ++i)
431  this->get_system(i).sensitivity_solve(parameters_in);
432 }
libmesh_assert(j)
unsigned int n_systems() const
const T_sys & get_system(const std::string &name) const
void libMesh::EquationSystems::solve ( )
virtual

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 416 of file equation_systems.C.

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

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

417 {
418  libmesh_assert (this->n_systems());
419 
420  for (unsigned int i=0; i != this->n_systems(); ++i)
421  this->get_system(i).solve();
422 }
libmesh_assert(j)
unsigned int n_systems() const
const T_sys & get_system(const std::string &name) const
void libMesh::EquationSystems::update ( )

Updates local values for all the systems.

Definition at line 304 of file equation_systems.C.

References get_system(), and n_systems().

Referenced by _read_impl(), and main().

305 {
306  LOG_SCOPE("update()", "EquationSystems");
307 
308  // Localize each system's vectors
309  for (unsigned int i=0; i != this->n_systems(); ++i)
310  this->get_system(i).update();
311 }
unsigned int n_systems() const
const T_sys & get_system(const std::string &name) const
void libMesh::EquationSystems::write ( const std::string &  name,
const XdrMODE  mode,
const unsigned int  write_flags = (WRITE_DATA),
bool  partition_agnostic = true 
) const

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!

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 381 of file equation_systems_io.C.

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

Referenced by main(), libMesh::ErrorVector::plot_error(), read(), SlitMeshRefinedSystemTest::testRestart(), write(), libMesh::NameBasedIO::write_equation_systems(), and write_output().

385 {
449  // the EquationSystems::write() method should look constant,
450  // but we need to assign a temporary numbering to the nodes
451  // and elements in the mesh, which requires that we abuse const_cast
452  if (partition_agnostic)
453  {
454  MeshBase & mesh = const_cast<MeshBase &>(this->get_mesh());
456  }
457 
458  // set booleans from write_flags argument
459  const bool write_data = write_flags & EquationSystems::WRITE_DATA;
460  const bool write_additional_data = write_flags & EquationSystems::WRITE_ADDITIONAL_DATA;
461 
462  // always write parallel files if we're instructed to write in
463  // parallel
464  const bool write_parallel_files =
466  // Even if we're on a distributed mesh, we may or may not have a
467  // consistent way of reconstructing the same mesh partitioning
468  // later, but we need the same mesh partitioning if we want to
469  // reread the parallel solution safely, so let's write a serial file
470  // unless specifically requested not to.
471  // ||
472  // // but also write parallel files if we haven't been instructed to
473  // // write in serial and we're on a distributed mesh
474  // (!(write_flags & EquationSystems::WRITE_SERIAL_FILES) &&
475  // !this->get_mesh().is_serial())
476  ;
477 
478  // New scope so that io will close before we try to zip the file
479  {
480  Xdr io((this->processor_id()==0) ? name : "", mode);
481  libmesh_assert (io.writing());
482 
483  LOG_SCOPE("write()", "EquationSystems");
484 
485  const unsigned int proc_id = this->processor_id();
486 
487  unsigned int n_sys = 0;
488  for (std::map<std::string, System *>::const_iterator pos = _systems.begin();
489  pos != _systems.end(); ++pos)
490  {
491  if (! pos->second->hide_output()) n_sys++;
492  }
493 
494  // set the version number in the Xdr object
495  io.set_version(LIBMESH_VERSION_ID(LIBMESH_MAJOR_VERSION,
496  LIBMESH_MINOR_VERSION,
497  LIBMESH_MICRO_VERSION));
498 
499  // Only write the header information
500  // if we are processor 0.
501  if (proc_id == 0)
502  {
503  std::string comment;
504  char buf[256];
505 
506  // 1.)
507  // Write the version header
508  std::string version("libMesh-" + libMesh::get_io_compatibility_version());
509  if (write_parallel_files) version += " parallel";
510 
511 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
512  version += " with infinite elements";
513 #endif
514  io.data (version, "# File Format Identifier");
515 
516  // 2.)
517  // Write the number of equation systems
518  io.data (n_sys, "# No. of Equation Systems");
519 
520  for (std::map<std::string, System *>::const_iterator pos = _systems.begin();
521  pos != _systems.end(); ++pos)
522  {
523  // Ignore this system if it has been marked as hidden
524  if (pos->second->hide_output()) continue;
525 
526  // 3.)
527  // Write the name of the sys_num-th system
528  {
529  const unsigned int sys_num = pos->second->number();
530  std::string sys_name = pos->first;
531 
532  comment = "# Name, System No. ";
533  std::sprintf(buf, "%u", sys_num);
534  comment += buf;
535 
536  io.data (sys_name, comment.c_str());
537  }
538 
539  // 4.)
540  // Write the type of system handled
541  {
542  const unsigned int sys_num = pos->second->number();
543  std::string sys_type = pos->second->system_type();
544 
545  comment = "# Type, System No. ";
546  std::sprintf(buf, "%u", sys_num);
547  comment += buf;
548 
549  io.data (sys_type, comment.c_str());
550  }
551 
552  // 5.) - 9.)
553  // Let System::write_header() do the job
554  pos->second->write_header (io, version, write_additional_data);
555  }
556  }
557 
558  // Start from the first system, again,
559  // to write vectors to disk, if wanted
560  if (write_data)
561  {
562  // open a parallel buffer if warranted.
563  Xdr local_io (write_parallel_files ? local_file_name(this->processor_id(),name) : "", mode);
564 
565  for (std::map<std::string, System *>::const_iterator pos = _systems.begin();
566  pos != _systems.end(); ++pos)
567  {
568  // Ignore this system if it has been marked as hidden
569  if (pos->second->hide_output()) continue;
570 
571  // 10.) + 11.)
572  if (write_parallel_files)
573  pos->second->write_parallel_data (local_io,write_additional_data);
574  else
575  pos->second->write_serialized_data (io,write_additional_data);
576  }
577  }
578  }
579 
580  // the EquationSystems::write() method should look constant,
581  // but we need to undo the temporary numbering of the nodes
582  // and elements in the mesh, which requires that we abuse const_cast
583  if (partition_agnostic)
584  const_cast<MeshBase &>(_mesh).fix_broken_node_and_element_numbering();
585 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
MeshBase & mesh
MeshBase & _mesh
The mesh data structure.
libmesh_assert(j)
std::string get_io_compatibility_version()
Specifier for I/O file compatibility features.
void globally_renumber_nodes_and_elements(MeshBase &)
There is no reason for a user to ever call this function.
Definition: mesh_tools.C:1968
const MeshBase & get_mesh() const
processor_id_type processor_id() const
std::map< std::string, System * > _systems
Data structure holding the systems.
void libMesh::EquationSystems::write ( const std::string &  name,
const unsigned int  write_flags = (WRITE_DATA),
bool  partition_agnostic = true 
) const

Definition at line 369 of file equation_systems_io.C.

References libMesh::ENCODE, libMesh::WRITE, and write().

372 {
373  XdrMODE mode = WRITE;
374  if (name.find(".xdr") != std::string::npos)
375  mode = ENCODE;
376  this->write(name, mode, write_flags, partition_agnostic);
377 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
void write(const std::string &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:32

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const EquationSystems es 
)
friend

Same as above, but allows you to also use stream syntax.

Definition at line 1146 of file equation_systems.C.

Referenced by read().

1148 {
1149  es.print_info(os);
1150  return os;
1151 }

Member Data Documentation

const Parallel::Communicator& libMesh::ParallelObject::_communicator
protectedinherited
ReferenceCounter::Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited
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().

MeshBase& libMesh::EquationSystems::_mesh
protected
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.

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().

bool libMesh::EquationSystems::_refine_in_reinit
protected

Flag for whether to call coarsen/refine in reinit().

Default value: true

Definition at line 497 of file equation_systems.h.

Referenced by disable_refine_in_reinit(), enable_refine_in_reinit(), EquationSystems(), refine_in_reinit_flag(), and reinit().

std::map<std::string, System *> libMesh::EquationSystems::_systems
protected
Parameters libMesh::EquationSystems::parameters

Data structure holding arbitrary parameters.

Definition at line 467 of file equation_systems.h.

Referenced by add_M_C_K_helmholtz(), assemble_biharmonic(), assemble_cd(), assemble_ellipticdg(), assemble_helmholtz(), assemble_laplace(), assemble_poisson(), assemble_shell(), assemble_stokes(), assemble_wave(), libMesh::ExactSolution::attach_exact_deriv(), libMesh::ExactSolution::attach_exact_value(), libMesh::ExactSolution::attach_reference_solution(), libMesh::NewmarkSystem::clear(), clear(), libMesh::FrequencySystem::clear_all(), LinearElasticityWithContact::compute_stresses(), LargeDeformationElasticity::compute_stresses(), EquationSystems(), 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(), Biharmonic::JR::initialize(), initialize(), LargeDeformationElasticity::jacobian(), 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(), libMesh::NewmarkSystem::set_newmark_parameters(), libMesh::NonlinearImplicitSystem::set_solver_parameters(), setup(), FETest< order, family, elem_type >::setUp(), SolidSystem::side_time_derivative(), libMesh::EigenSystem::solve(), libMesh::CondensedEigenSystem::solve(), libMesh::FrequencySystem::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::RBConstruction::solve_for_matrix_and_rhs(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), SystemsTest::testProjectCube(), SystemsTest::testProjectCubeWithMeshFunction(), SystemsTest::testProjectLine(), SystemsTest::testProjectSquare(), and libMesh::WrappedFunction< Output >::WrappedFunction().


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