[cig-commits] [commit] master: Bugfix and add test (fdb6b2a)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Fri May 23 18:31:33 PDT 2014


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

On branch  : master
Link       : https://github.com/geodynamics/aspect/compare/194b6f932f6ee27aea14eb44c36aa5432a9cd235...e2d2428a203331b4832dbc4e5f4d716934c22694

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

commit fdb6b2a39d8b8aae965f16a81af63f26d9afa0f5
Author: Siqi Zhang <siqi.zhang at mq.edu.au>
Date:   Fri May 23 17:20:48 2014 -0500

    Bugfix and add test


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

fdb6b2a39d8b8aae965f16a81af63f26d9afa0f5
 include/aspect/postprocess/interface.h             | 54 ++++++++--------
 include/aspect/simulator_access.h                  | 18 ++++--
 tests/find_postprocess.cc                          | 74 ++++++++++++++++++++++
 ...ox-first-time-step.prm => find_postprocess.prm} |  6 +-
 tests/find_postprocess/screen-output               | 41 ++++++++++++
 tests/find_postprocess/statistics                  | 13 ++++
 6 files changed, 170 insertions(+), 36 deletions(-)

diff --git a/include/aspect/postprocess/interface.h b/include/aspect/postprocess/interface.h
index 8b5d6ed..8fa070e 100644
--- a/include/aspect/postprocess/interface.h
+++ b/include/aspect/postprocess/interface.h
@@ -200,16 +200,16 @@ namespace aspect
         std::list<std::pair<std::string,std::string> >
         execute (TableHandler &statistics);
 
-		/**
-		* Go through the list of all postprocessors that have been selected in
-		* the input file (and are consequently currently active) and see if
-		* one of them has the desired type specified by the template
-		* argument. If so, return a pointer to it. If no postprocessor is
+        /**
+        * Go through the list of all postprocessors that have been selected in
+        * the input file (and are consequently currently active) and see if
+        * one of them has the desired type specified by the template
+        * argument. If so, return a pointer to it. If no postprocessor is
         * active that matches the given type, return a NULL pointer.        
-		*/
-		template <typename PostprocessorType>
-		PostprocessorType *
-		find_postprocessor ();		
+        */
+        template <typename PostprocessorType>
+        PostprocessorType *
+        find_postprocessor () const;      
         
         /**
          * Declare the parameters of all known postprocessors, as well as of
@@ -324,27 +324,27 @@ namespace aspect
         (*p)->load (saved_text);
     }
 
-	/**
-	* Go through the list of all postprocessors that have been selected in
-	* the input file (and are consequently currently active) and see if
-	* one of them has the desired type specified by the template
-	* argument. If so, return a pointer to it. If no postprocessor is
+    /**
+    * Go through the list of all postprocessors that have been selected in
+    * the input file (and are consequently currently active) and see if
+    * one of them has the desired type specified by the template
+    * argument. If so, return a pointer to it. If no postprocessor is
     * active that matches the given type, return a NULL pointer.        
-	*/
-		
-	template <int dim>
-	template <typename PostprocessorType>
-	inline
-	PostprocessorType *
-	Manager<dim>::find_postprocessor ()
-	{
-		for (typename std::list<std_cxx1x::shared_ptr<Interface<dim> > >::iterator
+    */
+        
+    template <int dim>
+    template <typename PostprocessorType>
+    inline
+    PostprocessorType *
+    Manager<dim>::find_postprocessor () const
+    {
+        for (typename std::list<std_cxx1x::shared_ptr<Interface<dim> > >::const_iterator
              p = postprocessors.begin();
              p != postprocessors.end(); ++p)
-		  if (PostprocessorType x = dynamic_cast<PostprocessorType>(p->get())
-			return x;
-		return 0;
-	}		
+        if (PostprocessorType * x = dynamic_cast<PostprocessorType *> ( (*p).get()) )
+            return x;
+        return 0;
+    }       
         
     
     /**
diff --git a/include/aspect/simulator_access.h b/include/aspect/simulator_access.h
index 0e683e4..efd7539 100644
--- a/include/aspect/simulator_access.h
+++ b/include/aspect/simulator_access.h
@@ -404,7 +404,7 @@ namespace aspect
       get_compositional_initial_conditions () const;
 
       /**
-       * Return a set of boudary indicators that describes which of the
+       * Return a set of boundary indicators that describes which of the
        * boundaries have a fixed temperature.
        */
       const std::set<types::boundary_id> &
@@ -432,12 +432,9 @@ namespace aspect
        * Find a pointer to a certain postprocessor, if not return a NULL pointer.
        */
       template <typename PostprocessorType>
-      inline
       PostprocessorType *
-      SimulatorAccess<dim>::find_postprocessor ()
-      {
-          return simulator->postprocessors.find_postprocessor<PostprocessorType>();
-      }                                         
+      find_postprocessor () const;
+                                      
        /** @} */
 
     private:
@@ -446,6 +443,15 @@ namespace aspect
        */
       const Simulator<dim> *simulator;
   };
+
+  template <int dim>
+  template <typename PostprocessorType>
+  inline
+  PostprocessorType *
+  SimulatorAccess<dim>::find_postprocessor<PostprocessorType> () const
+  {
+    return simulator->postprocessors.find_postprocessor<PostprocessorType>();
+  } 
 }
 
 
