Permalink
Browse files

Updated discontinuous plotting so that we can optionally plot a subse…

…t of the systems.

This functionality exists for continuous plotting, so good to add it in the
discontinuous case too.
  • Loading branch information...
1 parent f8fba60 commit a65043023730d9e005c41aa790b6b84feb0e4421 David Knezevic committed Mar 7, 2014
@@ -120,7 +120,9 @@ class ExodusII_IO : public MeshInput<MeshBase>,
/**
* 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<std::string>* system_names=NULL);
/**
* Write out element solution.
View
@@ -150,7 +150,8 @@ class GMVIO : public MeshInput<MeshBase>,
*/
void write_discontinuous_gmv (const std::string& name,
const EquationSystems& es,
- const bool write_partitioning) const;
+ const bool write_partitioning,
+ const std::set<std::string>* system_names=NULL) const;
/**
@@ -298,8 +298,11 @@ class EquationSystems : public ReferenceCountedObject<EquationSystems>,
* 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<Number>& soln) const;
+ void build_discontinuous_solution_vector (std::vector<Number>& soln,
+ const std::set<std::string>* system_names=NULL) const;
/**
* Read & initialize the systems from disk using the XDR data format.
View
@@ -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<std::string>* system_names)
{
std::vector<std::string> solution_names;
std::vector<Number> 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);
}
View
@@ -1610,16 +1610,17 @@ 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<std::string>* system_names) const
{
std::vector<std::string> solution_names;
std::vector<Number> v;
// Get a reference to the mesh
const MeshBase& mesh = MeshOutput<MeshBase>::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();
@@ -1005,14 +1005,41 @@ void EquationSystems::get_solution (std::vector<Number>& soln,
-void EquationSystems::build_discontinuous_solution_vector (std::vector<Number>& soln) const
+void EquationSystems::build_discontinuous_solution_vector (std::vector<Number>& soln,
+ const std::set<std::string>* 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<Number>&
// 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();

0 comments on commit a650430

Please sign in to comment.