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
 
UniquePtr< 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 ()
 
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 489 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 484 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:469
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 1334 of file equation_systems.C.

References _mesh, libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::MeshBase::nodes_begin(), and libMesh::MeshBase::nodes_end().

Referenced by add_system().

1335 {
1336  // All the nodes
1337  MeshBase::node_iterator node_it = _mesh.nodes_begin();
1338  const MeshBase::node_iterator node_end = _mesh.nodes_end();
1339 
1340  for ( ; node_it != node_end; ++node_it)
1341  (*node_it)->add_system();
1342 
1343  // All the elements
1344  MeshBase::element_iterator elem_it = _mesh.elements_begin();
1345  const MeshBase::element_iterator elem_end = _mesh.elements_end();
1346 
1347  for ( ; elem_it != elem_end; ++elem_it)
1348  (*elem_it)->add_system();
1349 }
virtual node_iterator nodes_begin()=0
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
virtual node_iterator nodes_end()=0
template<typename InValType >
template void libMesh::EquationSystems::_read_impl< Real > ( const std::string &  name,
const XdrMODE  ,
const unsigned int  read_flags,
bool  partition_agnostic = true 
)
private

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

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

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

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

for each system

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

handled through System::read():

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

end system loop


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

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

end system loop

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

Definition at line 143 of file equation_systems_io.C.

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

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

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

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

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

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

559 {
560  T_sys * ptr = libmesh_nullptr;
561 
562  if (!_systems.count(name))
563  {
564  ptr = new T_sys(*this, name, this->n_systems());
565 
566  _systems.insert (std::make_pair(name, ptr));
567 
568  // Tell all the \p DofObject entities to add a system.
570  }
571  else
572  {
573  // We now allow redundant add_system calls, to make it
574  // easier to load data from files for user-derived system
575  // subclasses
576  ptr = &(this->get_system<T_sys>(name));
577  }
578 
579  // Return a dynamically casted reference to the newly added System.
580  return *ptr;
581 }
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 468 of file equation_systems.C.

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

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

469 {
470  libmesh_assert (this->n_systems());
471 
472  for (unsigned int i=this->n_systems(); i != 0; --i)
473  this->get_system(i-1).adjoint_solve(qoi_indices);
474 }
libmesh_assert(j)
unsigned int n_systems() const
const T_sys & get_system(const std::string &name) const
void libMesh::EquationSystems::allgather ( )

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

Definition at line 291 of file equation_systems.C.

References _mesh, libMesh::MeshBase::allgather(), libMesh::DofMap::distribute_dofs(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::System::get_dof_map(), get_system(), libMesh::MeshBase::is_serial(), n_systems(), libMesh::MeshBase::nodes_begin(), libMesh::MeshBase::nodes_end(), libMesh::DofMap::prepare_send_list(), libMesh::System::reinit_constraints(), and libMesh::sys.

Referenced by read().

292 {
293  // A serial mesh means nothing needs to be done
294  if (_mesh.is_serial())
295  return;
296 
297  const unsigned int n_sys = this->n_systems();
298 
299  libmesh_assert_not_equal_to (n_sys, 0);
300 
301  // Gather the mesh
302  _mesh.allgather();
303 
304  // Tell all the \p DofObject entities how many systems
305  // there are.
306  {
307  MeshBase::node_iterator node_it = _mesh.nodes_begin();
308  const MeshBase::node_iterator node_end = _mesh.nodes_end();
309 
310  for ( ; node_it != node_end; ++node_it)
311  (*node_it)->set_n_systems(n_sys);
312 
313  MeshBase::element_iterator elem_it = _mesh.elements_begin();
314  const MeshBase::element_iterator elem_end = _mesh.elements_end();
315 
316  for ( ; elem_it != elem_end; ++elem_it)
317  (*elem_it)->set_n_systems(n_sys);
318  }
319 
320  // And distribute each system's dofs
321  for (unsigned int i=0; i != this->n_systems(); ++i)
322  {
323  System & sys = this->get_system(i);
324  DofMap & dof_map = sys.get_dof_map();
325  dof_map.distribute_dofs(_mesh);
326 
327  // The user probably won't need constraint equations or the
328  // send_list after an allgather, but let's keep it in consistent
329  // shape just in case.
330  sys.reinit_constraints();
331  dof_map.prepare_send_list();
332  }
333 }
virtual bool is_serial() const
Definition: mesh_base.h:137
ImplicitSystem & sys
virtual void allgather()
Definition: mesh_base.h:166
virtual node_iterator nodes_begin()=0
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
unsigned int n_systems() const
virtual node_iterator nodes_end()=0
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 1042 of file equation_systems.C.

References _mesh, _systems, libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), libMesh::DofMap::dof_indices(), end, libMesh::System::get_dof_map(), libMesh::Elem::infinite(), libMesh::libmesh_assert(), libmesh_nullptr, libMesh::MeshBase::mesh_dimension(), libMesh::Elem::n_nodes(), 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().

