[cig-commits] [commit] master: Allow mesh refinement plugins to act on global refinement (106dbef)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Thu May 22 14:37:42 PDT 2014
Repository : https://github.com/geodynamics/aspect
On branch : master
Link : https://github.com/geodynamics/aspect/compare/ed597fcc4b080a5fc9996bae17d13c03a7f50490...0e27b7c369cb511e155009e072df3d409df9bc37
>---------------------------------------------------------------
commit 106dbef98637d75fa030cc327a766292d49fedc0
Author: Timo Heister <timo.heister at gmail.com>
Date: Thu May 22 16:32:49 2014 -0400
Allow mesh refinement plugins to act on global refinement
Instead of calling global_refine(n) we now flag all cells for refinement
and then allow the mesh refinement plugins to unflag the cells if
desired. This procedure needs to be repeated n times. If there is no
plugin that modifies the flags, it is equivalent to refine_global().
>---------------------------------------------------------------
106dbef98637d75fa030cc327a766292d49fedc0
doc/modules/changes.h | 5 ++
source/simulator/core.cc | 17 +++++-
.../global_refine_amr.cc | 68 +++++++++++++++-------
...x-first-time-step.prm => global_refine_amr.prm} | 5 +-
tests/global_refine_amr/screen-output | 61 +++++++++++++++++++
.../statistics | 2 +-
6 files changed, 133 insertions(+), 25 deletions(-)
diff --git a/doc/modules/changes.h b/doc/modules/changes.h
index 3c5064a..3a12d5e 100644
--- a/doc/modules/changes.h
+++ b/doc/modules/changes.h
@@ -5,6 +5,11 @@
* 1.0. All entries are signed with the names of the author. </p>
*
* <ol>
+ * <li> Mesh refinement plugins can now interact with initial global mesh
+ * refinement and unflag certain cells if desired.
+ * <br>
+ * (Timo Heister, 2014/05/22)
+ *
* <li> Fixed: We accidentally evaluated the viscosity of the material model
* from the place where we compute the adiabatic conditions, but this
* required information that we didn't have. This is also unnecessary
diff --git a/source/simulator/core.cc b/source/simulator/core.cc
index 582e786..47191e2 100644
--- a/source/simulator/core.cc
+++ b/source/simulator/core.cc
@@ -1531,7 +1531,22 @@ namespace aspect
}
else
{
- triangulation.refine_global (parameters.initial_global_refinement);
+ // Instead of calling global_refine(n) we flag all cells for
+ // refinement and then allow the mesh refinement plugins to unflag
+ // the cells if desired. This procedure is repeated n times. If there
+ // is no plugin that modifies the flags, it is equivalent to
+ // refine_global(n).
+ for (unsigned int n=0;n<parameters.initial_global_refinement;++n)
+ {
+ for (typename Triangulation<dim>::active_cell_iterator
+ cell = triangulation.begin_active();
+ cell != triangulation.end(); ++cell)
+ cell->set_refine_flag ();
+
+ mesh_refinement_manager.tag_additional_cells ();
+ triangulation.execute_coarsening_and_refinement();
+ }
+
global_volume = GridTools::volume (triangulation, mapping);
time = parameters.start_time;
diff --git a/include/aspect/mesh_refinement/minimum_refinement_function.h b/tests/global_refine_amr.cc
similarity index 61%
copy from include/aspect/mesh_refinement/minimum_refinement_function.h
copy to tests/global_refine_amr.cc
index c8c90c2..0af94c2 100644
--- a/include/aspect/mesh_refinement/minimum_refinement_function.h
+++ b/tests/global_refine_amr.cc
@@ -20,28 +20,18 @@
-#ifndef __aspect__mesh_refinement_minimum_refinement_function_h
-#define __aspect__mesh_refinement_minimum_refinement_function_h
-
#include <aspect/mesh_refinement/interface.h>
#include <aspect/simulator_access.h>
+#include <math.h>
+
+
+using namespace dealii;
-#include <deal.II/base/parsed_function.h>
namespace aspect
{
- namespace MeshRefinement
- {
-
- /**
- * A class that implements a minimum refinement level
- * based on a functional description provided in the
- * input file.
- *
- * @ingroup MeshRefinement
- */
- template <int dim>
- class MinimumRefinementFunction : public Interface<dim>,
+ template <int dim>
+ class AMRLeft : public MeshRefinement::Interface<dim>,
public SimulatorAccess<dim>
{
public:
@@ -70,12 +60,46 @@ namespace aspect
parse_parameters (ParameterHandler &prm);
private:
- /**
- * A function object representing the minimum refinement level.
- */
- Functions::ParsedFunction<1> min_refinement_level;
};
+
+
+ template <int dim>
+ void
+ AMRLeft<dim>::tag_additional_cells () const
+ {
+ std::cout << "plugin is called!" << std::endl;
+
+ for (typename Triangulation<dim>::active_cell_iterator
+ cell = this->get_triangulation().begin_active();
+ cell != this->get_triangulation().end(); ++cell)
+ {
+ if (cell->is_locally_owned() && cell->center()[0]<0.5)
+ cell->clear_refine_flag ();
+ }
+ }
+
+ template <int dim>
+ void
+ AMRLeft<dim>::
+ declare_parameters (ParameterHandler &prm)
+ {
+ }
+
+ template <int dim>
+ void
+ AMRLeft<dim>::parse_parameters (ParameterHandler &prm)
+ {
+ }
+
}
-}
-#endif
+
+
+
+// explicit instantiations
+namespace aspect
+{
+ ASPECT_REGISTER_MESH_REFINEMENT_CRITERION(AMRLeft,
+ "AMRLeft",
+ "TODO")
+}
diff --git a/tests/box-first-time-step.prm b/tests/global_refine_amr.prm
similarity index 95%
copy from tests/box-first-time-step.prm
copy to tests/global_refine_amr.prm
index 6abb18f..a49a772 100644
--- a/tests/box-first-time-step.prm
+++ b/tests/global_refine_amr.prm
@@ -51,7 +51,10 @@ end
subsection Mesh refinement
set Initial adaptive refinement = 0
- set Initial global refinement = 5
+ set Initial global refinement = 6
+ set Strategy = AMRLeft
+
+
end
diff --git a/tests/global_refine_amr/screen-output b/tests/global_refine_amr/screen-output
new file mode 100644
index 0000000..5508de5
--- /dev/null
+++ b/tests/global_refine_amr/screen-output
@@ -0,0 +1,61 @@
+-----------------------------------------------------------------------------
+-- This is ASPECT, the Advanced Solver for Problems in Earth's ConvecTion.
+-- . running in OPTIMIZED mode
+-- . running with 1 MPI process
+-- . using Trilinos
+-----------------------------------------------------------------------------
+
+Loading shared library <./libglobal_refine_amr.so>
+
+plugin is called!
+plugin is called!
+plugin is called!
+plugin is called!
+plugin is called!
+plugin is called!
+Number of active cells: 2,140 (on 7 levels)
+Number of degrees of freedom: 28,711 (17,646+2,242+8,823)
+
+*** Timestep 0: t=0 seconds
+ Solving temperature system... 0 iterations.
+ Rebuilding Stokes preconditioner...
+ Solving Stokes system... 18 iterations.
+
+ Postprocessing:
+
+ Reference density (kg/m^3): 1
+ Reference gravity (m/s^2): 1
+ Reference thermal expansion (1/K): 2e-05
+ Temperature contrast across model domain (K): 1
+ Model domain depth (m): 1
+ Reference thermal diffusivity (m^2/s): 8e-10
+ Reference viscosity (Pas): 1
+ Ra number: 25000
+ k_value: 1e-06
+ reference_cp: 1250
+ reference_thermal_diffusivity: 8e-10
+
+ Writing graphical output: output-global_refine_amr/solution-00000
+ RMS, max velocity: 7.71e-09 m/s, 2.57e-08 m/s
+ Temperature min/avg/max: 0 K, 1.038 K, 1.1 K
+ Heat fluxes through boundary parts: 1.748e-07 W, 0.0001602 W, 2.426e-07 W, 2.426e-07 W
+
+Termination requested by criterion: end time
+
+
++---------------------------------------------+------------+------------+
+| Total wallclock time elapsed since start | 0.625s | |
+| | | |
+| Section | no. calls | wall time | % of total |
++---------------------------------+-----------+------------+------------+
+| Assemble Stokes system | 1 | 0.0996s | 16% |
+| Assemble temperature system | 1 | 0.0515s | 8.2% |
+| Build Stokes preconditioner | 1 | 0.101s | 16% |
+| Build temperature preconditioner| 1 | 0.0164s | 2.6% |
+| Solve Stokes system | 1 | 0.0878s | 14% |
+| Solve temperature system | 1 | 0.00203s | 0.33% |
+| Initialization | 2 | 0.0428s | 6.9% |
+| Postprocessing | 1 | 0.131s | 21% |
+| Setup dof systems | 1 | 0.0759s | 12% |
++---------------------------------+-----------+------------+------------+
+
diff --git a/tests/box-first-time-step/statistics b/tests/global_refine_amr/statistics
similarity index 75%
copy from tests/box-first-time-step/statistics
copy to tests/global_refine_amr/statistics
index 129209e..5a8545e 100644
--- a/tests/box-first-time-step/statistics
+++ b/tests/global_refine_amr/statistics
@@ -17,4 +17,4 @@
# 17: Outward heat flux through boundary with indicator 1 (W)
# 18: Outward heat flux through boundary with indicator 2 (W)
# 19: Outward heat flux through boundary with indicator 3 (W)
-0 0.0000e+00 1024 9539 4225 0 20 4.7717e+05 output-box-first-time-step/solution-00000 9.02065615e-09 3.23527790e-08 0.00000000e+00 1.03532014e+00 1.10000000e+00 1.03532014e+00 1.66800424e-07 8.01668004e-05 2.40192611e-07 2.40192611e-07
+0 0.0000e+00 2140 19888 8823 0 18 3.0258e+05 output-global_refine_amr/solution-00000 7.71052448e-09 2.57225788e-08 0.00000000e+00 1.03792614e+00 1.10000000e+00 1.03792614e+00 1.74802589e-07 1.60166700e-04 2.42564104e-07 2.42564104e-07
More information about the CIG-COMMITS
mailing list