[cig-commits] [commit] master: output velocity solution in m/years if needed (8a7c3bb)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Wed Jun 4 12:47:37 PDT 2014
Repository : https://github.com/geodynamics/aspect
On branch : master
Link : https://github.com/geodynamics/aspect/compare/dea94ae3fdac1f434e32718c384fe5ce83109802...db7eea299d721e7afa2dc72d8f42352dc88a9e16
>---------------------------------------------------------------
commit 8a7c3bbe2fecdefe25bf05c35d70975011cb9288
Author: Timo Heister <timo.heister at gmail.com>
Date: Sun Jun 1 19:36:14 2014 -0400
output velocity solution in m/years if needed
>---------------------------------------------------------------
8a7c3bbe2fecdefe25bf05c35d70975011cb9288
doc/modules/changes.h | 6 +++
source/postprocess/visualization.cc | 88 ++++++++++++++++++++++++++++++-------
2 files changed, 77 insertions(+), 17 deletions(-)
diff --git a/doc/modules/changes.h b/doc/modules/changes.h
index 6a28d63..1afc129 100644
--- a/doc/modules/changes.h
+++ b/doc/modules/changes.h
@@ -7,5 +7,11 @@
*
* <ol>
*
+ * <li> Fixed: When setting "Use years in output instead of seconds" the
+ * velocity solution is now exported in m/year instead of m/s in visualization
+ * files.
+ * <br>
+ * (Timo Heister, 2014/06/02)
+ *
* </ol>
*/
diff --git a/source/postprocess/visualization.cc b/source/postprocess/visualization.cc
index 81b0538..a21b628 100644
--- a/source/postprocess/visualization.cc
+++ b/source/postprocess/visualization.cc
@@ -38,8 +38,73 @@ namespace aspect
{
namespace Postprocess
{
+ namespace internal
+ {
+ /**
+ * This Postprocessor will generate the output variables of velocity,
+ * pressure, temperature, and compositional fields. They can not be added
+ * directly if the velocity needs to be converted from m/s to m/year, so
+ * this is what this class does.
+ */
+ template <int dim>
+ class BaseVariablePostprocessor: public DataPostprocessor< dim >, public SimulatorAccess<dim>
+ {
+ public:
+ virtual
+ void
+ compute_derived_quantities_vector (const std::vector<Vector<double> > &uh,
+ const std::vector<std::vector<Tensor<1,dim> > > &duh,
+ const std::vector<std::vector<Tensor<2,dim> > > &dduh,
+ const std::vector<Point<dim> > &normals,
+ const std::vector<Point<dim> > &evaluation_points,
+ std::vector<Vector<double> > &computed_quantities) const
+ {
+ const double velocity_scaling_factor =
+ this->convert_output_to_years() ? year_in_seconds : 1.0;
+ const unsigned int n_q_points = uh.size();
+ for (unsigned int q=0;q<n_q_points;++q)
+ for (unsigned int i=0;i<computed_quantities.size();++i)
+ computed_quantities[q][i]=uh[q][i] * ((i < dim) ? velocity_scaling_factor : 1.0);
+ }
+
+ virtual std::vector<std::string> get_names () const
+ {
+ std::vector<std::string> solution_names (dim, "velocity");
+ solution_names.push_back ("p");
+ solution_names.push_back ("T");
+ for (unsigned int c=0; c<this->n_compositional_fields(); ++c)
+ solution_names.push_back (this->introspection().name_for_compositional_index(c));
+
+ return solution_names;
+ }
+
+ virtual
+ std::vector<DataComponentInterpretation::DataComponentInterpretation>
+ get_data_component_interpretation () const
+ {
+ std::vector<DataComponentInterpretation::DataComponentInterpretation>
+ interpretation (dim,
+ DataComponentInterpretation::component_is_part_of_vector);
+ interpretation.push_back (DataComponentInterpretation::component_is_scalar);
+ interpretation.push_back (DataComponentInterpretation::component_is_scalar);
+ for (unsigned int c=0; c<this->n_compositional_fields(); ++c)
+ interpretation.push_back (DataComponentInterpretation::component_is_scalar);
+
+ return interpretation;
+ }
+
+ virtual UpdateFlags get_needed_update_flags () const
+ {
+ return update_values;
+ }
+ };
+ }
+
+
namespace VisualizationPostprocessors
{
+
+
template <int dim>
Interface<dim>::~Interface ()
{}
@@ -120,6 +185,9 @@ namespace aspect
return std::pair<std::string,std::string>();
+ internal::BaseVariablePostprocessor<dim> base_variables;
+ dynamic_cast<SimulatorAccess<dim>*>(&base_variables)->initialize(this->get_simulator());
+
// create a DataOut object on the heap; ownership of this
// object will later be transferred to a different thread
// that will write data in the background. the other thread
@@ -127,25 +195,11 @@ namespace aspect
DataOut<dim> data_out;
data_out.attach_dof_handler (this->get_dof_handler());
- // add the primary variables
- std::vector<std::string> solution_names (dim, "velocity");
- solution_names.push_back ("p");
- solution_names.push_back ("T");
- for (unsigned int c=0; c<this->n_compositional_fields(); ++c)
- solution_names.push_back (this->introspection().name_for_compositional_index(c));
-
- std::vector<DataComponentInterpretation::DataComponentInterpretation>
- interpretation (dim,
- DataComponentInterpretation::component_is_part_of_vector);
- interpretation.push_back (DataComponentInterpretation::component_is_scalar);
- interpretation.push_back (DataComponentInterpretation::component_is_scalar);
- for (unsigned int c=0; c<this->n_compositional_fields(); ++c)
- interpretation.push_back (DataComponentInterpretation::component_is_scalar);
+
data_out.add_data_vector (this->get_solution(),
- solution_names,
- DataOut<dim>::type_dof_data,
- interpretation);
+ base_variables);
+
// then for each additional selected output variable
// add the computed quantity as well. keep a list of
More information about the CIG-COMMITS
mailing list