Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
David Knezevic committed Mar 7, 2014
1 parent f8fba60 commit a650430
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 13 deletions.
4 changes: 3 additions & 1 deletion include/mesh/exodusII_io.h
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion include/mesh/gmv_io.h
Expand Up @@ -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;


/**
Expand Down
5 changes: 4 additions & 1 deletion include/systems/equation_systems.h
Expand Up @@ -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.
Expand Down
9 changes: 6 additions & 3 deletions src/mesh/exodusII_io.C
Expand Up @@ -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);
}
Expand Down
7 changes: 4 additions & 3 deletions src/mesh/gmv_io.C
Expand Up @@ -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();
Expand Down
47 changes: 43 additions & 4 deletions src/systems/equation_systems.C
Expand Up @@ -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
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit a650430

Please sign in to comment.