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 ()
 Handle any mesh changes and reinitialize all the systems on the updated mesh. More...
 
virtual void enable_default_ghosting (bool enable)
 Enable or disable default ghosting functors on the Mesh and on all Systems. More...
 
void update ()
 Updates local values for all the systems. More...
 
unsigned int n_systems () const
 
bool has_system (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=nullptr, const std::set< std::string > *system_names=nullptr) const
 Fill the input vector var_names with the names of the variables for each system. More...
 
void build_solution_vector (std::vector< Number > &soln, 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=nullptr) const
 Fill the input vector soln with solution values. More...
 
std::unique_ptr< NumericVector< Number > > build_parallel_solution_vector (const std::set< std::string > *system_names=nullptr) const
 A version of build_solution_vector which is appropriate for "parallel" output formats like Nemesis. More...
 
void get_vars_active_subdomains (const std::vector< std::string > &names, std::vector< std::set< subdomain_id_type >> &vars_active_subdomains) const
 Retrieve vars_active_subdomains, which indicates the active subdomains for each variable in names. More...
 
void get_solution (std::vector< Number > &soln, std::vector< std::string > &names) const
 Retrieve the solution data for CONSTANT MONOMIALs. More...
 
void build_elemental_solution_vector (std::vector< Number > &soln, std::vector< std::string > &names) const
 Retrieve the solution data for CONSTANT MONOMIALs. More...
 
std::unique_ptr< NumericVector< Number > > build_parallel_elemental_solution_vector (std::vector< std::string > &names) const
 Builds a parallel vector of CONSTANT MONOMIAL solution values corresponding to the entries in the input 'names' vector. More...
 
void build_discontinuous_solution_vector (std::vector< Number > &soln, const std::set< std::string > *system_names=nullptr) const
 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 ()
 
bool reinit_solutions ()
 Handle any mesh changes and project any solutions onto the updated mesh. More...
 
virtual void reinit_systems ()
 Reinitialize all systems on the current mesh. More...
 
const Parallel::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...
 
bool _enable_default_ghosting
 Flag for whether to enable default ghosting on newly added Systems. More...
 
const Parallel::Communicator_communicator
 

Static Protected Attributes

static Counts _counts
 Actually holds the data. More...
 
static Threads::atomic< unsigned int > _n_objects
 The number of objects. More...
 
static Threads::spin_mutex _mutex
 Mutual exclusion object to enable thread-safe reference counting. More...
 
static bool _enable_print_counter
 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...
 
void _remove_default_ghosting (unsigned int sys_num)
 This just calls DofMap::remove_default_ghosting() but using a shim lets us forward-declare DofMap. 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 74 of file equation_systems.h.

Member Typedef Documentation

◆ const_system_iterator

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

Typedef for constant system iterators.

Definition at line 566 of file equation_systems.h.

◆ Counts

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

Data structure to log the information.

The log is identified by the class name.

Definition at line 117 of file reference_counter.h.

◆ system_iterator

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

Typedef for system iterators.

Definition at line 561 of file equation_systems.h.

Member Enumeration Documentation

◆ ReadFlags

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

Enumerator
READ_HEADER 
READ_DATA 
READ_ADDITIONAL_DATA 
READ_LEGACY_FORMAT 
TRY_READ_IFEMS 
READ_BASIC_ONLY 

Definition at line 83 of file equation_systems.h.

◆ WriteFlags

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

Enumerator
WRITE_DATA 
WRITE_ADDITIONAL_DATA 
WRITE_PARALLEL_FILES 
WRITE_SERIAL_FILES 

Definition at line 93 of file equation_systems.h.

Constructor & Destructor Documentation

◆ EquationSystems()

libMesh::EquationSystems::EquationSystems ( MeshBase mesh)

Constructor.

◆ ~EquationSystems()

virtual libMesh::EquationSystems::~EquationSystems ( )
virtual

Destructor.

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

Member Function Documentation

◆ _add_system_to_nodes_and_elems()

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.

Referenced by add_system().

◆ _read_impl()

