Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ExodusII_IO to have empty variable list #186

Merged
merged 1 commit into from
Jan 2, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions include/mesh/exodusII_io.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -164,9 +164,12 @@ class ExodusII_IO : public MeshInput<MeshBase>,
/** /**
* Sets the list of variable names to be included in the output. * Sets the list of variable names to be included in the output.
* This is _optional_. If this is never called then all variables * This is _optional_. If this is never called then all variables
* will be present. * will be present. If this is called and an empty vector is supplied
* no variables will be output. Setting the allow_empty = false will
* result in empty vectors supplied here to also be populated with all
* variables.
*/ */
void set_output_variables(const std::vector<std::string> & output_variables); void set_output_variables(const std::vector<std::string> & output_variables, bool allow_empty = true);


/** /**
* In the general case, meshes containing 2D elements can be * In the general case, meshes containing 2D elements can be
Expand Down Expand Up @@ -234,6 +237,14 @@ class ExodusII_IO : public MeshInput<MeshBase>,
void write_nodal_data_common(std::string fname, void write_nodal_data_common(std::string fname,
const std::vector<std::string>& names, const std::vector<std::string>& names,
bool continuous=true); bool continuous=true);

/**
* If true, _output_variables is allowed to remain empty.
* If false, if _output_variables is empty it will be populated with a complete list of all variables
* By default, calling set_output_variables() sets this flag to true, but it provides an override.
*/
bool _allow_empty_variables;

}; };




Expand Down
8 changes: 5 additions & 3 deletions src/mesh/exodusII_io.C
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -46,14 +46,16 @@ ExodusII_IO::ExodusII_IO (MeshBase& mesh) :
#endif #endif
_timestep(1), _timestep(1),
_verbose(false), _verbose(false),
_append(false) _append(false),
_allow_empty_variables(false)
{ {
} }




void ExodusII_IO::set_output_variables(const std::vector<std::string> & output_variables) void ExodusII_IO::set_output_variables(const std::vector<std::string> & output_variables, bool allow_empty)
{ {
_output_variables = output_variables; _output_variables = output_variables;
_allow_empty_variables = allow_empty;
} }




Expand Down Expand Up @@ -549,7 +551,7 @@ void ExodusII_IO::write_nodal_data (const std::string& fname,
// The names of the variables to be output // The names of the variables to be output
std::vector<std::string> output_names; std::vector<std::string> output_names;


if(_output_variables.size()) if(_allow_empty_variables || !_output_variables.empty())
output_names = _output_variables; output_names = _output_variables;
else else
output_names = names; output_names = names;
Expand Down