1044 {
1045  LOG_SCOPE("build_discontinuous_solution_vector()", "EquationSystems");
1046 
1047  libmesh_assert (this->n_systems());
1048 
1049  const unsigned int dim = _mesh.mesh_dimension();
1050 
1051  // Get the number of variables (nv) by counting the number of variables
1052  // in each system listed in system_names
1053  unsigned int nv = 0;
1054 
1055  {
1056  const_system_iterator pos = _systems.begin();
1057  const const_system_iterator end = _systems.end();
1058 
1059  for (; pos != end; ++pos)
1060  {
1061  // Check current system is listed in system_names, and skip pos if not
1062  bool use_current_system = (system_names == libmesh_nullptr);
1063  if (!use_current_system)
1064  use_current_system = system_names->count(pos->first);
1065  if (!use_current_system)
1066  continue;
1067 
1068  const System & system = *(pos->second);
1069  nv += system.n_vars();
1070  }
1071  }
1072 
1073  unsigned int tw=0;
1074 
1075  // get the total weight
1076  {
1077  MeshBase::element_iterator it = _mesh.active_elements_begin();
1078  const MeshBase::element_iterator end = _mesh.active_elements_end();
1079 
1080  for ( ; it != end; ++it)
1081  tw += (*it)->n_nodes();
1082  }
1083 
1084 
1085  // Only if we are on processor zero, allocate the storage
1086  // to hold (number_of_nodes)*(number_of_variables) entries.
1087  if (_mesh.processor_id() == 0)
1088  soln.resize(tw*nv);
1089 
1090  std::vector<Number> sys_soln;
1091 
1092 
1093  unsigned int var_num=0;
1094 
1095  // For each system in this EquationSystems object,
1096  // update the global solution and if we are on processor 0,
1097  // loop over the elements and build the nodal solution
1098  // from the element solution. Then insert this nodal solution
1099  // into the vector passed to build_solution_vector.
1100  {
1101  const_system_iterator pos = _systems.begin();
1102  const const_system_iterator end = _systems.end();
1103 
1104  for (; pos != end; ++pos)
1105  {
1106  // Check current system is listed in system_names, and skip pos if not
1107  bool use_current_system = (system_names == libmesh_nullptr);
1108  if (!use_current_system)
1109  use_current_system = system_names->count(pos->first);
1110  if (!use_current_system)
1111  continue;
1112 
1113  const System & system = *(pos->second);
1114  const unsigned int nv_sys = system.n_vars();
1115 
1116  system.update_global_solution (sys_soln, 0);
1117 
1118  if (_mesh.processor_id() == 0)
1119  {
1120  std::vector<Number> elem_soln; // The finite element solution
1121  std::vector<Number> nodal_soln; // The FE solution interpolated to the nodes
1122  std::vector<dof_id_type> dof_indices; // The DOF indices for the finite element
1123 
1124  for (unsigned int var=0; var<nv_sys; var++)
1125  {
1126  const FEType & fe_type = system.variable_type(var);
1127 
1128  MeshBase::element_iterator it = _mesh.active_elements_begin();
1129  const MeshBase::element_iterator end_elem = _mesh.active_elements_end();
1130 
1131  unsigned int nn=0;
1132 
1133  for ( ; it != end_elem; ++it)
1134  {
1135  const Elem * elem = *it;
1136  system.get_dof_map().dof_indices (elem, dof_indices, var);
1137 
1138  elem_soln.resize(dof_indices.size());
1139 
1140  for (std::size_t i=0; i<dof_indices.size(); i++)
1141  elem_soln[i] = sys_soln[dof_indices[i]];
1142 
1144  fe_type,
1145  elem,
1146  elem_soln,
1147  nodal_soln);
1148 
1149 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1150  // infinite elements should be skipped...
1151  if (!elem->infinite())
1152 #endif
1153  {
1154  libmesh_assert_equal_to (nodal_soln.size(), elem->n_nodes());
1155 
1156  for (unsigned int n=0; n<elem->n_nodes(); n++)
1157  {
1158  soln[nv*(nn++) + (var + var_num)] +=
1159  nodal_soln[n];
1160  }
1161  }
1162  }
1163  }
1164  }
1165 
1166  var_num += nv_sys;
1167  }
1168  }
1169 }
const class libmesh_nullptr_t libmesh_nullptr
IterBase * end
libmesh_assert(j)
std::map< std::string, System * >::const_iterator const_system_iterator
virtual element_iterator active_elements_begin()=0
unsigned int n_systems() const
virtual element_iterator active_elements_end()=0
unsigned int mesh_dimension() const
Definition: mesh_base.C:147
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:513
processor_id_type processor_id() const
std::map< std::string, System * > _systems
UniquePtr< NumericVector< Number > > libMesh::EquationSystems::build_parallel_solution_vector ( const std::set< std::string > *  system_names = libmesh_nullptr) const

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

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

Definition at line 668 of file equation_systems.C.

References libMesh::ParallelObject::_communicator, _mesh, _systems, libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), 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::Elem::infinite(), libMesh::NumericVector< T >::init(), libMesh::libmesh_assert(), libmesh_nullptr, libMesh::MeshBase::local_nodes_begin(), libMesh::MeshBase::local_nodes_end(), libMesh::MeshBase::max_node_id(), libMesh::MeshBase::mesh_dimension(), libMesh::DofObject::n_dofs(), libMesh::MeshBase::n_nodes(), libMesh::Elem::n_nodes(), libMesh::System::n_vars(), libMesh::FEInterface::n_vec_dim(), libMesh::FEInterface::nodal_soln(), libMesh::Elem::node_id(), libMesh::Elem::node_ptr(), 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().

