From: Timo Heister Date: Thu, 11 Feb 2016 19:26:51 +0000 (-0500) Subject: update graphical output in examples X-Git-Tag: v8.5.0-rc1~1322^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=511c8ff4b5c1acd98819d37d444da33dac7a614f;p=dealii.git update graphical output in examples - switch from gmv to vtu in several places - format numbers in filenames with leading zeros - vector output in step-20 - step-29: enable some debug output --- diff --git a/examples/step-20/step-20.cc b/examples/step-20/step-20.cc index 7c01c502cb..a12e7ea5f6 100644 --- a/examples/step-20/step-20.cc +++ b/examples/step-20/step-20.cc @@ -849,59 +849,36 @@ namespace Step20 // @sect4{MixedLaplace::output_results} // The last interesting function is the one in which we generate graphical - // output. Everything here looks obvious and familiar. Note how we construct - // unique names for all the solution variables at the beginning, like we did - // in step-8 and other programs later on. The only thing worth mentioning is - // that for higher order elements, in seems inappropriate to only show a - // single bilinear quadrilateral per cell in the graphical output. We - // therefore generate patches of size (degree+1)x(degree+1) to capture the - // full information content of the solution. See the step-7 tutorial program - // for more information on this. - // - // Note that we output the dim+1 components of the solution - // vector as a collection of individual scalars here. Most visualization - // programs will then only offer to visualize them individually, rather than - // allowing us to plot the flow field as a vector field. However, as - // explained in the corresponding function of step-22 or the @ref VVOutput - // "Generating graphical output" section of the @ref vector_valued module, - // instructing the DataOut class to identify components of the FESystem - // object as elements of a dim-dimensional vector is not - // actually very difficult and will then allow us to show results as vector - // plots. We skip this here for simplicity and refer to the links above for - // more information. + // output. Note that all velocity components get the same solution name + // "u". Together with using + // DataComponentInterpretation::::component_is_part_of_vector this will + // cause DataOut::write_vtu() to generate a vector representation of + // the individual velocity components, see step-22 or the + // @ref VVOutput "Generating graphical output" + // section of the + // @ref vector_valued + // module for more information. Finally, it seems inappropriate for higher + // order elements to only show a single bilinear quadrilateral per cell in + // the graphical output. We therefore generate patches of size + // (degree+1)x(degree+1) to capture the full information content of the + // solution. See the step-7 tutorial program for more information on this. template void MixedLaplaceProblem::output_results () const { - std::vector solution_names; - switch (dim) - { - case 2: - solution_names.push_back ("u"); - solution_names.push_back ("v"); - solution_names.push_back ("p"); - break; - - case 3: - solution_names.push_back ("u"); - solution_names.push_back ("v"); - solution_names.push_back ("w"); - solution_names.push_back ("p"); - break; - - default: - Assert (false, ExcNotImplemented()); - } - + std::vector solution_names(dim, "u"); + solution_names.push_back ("p"); + std::vector + interpretation (dim, + DataComponentInterpretation::component_is_part_of_vector); + interpretation.push_back (DataComponentInterpretation::component_is_scalar); DataOut data_out; - - data_out.attach_dof_handler (dof_handler); - data_out.add_data_vector (solution, solution_names); + data_out.add_data_vector (dof_handler, solution, solution_names, interpretation); data_out.build_patches (degree+1); - std::ofstream output ("solution.gmv"); - data_out.write_gmv (output); + std::ofstream output ("solution.vtu"); + data_out.write_vtu (output); } diff --git a/examples/step-21/step-21.cc b/examples/step-21/step-21.cc index 208c1c87d3..3b821afd44 100644 --- a/examples/step-21/step-21.cc +++ b/examples/step-21/step-21.cc @@ -1122,7 +1122,9 @@ namespace Step21 data_out.build_patches (degree+1); std::ostringstream filename; - filename << "solution-" << timestep_number << ".vtk"; + filename << "solution-" + << Utilities::int_to_string(timestep_number,4) + << ".vtk"; std::ofstream output (filename.str().c_str()); data_out.write_vtk (output); diff --git a/examples/step-28/doc/results.dox b/examples/step-28/doc/results.dox index edbacad443..390bb1feb5 100644 --- a/examples/step-28/doc/results.dox +++ b/examples/step-28/doc/results.dox @@ -2,8 +2,8 @@ The output of this program consist of the console output, a file -named ``convergence_table'' to record main results of mesh iteration, the eps -files including the grids, and the solutions given in gnuplot format. +named ``convergence_table'' to record main results of mesh iteration, +and the graphical output in vtu format. When we set Polynomial_Order to 2, we got following console output: @code diff --git a/examples/step-28/step-28.cc b/examples/step-28/step-28.cc index b73f9070de..5a84cfd913 100644 --- a/examples/step-28/step-28.cc +++ b/examples/step-28/step-28.cc @@ -1133,34 +1133,20 @@ namespace Step28 void EnergyGroup::output_results (const unsigned int cycle) const { - { - const std::string filename = std::string("grid-") + - Utilities::int_to_string(group,1) + - "." + - Utilities::int_to_string(cycle,1) + - ".eps"; - std::ofstream output (filename.c_str()); - - GridOut grid_out; - grid_out.write_eps (triangulation, output); - } + const std::string filename = std::string("solution-") + + Utilities::int_to_string(group, 2) + + "." + + Utilities::int_to_string(cycle, 2) + + ".vtu"; - { - const std::string filename = std::string("solution-") + - Utilities::int_to_string(group,1) + - "." + - Utilities::int_to_string(cycle,1) + - ".gmv"; + DataOut data_out; - DataOut data_out; + data_out.attach_dof_handler (dof_handler); + data_out.add_data_vector (solution, "solution"); + data_out.build_patches (); - data_out.attach_dof_handler (dof_handler); - data_out.add_data_vector (solution, "solution"); - data_out.build_patches (); - - std::ofstream output (filename.c_str()); - data_out.write_gmv (output); - } + std::ofstream output (filename.c_str()); + data_out.write_vtu (output); } diff --git a/examples/step-29/doc/results.dox b/examples/step-29/doc/results.dox index 9ff67525cf..6a8ad54a69 100644 --- a/examples/step-29/doc/results.dox +++ b/examples/step-29/doc/results.dox @@ -27,14 +27,14 @@ subsection Output parameters set Output file = solution # A name for the output format to be used - set Output format = gmv + set Output format = vtu end @endcode As can be seen, we set $d=0.3$, which amounts to a focus of the transducer lens at $x=0.5$, $y=0.3$. The coarse mesh is refined 5 times, -resulting in 160x160 cells, and the output is written in gmv +resulting in 160x160 cells, and the output is written in vtu format. The parameter reader understands many more parameters pertaining in particular to the generation of output, see the explanation in step-19, but we need none of these diff --git a/examples/step-29/step-29.cc b/examples/step-29/step-29.cc index d5e0f231e3..bf1789e42f 100644 --- a/examples/step-29/step-29.cc +++ b/examples/step-29/step-29.cc @@ -940,6 +940,8 @@ int main () using namespace dealii; using namespace Step29; + deallog.depth_console(5); + ParameterHandler prm; ParameterReader param(prm); param.read_parameters("step-29.prm"); diff --git a/examples/step-29/step-29.prm b/examples/step-29/step-29.prm index 13b589c477..d6c5f37ee8 100644 --- a/examples/step-29/step-29.prm +++ b/examples/step-29/step-29.prm @@ -24,5 +24,5 @@ subsection Output parameters set Output file = solution # A name for the output format to be used - set Output format = gmv + set Output format = vtu end