diff --git a/include/mesh/exodusII_io.h b/include/mesh/exodusII_io.h index d8189059f86..f650cb2993e 100644 --- a/include/mesh/exodusII_io.h +++ b/include/mesh/exodusII_io.h @@ -120,7 +120,9 @@ class ExodusII_IO : public MeshInput, /** * Writes a exodusII file with discontinuous data */ - void write_discontinuous_exodusII (const std::string& name, const EquationSystems& es); + void write_discontinuous_exodusII (const std::string& name, + const EquationSystems& es, + const std::set* system_names=NULL); /** * Write out element solution. diff --git a/include/mesh/gmv_io.h b/include/mesh/gmv_io.h index dbe72a982cc..3bb41e47bc5 100644 --- a/include/mesh/gmv_io.h +++ b/include/mesh/gmv_io.h @@ -150,7 +150,8 @@ class GMVIO : public MeshInput, */ void write_discontinuous_gmv (const std::string& name, const EquationSystems& es, - const bool write_partitioning) const; + const bool write_partitioning, + const std::set* system_names=NULL) const; /** diff --git a/include/systems/equation_systems.h b/include/systems/equation_systems.h index 96ba690ff15..f8d8994d4c4 100644 --- a/include/systems/equation_systems.h +++ b/include/systems/equation_systems.h @@ -298,8 +298,11 @@ class EquationSystems : public ReferenceCountedObject, * Fill the input vector \p soln with solution values. The * entries will be in variable-major format (corresponding to * the names from \p build_variable_names()). + * If systems_names!=NULL, only include data from the + * specified systems. */ - void build_discontinuous_solution_vector (std::vector& soln) const; + void build_discontinuous_solution_vector (std::vector& soln, + const std::set* system_names=NULL) const; /** * Read & initialize the systems from disk using the XDR data format. diff --git a/src/mesh/exodusII_io.C b/src/mesh/exodusII_io.C index eeddff1712e..be858bdf444 100644 --- a/src/mesh/exodusII_io.C +++ b/src/mesh/exodusII_io.C @@ -70,13 +70,16 @@ void ExodusII_IO::copy_nodal_solution(System& system, std::string var_name, unsi -void ExodusII_IO::write_discontinuous_exodusII(const std::string& name, const EquationSystems& es) +void ExodusII_IO::write_discontinuous_exodusII( + const std::string& name, + const EquationSystems& es, + const std::set* system_names) { std::vector solution_names; std::vector v; - es.build_variable_names (solution_names); - es.build_discontinuous_solution_vector (v); + es.build_variable_names (solution_names, NULL, system_names); + es.build_discontinuous_solution_vector (v, system_names); this->write_nodal_data_discontinuous(name, v, solution_names); } diff --git a/src/mesh/gmv_io.C b/src/mesh/gmv_io.C index d647429b1a6..0138cb2459d 100644 --- a/src/mesh/gmv_io.C +++ b/src/mesh/gmv_io.C @@ -1610,7 +1610,8 @@ void GMVIO::write_binary (const std::string& fname, void GMVIO::write_discontinuous_gmv (const std::string& name, const EquationSystems& es, - const bool write_partitioning) const + const bool write_partitioning, + const std::set* system_names) const { std::vector solution_names; std::vector v; @@ -1618,8 +1619,8 @@ void GMVIO::write_discontinuous_gmv (const std::string& name, // Get a reference to the mesh const MeshBase& mesh = MeshOutput::mesh(); - es.build_variable_names (solution_names); - es.build_discontinuous_solution_vector (v); + es.build_variable_names (solution_names, NULL, system_names); + es.build_discontinuous_solution_vector (v, system_names); // These are parallel_only functions const unsigned int n_active_elem = mesh.n_active_elem(); diff --git a/src/systems/equation_systems.C b/src/systems/equation_systems.C index c93cddf1724..445701172c1 100644 --- a/src/systems/equation_systems.C +++ b/src/systems/equation_systems.C @@ -1005,14 +1005,41 @@ void EquationSystems::get_solution (std::vector& soln, -void EquationSystems::build_discontinuous_solution_vector (std::vector& soln) const +void EquationSystems::build_discontinuous_solution_vector (std::vector& soln, + const std::set* system_names) const { START_LOG("build_discontinuous_solution_vector()", "EquationSystems"); libmesh_assert (this->n_systems()); const unsigned int dim = _mesh.mesh_dimension(); - const unsigned int nv = this->n_vars(); + + // Get the number of variables (nv) by counting the number of variables + // in each system listed in system_names + unsigned int nv = 0; + + const_system_iterator pos = _systems.begin(); + const const_system_iterator end = _systems.end(); + + for (; pos != end; ++pos) + { + // Check current system is listed in system_names, and skip pos if not + bool use_current_system = (system_names == NULL); + if(!use_current_system) + { + use_current_system = + (std::find( system_names->begin(), system_names->end(), pos->first ) + != system_names->end()); + } + if(!use_current_system) + { + continue; + } + + const System& system = *(pos->second); + nv += system.n_vars(); + } + unsigned int tw=0; // get the total weight @@ -1040,11 +1067,23 @@ void EquationSystems::build_discontinuous_solution_vector (std::vector& // loop over the elements and build the nodal solution // from the element solution. Then insert this nodal solution // into the vector passed to build_solution_vector. - const_system_iterator pos = _systems.begin(); - const const_system_iterator end = _systems.end(); + pos = _systems.begin(); for (; pos != end; ++pos) { + // Check current system is listed in system_names, and skip pos if not + bool use_current_system = (system_names == NULL); + if(!use_current_system) + { + use_current_system = + (std::find( system_names->begin(), system_names->end(), pos->first ) + != system_names->end()); + } + if(!use_current_system) + { + continue; + } + const System& system = *(pos->second); const unsigned int nv_sys = system.n_vars();