libMesh::EquationSystems Class Reference

Manages multiples systems of equations. More...

#include <equation_systems.h>

Inheritance diagram for libMesh::EquationSystems:

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
}
 
enum  WriteFlags { WRITE_DATA = 1, WRITE_ADDITIONAL_DATA = 2, WRITE_PARALLEL_FILES = 4, WRITE_SERIAL_FILES = 8 }
 

Public Member Functions

 EquationSystems (MeshBase &mesh)
 
virtual ~EquationSystems ()
 
virtual void clear ()
 
virtual void init ()
 
virtual void reinit ()
 
void update ()
 
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)
 
template<typename T_sys >
T_sys & add_system (const std::string &name)
 
void delete_system (const std::string &name)
 
unsigned int n_vars () const
 
std::size_t n_dofs () const
 
std::size_t n_active_dofs () const
 
virtual void solve ()
 
virtual void adjoint_solve (const QoISet &qoi_indices=QoISet())
 
virtual void sensitivity_solve (const ParameterVector &parameters)
 
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
 
void build_solution_vector (std::vector< Number > &soln, const std::string &system_name, const std::string &variable_name="all_vars") const
 
void build_solution_vector (std::vector< Number > &soln, const std::set< std::string > *system_names=libmesh_nullptr) const
 
std::unique_ptr< NumericVector< Number > > build_parallel_solution_vector (const std::set< std::string > *system_names=libmesh_nullptr) const
 
void get_solution (std::vector< Number > &soln, std::vector< std::string > &names) const
 
void build_discontinuous_solution_vector (std::vector< Number > &soln, const std::set< std::string > *system_names=libmesh_nullptr) const
 
template<typename InValType >
void read (const std::string &name, const XdrMODE, const unsigned int read_flags=(READ_HEADER|READ_DATA), bool partition_agnostic=true)
 
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
 
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
 
const MeshBaseget_mesh () const
 
MeshBaseget_mesh ()
 
void allgather ()
 
void enable_refine_in_reinit ()
 
void disable_refine_in_reinit ()
 
bool refine_in_reinit_flag ()
 
bool reinit_solutions ()
 
virtual void reinit_systems ()
 
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 ()
 
static void print_info (std::ostream &out=libMesh::out)
 
static unsigned int n_objects ()
 
static void enable_print_counter_info ()
 
static void disable_print_counter_info ()
 

Public Attributes

Parameters parameters
 

Protected Types

typedef std::map< std::string, System * >::iterator system_iterator
 
typedef std::map< std::string, System * >::const_iterator const_system_iterator
 
typedef std::map< std::string, std::pair< unsigned int, unsigned int > > Counts
 

Protected Member Functions

void increment_constructor_count (const std::string &name)
 
void increment_destructor_count (const std::string &name)
 

Protected Attributes

MeshBase_mesh
 
std::map< std::string, System * > _systems
 
bool _refine_in_reinit
 
const Parallel::Communicator_communicator
 

Static Protected Attributes

static Counts _counts
 
static Threads::atomic< unsigned int > _n_objects
 
static Threads::spin_mutex _mutex
 
static bool _enable_print_counter = true
 

Private Member Functions

template<typename InValType >
void _read_impl (const std::string &name, const XdrMODE, const unsigned int read_flags, bool partition_agnostic=true)
 
void _add_system_to_nodes_and_elems ()
 

Friends

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

Detailed Description

Manages multiples systems of equations.

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

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

Member Enumeration Documentation

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)
static const Real TOLERANCE
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
T & set(const std::string &)
Definition: parameters.h:465
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 }

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

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

Referenced by add_system().

1218 {
1219  // All the nodes
1220  for (auto & node : _mesh.node_ptr_range())
1221  node->add_system();
1222 
1223  // All the elements
1224  for (auto & elem : _mesh.element_ptr_range())
1225  elem->add_system();
1226 }
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(), 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(), 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)
Definition: elem_quality.C:39
MeshBase & mesh
virtual void fix_broken_node_and_element_numbering()=0
void read(const std::string &name, const XdrMODE, const unsigned int read_flags=(READ_HEADER|READ_DATA), bool partition_agnostic=true)
virtual System & add_system(const std::string &system_type, const std::string &name)
void broadcast(T &data, const unsigned int root_id=0) const
void globally_renumber_nodes_and_elements(MeshBase &)
Definition: mesh_tools.C:1963
const Parallel::Communicator & comm() const
const MeshBase & get_mesh() const
const T_sys & get_system(const std::string &name) const
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 332 of file equation_systems.C.

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