template<typename InValType >
void libMesh::EquationSystems::_read_impl ( 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!

◆ _remove_default_ghosting()

void libMesh::EquationSystems::_remove_default_ghosting ( unsigned int  sys_num)
private

This just calls DofMap::remove_default_ghosting() but using a shim lets us forward-declare DofMap.

Referenced by add_system().

◆ add_system() [1/2]

virtual 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.

Referenced by build_system(), TimeSolverTestImplementation< TimeSolverType >::run_test_with_exact_soln(), and FETest< order, family, elem_type >::setUp().

◆ add_system() [2/2]

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

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

648 {
649  T_sys * ptr = nullptr;
650 
651  if (!_systems.count(name))
652  {
653  const unsigned int sys_num = this->n_systems();
654  ptr = new T_sys(*this, name, sys_num);
655 
656  _systems.insert (std::make_pair(name, ptr));
657 
659  this->_remove_default_ghosting(sys_num);
660 
661  // Tell all the \p DofObject entities to add a system.
663  }
664  else
665  {
666  // We now allow redundant add_system calls, to make it
667  // easier to load data from files for user-derived system
668  // subclasses
669  ptr = &(this->get_system<T_sys>(name));
670  }
671 
672  // Return a dynamically casted reference to the newly added System.
673  return *ptr;
674 }
std::string name(const ElemQuality q)
unsigned int n_systems() const
bool _enable_default_ghosting
Flag for whether to enable default ghosting on newly added Systems.
void _remove_default_ghosting(unsigned int sys_num)
This just calls DofMap::remove_default_ghosting() but using a shim lets us forward-declare DofMap...
void _add_system_to_nodes_and_elems()
This function is used in the implementation of add_system, it loops over the nodes and elements of th...
std::map< std::string, System * > _systems
Data structure holding the systems.

◆ adjoint_solve()

virtual 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.

◆ allgather()

void libMesh::EquationSystems::allgather ( )

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

◆ build_discontinuous_solution_vector()

void libMesh::EquationSystems::build_discontinuous_solution_vector ( std::vector< Number > &  soln,
const std::set< std::string > *  system_names = 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!=nullptr, only include data from the specified systems.

◆ build_elemental_solution_vector()

void libMesh::EquationSystems::build_elemental_solution_vector ( 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.

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

◆ build_parallel_elemental_solution_vector()

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

Builds a parallel vector of CONSTANT MONOMIAL solution values corresponding to the entries in the input 'names' vector.

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

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

Returns
A nullptr (if no CONSTANT, MONOMIAL variables exist on the system) or a std::unique_ptr to a var-major numeric vector of total length n_elem * n_vars ordered according to: [u0, u1, ... uN, v0, v1, ... vN, w0, w1, ... wN] for constant monomial variables (u, v, w) on a mesh with N elements.

◆ build_parallel_solution_vector()

std::unique_ptr<NumericVector<Number> > libMesh::EquationSystems::build_parallel_solution_vector ( const std::set< std::string > *  system_names = nullptr) const

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

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

◆ build_solution_vector() [1/2]

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.

◆ build_solution_vector() [2/2]

void libMesh::EquationSystems::build_solution_vector ( std::vector< Number > &  soln,
const std::set< std::string > *  system_names = 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!=nullptr, only include data from the specified systems.

◆ build_variable_names()

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

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

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

◆ clear()

virtual void libMesh::EquationSystems::clear ( )
virtual

Restores the data structure to a pristine state.

◆ comm()

const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inherited

◆ compare()

virtual 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

◆ delete_system()

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.

◆ disable_print_counter_info()

static void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

◆ disable_refine_in_reinit()

void libMesh::EquationSystems::disable_refine_in_reinit ( )

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

Definition at line 519 of file equation_systems.h.

References _refine_in_reinit.

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

◆ enable_default_ghosting()

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

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

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

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

◆ enable_print_counter_info()

static void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

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

◆ enable_refine_in_reinit()

void libMesh::EquationSystems::enable_refine_in_reinit ( )

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

Definition at line 514 of file equation_systems.h.

References _refine_in_reinit.

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

◆ get_info() [1/2]

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

Gets a string containing the reference information.

◆ get_info() [2/2]

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

◆ get_mesh() [1/2]

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

Definition at line 622 of file equation_systems.h.

References _mesh.

623 {
624  return _mesh;
625 }
MeshBase & _mesh
The mesh data structure.

◆ get_mesh() [2/2]

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

Definition at line 630 of file equation_systems.h.

References _mesh.

631 {
632  return _mesh;
633 }
MeshBase & _mesh
The mesh data structure.

◆ get_solution()

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.

Deprecated:
Call the more appropriately-named build_elemental_solution_vector() instead.

◆ get_system() [1/8]

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

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

743 {
744  const_system_iterator pos = _systems.find(name);
745 
746  // Check for errors
747  if (pos == _systems.end())
748  libmesh_error_msg("ERROR: no system named \"" << name << "\" found!");
749 
750  // Attempt dynamic cast
751  return *cast_ptr<T_sys *>(pos->second);
752 }
std::string name(const ElemQuality q)
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.

◆ get_system() [2/8]

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

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

762 {
763  system_iterator pos = _systems.find(name);
764 
765  // Check for errors
766  if (pos == _systems.end())
767  libmesh_error_msg("ERROR: no system named " << name << " found!");
768 
769  // Attempt dynamic cast
770  return *cast_ptr<T_sys *>(pos->second);
771 }
std::string name(const ElemQuality q)
std::map< std::string, System * >::iterator system_iterator
Typedef for system iterators.
std::map< std::string, System * > _systems
Data structure holding the systems.

◆ get_system() [3/8]

template<typename T_sys >
const T_sys & libMesh::EquationSystems::get_system ( const unsigned int  num) const
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 691 of file equation_systems.h.

References _systems, end, and n_systems().

692 {
693  libmesh_assert_less (num, this->n_systems());
694 
695 
696  const_system_iterator pos = _systems.begin();
697  const const_system_iterator end = _systems.end();
698 
699  for (; pos != end; ++pos)
700  if (pos->second->number() == num)
701  break;
702 
703  // Check for errors
704  if (pos == end)
705  libmesh_error_msg("ERROR: no system number " << num << " found!");
706 
707  // Attempt dynamic cast
708  return *cast_ptr<T_sys *>(pos->second);
709 }
unsigned int n_systems() const
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.

◆ get_system() [4/8]

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

References _systems, end, and n_systems().

717 {
718  libmesh_assert_less (num, this->n_systems());
719 
720  const_system_iterator pos = _systems.begin();
721  const const_system_iterator end = _systems.end();
722 
723  for (; pos != end; ++pos)
724  if (pos->second->number() == num)
725  break;
726 
727  // Check for errors
728  if (pos == end)
729  libmesh_error_msg("ERROR: no system number " << num << " found!");
730 
731  // Attempt dynamic cast
732  return *cast_ptr<T_sys *>(pos->second);
733 }
unsigned int n_systems() const
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.

◆ get_system() [5/8]

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

Definition at line 780 of file equation_systems.h.

References libMesh::Quality::name().

781 {
782  return this->get_system<System>(name);
783 }
std::string name(const ElemQuality q)

◆ get_system() [6/8]

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

Definition at line 788 of file equation_systems.h.

References libMesh::Quality::name().

789 {
790  return this->get_system<System>(name);
791 }
std::string name(const ElemQuality q)

◆ get_system() [7/8]

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

Definition at line 796 of file equation_systems.h.

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

◆ get_system() [8/8]

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

Definition at line 804 of file equation_systems.h.

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

◆ get_vars_active_subdomains()

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

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

◆ has_system()

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

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

680 {
681  if (_systems.find(name) == _systems.end())
682  return false;
683  return true;
684 }
std::string name(const ElemQuality q)
std::map< std::string, System * > _systems
Data structure holding the systems.

◆ increment_constructor_count()

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 181 of file reference_counter.h.

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

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

182 {
183  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
184  std::pair<unsigned int, unsigned int> & p = _counts[name];
185 
186  p.first++;
187 }
std::string name(const ElemQuality q)
static Counts _counts
Actually holds the data.
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.

◆ increment_destructor_count()

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 194 of file reference_counter.h.

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

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

195 {
196  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
197  std::pair<unsigned int, unsigned int> & p = _counts[name];
198 
199  p.second++;
200 }
std::string name(const ElemQuality q)
static Counts _counts
Actually holds the data.
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.

◆ init()

virtual void libMesh::EquationSystems::init ( )
virtual

◆ n_active_dofs()

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

◆ n_dofs()

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

◆ n_objects()

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

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

Definition at line 83 of file reference_counter.h.

References libMesh::ReferenceCounter::_n_objects.

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

◆ n_processors()

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::MeshBase::partition().

94  { return cast_int<processor_id_type>(_communicator.size()); }
processor_id_type size() const
Definition: communicator.h:175
const Parallel::Communicator & _communicator

◆ n_systems()

unsigned int libMesh::EquationSystems::n_systems ( ) const
Returns
The number of equation systems.

Definition at line 637 of file equation_systems.h.

References _systems.

Referenced by add_system(), and get_system().

638 {
639  return cast_int<unsigned int>(_systems.size());
640 }
std::map< std::string, System * > _systems
Data structure holding the systems.

◆ n_vars()

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

◆ print_info() [1/2]

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

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

◆ print_info() [2/2]

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

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

◆ processor_id()

processor_id_type libMesh::ParallelObject::processor_id ( ) const
inherited

◆ read() [1/4]

template<typename InValType >
void libMesh::EquationSystems::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.

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!

◆ read() [2/4]

void libMesh::EquationSystems::read ( const std::string &  name,
const XdrMODE  mode,
const unsigned int  read_flags = (READ_HEADER | READ_DATA),
bool  partition_agnostic = true 
)

Definition at line 417 of file equation_systems.h.

References libMesh::Quality::name().

421  { read<Number>(name, mode, read_flags, partition_agnostic); }
std::string name(const ElemQuality q)

◆ read() [3/4]

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

◆ read() [4/4]

void libMesh::EquationSystems::read ( const std::string &  name,
const unsigned int  read_flags = (READ_HEADER | READ_DATA),
bool  partition_agnostic = true 
)

Definition at line 428 of file equation_systems.h.

References libMesh::Quality::name().

431  { read<Number>(name, read_flags, partition_agnostic); }
std::string name(const ElemQuality q)

◆ refine_in_reinit_flag()

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

Definition at line 524 of file equation_systems.h.

References _refine_in_reinit.

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

◆ reinit()

virtual void libMesh::EquationSystems::reinit ( )
virtual

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

◆ reinit_solutions()

bool libMesh::EquationSystems::reinit_solutions ( )

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

Returns
Whether or not the mesh may have changed.

◆ reinit_systems()

virtual void libMesh::EquationSystems::reinit_systems ( )
virtual

Reinitialize all systems on the current mesh.

◆ sensitivity_solve()

virtual 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.

◆ solve()

virtual 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.

◆ update()

void libMesh::EquationSystems::update ( )

Updates local values for all the systems.

◆ write() [1/2]

void libMesh::EquationSystems::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.

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!

◆ write() [2/2]

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

Friends And Related Function Documentation

◆ operator<<

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

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

Member Data Documentation

◆ _communicator

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

◆ _counts

Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited

◆ _enable_default_ghosting

bool libMesh::EquationSystems::_enable_default_ghosting
protected

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

Default value: true

Definition at line 578 of file equation_systems.h.

Referenced by add_system().

◆ _enable_print_counter

bool libMesh::ReferenceCounter::_enable_print_counter
staticprotectedinherited

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

Definition at line 141 of file reference_counter.h.

◆ _mesh

MeshBase& libMesh::EquationSystems::_mesh
protected

The mesh data structure.

Definition at line 551 of file equation_systems.h.

Referenced by get_mesh().

◆ _mutex

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

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 135 of file reference_counter.h.

◆ _n_objects

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

The number of objects.

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

Definition at line 130 of file reference_counter.h.

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

◆ _refine_in_reinit

bool libMesh::EquationSystems::_refine_in_reinit
protected

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

Default value: true

Definition at line 572 of file equation_systems.h.

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

◆ _systems

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

Data structure holding the systems.

Definition at line 556 of file equation_systems.h.

Referenced by add_system(), get_system(), has_system(), and n_systems().

◆ parameters

Parameters libMesh::EquationSystems::parameters

Data structure holding arbitrary parameters.

Definition at line 542 of file equation_systems.h.

Referenced by FETest< order, family, elem_type >::setUp(), and libMesh::WrappedFunction< Output >::WrappedFunction().


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