669 {
670  LOG_SCOPE("build_parallel_solution_vector()", "EquationSystems");
671 
672  // This function must be run on all processors at once
673  parallel_object_only();
674 
675  const unsigned int dim = _mesh.mesh_dimension();
676  const dof_id_type nn = _mesh.n_nodes();
677 
678  // We'd better have a contiguous node numbering
679  libmesh_assert_equal_to (nn, _mesh.max_node_id());
680 
681  // allocate storage to hold
682  // (number_of_nodes)*(number_of_variables) entries.
683  // We have to differentiate between between scalar and vector
684  // variables. We intercept vector variables and treat each
685  // component as a scalar variable (consistently with build_solution_names).
686 
687  unsigned int nv = 0;
688 
689  //Could this be replaced by a/some convenience methods?[PB]
690  {
691  unsigned int n_scalar_vars = 0;
692  unsigned int n_vector_vars = 0;
693  const_system_iterator pos = _systems.begin();
694  const const_system_iterator end = _systems.end();
695 
696  for (; pos != end; ++pos)
697  {
698  // Check current system is listed in system_names, and skip pos if not
699  bool use_current_system = (system_names == libmesh_nullptr);
700  if (!use_current_system)
701  use_current_system = system_names->count(pos->first);
702  if (!use_current_system)
703  continue;
704 
705  for (unsigned int vn=0; vn<pos->second->n_vars(); vn++)
706  {
707  if (FEInterface::field_type(pos->second->variable_type(vn)) == TYPE_VECTOR)
708  n_vector_vars++;
709  else
710  n_scalar_vars++;
711  }
712  }
713  // Here, we're assuming the number of vector components is the same
714  // as the mesh dimension. Will break for mixed dimension meshes.
715  nv = n_scalar_vars + dim*n_vector_vars;
716  }
717 
718  // Get the number of elements that share each node. We will
719  // compute the average value at each node. This is particularly
720  // useful for plotting discontinuous data.
721  MeshBase::element_iterator e_it = _mesh.active_local_elements_begin();
722  const MeshBase::element_iterator e_end = _mesh.active_local_elements_end();
723 
724  // Get the number of local nodes
725  dof_id_type n_local_nodes = cast_int<dof_id_type>
726  (std::distance(_mesh.local_nodes_begin(),
728 
729  // Create a NumericVector to hold the parallel solution
730  UniquePtr<NumericVector<Number> > parallel_soln_ptr = NumericVector<Number>::build(_communicator);
731  NumericVector<Number> & parallel_soln = *parallel_soln_ptr;
732  parallel_soln.init(nn*nv, n_local_nodes*nv, false, PARALLEL);
733 
734  // Create a NumericVector to hold the "repeat_count" for each node - this is essentially
735  // the number of elements contributing to that node's value
736  UniquePtr<NumericVector<Number> > repeat_count_ptr = NumericVector<Number>::build(_communicator);
737  NumericVector<Number> & repeat_count = *repeat_count_ptr;
738  repeat_count.init(nn*nv, n_local_nodes*nv, false, PARALLEL);
739 
740  repeat_count.close();
741 
742  unsigned int var_num=0;
743 
744  // For each system in this EquationSystems object,
745  // update the global solution and if we are on processor 0,
746  // loop over the elements and build the nodal solution
747  // from the element solution. Then insert this nodal solution
748  // into the vector passed to build_solution_vector.
749  const_system_iterator pos = _systems.begin();
750  const const_system_iterator end = _systems.end();
751 
752  for (; pos != end; ++pos)
753  {
754  // Check current system is listed in system_names, and skip pos if not
755  bool use_current_system = (system_names == libmesh_nullptr);
756  if (!use_current_system)
757  use_current_system = system_names->count(pos->first);
758  if (!use_current_system)
759  continue;
760 
761  const System & system = *(pos->second);
762  const unsigned int nv_sys = system.n_vars();
763  const unsigned int sys_num = system.number();
764 
765  //Could this be replaced by a/some convenience methods?[PB]
766  unsigned int n_scalar_vars = 0;
767  unsigned int n_vector_vars = 0;
768  for (unsigned int vn=0; vn<pos->second->n_vars(); vn++)
769  {
770  if (FEInterface::field_type(pos->second->variable_type(vn)) == TYPE_VECTOR)
771  n_vector_vars++;
772  else
773  n_scalar_vars++;
774  }
775 
776  // Here, we're assuming the number of vector components is the same
777  // as the mesh dimension. Will break for mixed dimension meshes.
778  unsigned int nv_sys_split = n_scalar_vars + dim*n_vector_vars;
779 
780  // Update the current_local_solution
781  {
782  System & non_const_sys = const_cast<System &>(system);
783  // We used to simply call non_const_sys.solution->close()
784  // here, but that is not allowed when the solution vector is
785  // locked read-only, for example when printing the solution
786  // during the middle of a solve... So try to be a bit
787  // more careful about calling close() unnecessarily.
788  libmesh_assert(this->comm().verify(non_const_sys.solution->closed()));
789  if (!non_const_sys.solution->closed())
790  non_const_sys.solution->close();
791  non_const_sys.update();
792  }
793 
794  NumericVector<Number> & sys_soln(*system.current_local_solution);
795 
796  std::vector<Number> elem_soln; // The finite element solution
797  std::vector<Number> nodal_soln; // The FE solution interpolated to the nodes
798  std::vector<dof_id_type> dof_indices; // The DOF indices for the finite element
799 
800  for (unsigned int var=0; var<nv_sys; var++)
801  {
802  const FEType & fe_type = system.variable_type(var);
803  const Variable & var_description = system.variable(var);
804  const DofMap & dof_map = system.get_dof_map();
805 
806  unsigned int n_vec_dim = FEInterface::n_vec_dim( pos->second->get_mesh(), fe_type );
807 
808  MeshBase::element_iterator it = _mesh.active_local_elements_begin();
809  const MeshBase::element_iterator end_elem = _mesh.active_local_elements_end();
810 
811  for ( ; it != end_elem; ++it)
812  {
813  const Elem * elem = *it;
814 
815  if (var_description.active_on_subdomain((*it)->subdomain_id()))
816  {
817  dof_map.dof_indices (elem, dof_indices, var);
818 
819  elem_soln.resize(dof_indices.size());
820 
821  for (std::size_t i=0; i<dof_indices.size(); i++)
822  elem_soln[i] = sys_soln(dof_indices[i]);
823 
825  fe_type,
826  elem,
827  elem_soln,
828  nodal_soln);
829 
830 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
831  // infinite elements should be skipped...
832  if (!elem->infinite())
833 #endif
834  {
835  libmesh_assert_equal_to (nodal_soln.size(), n_vec_dim*elem->n_nodes());
836 
837  for (unsigned int n=0; n<elem->n_nodes(); n++)
838  {
839  for (unsigned int d=0; d < n_vec_dim; d++)
840  {
841  // For vector-valued elements, all components are in nodal_soln. For each
842  // node, the components are stored in order, i.e. node_0 -> s0_x, s0_y, s0_z
843  parallel_soln.add(nv*(elem->node_id(n)) + (var+d + var_num), nodal_soln[n_vec_dim*n+d]);
844 
845  // Increment the repeat count for this position
846  repeat_count.add(nv*(elem->node_id(n)) + (var+d + var_num), 1);
847  }
848  }
849  }
850  }
851  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:
852  for (unsigned int n=0; n<elem->n_nodes(); n++)
853  // Only do this if this variable has NO DoFs at this node... it might have some from an adjoining element...
854  if (!elem->node_ptr(n)->n_dofs(sys_num, var))
855  for (unsigned int d=0; d < n_vec_dim; d++)
856  repeat_count.add(nv*(elem->node_id(n)) + (var+d + var_num), 1);
857 
858  } // end loop over elements
859  } // end loop on variables in this system
860 
861  var_num += nv_sys_split;
862  } // end loop over systems
863 
864  parallel_soln.close();
865  repeat_count.close();
866 
867  // Divide to get the average value at the nodes
868  parallel_soln /= repeat_count;
869 
870  return UniquePtr<NumericVector<Number> >(parallel_soln_ptr.release());
871 }
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
libmesh_assert(j)
static UniquePtr< NumericVector< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
std::map< std::string, System * >::const_iterator const_system_iterator
virtual node_iterator local_nodes_end()=0
virtual element_iterator active_local_elements_begin()=0
static unsigned int n_vec_dim(const MeshBase &mesh, const FEType &fe_type)
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:147
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:513
virtual dof_id_type n_nodes() const =0
virtual element_iterator active_local_elements_end()=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 580 of file equation_systems.C.

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

583 {
584  //TODO:[BSK] re-implement this from the method below
585  libmesh_not_implemented();
586 
587  // // Get a reference to the named system
588  // const System & system = this->get_system(system_name);
589 
590  // // Get the number associated with the variable_name we are passed
591  // const unsigned short int variable_num = system.variable_number(variable_name);
592 
593  // // Get the dimension of the current mesh
594  // const unsigned int dim = _mesh.mesh_dimension();
595 
596  // // If we're on processor 0, allocate enough memory to hold the solution.
597  // // Since we're only looking at one variable, there will be one solution value
598  // // for each node in the mesh.
599  // if (_mesh.processor_id() == 0)
600  // soln.resize(_mesh.n_nodes());
601 
602  // // Vector to hold the global solution from all processors
603  // std::vector<Number> sys_soln;
604 
605  // // Update the global solution from all processors
606  // system.update_global_solution (sys_soln, 0);
607 
608  // // Temporary vector to store the solution on an individual element.
609  // std::vector<Number> elem_soln;
610 
611  // // The FE solution interpolated to the nodes
612  // std::vector<Number> nodal_soln;
613 
614  // // The DOF indices for the element
615  // std::vector<dof_id_type> dof_indices;
616 
617  // // Determine the finite/infinite element type used in this system
618  // const FEType & fe_type = system.variable_type(variable_num);
619 
620  // // Define iterators to iterate over all the elements of the mesh
621  // const_active_elem_iterator it (_mesh.elements_begin());
622  // const const_active_elem_iterator end(_mesh.elements_end());
623 
624  // // Loop over elements
625  // for ( ; it != end; ++it)
626  // {
627  // // Convenient shortcut to the element pointer
628  // const Elem * elem = *it;
629 
630  // // Fill the dof_indices vector for this variable
631  // system.get_dof_map().dof_indices(elem,
632  // dof_indices,
633  // variable_num);
634 
635  // // Resize the element solution vector to fit the
636  // // dof_indices for this element.
637  // elem_soln.resize(dof_indices.size());
638 
639  // // Transfer the system solution to the element
640  // // solution by mapping it through the dof_indices vector.
641  // for (std::size_t i=0; i<dof_indices.size(); i++)
642  // elem_soln[i] = sys_soln[dof_indices[i]];
643 
644  // // Using the FE interface, compute the nodal_soln
645  // // for the current element type given the elem_soln
646  // FEInterface::nodal_soln (dim,
647  // fe_type,
648  // elem,
649  // elem_soln,
650  // nodal_soln);
651 
652  // // Sanity check -- make sure that there are the same number
653  // // of entries in the nodal_soln as there are nodes in the
654  // // element!
655  // libmesh_assert_equal_to (nodal_soln.size(), elem->n_nodes());
656 
657  // // Copy the nodal solution over into the correct place in
658  // // the global soln vector which will be returned to the user.
659  // for (unsigned int n=0; n<elem->n_nodes(); n++)
660  // soln[elem->node_id(n)] = nodal_soln[n];
661  // }
662 }
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 875 of file equation_systems.C.

References build_parallel_solution_vector().

877 {
878  LOG_SCOPE("build_solution_vector()", "EquationSystems");
879 
880  // Call the parallel implementation
881  UniquePtr<NumericVector<Number> > parallel_soln =
882  this->build_parallel_solution_vector(system_names);
883 
884  // Localize the NumericVector into the provided std::vector.
885  parallel_soln->localize_to_one(soln);
886 }
UniquePtr< 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 478 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().

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

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 }
ImplicitSystem & sys
const class libmesh_nullptr_t libmesh_nullptr
std::map< std::string, System * >::iterator system_iterator
virtual void clear()
Definition: parameters.h:321
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_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_snes_jacobian(), libMesh::__libmesh_petsc_snes_postcheck(), libMesh::__libmesh_petsc_snes_residual(), libMesh::__libmesh_tao_equality_constraints(), libMesh::__libmesh_tao_equality_constraints_jacobian(), libMesh::__libmesh_tao_gradient(), libMesh::__libmesh_tao_hessian(), libMesh::__libmesh_tao_inequality_constraints(), libMesh::__libmesh_tao_inequality_constraints_jacobian(), libMesh::__libmesh_tao_objective(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::ParmetisPartitioner::_do_repartition(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult_add(), _read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::MeshRefinement::_smooth_flags(), 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::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::PetscDiffSolver::init(), libMesh::TimeSolver::init(), libMesh::TopologyMap::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::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::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::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::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::DistributedMesh::renumber_dof_objects(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::Parallel::Sort< KeyType, IdxType >::sort(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::Parallel::sync_element_data_by_parent_id(), libMesh::Parallel::sync_node_data_by_element_id(), libMesh::MeshRefinement::test_level_one(), 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::LaspackVector< T >::zero_clone(), libMesh::EigenSparseVector< 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 1173 of file equation_systems.C.

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

Referenced by read().

1176 {
1177  // safety check, whether we handle at least the same number
1178  // of systems
1179  std::vector<bool> os_result;
1180 
1181  if (this->n_systems() != other_es.n_systems())
1182  {
1183  if (verbose)
1184  {
1185  libMesh::out << " Fatal difference. This system handles "
1186  << this->n_systems() << " systems," << std::endl
1187  << " while the other system handles "
1188  << other_es.n_systems()
1189  << " systems." << std::endl
1190  << " Aborting comparison." << std::endl;
1191  }
1192  return false;
1193  }
1194  else
1195  {
1196  // start comparing each system
1197  const_system_iterator pos = _systems.begin();
1198  const const_system_iterator end = _systems.end();
1199 
1200  for (; pos != end; ++pos)
1201  {
1202  const std::string & sys_name = pos->first;
1203  const System & system = *(pos->second);
1204 
1205  // get the other system
1206  const System & other_system = other_es.get_system (sys_name);
1207 
1208  os_result.push_back (system.compare (other_system, threshold, verbose));
1209 
1210  }
1211 
1212  }
1213 
1214 
1215  // sum up the results
1216  if (os_result.size()==0)
1217  return true;
1218  else
1219  {
1220  bool os_identical;
1221  unsigned int n = 0;
1222  do
1223  {
1224  os_identical = os_result[n];
1225  n++;
1226  }
1227  while (os_identical && n<os_result.size());
1228  return os_identical;
1229  }
1230 }
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 434 of file equation_systems.C.

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

435 {
436  libmesh_deprecated();
437 
438  if (!_systems.count(name))
439  libmesh_error_msg("ERROR: no system named " << name);
440 
441  delete _systems[name];
442 
443  _systems.erase (name);
444 }
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 454 of file equation_systems.h.

References _refine_in_reinit.

454 { 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 449 of file equation_systems.h.

References _refine_in_reinit.

449 { 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 1234 of file equation_systems.C.

References _systems, end, and n_systems().

Referenced by print_info(), and read().

1235 {
1236  std::ostringstream oss;
1237 
1238  oss << " EquationSystems\n"
1239  << " n_systems()=" << this->n_systems() << '\n';
1240 
1241  // Print the info for the individual systems
1242  const_system_iterator pos = _systems.begin();
1243  const const_system_iterator end = _systems.end();
1244 
1245  for (; pos != end; ++pos)
1246  oss << pos->second->get_info();
1247 
1248 
1249  // // Possibly print the parameters
1250  // if (!this->parameters.empty())
1251  // {
1252  // oss << " n_parameters()=" << this->n_parameters() << '\n';
1253  // oss << " Parameters:\n";
1254 
1255  // for (std::map<std::string, Real>::const_iterator
1256  // param = _parameters.begin(); param != _parameters.end();
1257  // ++param)
1258  // oss << " "
1259  // << "\""
1260  // << param->first
1261  // << "\""
1262  // << "="
1263  // << param->second
1264  // << '\n';
1265  // }
1266 
1267  return oss.str();
1268 }
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 541 of file equation_systems.h.

References _mesh.

542 {
543  return _mesh;
544 }
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 890 of file equation_systems.C.

References libMesh::ParallelObject::_communicator, _mesh, _systems, libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), 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::DofObject::id(), libMesh::NumericVector< T >::init(), libMesh::libmesh_assert(), libMesh::NumericVector< T >::localize_to_one(), libMesh::MeshBase::max_elem_id(), libMesh::MONOMIAL, libMesh::MeshBase::n_elem(), libMesh::ParallelObject::n_processors(), n_systems(), libMesh::System::n_vars(), libMesh::PARALLEL, libMesh::ParallelObject::processor_id(), libMesh::NumericVector< T >::set(), libMesh::System::solution, libMesh::Elem::subdomain_id(), 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().

892 {
893  // This function must be run on all processors at once
894  parallel_object_only();
895 
896  libmesh_assert (this->n_systems());
897 
898  const dof_id_type ne = _mesh.n_elem();
899 
900  libmesh_assert_equal_to (ne, _mesh.max_elem_id());
901 
902  // If the names vector has entries, we will only populate the soln vector
903  // with names included in that list. Note: The names vector may be
904  // reordered upon exiting this function
905  std::vector<std::string> filter_names = names;
906  bool is_filter_names = !filter_names.empty();
907 
908  soln.clear();
909  names.clear();
910 
911  const FEType type(CONSTANT, MONOMIAL);
912 
913  dof_id_type nv = 0;
914 
915  // Find the total number of variables to output
916  std::vector<std::vector<unsigned> > do_output(_systems.size());
917  {
918  const_system_iterator pos = _systems.begin();
919  const const_system_iterator end = _systems.end();
920  unsigned sys_ctr = 0;
921 
922  for (; pos != end; ++pos, ++sys_ctr)
923  {
924  const System & system = *(pos->second);
925  const unsigned int nv_sys = system.n_vars();
926 
927  do_output[sys_ctr].resize(nv_sys);
928 
929  for (unsigned int var=0; var < nv_sys; ++var)
930  {
931  if (system.variable_type(var) != type ||
932  (is_filter_names && std::find(filter_names.begin(), filter_names.end(), system.variable_name(var)) == filter_names.end()))
933  continue;
934 
935  // Otherwise, this variable should be output
936  nv++;
937  do_output[sys_ctr][var] = 1;
938  }
939  }
940  }
941 
942  // If there are no variables to write out don't do anything...
943  if (!nv)
944  return;
945 
946  // We can handle the case where there are NULLs in the Elem vector
947  // by just having extra zeros in the solution vector.
948  numeric_index_type parallel_soln_global_size = ne*nv;
949 
950  numeric_index_type div = parallel_soln_global_size / this->n_processors();
951  numeric_index_type mod = parallel_soln_global_size % this->n_processors();
952 
953  // Initialize all processors to the average size.
954  numeric_index_type parallel_soln_local_size = div;
955 
956  // The first "mod" processors get an extra entry.
957  if (this->processor_id() < mod)
958  parallel_soln_local_size = div+1;
959 
960  // Create a NumericVector to hold the parallel solution
961  UniquePtr<NumericVector<Number> > parallel_soln_ptr = NumericVector<Number>::build(_communicator);
962  NumericVector<Number> & parallel_soln = *parallel_soln_ptr;
963  parallel_soln.init(parallel_soln_global_size,
964  parallel_soln_local_size,
965  /*fast=*/false,
966  /*ParallelType=*/PARALLEL);
967 
968  dof_id_type var_num = 0;
969 
970  // For each system in this EquationSystems object,
971  // update the global solution and collect the
972  // CONSTANT MONOMIALs. The entries are in variable-major
973  // format.
974  const_system_iterator pos = _systems.begin();
975  const const_system_iterator end = _systems.end();
976  unsigned sys_ctr = 0;
977 
978  for (; pos != end; ++pos, ++sys_ctr)
979  {
980  const System & system = *(pos->second);
981  const unsigned int nv_sys = system.n_vars();
982 
983  // Update the current_local_solution
984  {
985  System & non_const_sys = const_cast<System &>(system);
986  // We used to simply call non_const_sys.solution->close()
987  // here, but that is not allowed when the solution vector is
988  // locked read-only, for example when printing the solution
989  // during during the middle of a solve... So try to be a bit
990  // more careful about calling close() unnecessarily.
991  libmesh_assert(this->comm().verify(non_const_sys.solution->closed()));
992  if (!non_const_sys.solution->closed())
993  non_const_sys.solution->close();
994  non_const_sys.update();
995  }
996 
997  NumericVector<Number> & sys_soln(*system.current_local_solution);
998 
999  // The DOF indices for the finite element
1000  std::vector<dof_id_type> dof_indices;
1001 
1002  // Loop over the variable names and load them in order
1003  for (unsigned int var=0; var < nv_sys; ++var)
1004  {
1005  // Skip this variable if we are not outputting it.
1006  if (!do_output[sys_ctr][var])
1007  continue;
1008 
1009  names.push_back(system.variable_name(var));
1010 
1011  const Variable & variable = system.variable(var);
1012  const DofMap & dof_map = system.get_dof_map();
1013 
1014  MeshBase::element_iterator it = _mesh.active_local_elements_begin();
1015  const MeshBase::element_iterator end_elem = _mesh.active_local_elements_end();
1016 
1017  for ( ; it != end_elem; ++it)
1018  {
1019  const Elem * elem = *it;
1020 
1021  if (variable.active_on_subdomain(elem->subdomain_id()))
1022  {
1023  dof_map.dof_indices (elem, dof_indices, var);
1024 
1025  libmesh_assert_equal_to (1, dof_indices.size());
1026 
1027  parallel_soln.set((ne*var_num)+elem->id(), sys_soln(dof_indices[0]));
1028  }
1029  }
1030 
1031  var_num++;
1032  } // end loop on variables in this system
1033  } // end loop over systems
1034 
1035  parallel_soln.close();
1036 
1037  parallel_soln.localize_to_one(soln);
1038 }
processor_id_type n_processors() const
IterBase * end
const Parallel::Communicator & _communicator
libmesh_assert(j)
static UniquePtr< NumericVector< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
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
virtual element_iterator active_local_elements_begin()=0
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
virtual element_iterator active_local_elements_end()=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 649 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_value(), libMesh::ExactSolution::attach_reference_solution(), 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(), sensitivity_solve(), solve(), update(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().

650 {
651  const_system_iterator pos = _systems.find(name);
652 
653  // Check for errors
654  if (pos == _systems.end())
655  libmesh_error_msg("ERROR: no system named \"" << name << "\" found!");
656 
657  // Attempt dynamic cast
658  return *cast_ptr<T_sys *>(pos->second);
659 }
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 668 of file equation_systems.h.

References _systems.

669 {
670  system_iterator pos = _systems.find(name);
671 
672  // Check for errors
673  if (pos == _systems.end())
674  libmesh_error_msg("ERROR: no system named " << name << " found!");
675 
676  // Attempt dynamic cast
677  return *cast_ptr<T_sys *>(pos->second);
678 }
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 598 of file equation_systems.h.

References _systems, end, and n_systems().

599 {
600  libmesh_assert_less (num, this->n_systems());
601 
602 
603  const_system_iterator pos = _systems.begin();
604  const const_system_iterator end = _systems.end();
605 
606  for (; pos != end; ++pos)
607  if (pos->second->number() == num)
608  break;
609 
610  // Check for errors
611  if (pos == end)
612  libmesh_error_msg("ERROR: no system number " << num << " found!");
613 
614  // Attempt dynamic cast
615  return *cast_ptr<T_sys *>(pos->second);
616 }
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 623 of file equation_systems.h.

References _systems, end, and n_systems().

624 {
625  libmesh_assert_less (num, this->n_systems());
626 
627  const_system_iterator pos = _systems.begin();
628  const const_system_iterator end = _systems.end();
629 
630  for (; pos != end; ++pos)
631  if (pos->second->number() == num)
632  break;
633 
634  // Check for errors
635  if (pos == end)
636  libmesh_error_msg("ERROR: no system number " << num << " found!");
637 
638  // Attempt dynamic cast
639  return *cast_ptr<T_sys *>(pos->second);
640 }
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 687 of file equation_systems.h.

References libMesh::Quality::name().

688 {
689  return this->get_system<System>(name);
690 }
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 695 of file equation_systems.h.

References libMesh::Quality::name().

696 {
697  return this->get_system<System>(name);
698 }
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 703 of file equation_systems.h.

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

Definition at line 711 of file equation_systems.h.

712 {
713  return this->get_system<System>(num);
714 }
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 586 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().

587 {
588  if (_systems.find(name) == _systems.end())
589  return false;
590  return true;
591 }
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::elements_begin(), libMesh::MeshBase::elements_end(), get_system(), n_systems(), libMesh::MeshBase::nodes_begin(), and libMesh::MeshBase::nodes_end().

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  {
103  MeshBase::node_iterator node_it = _mesh.nodes_begin();
104  const MeshBase::node_iterator node_end = _mesh.nodes_end();
105 
106  for ( ; node_it != node_end; ++node_it)
107  (*node_it)->set_n_systems(n_sys);
108 
109  MeshBase::element_iterator elem_it = _mesh.elements_begin();
110  const MeshBase::element_iterator elem_end = _mesh.elements_end();
111 
112  for ( ; elem_it != elem_end; ++elem_it)
113  (*elem_it)->set_n_systems(n_sys);
114  }
115 
116  for (unsigned int i=0; i != this->n_systems(); ++i)
117  this->get_system(i).init();
118 
119 #ifdef LIBMESH_ENABLE_AMR
120  MeshRefinement mesh_refine(_mesh);
121  mesh_refine.clean_refinement_flags();
122 #endif
123 }
virtual node_iterator nodes_begin()=0
virtual element_iterator elements_begin()=0
virtual element_iterator elements_end()=0
unsigned int n_systems() const
virtual node_iterator nodes_end()=0
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 1320 of file equation_systems.C.

References _systems, and end.

1321 {
1322  std::size_t tot=0;
1323 
1324  const_system_iterator pos = _systems.begin();
1325  const const_system_iterator end = _systems.end();
1326 
1327  for (; pos != end; ++pos)
1328  tot += pos->second->n_active_dofs();
1329 
1330  return tot;
1331 }
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 1304 of file equation_systems.C.

References _systems, and end.

1305 {
1306  std::size_t tot=0;
1307 
1308  const_system_iterator pos = _systems.begin();
1309  const const_system_iterator end = _systems.end();
1310 
1311  for (; pos != end; ++pos)
1312  tot += pos->second->n_dofs();
1313 
1314  return tot;
1315 }
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::XdrIO::read(), libMesh::CheckpointIO::read_connectivity(), 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:722
const Parallel::Communicator & _communicator
unsigned int libMesh::EquationSystems::n_vars ( ) const
Returns
The total number of variables in all systems.

Definition at line 1289 of file equation_systems.C.

References _systems, and end.

Referenced by build_variable_names().

1290 {
1291  unsigned int tot=0;
1292 
1293  const_system_iterator pos = _systems.begin();
1294  const const_system_iterator end = _systems.end();
1295 
1296  for (; pos != end; ++pos)
1297  tot += pos->second->n_vars();
1298 
1299  return tot;
1300 }
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 1272 of file equation_systems.C.

References get_info().

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

1273 {
1274  os << this->get_info()
1275  << std::endl;
1276 }
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::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::CheckpointIO::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::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::CheckpointIO::write(), libMesh::XdrIO::write(), write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::UCDIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), and libMesh::ExodusII_IO_Helper::write_timestep().

100  { return cast_int<processor_id_type>(_communicator.rank()); }
const Parallel::Communicator & _communicator
unsigned int rank() const
Definition: parallel.h:720
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 352 of file equation_systems.h.

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

356  { 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 363 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.

366  { 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 459 of file equation_systems.h.

References _refine_in_reinit.

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

Reinitialize all the systems

Definition at line 127 of file equation_systems.C.

References _mesh, _refine_in_reinit, libMesh::MeshRefinement::coarsen_elements(), libMesh::MeshBase::contract(), libMesh::DofMap::distribute_dofs(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::MeshRefinement::face_level_mismatch_limit(), libMesh::System::get_dof_map(), get_mesh(), get_system(), n_systems(), libMesh::MeshBase::nodes_begin(), libMesh::MeshBase::nodes_end(), libMesh::MeshRefinement::overrefined_boundary_limit(), libMesh::System::prolong_vectors(), libMesh::MeshRefinement::refine_elements(), libMesh::System::reinit_constraints(), libMesh::System::restrict_vectors(), libMesh::DofObject::set_n_systems(), libMesh::sys, and libMesh::MeshRefinement::underrefined_boundary_limit().

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

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

Call sensitivity_solve on all the individual equation systems.

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

Definition at line 458 of file equation_systems.C.

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

459 {
460  libmesh_assert (this->n_systems());
461 
462  for (unsigned int i=0; i != this->n_systems(); ++i)
463  this->get_system(i).sensitivity_solve(parameters_in);
464 }
libmesh_assert(j)
unsigned int n_systems() const
const T_sys & get_system(const std::string &name) const
void libMesh::EquationSystems::solve ( )
virtual

Call solve on all the individual equation systems.

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

Definition at line 448 of file equation_systems.C.

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

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

449 {
450  libmesh_assert (this->n_systems());
451 
452  for (unsigned int i=0; i != this->n_systems(); ++i)
453  this->get_system(i).solve();
454 }
libmesh_assert(j)
unsigned int n_systems() const
const T_sys & get_system(const std::string &name) const
void libMesh::EquationSystems::update ( )

Updates local values for all the systems

Definition at line 338 of file equation_systems.C.

References get_system(), and n_systems().

Referenced by _read_impl().

339 {
340  LOG_SCOPE("update()", "EquationSystems");
341 
342  // Localize each system's vectors
343  for (unsigned int i=0; i != this->n_systems(); ++i)
344  this->get_system(i).update();
345 }
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 379 of file equation_systems_io.C.

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

Referenced by libMesh::ErrorVector::plot_error(), read(), write(), and libMesh::NameBasedIO::write_equation_systems().

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

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

370 {
371  XdrMODE mode = WRITE;
372  if (name.find(".xdr") != std::string::npos)
373  mode = ENCODE;
374  this->write(name, mode, write_flags, partition_agnostic);
375 }
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 1280 of file equation_systems.C.

Referenced by read().

1282 {
1283  es.print_info(os);
1284  return os;
1285 }

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

MeshBase& libMesh::EquationSystems::_mesh
protected
Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 137 of file reference_counter.h.

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

The number of objects. Print the reference count information when the number returns to 0.

Definition at line 132 of file reference_counter.h.

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

bool libMesh::EquationSystems::_refine_in_reinit
protected

Flag for whether to call coarsen/refine in reinit(). Default value: true

Definition at line 495 of file equation_systems.h.

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

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

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