The attached patch does the job for me. Let me know if there are any
suggestions, otherwise I'll go ahead and check it in.
David
On 10/29/2012 07:18 PM, Kirk, Benjamin (JSC-EG311) wrote:
That would be a very, very welcome patch.
-Ben
On Oct 29, 2012, at 4:30 PM, "David Knezevic" <dkneze...@seas.harvard.edu>
wrote:
I'd like to be able to plot data from a subset of the Systems in an
EquationSystems object. I generally use write_equation_systems, which
writes out data from all the systems. I didn't notice functionality for
specifying a subset of the systems, but I wanted to check?
Otherwise, I guess a patch would involve some edits to MeshOutput and
EquationSystems so that I can pass in a std::set<std::string>* (that
defaults to NULL) of system names? If this sounds like desirable
functionality more generally, I'll be happy to make a patch.
Thanks,
David
------------------------------------------------------------------------------
The Windows 8 Center - In partnership with Sourceforge
Your idea - your app - 30 days.
Get started!
http://windows8center.sourceforge.net/
what-html-developers-need-to-know-about-coding-windows-8-metro-style-apps/
_______________________________________________
Libmesh-users mailing list
Libmesh-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-users
Index: include/systems/equation_systems.h
===================================================================
--- include/systems/equation_systems.h (revision 6238)
+++ include/systems/equation_systems.h (working copy)
@@ -256,8 +256,12 @@
* Fill the input vector \p var_names with the names
* of the variables for each system. If \p type is passed,
* only variables of the specified type will be populated.
+ * If systems_names!=NULL, only include names from the
+ * specified systems.
*/
- void build_variable_names (std::vector<std::string>& var_names, const FEType
*type=NULL) const;
+ void build_variable_names (std::vector<std::string>& var_names,
+ const FEType *type=NULL,
+ const std::set<std::string>* system_names=NULL)
const;
/**
* Fill the input vector \p soln with the solution values for the
@@ -273,8 +277,11 @@
* 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_solution_vector (std::vector<Number>& soln) const;
+ void build_solution_vector (std::vector<Number>& soln,
+ const std::set<std::string>* system_names=NULL)
const;
/**
* Retrieve the solution data for CONSTANT MONOMIALs. If \p names
Index: include/mesh/vtk_io.h
===================================================================
--- include/mesh/vtk_io.h (revision 6238)
+++ include/mesh/vtk_io.h (working copy)
@@ -85,7 +85,9 @@
* write_nodal_data there would be no way to export cell centered data
*/
- virtual void write_equation_systems(const std::string& fname, const
EquationSystems& es);
+ virtual void write_equation_systems(const std::string& fname,
+ const EquationSystems& es,
+ const std::set<std::string>*
system_names=NULL);
/**
* This method implements reading a mesh from a specified file
Index: include/mesh/mesh_output.h
===================================================================
--- include/mesh/mesh_output.h (revision 6238)
+++ include/mesh/mesh_output.h (working copy)
@@ -88,7 +88,8 @@
* where the data is taken from the \p EquationSystems object.
*/
virtual void write_equation_systems (const std::string&,
- const EquationSystems&);
+ const EquationSystems&,
+ const std::set<std::string>*
system_names=NULL);
/**
* This method implements writing a mesh with nodal data to a
@@ -141,11 +142,14 @@
/**
* A helper function which allows us to fill temporary
- * name and solution vectors with an EquationSystems object
+ * name and solution vectors with an EquationSystems object.
+ * Only generate names and solution data corresponding to
+ * systems specified in system_names.
*/
void _build_variable_names_and_solution_vector(const EquationSystems& es,
std::vector<Number>& soln,
- std::vector<std::string>&
names);
+ std::vector<std::string>&
names,
+ const std::set<std::string>*
system_names=NULL);
};
@@ -197,7 +201,8 @@
template <class MT>
inline
void MeshOutput<MT>::write_equation_systems (const std::string& fname,
- const EquationSystems& es)
+ const EquationSystems& es,
+ const std::set<std::string>*
system_names)
{
START_LOG("write_equation_systems()", "MeshOutput");
@@ -210,7 +215,7 @@
std::vector<Number> soln;
std::vector<std::string> names;
- this->_build_variable_names_and_solution_vector(es, soln, names);
+ this->_build_variable_names_and_solution_vector(es, soln, names,
system_names);
//es.build_variable_names (names);
//es.build_solution_vector (soln);
Index: src/mesh/mesh_output.C
===================================================================
--- src/mesh/mesh_output.C (revision 6238)
+++ src/mesh/mesh_output.C (working copy)
@@ -30,7 +30,8 @@
void MeshOutput<MT>::
_build_variable_names_and_solution_vector (const EquationSystems& es,
std::vector<Number>& soln,
- std::vector<std::string>& names)
+ std::vector<std::string>& names,
+ const std::set<std::string>*
system_names)
{
if(!_is_parallel_format)
{
@@ -38,8 +39,8 @@
const_cast<EquationSystems&>(es).allgather();
}
- es.build_variable_names (names);
- es.build_solution_vector (soln);
+ es.build_variable_names (names, NULL, system_names);
+ es.build_solution_vector (soln, system_names);
}
Index: src/mesh/vtk_io.C
===================================================================
--- src/mesh/vtk_io.C (revision 6238)
+++ src/mesh/vtk_io.C (working copy)
@@ -578,7 +578,9 @@
* This method writes out the equationsystems to a .pvtu file (VTK parallel
* unstructured grid).
*/
-void VTKIO::write_equation_systems(const std::string& fname, const
EquationSystems& es)
+void VTKIO::write_equation_systems(const std::string& fname,
+ const EquationSystems& es,
+ const std::set<std::string>*)
{
#ifndef LIBMESH_HAVE_VTK
Index: src/systems/equation_systems.C
===================================================================
--- src/systems/equation_systems.C (revision 6238)
+++ src/systems/equation_systems.C (working copy)
@@ -469,7 +469,9 @@
-void EquationSystems::build_variable_names (std::vector<std::string>&
var_names, const FEType *type) const
+void EquationSystems::build_variable_names (std::vector<std::string>&
var_names,
+ const FEType *type,
+ const std::set<std::string>*
system_names) const
{
libmesh_assert (this->n_systems());
@@ -486,6 +488,18 @@
unsigned int n_vector_vars = 0;
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;
+ }
+
for (unsigned int vn=0; vn<pos->second->n_vars(); vn++)
{
if( FEInterface::field_type(pos->second->variable_type(vn)) ==
@@ -494,6 +508,7 @@
else
n_scalar_vars++;
}
+ }
// Here, we're assuming the number of vector components is the same
// as the mesh dimension. Will break for mixed dimension meshes.
@@ -517,6 +532,17 @@
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;
+ }
+
for (unsigned int vn=0; vn<pos->second->n_vars(); vn++)
{
std::string var_name = pos->second->variable_name(vn);
@@ -647,7 +673,8 @@
-void EquationSystems::build_solution_vector (std::vector<Number>& soln) const
+void EquationSystems::build_solution_vector (std::vector<Number>& soln,
+ const std::set<std::string>*
system_names) const
{
START_LOG("build_solution_vector()", "EquationSystems");
@@ -679,6 +706,18 @@
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;
+ }
+
for (unsigned int vn=0; vn<pos->second->n_vars(); vn++)
{
if( FEInterface::field_type(pos->second->variable_type(vn)) ==
@@ -687,6 +726,7 @@
else
n_scalar_vars++;
}
+ }
// Here, we're assuming the number of vector components is the same
// as the mesh dimension. Will break for mixed dimension meshes.
nv = n_scalar_vars + dim*n_vector_vars;
@@ -731,6 +771,17 @@
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();
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Libmesh-users mailing list
Libmesh-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-users