Referenced by _read_impl(), and libMesh::ErrorVector::plot_error().

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

Add the system named name to the systems array.

Definition at line 573 of file equation_systems.h.

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

574 {
575  T_sys * ptr = libmesh_nullptr;
576 
577  if (!_systems.count(name))
578  {
579  ptr = new T_sys(*this, name, this->n_systems());
580 
581  _systems.insert (std::make_pair(name, ptr));
582 
583  // Tell all the \p DofObject entities to add a system.
585  }
586  else
587  {
588  // We now allow redundant add_system calls, to make it
589  // easier to load data from files for user-derived system
590  // subclasses
591  ptr = &(this->get_system<T_sys>(name));
592  }
593 
594  // Return a dynamically casted reference to the newly added System.
595  return *ptr;
596 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
const class libmesh_nullptr_t libmesh_nullptr
unsigned int n_systems() const
std::map< std::string, System * > _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 453 of file equation_systems.C.

References get_system(), and n_systems().

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

454 {
455  libmesh_assert (this->n_systems());
456 
457  for (unsigned int i=this->n_systems(); i != 0; --i)
458  this->get_system(i-1).adjoint_solve(qoi_indices);
459 }
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 282 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(), and libMesh::System::reinit_constraints().

Referenced by read().

283 {
284  // A serial mesh means nothing needs to be done
285  if (_mesh.is_serial())
286  return;
287 
288  const unsigned int n_sys = this->n_systems();
289 
290  libmesh_assert_not_equal_to (n_sys, 0);
291 
292  // Gather the mesh
293  _mesh.allgather();
294 
295  // Tell all the \p DofObject entities how many systems
296  // there are.
297  for (auto & node : _mesh.node_ptr_range())
298  node->set_n_systems(n_sys);
299 
300  for (auto & elem : _mesh.element_ptr_range())
301  elem->set_n_systems(n_sys);
302 
303  // And distribute each system's dofs
304  for (unsigned int i=0; i != this->n_systems(); ++i)
305  {
306  System & sys = this->get_system(i);
307  DofMap & dof_map = sys.get_dof_map();
308  dof_map.distribute_dofs(_mesh);
309 
310  // The user probably won't need constraint equations or the
311  // send_list after an allgather, but let's keep it in consistent
312  // shape just in case.
313  sys.reinit_constraints();
314  dof_map.prepare_send_list();
315  }
316 }
virtual bool is_serial() const
Definition: mesh_base.h:141
virtual void allgather()
Definition: mesh_base.h:170
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 935 of file equation_systems.C.

References _mesh, _systems, libMesh::MeshBase::active_element_ptr_range(), libMesh::DofMap::dof_indices(), end, libMesh::System::get_dof_map(), 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().

937 {
938  LOG_SCOPE("build_discontinuous_solution_vector()", "EquationSystems");
939 
940  libmesh_assert (this->n_systems());
941 
942  const unsigned int dim = _mesh.mesh_dimension();
943 
944  // Get the number of variables (nv) by counting the number of variables
945  // in each system listed in system_names
946  unsigned int nv = 0;
947 
948  {
949  const_system_iterator pos = _systems.begin();
950  const const_system_iterator end = _systems.end();
951 
952  for (; pos != end; ++pos)
953  {
954  // Check current system is listed in system_names, and skip pos if not
955  bool use_current_system = (system_names == libmesh_nullptr);
956  if (!use_current_system)
957  use_current_system = system_names->count(pos->first);
958  if (!use_current_system)
959  continue;
960 
961  const System & system = *(pos->second);
962  nv += system.n_vars();
963  }
964  }
965 
966  unsigned int tw=0;
967 
968  // get the total weight
969  for (const auto & elem : _mesh.active_element_ptr_range())
970  tw += elem->n_nodes();
971 
972  // Only if we are on processor zero, allocate the storage
973  // to hold (number_of_nodes)*(number_of_variables) entries.
974  if (_mesh.processor_id() == 0)
975  soln.resize(tw*nv);
976 
977  std::vector<Number> sys_soln;
978 
979 
980  unsigned int var_num=0;
981 
982  // For each system in this EquationSystems object,
983  // update the global solution and if we are on processor 0,
984  // loop over the elements and build the nodal solution
985  // from the element solution. Then insert this nodal solution
986  // into the vector passed to build_solution_vector.
987  {
988  const_system_iterator pos = _systems.begin();
989  const const_system_iterator end = _systems.end();
990 
991  for (; pos != end; ++pos)
992  {
993  // Check current system is listed in system_names, and skip pos if not
994  bool use_current_system = (system_names == libmesh_nullptr);
995  if (!use_current_system)
996  use_current_system = system_names->count(pos->first);
997  if (!use_current_system)
998  continue;
999 
1000  const System & system = *(pos->second);
1001  const unsigned int nv_sys = system.n_vars();
1002 
1003  system.update_global_solution (sys_soln, 0);
1004 
1005  if (_mesh.processor_id() == 0)
1006  {
1007  std::vector<Number> elem_soln; // The finite element solution
1008  std::vector<Number> nodal_soln; // The FE solution interpolated to the nodes
1009  std::vector<dof_id_type> dof_indices; // The DOF indices for the finite element
1010 
1011  for (unsigned int var=0; var<nv_sys; var++)
1012  {
1013  const FEType & fe_type = system.variable_type(var);
1014 
1015  unsigned int nn=0;
1016 
1017  for (auto & elem : _mesh.active_element_ptr_range())
1018  {
1019  system.get_dof_map().dof_indices (elem, dof_indices, var);
1020 
1021  elem_soln.resize(dof_indices.size());
1022 
1023  for (std::size_t i=0; i<dof_indices.size(); i++)
1024  elem_soln[i] = sys_soln[dof_indices[i]];
1025 
1027  fe_type,
1028  elem,
1029  elem_soln,
1030  nodal_soln);
1031 
1032 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1033  // infinite elements should be skipped...
1034  if (!elem->infinite())
1035 #endif
1036  {
1037  libmesh_assert_equal_to (nodal_soln.size(), elem->n_nodes());
1038 
1039  for (unsigned int n=0; n<elem->n_nodes(); n++)
1040  {
1041  soln[nv*(nn++) + (var + var_num)] +=
1042  nodal_soln[n];
1043  }
1044  }
1045  }
1046  }
1047  }
1048 
1049  var_num += nv_sys;
1050  }
1051  }
1052 }
const class libmesh_nullptr_t libmesh_nullptr
IterBase * end
virtual SimpleRange< element_iterator > active_element_ptr_range()=0
std::map< std::string, System * >::const_iterator const_system_iterator
unsigned int n_systems() const
unsigned int mesh_dimension() const
Definition: mesh_base.C:150
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)
Definition: fe_interface.C:507
processor_id_type processor_id() const
std::map< std::string, System * > _systems
std::unique_ptr< 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 std::unique_ptr to a node-major NumericVector of total length n_nodes*n_vars that various I/O classes can then use to get the local values they need to write on each processor.

