[cig-commits] [commit] master: Add a function heating model. set_current_time now gets called at the beginning of a new timestep. (fb5666d)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Fri May 16 18:39:36 PDT 2014


Repository : https://github.com/geodynamics/aspect

On branch  : master
Link       : https://github.com/geodynamics/aspect/compare/7b658caa05d489ae3f8d61b8049b015e7be94f77...cc43d3ac6f571573118eb54c2103bf92dfe8355f

>---------------------------------------------------------------

commit fb5666dfad047309f5678c52966cda15d43e333b
Author: Rene Gassmoeller <R.Gassmoeller at mailbox.org>
Date:   Fri May 16 10:32:07 2014 -0500

    Add a function heating model. set_current_time now gets called at the beginning of a new timestep.


>---------------------------------------------------------------

fb5666dfad047309f5678c52966cda15d43e333b
 .../function.h                                     |  27 ++---
 source/heating_model/function.cc                   | 118 +++++++++++++++++++++
 source/simulator/core.cc                           |   1 +
 3 files changed, 133 insertions(+), 13 deletions(-)

diff --git a/include/aspect/velocity_boundary_conditions/function.h b/include/aspect/heating_model/function.h
similarity index 76%
copy from include/aspect/velocity_boundary_conditions/function.h
copy to include/aspect/heating_model/function.h
index bf61096..0e35ee2 100644
--- a/include/aspect/velocity_boundary_conditions/function.h
+++ b/include/aspect/heating_model/function.h
@@ -20,25 +20,25 @@
 /*  $Id$  */
 
 
-#ifndef __aspect__velocity_boundary_conditions_function_h
-#define __aspect__velocity_boundary_conditions_function_h
+#ifndef __aspect__heating_model_function_h
+#define __aspect__heating_model_function_h
 
-#include <aspect/velocity_boundary_conditions/interface.h>
+#include <aspect/heating_model/interface.h>
 #include <aspect/simulator_access.h>
 
 #include <deal.II/base/parsed_function.h>
 
 namespace aspect
 {
-  namespace VelocityBoundaryConditions
+  namespace HeatingModel
   {
     using namespace dealii;
 
     /**
-     * A class that implements velocity boundary conditions based on a
+     * A class that implements a heating model based on a
      * functional description provided in the input file.
      *
-     * @ingroup VelocityBoundaryConditionsModels
+     * @ingroup HeatingModels
      */
     template <int dim>
     class Function : public Interface<dim>, public SimulatorAccess<dim>
@@ -50,17 +50,18 @@ namespace aspect
         Function ();
 
         /**
-         * Return the boundary velocity as a function of position. For the
-         * current class, this function obviously simply returns a zero
-         * tensor.
+         * Return the specific heating rate.
          */
         virtual
-        Tensor<1,dim>
-        boundary_velocity (const Point<dim> &position) const;
+        double
+        specific_heating_rate (const double,
+                               const double,
+                               const std::vector<double> &,
+                               const Point<dim> &) const;
 
         /**
          * A function that is called at the beginning of each time step to
-         * indicate what the model time is for which the boundary values will
+         * indicate what the model time is for which the heating rate will
          * next be evaluated. For the current class, the function passes to
          * the parsed function what the current time is.
          */
@@ -92,7 +93,7 @@ namespace aspect
         /**
          * A function object representing the components of the velocity.
          */
-        Functions::ParsedFunction<dim> boundary_velocity_function;
+        Functions::ParsedFunction<dim> heating_model_function;
     };
   }
 }
diff --git a/source/heating_model/function.cc b/source/heating_model/function.cc
new file mode 100644
index 0000000..213bce0
--- /dev/null
+++ b/source/heating_model/function.cc
@@ -0,0 +1,118 @@
+/*
+  Copyright (C) 2011 - 2014 by the authors of the ASPECT code.
+
+  This file is part of ASPECT.
+
+  ASPECT is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2, or (at your option)
+  any later version.
+
+  ASPECT is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with ASPECT; see the file doc/COPYING.  If not see
+  <http://www.gnu.org/licenses/>.
+*/
+/*  $Id$  */
+
+
+#include <aspect/heating_model/function.h>
+#include <aspect/global.h>
+
+namespace aspect
+{
+  namespace HeatingModel
+  {
+    template <int dim>
+    Function<dim>::Function ()
+      :
+      heating_model_function (1)
+    {}
+
+
+
+    template <int dim>
+    double
+    Function<dim>::
+    specific_heating_rate (const double,
+        const double,
+        const std::vector<double> &,
+        const Point<dim> &p) const
+    {
+      return heating_model_function.value(p);
+    }
+
+
+    template <int dim>
+    void
+    Function<dim>::set_current_time (const double time)
+    {
+      // we get time passed as seconds (always) but may want
+      // to reinterpret it in years
+      if (this->convert_output_to_years())
+        heating_model_function.set_time (time / year_in_seconds);
+      else
+        heating_model_function.set_time (time);
+    }
+
+
+    template <int dim>
+    void
+    Function<dim>::declare_parameters (ParameterHandler &prm)
+    {
+      prm.enter_subsection("Heating model");
+      {
+        prm.enter_subsection("Function");
+        {
+          Functions::ParsedFunction<dim>::declare_parameters (prm, dim);
+        }
+        prm.leave_subsection();
+      }
+      prm.leave_subsection();
+    }
+
+
+    template <int dim>
+    void
+    Function<dim>::parse_parameters (ParameterHandler &prm)
+    {
+      prm.enter_subsection("Heating model");
+      {
+        prm.enter_subsection("Function");
+        {
+          heating_model_function.parse_parameters (prm);
+        }
+        prm.leave_subsection();
+      }
+      prm.leave_subsection();
+    }
+
+  }
+}
+
+// explicit instantiations
+namespace aspect
+{
+  namespace HeatingModel
+  {
+    ASPECT_REGISTER_HEATING_MODEL(Function,
+                                                 "function",
+                                                 "Implementation of a model in which the heating "
+                                                 "rate is given in terms of an explicit formula "
+                                                 "that is elaborated in the parameters in section "
+                                                 "``Heating model|Function''. "
+                                                 "\n\n"
+                                                 "The formula is interpreted as having units "
+                                                 "W/kg."
+                                                 "\n\n"
+                                                 "Since the symbol $t$ indicating time "
+                                                 "may appear in the formulas for the heating rate"
+                                                 ", it is interpreted as having units "
+                                                 "seconds unless the global parameter ``Use "
+                                                 "years in output instead of seconds'' is set.")
+  }
+}
diff --git a/source/simulator/core.cc b/source/simulator/core.cc
index f47c3a2..1b39c20 100644
--- a/source/simulator/core.cc
+++ b/source/simulator/core.cc
@@ -550,6 +550,7 @@ namespace aspect
     // notify different system components that we started the next time step
     material_model->update();
     gravity_model->update();
+    heating_model->set_current_time(time);
   }
 
 



More information about the CIG-COMMITS mailing list