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

dealii.demon at gmail.com dealii.demon at gmail.com
Mon Nov 25 06:07:19 PST 2013


Revision 2050

Take over the first part of r1679 from Juliane's branch: always refine toward the surface.

U   trunk/aspect/doc/modules/changes.h
A   trunk/aspect/include/aspect/mesh_refinement/topography.h
A   trunk/aspect/source/mesh_refinement/topography.cc


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

Diff:
Modified: trunk/aspect/doc/modules/changes.h
===================================================================
--- trunk/aspect/doc/modules/changes.h	2013-11-25 01:11:33 UTC (rev 2049)
+++ trunk/aspect/doc/modules/changes.h	2013-11-25 14:06:39 UTC (rev 2050)
@@ -8,6 +8,11 @@
 </p>
 
 <ol>
+  <li>New: There is now a refinement criterion "topography" that makes sure
+  the mesh is always refined at the surface of the domain.
+  <br>
+  (Juliane Dannberg 2013/11/24)
+
   <li>Fixed: When using compressible models with nonlinear iterations
   such as "Stokes", "iterated IMPES" or "iterated Stokes" and prescribed
   boundary values, there were numerous bugs that should now be fixed.
@@ -44,7 +49,7 @@
   <br>
   (Timo Heister 2013/10/28)
 
-  <li>Fixed: moved particle generation to a class, changed particle 
+  <li>Fixed: moved particle generation to a class, changed particle
   integration and generation to be factory patterned classes. There
   should be no effect on the user but this will allow for easier
   extension of particle functionality in the future.

Copied: trunk/aspect/include/aspect/mesh_refinement/topography.h (from rev 1679, branches/j-dannberg/include/aspect/mesh_refinement/topography.h)
===================================================================
--- trunk/aspect/include/aspect/mesh_refinement/topography.h	                        (rev 0)
+++ trunk/aspect/include/aspect/mesh_refinement/topography.h	2013-11-25 14:06:39 UTC (rev 2050)
@@ -0,0 +1,63 @@
+/*
+  Copyright (C) 2013 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: composition.h 1433 2012-12-08 08:24:55Z bangerth $  */
+
+
+#ifndef __aspect__mesh_refinement_topography_h
+#define __aspect__mesh_refinement_topography_h
+
+#include <aspect/mesh_refinement/interface.h>
+#include <aspect/simulator_access.h>
+
+namespace aspect
+{
+  namespace MeshRefinement
+  {
+
+    /**
+     * A class that implements a mesh refinement criterion that
+     * refines the mesh in the uppermost nodes. This is useful
+     * for cases where one wants to accurately model processes
+     * at of close to the surface of the model.
+     *
+     * @ingroup MeshRefinement
+     */
+    template <int dim>
+    class Topography : public Interface<dim>,
+      public SimulatorAccess<dim>
+    {
+      public:
+        /**
+         * Execute this mesh refinement criterion.
+         *
+         * @param[out] error_indicators A vector that for every active
+         * cell of the current mesh
+         * (which may be a partition of a distributed mesh) provides an error
+         * indicator. This vector will already have the correct size when the
+         * function is called.
+         */
+        virtual
+        void
+        execute (Vector<float> &error_indicators) const;
+    };
+  }
+}
+
+#endif

Copied: trunk/aspect/source/mesh_refinement/topography.cc (from rev 1679, branches/j-dannberg/source/mesh_refinement/topography.cc)
===================================================================
--- trunk/aspect/source/mesh_refinement/topography.cc	                        (rev 0)
+++ trunk/aspect/source/mesh_refinement/topography.cc	2013-11-25 14:06:39 UTC (rev 2050)
@@ -0,0 +1,91 @@
+/*
+  Copyright (C) 2013 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: composition.cc 1437 2012-12-08 12:02:49Z bangerth $  */
+
+
+#include <aspect/mesh_refinement/topography.h>
+
+#include <deal.II/base/quadrature_lib.h>
+#include <deal.II/numerics/error_estimator.h>
+#include <deal.II/fe/fe_values.h>
+
+namespace aspect
+{
+  namespace MeshRefinement
+  {
+    template <int dim>
+    void
+    Topography<dim>::execute(Vector<float> &indicators) const
+    {
+      // For calculating surface topography in the respective postprocessor
+      // we use the pressure in the middle of the cell. Thus, to get an
+      // accurate result, all the cells at the upper boundary should have
+      // the same level of refinement. This postprocessor causes a refinement
+      // in the upermost cells, which also makes sure that the upper
+      // boundary layer is resolved as good as possible.
+
+      indicators = 0;
+
+      // need quadrature formula to calculate the depth
+      // evaluate a single point per cell
+      const QMidpoint<dim> quadrature_formula;
+
+      FEValues<dim> fe_values (this->get_mapping(),
+                               this->get_fe(),
+                               quadrature_formula,
+                               update_quadrature_points |
+                               update_JxW_values);
+
+      // iterate over all of the cells and choose the ones at the upper
+      // boundary for refinement (assign the largest error to them)
+      typename DoFHandler<dim>::active_cell_iterator
+      cell = this->get_dof_handler().begin_active(),
+      endc = this->get_dof_handler().end();
+      unsigned int i=0;
+      for (; cell!=endc; ++cell, ++i)
+        if (cell->is_locally_owned())
+        {
+          fe_values.reinit (cell);
+          const double depth = this->get_geometry_model().depth(fe_values.quadrature_point(0));
+          if (cell->at_boundary() && depth < cell->diameter())
+            indicators(i) = 1.0;
+        }
+    }
+  }
+}
+
+// explicit instantiations
+namespace aspect
+{
+  namespace MeshRefinement
+  {
+    ASPECT_REGISTER_MESH_REFINEMENT_CRITERION(Topography,
+                                              "topography",
+                                              "A class that implements a mesh refinement criterion, which "
+                                              "always flags all cells in the uppermost layer for refinement. "
+					      "This is useful to provide high accuracy for processes at or "
+					      "close to the surface."
+					      "

"
+					      "To use this refinement criterion, you may want to combine "
+					      "it with other refinement criteria, setting the 'Normalize "
+					      "individual refinement criteria' flag and using the 'max' "
+					      "setting for 'Refinement criteria merge operation'.")
+  }
+}


More information about the CIG-COMMITS mailing list