Definition at line 577 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, libMesh::DofMap::dof_indices(), end, libMesh::FEInterface::field_type(), libMesh::System::get_dof_map(), libMesh::NumericVector< T >::init(), 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().

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

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

568 {
569  // TODO:[BSK] re-implement this from the method below
570  libmesh_not_implemented();
571 }
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 775 of file equation_systems.C.

References build_parallel_solution_vector().

777 {
778  LOG_SCOPE("build_solution_vector()", "EquationSystems");
779 
780  // Call the parallel implementation
781  std::unique_ptr<NumericVector<Number>> parallel_soln =
782  this->build_parallel_solution_vector(system_names);
783 
784  // Localize the NumericVector into the provided std::vector.
785  parallel_soln->localize_to_one(soln);
786 }
std::unique_ptr< NumericVector< Number > > build_parallel_solution_vector(const std::set< std::string > *system_names=libmesh_nullptr) const
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 463 of file equation_systems.C.

References _systems, 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().

466 {
467  unsigned int var_num=0;
468 
469  const_system_iterator pos = _systems.begin();
470  const const_system_iterator end = _systems.end();
471 
472  // Need to size var_names by scalar variables plus all the
473  // vector components for all the vector variables
474  //Could this be replaced by a/some convenience methods?[PB]
475  {
476  unsigned int n_scalar_vars = 0;
477  unsigned int n_vector_vars = 0;
478 
479  for (; pos != end; ++pos)
480  {
481  // Check current system is listed in system_names, and skip pos if not
482  bool use_current_system = (system_names == libmesh_nullptr);
483  if (!use_current_system)
484  use_current_system = system_names->count(pos->first);
485  if (!use_current_system)
486  continue;
487 
488  for (unsigned int vn=0; vn<pos->second->n_vars(); vn++)
489  {
490  if (FEInterface::field_type(pos->second->variable_type(vn)) == TYPE_VECTOR)
491  n_vector_vars++;
492  else
493  n_scalar_vars++;
494  }
495  }
496 
497  // Here, we're assuming the number of vector components is the same
498  // as the mesh dimension. Will break for mixed dimension meshes.
499  unsigned int dim = this->get_mesh().mesh_dimension();
500  unsigned int nv = n_scalar_vars + dim*n_vector_vars;
501 
502  // We'd better not have more than dim*his->n_vars() (all vector variables)
503  libmesh_assert_less_equal ( nv, dim*this->n_vars() );
504 
505  // Here, we're assuming the number of vector components is the same
506  // as the mesh dimension. Will break for mixed dimension meshes.
507 
508  var_names.resize( nv );
509  }
510 
511  // reset
512  pos = _systems.begin();
513 
514  for (; pos != end; ++pos)
515  {
516  // Check current system is listed in system_names, and skip pos if not
517  bool use_current_system = (system_names == libmesh_nullptr);
518  if (!use_current_system)
519  use_current_system = system_names->count(pos->first);
520  if (!use_current_system)
521  continue;
522 
523  for (unsigned int vn=0; vn<pos->second->n_vars(); vn++)
524  {
525  std::string var_name = pos->second->variable_name(vn);
526  FEType fe_type = pos->second->variable_type(vn);
527 
528  unsigned int n_vec_dim = FEInterface::n_vec_dim( pos->second->get_mesh(), fe_type);
529 
530  // Filter on the type if requested
531  if (type == libmesh_nullptr || (type && *type == fe_type))
532  {
533  if (FEInterface::field_type(fe_type) == TYPE_VECTOR)
534  {
535  switch(n_vec_dim)
536  {
537  case 0:
538  case 1:
539  var_names[var_num++] = var_name;
540  break;
541  case 2:
542  var_names[var_num++] = var_name+"_x";
543  var_names[var_num++] = var_name+"_y";
544  break;
545  case 3:
546  var_names[var_num++] = var_name+"_x";
547  var_names[var_num++] = var_name+"_y";
548  var_names[var_num++] = var_name+"_z";
549  break;
550  default:
551  libmesh_error_msg("Invalid dim in build_variable_names");
552  }
553  }
554  else
555  var_names[var_num++] = var_name;
556  }
557  }
558  }
559  // Now resize again in case we filtered any names
560  var_names.resize(var_num);
561 }
static FEFieldType field_type(const FEType &fe_type)
const class libmesh_nullptr_t libmesh_nullptr
IterBase * end
std::map< std::string, System * >::const_iterator const_system_iterator
static unsigned int n_vec_dim(const MeshBase &mesh, const FEType &fe_type)
unsigned int mesh_dimension() const
Definition: mesh_base.C:150
unsigned int n_vars() const
const MeshBase & get_mesh() const
std::map< std::string, System * > _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, and parameters.

