[cig-commits] commit by heien to /var/svn/dealii/aspect

dealii.demon at gmail.com dealii.demon at gmail.com
Wed Jul 3 16:49:30 PDT 2013


Revision 1816

Added end step termination criterion

U   trunk/aspect/doc/modules/changes.h
A   trunk/aspect/include/aspect/termination_criteria/end_step.h
A   trunk/aspect/source/termination_criteria/end_step.cc


Diff:
Modified: trunk/aspect/doc/modules/changes.h
===================================================================
--- trunk/aspect/doc/modules/changes.h	2013-07-02 10:32:35 UTC (rev 1815)
+++ trunk/aspect/doc/modules/changes.h	2013-07-03 23:48:56 UTC (rev 1816)
@@ -8,6 +8,11 @@
 </p>
 
 <ol>
+  <li>Added: ability to terminate simulation after
+  specified number of steps.
+  <br>
+  (Ted Studley, 2013/07/03)
+
   <li>Added: new initial conditions for the Box geometry
   to test different shaped inclusions.
   <br>

Added: trunk/aspect/include/aspect/termination_criteria/end_step.h
===================================================================
--- trunk/aspect/include/aspect/termination_criteria/end_step.h	                        (rev 0)
+++ trunk/aspect/include/aspect/termination_criteria/end_step.h	2013-07-03 23:48:56 UTC (rev 1816)
@@ -0,0 +1,72 @@
+/*
+  Copyright (C) 2011, 2012 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/>.
+*/
+
+#ifndef __aspect__termination_criteria_end_step_h
+#define __aspect__termination_criteria_end_step_h
+
+#include <aspect/termination_criteria/interface.h>
+#include <aspect/simulator.h>
+
+namespace aspect
+{
+  namespace TerminationCriteria
+  {
+
+    /**
+     * A class that terminates the simulation when a specified end timestep
+     * is reached.
+     *
+     * @ingroup TerminationCriteria
+     */
+    template <int dim>
+    class EndStep : public Interface<dim>, public SimulatorAccess<dim>
+    {
+      public:
+        /**
+         * Evaluate this termination criterion.
+         *
+         * @return Whether to terminate the simulation (true) or continue (false).
+         */
+        virtual
+        bool
+        execute (void);
+
+        /**
+         * Declare the parameters this class takes through input files.
+         */
+        static
+        void
+        declare_parameters (ParameterHandler &prm);
+
+        /**
+         * Read the parameters this class declares from the parameter
+         * file.
+         */
+        virtual
+        void
+        parse_parameters (ParameterHandler &prm);
+
+      private:
+        unsigned int end_step;
+    };
+  }
+}
+
+#endif

Added: trunk/aspect/source/termination_criteria/end_step.cc
===================================================================
--- trunk/aspect/source/termination_criteria/end_step.cc	                        (rev 0)
+++ trunk/aspect/source/termination_criteria/end_step.cc	2013-07-03 23:48:56 UTC (rev 1816)
@@ -0,0 +1,71 @@
+/*
+  Copyright (C) 2011, 2012 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/>.
+*/
+
+#include <aspect/termination_criteria/end_step.h>
+
+namespace aspect
+{
+  namespace TerminationCriteria
+  {
+    template <int dim>
+    bool
+    EndStep<dim>::execute()
+    {
+      return (this->get_timestep_number () > end_step);
+    }
+
+    template <int dim>
+    void
+    EndStep<dim>::declare_parameters (ParameterHandler &prm)
+    {
+      prm.enter_subsection("Termination criteria");
+      {
+        prm.declare_entry ("End step", "100",
+                           Patterns::Integer (0),
+                           "Terminate the simulation once the specified timestep has been reached.");
+      }
+      prm.leave_subsection ();
+    }
+
+
+    template <int dim>
+    void
+    EndStep<dim>::parse_parameters (ParameterHandler &prm)
+    {
+      prm.enter_subsection("Termination criteria");
+      {
+        end_step = prm.get_integer ("End step");
+      }
+      prm.leave_subsection ();
+    }
+  }
+}
+
+// explicit instantiations
+namespace aspect
+{
+  namespace TerminationCriteria
+  {
+    ASPECT_REGISTER_TERMINATION_CRITERION(EndStep,
+                                          "end step",
+                                          "Terminate the simulation once the specified timestep"
+                                          "has been reached. ")
+  }
+}


More information about the CIG-COMMITS mailing list