diff --git a/tests/find_postprocess.cc b/tests/find_postprocess.cc
new file mode 100644
index 0000000..f7e1d74
--- /dev/null
+++ b/tests/find_postprocess.cc
@@ -0,0 +1,74 @@
+/*
+  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/>.
+*/
+
+
+#include <aspect/boundary_temperature/box.h>
+#include <aspect/geometry_model/box.h>
+#include <aspect/postprocess/heat_flux_statistics.h>
+#include <aspect/postprocess/pressure_statistics.h>
+#include <aspect/simulator_access.h>
+#include <aspect/simulator.h>
+
+#include <utility>
+#include <limits>
+
+
+namespace aspect
+{
+  namespace BoundaryTemperature
+  {
+    template <int dim>
+    class Box2 : public Box<dim>, public aspect::SimulatorAccess<dim>
+    {
+        public:
+        virtual void update();
+    };
+    template <int dim>
+    void Box2<dim>::update()
+    {
+
+        const Postprocess::HeatFluxStatistics<dim> * heat_flux_postprocess=
+        this->template find_postprocessor<const Postprocess::HeatFluxStatistics<dim> >();
+        const Postprocess::PressureStatistics<dim> * pressure_postprocess=
+            this->template find_postprocessor<const Postprocess::PressureStatistics<dim> >();
+        if(pressure_postprocess==NULL)
+          cout<<"PressureStatistics is not found!"<<endl;
+        else
+          cout<<"PressureStatistics is found!"<<endl;
+        if(heat_flux_postprocess==NULL)
+          cout<<"HeatFluxStatistics is not found!"<<endl;
+        else
+          cout<<"HeatFluxStatistics is found!"<<endl;         
+    }
+  }
+}
+
+// explicit instantiations
+namespace aspect
+{
+  namespace BoundaryTemperature
+  {
+    ASPECT_REGISTER_BOUNDARY_TEMPERATURE_MODEL(Box2,
+                                               "box2",
+                                               "A model in which the temperature is chosen constant on "
+                                               "all the sides of a box. For test")
+  }
+}
+  
diff --git a/tests/box-first-time-step.prm b/tests/find_postprocess.prm
similarity index 88%
copy from tests/box-first-time-step.prm
copy to tests/find_postprocess.prm
index f09526e..3d54c8a 100644
--- a/tests/box-first-time-step.prm
+++ b/tests/find_postprocess.prm
@@ -9,7 +9,7 @@ set Nonlinear solver scheme                = IMPES
 
 
 subsection Boundary temperature model
-  set Model name = box
+  set Model name = box2
 end
 
 
@@ -51,7 +51,7 @@ end
 
 subsection Mesh refinement
   set Initial adaptive refinement        = 0
-  set Initial global refinement          = 5
+  set Initial global refinement          = 3
 end
 
 
@@ -63,6 +63,6 @@ subsection Model settings
 end
 
 subsection Postprocess
-  set List of postprocessors = visualization, velocity statistics, basic statistics,  temperature statistics, heat flux statistics
+  set List of postprocessors =  heat flux statistics
 end
 
diff --git a/tests/find_postprocess/screen-output b/tests/find_postprocess/screen-output
new file mode 100644
index 0000000..f0818c8
--- /dev/null
+++ b/tests/find_postprocess/screen-output
@@ -0,0 +1,41 @@
+-----------------------------------------------------------------------------
+-- This is ASPECT, the Advanced Solver for Problems in Earth's ConvecTion.
+--     . running in DEBUG mode
+--     . running with 1 MPI process
+--     . using Trilinos
+-----------------------------------------------------------------------------
+
+Number of active cells: 64 (on 4 levels)
+Number of degrees of freedom: 948 (578+81+289)
+
+PressureStatistics is not found!
+HeatFluxStatistics is found!
+*** Timestep 0:  t=0 seconds
+PressureStatistics is not found!
+HeatFluxStatistics is found!
+   Solving temperature system... 0 iterations.
+   Rebuilding Stokes preconditioner...
+   Solving Stokes system... 14 iterations.
+
+   Postprocessing:
+     Heat fluxes through boundary parts: 1.688e-07 W, 2.017e-05 W, 2.43e-07 W, 2.43e-07 W
+
+Termination requested by criterion: end time
+
+
++---------------------------------------------+------------+------------+
+| Total wallclock time elapsed since start    |     0.374s |            |
+|                                             |            |            |
+| Section                         | no. calls |  wall time | % of total |
++---------------------------------+-----------+------------+------------+
+| Assemble Stokes system          |         1 |    0.0729s |        20% |
+| Assemble temperature system     |         1 |    0.0599s |        16% |
+| Build Stokes preconditioner     |         1 |    0.0579s |        15% |
+| Build temperature preconditioner|         1 |   0.00142s |      0.38% |
+| Solve Stokes system             |         1 |    0.0151s |         4% |
+| Solve temperature system        |         1 |   0.00117s |      0.31% |
+| Initialization                  |         2 |    0.0569s |        15% |
+| Postprocessing                  |         1 |   0.00487s |       1.3% |
+| Setup dof systems               |         1 |     0.062s |        17% |
++---------------------------------+-----------+------------+------------+
+
diff --git a/tests/find_postprocess/statistics b/tests/find_postprocess/statistics
new file mode 100644
index 0000000..c92c9cb
--- /dev/null
+++ b/tests/find_postprocess/statistics
@@ -0,0 +1,13 @@
+# 1: Time step number
+# 2: Time (seconds)
+# 3: Number of mesh cells
+# 4: Number of Stokes degrees of freedom
+# 5: Number of temperature degrees of freedom
+# 6: Iterations for temperature solver
+# 7: Iterations for Stokes solver
+# 8: Time step size (seconds)
+# 9: Outward heat flux through boundary with indicator 0 (W)
+# 10: Outward heat flux through boundary with indicator 1 (W)
+# 11: Outward heat flux through boundary with indicator 2 (W)
+# 12: Outward heat flux through boundary with indicator 3 (W)
+0 0.0000e+00 64 659 289 0 14 7.4987e+05 1.68781124e-07 2.01687811e-05 2.43044819e-07 2.43044819e-07 



More information about the CIG-COMMITS mailing list