Referenced by ~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 }
const class libmesh_nullptr_t libmesh_nullptr
std::map< std::string, System * >::iterator system_iterator
virtual void clear()
Definition: parameters.h:317
std::map< std::string, System * > _systems
const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inlineinherited
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_jacobian(), libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_snes_fd_residual(), libMesh::__libmesh_petsc_snes_jacobian(), libMesh::__libmesh_petsc_snes_mffd_residual(), 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(), libMesh::ImplicitSystem::add_matrix(), libMesh::System::add_vector(), libMesh::EigenSparseLinearSolver< T >::adjoint_solve(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), 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::DistributedVector< T >::clone(), libMesh::EigenSparseVector< T >::clone(), libMesh::LaspackVector< T >::clone(), libMesh::EpetraVector< T >::clone(), libMesh::PetscVector< T >::clone(), libMesh::EpetraVector< T >::close(), libMesh::Parallel::Sort< KeyType, IdxType >::communicate_bins(), 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::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::EpetraVector< T >::EpetraVector(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), 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::CondensedEigenSystem::get_eigenpair(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), get_solution(), libMesh::LocationMap< T >::init(), libMesh::TopologyMap::init(), libMesh::TimeSolver::init(), libMesh::TaoOptimizationSolver< T >::init(), libMesh::PetscNonlinearSolver< T >::init(), libMesh::DistributedVector< T >::init(), libMesh::EpetraVector< T >::init(), libMesh::PetscVector< 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::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::libmesh_petsc_snes_residual_helper(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::limit_overrefined_boundary(), libMesh::MeshRefinement::limit_underrefined_boundary(), libMesh::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::DistributedVector< T >::max(), libMesh::FEMSystem::mesh_position_set(), libMesh::MeshSerializer::MeshSerializer(), libMesh::DistributedVector< T >::min(), 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(), 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::LinearPartitioner::partition_range(), 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(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), 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(), libMesh::CheckpointIO::select_split_config(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::PetscDiffSolver::setup_petsc_data(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::Parallel::Sort< KeyType, IdxType >::sort(), libMesh::split_mesh(), 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(), libMesh::MeshRefinement::test_unflagged(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::DistributedVector< T >::zero_clone(), libMesh::EigenSparseVector< T >::zero_clone(), libMesh::LaspackVector< T >::zero_clone(), libMesh::EpetraVector< T >::zero_clone(), and libMesh::PetscVector< T >::zero_clone().

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

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

Referenced by read().

1059 {
1060  // safety check, whether we handle at least the same number
1061  // of systems
1062  std::vector<bool> os_result;
1063 
1064  if (this->n_systems() != other_es.n_systems())
1065  {
1066  if (verbose)
1067  {
1068  libMesh::out << " Fatal difference. This system handles "
1069  << this->n_systems() << " systems," << std::endl
1070  << " while the other system handles "
1071  << other_es.n_systems()
1072  << " systems." << std::endl
1073  << " Aborting comparison." << std::endl;
1074  }
1075  return false;
1076  }
1077  else
1078  {
1079  // start comparing each system
1080  const_system_iterator pos = _systems.begin();
1081  const const_system_iterator end = _systems.end();
1082 
1083  for (; pos != end; ++pos)
1084  {
1085  const std::string & sys_name = pos->first;
1086  const System & system = *(pos->second);
1087 
1088  // get the other system
1089  const System & other_system = other_es.get_system (sys_name);
1090 
1091  os_result.push_back (system.compare (other_system, threshold, verbose));
1092 
1093  }
1094 
1095  }
1096 
1097 
1098  // sum up the results
1099  if (os_result.size()==0)
1100  return true;
1101  else
1102  {
1103  bool os_identical;
1104  unsigned int n = 0;
1105  do
1106  {
1107  os_identical = os_result[n];
1108  n++;
1109  }
1110  while (os_identical && n<os_result.size());
1111  return os_identical;
1112  }
1113 }
IterBase * end
std::map< std::string, System * >::const_iterator const_system_iterator
unsigned int n_systems() const
OStreamProxy out(std::cout)
std::map< std::string, System * > _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 418 of file equation_systems.C.

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

419 {
420  libmesh_deprecated();
421 
422  if (!_systems.count(name))
423  libmesh_error_msg("ERROR: no system named " << name);
424 
425  delete _systems[name];
426 
427  _systems.erase (name);
428 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
std::map< std::string, System * > _systems
void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited
void libMesh::EquationSystems::disable_refine_in_reinit ( )
inline

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

Definition at line 457 of file equation_systems.h.

References _refine_in_reinit.

457 { this->_refine_in_reinit = false; }
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 }
void libMesh::EquationSystems::enable_refine_in_reinit ( )
inline

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

Definition at line 452 of file equation_systems.h.

References _refine_in_reinit.

452 { this->_refine_in_reinit = true; }
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)
Definition: elem_quality.C:39
std::string libMesh::EquationSystems::get_info ( ) const
virtual
Returns
A string containing information about the systems, flags, and parameters.

Definition at line 1117 of file equation_systems.C.

References _systems, end, and n_systems().

Referenced by print_info(), and read().

1118 {
1119  std::ostringstream oss;
1120 
1121  oss << " EquationSystems\n"
1122  << " n_systems()=" << this->n_systems() << '\n';
1123 
1124  // Print the info for the individual systems
1125  const_system_iterator pos = _systems.begin();
1126  const const_system_iterator end = _systems.end();
1127 
1128  for (; pos != end; ++pos)
1129  oss << pos->second->get_info();
1130 
1131 
1132  // // Possibly print the parameters
1133  // if (!this->parameters.empty())
1134  // {
1135  // oss << " n_parameters()=" << this->n_parameters() << '\n';
1136  // oss << " Parameters:\n";
1137 
1138  // for (std::map<std::string, Real>::const_iterator
1139  // param = _parameters.begin(); param != _parameters.end();
1140  // ++param)
1141  // oss << " "
1142  // << "\""
1143  // << param->first
1144  // << "\""
1145  // << "="
1146  // << param->second
1147  // << '\n';
1148  // }
1149 
1150  return oss.str();
1151 }
IterBase * end
std::map< std::string, System * >::const_iterator const_system_iterator
unsigned int n_systems() const
std::map< std::string, System * > _systems
const MeshBase & libMesh::EquationSystems::get_mesh ( ) const
inline
MeshBase & libMesh::EquationSystems::get_mesh ( )
inline
Returns
A reference to the mesh

Definition at line 556 of file equation_systems.h.

References _mesh.

557 {
558  return _mesh;
559 }
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 790 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::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().

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

References _systems.

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), _read_impl(), libMesh::EnsightIO::add_scalar(), add_system(), libMesh::EnsightIO::add_vector(), adjoint_solve(), allgather(), libMesh::ExactSolution::attach_exact_deriv(), libMesh::ExactSolution::attach_exact_hessian(), libMesh::ExactSolution::attach_exact_value(), compare(), libMesh::ExactSolution::compute_error(), libMesh::GMVIO::copy_nodal_solution(), libMesh::ExactSolution::error_norm(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::ErrorEstimator::estimate_errors(), libMesh::ExactSolution::ExactSolution(), init(), reinit_solutions(), reinit_systems(), sensitivity_solve(), solve(), update(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().

665 {
666  const_system_iterator pos = _systems.find(name);
667 
668  // Check for errors
669  if (pos == _systems.end())
670  libmesh_error_msg("ERROR: no system named \"" << name << "\" found!");
671 
672  // Attempt dynamic cast
673  return *cast_ptr<T_sys *>(pos->second);
674 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
std::map< std::string, System * >::const_iterator const_system_iterator
std::map< std::string, System * > _systems
template<typename T_sys >
T_sys & libMesh::EquationSystems::get_system ( const std::string &  name)
inline
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 683 of file equation_systems.h.

References _systems.

684 {
685  system_iterator pos = _systems.find(name);
686 
687  // Check for errors
688  if (pos == _systems.end())
689  libmesh_error_msg("ERROR: no system named " << name << " found!");
690 
691  // Attempt dynamic cast
692  return *cast_ptr<T_sys *>(pos->second);
693 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
std::map< std::string, System * >::iterator system_iterator
std::map< std::string, System * > _systems
template<typename T_sys >
const T_sys & libMesh::EquationSystems::get_system ( const unsigned int  num) const
inline
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 613 of file equation_systems.h.

References _systems, end, and n_systems().

614 {
615  libmesh_assert_less (num, this->n_systems());
616 
617 
618  const_system_iterator pos = _systems.begin();
619  const const_system_iterator end = _systems.end();
620 
621  for (; pos != end; ++pos)
622  if (pos->second->number() == num)
623  break;
624 
625  // Check for errors
626  if (pos == end)
627  libmesh_error_msg("ERROR: no system number " << num << " found!");
628 
629  // Attempt dynamic cast
630  return *cast_ptr<T_sys *>(pos->second);
631 }
IterBase * end
std::map< std::string, System * >::const_iterator const_system_iterator
unsigned int n_systems() const
std::map< std::string, System * > _systems
template<typename T_sys >
T_sys & libMesh::EquationSystems::get_system ( const unsigned int  num)
inline
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 638 of file equation_systems.h.

References _systems, end, and n_systems().

639 {
640  libmesh_assert_less (num, this->n_systems());
641 
642  const_system_iterator pos = _systems.begin();
643  const const_system_iterator end = _systems.end();
644 
645  for (; pos != end; ++pos)
646  if (pos->second->number() == num)
647  break;
648 
649  // Check for errors
650  if (pos == end)
651  libmesh_error_msg("ERROR: no system number " << num << " found!");
652 
653  // Attempt dynamic cast
654  return *cast_ptr<T_sys *>(pos->second);
655 }
IterBase * end
std::map< std::string, System * >::const_iterator const_system_iterator
unsigned int n_systems() const
std::map< std::string, System * > _systems
const System & libMesh::EquationSystems::get_system ( const std::string &  name) const
inline
Returns
A constant reference to the system named name.

Definition at line 702 of file equation_systems.h.

References libMesh::Quality::name().

703 {
704  return this->get_system<System>(name);
705 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
System & libMesh::EquationSystems::get_system ( const std::string &  name)
inline
Returns
A writable reference to the system named name.

Definition at line 710 of file equation_systems.h.

References libMesh::Quality::name().

711 {
712  return this->get_system<System>(name);
713 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
const System & libMesh::EquationSystems::get_system ( const unsigned int  num) const
inline
Returns
A constant reference to system number num.

Definition at line 718 of file equation_systems.h.

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

Definition at line 726 of file equation_systems.h.

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

Definition at line 601 of file equation_systems.h.

References _systems.

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

602 {
603  if (_systems.find(name) == _systems.end())
604  return false;
605  return true;
606 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
std::map< std::string, System * > _systems
void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name)
inlineprotectedinherited

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)
Definition: elem_quality.C:39
spin_mutex spin_mtx
Definition: threads.C:29
void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name)
inlineprotectedinherited

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)
Definition: elem_quality.C:39
spin_mutex spin_mtx
Definition: threads.C:29
void libMesh::EquationSystems::init ( )
virtual

Initialize all the systems

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(), and libMesh::ErrorVector::plot_error().

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

References _systems, and end.

1204 {
1205  std::size_t tot=0;
1206 
1207  const_system_iterator pos = _systems.begin();
1208  const const_system_iterator end = _systems.end();
1209 
1210  for (; pos != end; ++pos)
1211  tot += pos->second->n_active_dofs();
1212 
1213  return tot;
1214 }
IterBase * end
std::map< std::string, System * >::const_iterator const_system_iterator
std::map< std::string, System * > _systems
std::size_t libMesh::EquationSystems::n_dofs ( ) const
Returns
The total number of degrees of freedom in all systems.

Definition at line 1187 of file equation_systems.C.

References _systems, and end.

1188 {
1189  std::size_t tot=0;
1190 
1191  const_system_iterator pos = _systems.begin();
1192  const const_system_iterator end = _systems.end();
1193 
1194  for (; pos != end; ++pos)
1195  tot += pos->second->n_dofs();
1196 
1197  return tot;
1198 }
IterBase * end
std::map< std::string, System * >::const_iterator const_system_iterator
std::map< std::string, System * > _systems
static unsigned int libMesh::ReferenceCounter::n_objects ( )
inlinestaticinherited
processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
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::DistributedVector< T >::init(), 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(), 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:725
const Parallel::Communicator & _communicator
unsigned int libMesh::EquationSystems::n_vars ( ) const
Returns
The total number of variables in all systems.

Definition at line 1172 of file equation_systems.C.

References _systems, and end.

Referenced by build_variable_names().

1173 {
1174  unsigned int tot=0;
1175 
1176  const_system_iterator pos = _systems.begin();
1177  const const_system_iterator end = _systems.end();
1178 
1179  for (; pos != end; ++pos)
1180  tot += pos->second->n_vars();
1181 
1182  return tot;
1183 }
IterBase * end
std::map< std::string, System * >::const_iterator const_system_iterator
std::map< std::string, System * > _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()
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 1155 of file equation_systems.C.

References get_info().

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

1156 {
1157  os << this->get_info()
1158  << std::endl;
1159 }
virtual std::string get_info() const
processor_id_type libMesh::ParallelObject::processor_id ( ) const
inlineinherited
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::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::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::DistributedVector< T >::init(), libMesh::SystemSubsetBySubdomain::init(), 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::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(), libMesh::MeshRefinement::make_coarsening_compatible(), 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::XdrIO::read(), libMesh::CheckpointIO::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_global_values(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::ExodusII_IO_Helper::read_node_num_map(), 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::CheckpointIO::select_split_config(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), 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::MeshTools::weight(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::CheckpointIO::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::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(), libMesh::ExodusII_IO_Helper::write_timestep(), and libMesh::ExodusII_IO::write_timestep_discontinuous().

100  { return cast_int<processor_id_type>(_communicator.rank()); }
const Parallel::Communicator & _communicator
unsigned int rank() const
Definition: parallel.h:723
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(), and read().

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)
Definition: elem_quality.C:39
OStreamProxy out(std::cout)
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 
)
inline

Definition at line 355 of file equation_systems.h.

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

359  { read<Number>(name, mode, read_flags, partition_agnostic); }
std::string name(const ElemQuality 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)
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)
template void libMesh::EquationSystems::read< Real > ( const std::string &  name,
const unsigned int  read_flags = (READ_HEADER|READ_DATA),
bool  partition_agnostic = true 
)
inline

Definition at line 366 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.

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

Definition at line 462 of file equation_systems.h.

References _refine_in_reinit, reinit_solutions(), and reinit_systems().

462 { return this->_refine_in_reinit; }
void libMesh::EquationSystems::reinit ( )
virtual

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

Definition at line 119 of file equation_systems.C.

References reinit_solutions(), and reinit_systems().

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), and libMesh::AdjointRefinementEstimator::estimate_error().

120 {
121  const bool mesh_changed = this->reinit_solutions();
122 
123  // If the mesh has changed, systems will need to reinitialize their
124  // own data on the new mesh.
125  if (mesh_changed)
126  this->reinit_systems();
127 }
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.

Definition at line 131 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(), and libMesh::MeshRefinement::underrefined_boundary_limit().

Referenced by refine_in_reinit_flag(), and reinit().

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

Reinitialize all systems on the current mesh.

Definition at line 274 of file equation_systems.C.

References get_system(), and n_systems().

Referenced by refine_in_reinit_flag(), and reinit().

275 {
276  for (unsigned int i=0; i != this->n_systems(); ++i)
277  this->get_system(i).reinit();
278 }
unsigned int n_systems() 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 443 of file equation_systems.C.

References get_system(), and n_systems().

444 {
445  libmesh_assert (this->n_systems());
446 
447  for (unsigned int i=0; i != this->n_systems(); ++i)
448  this->get_system(i).sensitivity_solve(parameters_in);
449 }
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 433 of file equation_systems.C.

References get_system(), and n_systems().

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

434 {
435  libmesh_assert (this->n_systems());
436 
437  for (unsigned int i=0; i != this->n_systems(); ++i)
438  this->get_system(i).solve();
439 }
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 321 of file equation_systems.C.

References get_system(), and n_systems().

Referenced by _read_impl().

322 {
323  LOG_SCOPE("update()", "EquationSystems");
324 
325  // Localize each system's vectors
326  for (unsigned int i=0; i != this->n_systems(); ++i)
327  this->get_system(i).update();
328 }
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(), 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 libMesh::ErrorVector::plot_error(), read(), write(), and libMesh::NameBasedIO::write_equation_systems().

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)
Definition: elem_quality.C:39
MeshBase & mesh
std::string get_io_compatibility_version()
void globally_renumber_nodes_and_elements(MeshBase &)
Definition: mesh_tools.C:1963
const MeshBase & get_mesh() const
processor_id_type processor_id() const
std::map< std::string, System * > _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)
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

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

Referenced by read().

1165 {
1166  es.print_info(os);
1167  return os;
1168 }

Member Data Documentation

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

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

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

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

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