> There's another test where we die with an error: mixed-order elements.
> E.g. ex11 with VTKIO dies screaming as soon as VTKIO::solution_to_vtk
> hits a side node on a QUAD9, when it expects to see two velocity
> components plus one pressure component but it only sees one pressure
> component. I don't know enough about the VTK formats to say what the
> right way to handle this is.
Judging from the latest VTK file format specification (4.2) apparently
existing on the web, mixed-number-of-component entities seem
unsupported. A field can be scalar or vectorial, but has a fixed
number of components for all nodes/elements either way.
Anyway, here's my patch that adds higher order components as
additional scalars with an integer suffix in the name to VTK output
files, leaving the first order component untouched.
Roman
Index: src/mesh/vtk_io.C
===================================================================
--- src/mesh/vtk_io.C (revision 4219)
+++ src/mesh/vtk_io.C (working copy)
@@ -304,6 +304,10 @@
const MeshBase& mesh = es.get_mesh();
const unsigned int n_nodes = mesh.n_nodes();
+ // check for an easy return (below, we need to access at least one node for determining the nb. of components)
+ if (n_nodes < 1)
+ return;
+
// loop over the systems
for(unsigned int i=0;i<es.n_systems();++i){ // for all systems, regardless of whether they are active or not
@@ -318,29 +322,42 @@
// loop over variables
for(unsigned int j=0;j<n_vars;++j){
- std::string name = sys.variable_name(j);
+ const unsigned int n_comp = mesh.node(0).n_comp(i,j);
+ // loop over components
+ for(unsigned int c=0;c<n_comp;++c)
+ {
+ std::string name = sys.variable_name(j);
- vtkDoubleArray *data = vtkDoubleArray::New();
+ // append the component number (starting with "_2" for the second) if the variable order is > 1
+ if (n_comp > 1 && c > 0)
+ {
+ libmesh_assert(n_comp < 1000);
+ char suffix [4]; // maximum nb. of components: 999
+ sprintf(suffix, "%u", c+1);
+ name = name + "_" + suffix;
+ }
- data->SetName(name.c_str());
+ vtkDoubleArray *data = vtkDoubleArray::New();
- data->SetNumberOfValues(n_nodes);
+ data->SetName(name.c_str());
- for(unsigned int k=0;k<n_nodes;++k){
+ data->SetNumberOfValues(n_nodes);
- const unsigned int dof_nr = mesh.node(k).dof_number(i,j,0);
+ for(unsigned int k=0;k<n_nodes;++k){
+ const unsigned int dof_nr = mesh.node(k).dof_number(i,j,c);
+
#ifdef LIBMESH_USE_COMPLEX_NUMBERS
- data->SetValue(k,soln[dof_nr].real());
+ data->SetValue(k,soln[dof_nr].real());
#else
- data->SetValue(k,soln[dof_nr]);
+ data->SetValue(k,soln[dof_nr]);
#endif
- }
- grid->GetPointData()->AddArray(data);
- data->Delete();
- }
-
+ }
+ grid->GetPointData()->AddArray(data);
+ data->Delete();
+ }
+ }
}
}
}
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in
Real-Time with Splunk. Collect, index and harness all the fast moving IT data
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business
insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Libmesh-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-devel