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

dealii.demon at gmail.com dealii.demon at gmail.com
Mon Sep 23 09:15:20 PDT 2013


Revision 1907

Insert r1623.

U   trunk/aspire/include/aspect/simulator.h
A   trunk/aspire/include/aspect/termination_criteria/end_time.h
U   trunk/aspire/source/simulator/core.cc
U   trunk/aspire/source/simulator/parameters.cc
A   trunk/aspire/source/termination_criteria/end_time.cc


http://www.dealii.org/websvn/revision.php?repname=Aspect+Repository&path=%2F&rev=1907&peg=1907

Diff:
Modified: trunk/aspire/include/aspect/simulator.h
===================================================================
--- trunk/aspire/include/aspect/simulator.h	2013-09-23 15:44:48 UTC (rev 1906)
+++ trunk/aspire/include/aspect/simulator.h	2013-09-23 16:15:08 UTC (rev 1907)
@@ -160,7 +160,6 @@
 
         bool                           resume_computation;
         double                         start_time;
-        double                         end_time;
         double                         time_step;
         double                         CFL_number;
         bool                           use_conduction_timestep;

Added: trunk/aspire/include/aspect/termination_criteria/end_time.h
===================================================================
--- trunk/aspire/include/aspect/termination_criteria/end_time.h	                        (rev 0)
+++ trunk/aspire/include/aspect/termination_criteria/end_time.h	2013-09-23 16:15:08 UTC (rev 1907)
@@ -0,0 +1,74 @@
+/*
+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/>.
+*/
+/* $Id$ */
+ 
+ 
+#ifndef __aspect__termination_criteria_end_time_h
+#define __aspect__termination_criteria_end_time_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 time
+     * is reached.
+     *
+     * @ingroup TerminationCriteria
+     */
+    template <int dim>
+    class EndTime : 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:
+        double end_time;
+    };
+  }
+}
+ 
+#endif

Modified: trunk/aspire/source/simulator/core.cc
===================================================================
--- trunk/aspire/source/simulator/core.cc	2013-09-23 15:44:48 UTC (rev 1906)
+++ trunk/aspire/source/simulator/core.cc	2013-09-23 16:15:08 UTC (rev 1907)
@@ -1186,7 +1186,6 @@
         // the execution; the second indicates whether to do one
         // more checkpoint
         std::pair<bool,bool> termination = termination_manager.execute();
-        termination.first |= (time >= parameters.end_time);
         
         // periodically generate snapshots so that we can resume here
         // if the program aborts or is terminated

Modified: trunk/aspire/source/simulator/parameters.cc
===================================================================
--- trunk/aspire/source/simulator/parameters.cc	2013-09-23 15:44:48 UTC (rev 1906)
+++ trunk/aspire/source/simulator/parameters.cc	2013-09-23 16:15:08 UTC (rev 1907)
@@ -56,11 +56,6 @@
                        "The start time of the simulation. Units: years if the "
                        "'Use years in output instead of seconds' parameter is set; "
                        "seconds otherwise.");
-    prm.declare_entry ("End time", "1e8",
-                       Patterns::Double (),
-                       "The end time of the simulation. Units: years if the "
-                       "'Use years in output instead of seconds' parameter is set; "
-                       "seconds otherwise.");
     prm.declare_entry ("Time step", "1.0",
                        Patterns::Double (),
                        "The size of the time step of the simulation.");
@@ -426,7 +421,6 @@
       AssertThrow (false, ExcNotImplemented());
     
     start_time              = prm.get_double ("Start time");
-    end_time                = prm.get_double ("End time");
     time_step               = prm.get_double ("Time step");
 
     output_directory        = prm.get ("Output directory");

Added: trunk/aspire/source/termination_criteria/end_time.cc
===================================================================
--- trunk/aspire/source/termination_criteria/end_time.cc	                        (rev 0)
+++ trunk/aspire/source/termination_criteria/end_time.cc	2013-09-23 16:15:08 UTC (rev 1907)
@@ -0,0 +1,76 @@
+/*
+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/>.
+*/
+/* $Id$ */
+ 
+ 
+#include <aspect/termination_criteria/end_time.h>
+ 
+namespace aspect
+{
+  namespace TerminationCriteria
+  {
+    template <int dim>
+    bool
+    EndTime<dim>::execute()
+    {
+      return (this->get_time() >= end_time);
+    }
+ 
+    template <int dim>
+    void
+    EndTime<dim>::declare_parameters (ParameterHandler &prm)
+    {
+      prm.declare_entry ("End time", "1e300",
+                         Patterns::Double (),
+                         "The end time of the simulation. Units: years if the "
+                         "'Use years in output instead of seconds' parameter is set; "
+                         "seconds otherwise.");
+    }
+ 
+ 
+    template <int dim>
+    void
+    EndTime<dim>::parse_parameters (ParameterHandler &prm)
+    {
+      // read end time from parameter file. if it is to be interpreted
+      // in years rather than seconds, then do the conversion
+      end_time = prm.get_double ("End time");
+    }
+  }
+}
+ 
+// explicit instantiations
+namespace aspect
+{
+  namespace TerminationCriteria
+  {
+    ASPECT_REGISTER_TERMINATION_CRITERION(EndTime,
+                                          "end_time",
+                                          "Terminate the simulation once the end time "
+                                          "specified in the input file has been reached. "
+                                          "Unlike all other termination criteria, this "
+                                          "criterion is \textit{always} active, whether it "
+                                          "has been explicitly selected or not in the input file "
+                                          "(this is done to preserve historical behavior of "
+                                          "\aspect{}, but it also likely does not inconvenience "
+                                          "anyone since it is what would be selected in most "
+                                          "cases anyway).")
+  }
+}


More information about the CIG-COMMITS mailing list