[cig-commits] commit: Make viscosity coarsening work. Improves convergence with large
Mercurial
hg at geodynamics.org
Sat Mar 12 05:37:01 PST 2011
changeset: 111:5816f25e3c94
user: Walter Landry <wlandry at caltech.edu>
date: Thu Mar 10 16:19:05 2011 -0800
files: Cell_Viscosity_Coarsen.C Cell_Viscosity_Coarsen.h Edge_Viscosity_Coarsen.C Edge_Viscosity_Coarsen.h FACStokes.h FACStokes/solveStokes.C input/shear_corner.input main.C wscript
description:
Make viscosity coarsening work. Improves convergence with large
viscosity variations.
diff -r 351b8d159b53 -r 5816f25e3c94 Cell_Viscosity_Coarsen.C
--- a/Cell_Viscosity_Coarsen.C Wed Mar 09 00:23:36 2011 -0800
+++ b/Cell_Viscosity_Coarsen.C Thu Mar 10 16:19:05 2011 -0800
@@ -55,13 +55,25 @@ void SAMRAI::geom::Cell_Viscosity_Coarse
coarse.getPatchGeometry();
hier::Index ip(1,0), jp(0,1);
- for(int j=coarse_box.lower(1); j<=coarse_box.upper(1)+1; ++j)
- for(int i=coarse_box.lower(0); i<=coarse_box.upper(0)+1; ++i)
+ for(int j=coarse_box.lower(1); j<=coarse_box.upper(1); ++j)
+ for(int i=coarse_box.lower(0); i<=coarse_box.upper(0); ++i)
{
pdat::CellIndex coarse_cell(hier::Index(i,j));
+
(*cell_viscosity_coarse)(coarse_cell)=
viscosity_coarsen(*cell_viscosity_fine,*edge_viscosity_fine,
coarse_cell*2+ip+jp);
+
+ tbox::plog << "Cell "
+ << coarse_box.lower(0) << " "
+ << coarse_box.upper(0) << " "
+ << coarse_box.lower(1) << " "
+ << coarse_box.upper(1) << " "
+ << i << " "
+ << j << " "
+ << (*cell_viscosity_coarse)(coarse_cell) << " "
+ << "\n";
+
}
}
diff -r 351b8d159b53 -r 5816f25e3c94 Cell_Viscosity_Coarsen.h
--- a/Cell_Viscosity_Coarsen.h Wed Mar 09 00:23:36 2011 -0800
+++ b/Cell_Viscosity_Coarsen.h Thu Mar 10 16:19:05 2011 -0800
@@ -19,7 +19,7 @@
#include "SAMRAI/hier/IntVector.h"
#include "SAMRAI/hier/Patch.h"
#include "SAMRAI/tbox/Pointer.h"
-#include "SAMRAI/pdat/SideVariable.h"
+#include "SAMRAI/pdat/CellVariable.h"
#include <string>
@@ -57,7 +57,7 @@ public:
virtual ~Cell_Viscosity_Coarsen(){}
/**
- * Return true if the variable and name std::string match the side-centered
+ * Return true if the variable and name std::string match the cell-centered
* double weighted averaging; otherwise, return false.
*/
@@ -66,7 +66,7 @@ public:
{
TBOX_DIM_ASSERT_CHECK_ARGS2(*this, *var);
- const tbox::Pointer<pdat::SideVariable<double> > cast_var(var);
+ const tbox::Pointer<pdat::CellVariable<double> > cast_var(var);
if (!cast_var.isNull() && (op_name == d_name_id)) {
return true;
} else {
@@ -83,7 +83,7 @@ public:
}
/**
- * The priority of side-centered double weighted averaging is 0.
+ * The priority of cell-centered double weighted averaging is 0.
* It will be performed before any user-defined coarsen operations.
*/
int getOperatorPriority() const
@@ -102,7 +102,7 @@ public:
/**
* Coarsen the source component on the fine patch to the destination
- * component on the coarse patch using the side-centered double weighted
+ * component on the coarse patch using the cell-centered double weighted
* averaging operator. Coarsening is performed on the intersection of
* the destination patch and the coarse box. It is assumed that the
* fine patch contains sufficient data for the stencil width of the
diff -r 351b8d159b53 -r 5816f25e3c94 Edge_Viscosity_Coarsen.C
--- a/Edge_Viscosity_Coarsen.C Wed Mar 09 00:23:36 2011 -0800
+++ b/Edge_Viscosity_Coarsen.C Thu Mar 10 16:19:05 2011 -0800
@@ -26,18 +26,6 @@
#include "viscosity_coarsen.h"
using namespace SAMRAI;
-
-inline void coarsen_v(const pdat::SideIndex &coarse,
- const hier::Index &ip, const hier::Index &jp,
- tbox::Pointer<pdat::SideData<double> > &v,
- tbox::Pointer<pdat::SideData<double> > &v_fine )
-{
- pdat::SideIndex center(coarse*2);
- (*v)(coarse)=((*v_fine)(center) + (*v_fine)(center+jp))/4
- + ((*v_fine)(center-ip) + (*v_fine)(center-ip+jp)
- + (*v_fine)(center+ip) + (*v_fine)(center+jp+ip))/8;
-}
-
void SAMRAI::geom::Edge_Viscosity_Coarsen::coarsen(hier::Patch& coarse,
const hier::Patch& fine,
@@ -70,9 +58,22 @@ void SAMRAI::geom::Edge_Viscosity_Coarse
{
pdat::NodeIndex coarse_edge(hier::Index(i,j),
pdat::NodeIndex::LowerLeft);
+
(*edge_viscosity_coarse)(coarse_edge)=
viscosity_coarsen(*cell_viscosity_fine,*edge_viscosity_fine,
coarse_edge*2);
+
+
+ tbox::plog << "Edge "
+ << coarse_box.lower(0) << " "
+ << coarse_box.upper(0) << " "
+ << coarse_box.lower(1) << " "
+ << coarse_box.upper(1) << " "
+ << i << " "
+ << j << " "
+ << (*edge_viscosity_coarse)(coarse_edge) << " "
+ << "\n";
+
}
}
diff -r 351b8d159b53 -r 5816f25e3c94 Edge_Viscosity_Coarsen.h
--- a/Edge_Viscosity_Coarsen.h Wed Mar 09 00:23:36 2011 -0800
+++ b/Edge_Viscosity_Coarsen.h Thu Mar 10 16:19:05 2011 -0800
@@ -19,7 +19,7 @@
#include "SAMRAI/hier/IntVector.h"
#include "SAMRAI/hier/Patch.h"
#include "SAMRAI/tbox/Pointer.h"
-#include "SAMRAI/pdat/SideVariable.h"
+#include "SAMRAI/pdat/NodeVariable.h"
#include <string>
@@ -57,7 +57,7 @@ public:
virtual ~Edge_Viscosity_Coarsen(){}
/**
- * Return true if the variable and name std::string match the side-centered
+ * Return true if the variable and name std::string match the edge-centered
* double weighted averaging; otherwise, return false.
*/
@@ -66,7 +66,7 @@ public:
{
TBOX_DIM_ASSERT_CHECK_ARGS2(*this, *var);
- const tbox::Pointer<pdat::SideVariable<double> > cast_var(var);
+ const tbox::Pointer<pdat::NodeVariable<double> > cast_var(var);
if (!cast_var.isNull() && (op_name == d_name_id)) {
return true;
} else {
@@ -83,7 +83,7 @@ public:
}
/**
- * The priority of side-centered double weighted averaging is 0.
+ * The priority of edge-centered double weighted averaging is 0.
* It will be performed before any user-defined coarsen operations.
*/
int getOperatorPriority() const
@@ -102,7 +102,7 @@ public:
/**
* Coarsen the source component on the fine patch to the destination
- * component on the coarse patch using the side-centered double weighted
+ * component on the coarse patch using the edge-centered double weighted
* averaging operator. Coarsening is performed on the intersection of
* the destination patch and the coarse box. It is assumed that the
* fine patch contains sufficient data for the stencil width of the
diff -r 351b8d159b53 -r 5816f25e3c94 FACStokes.h
--- a/FACStokes.h Wed Mar 09 00:23:36 2011 -0800
+++ b/FACStokes.h Thu Mar 10 16:19:05 2011 -0800
@@ -129,6 +129,7 @@ namespace SAMRAI {
#endif
private:
+ void fix_viscosity();
std::string d_object_name;
const tbox::Dimension d_dim;
@@ -168,6 +169,7 @@ namespace SAMRAI {
*
* These are initialized in the constructor and never change.
*/
+ public:
int p_id, cell_viscosity_id, edge_viscosity_id, dp_id, p_exact_id,
p_rhs_id, v_id, v_rhs_id;
diff -r 351b8d159b53 -r 5816f25e3c94 FACStokes/solveStokes.C
--- a/FACStokes/solveStokes.C Wed Mar 09 00:23:36 2011 -0800
+++ b/FACStokes/solveStokes.C Thu Mar 10 16:19:05 2011 -0800
@@ -55,6 +55,8 @@ int SAMRAI::FACStokes::solveStokes()
d_stokes_fac_solver.set_boundaries(v_id,level,false);
}
+ fix_viscosity();
+
d_stokes_fac_solver.initializeSolverState
(p_id,cell_viscosity_id,edge_viscosity_id,dp_id,p_rhs_id,v_id,v_rhs_id,
d_hierarchy,0,d_hierarchy->getFinestLevelNumber());
diff -r 351b8d159b53 -r 5816f25e3c94 input/shear_corner.input
--- a/input/shear_corner.input Wed Mar 09 00:23:36 2011 -0800
+++ b/input/shear_corner.input Thu Mar 10 16:19:05 2011 -0800
@@ -32,16 +32,16 @@ FACStokes {
// This is the input for the cell-centered Stokes FAC solver
// class in the SAMRAI library.
enable_logging = TRUE // Bool flag to switch logging on/off
- max_cycles = 100 // Max number of FAC cycles to use
+ max_cycles = 1000 // Max number of FAC cycles to use
residual_tol = 1e-8 // Residual tolerance to solve for
- num_pre_sweeps = 5 // Number of presmoothing sweeps to use
- num_post_sweeps = 5 // Number of postsmoothing sweeps to use
+ num_pre_sweeps = 30 // Number of presmoothing sweeps to use
+ num_post_sweeps = 30 // Number of postsmoothing sweeps to use
smoothing_choice = "Tackley"
coarse_solver_choice = "Tackley"
// smoothing_choice = "Gerya"
// coarse_solver_choice = "Gerya"
- coarse_solver_max_iterations = 25
- coarse_solver_tolerance = 1e-10
+ coarse_solver_max_iterations = 25000
+ coarse_solver_tolerance = 1e-8
p_prolongation_method = "P_REFINE" // Type of refinement
// used in prolongation.
// Suggested values are
@@ -90,7 +90,7 @@ CartesianGridGeometry {
// domain is periodic. Zero indicates not
// periodic, non-zero value indicates periodicity.
// [0]
- // domain_boxes = [(0,0), (63,63)]
+ // domain_boxes = [(0,0), (15,15)]
domain_boxes = [(0,0), (3,3)]
x_lo = 0, 0
x_up = 1, 1
@@ -99,13 +99,13 @@ StandardTagAndInitialize {
StandardTagAndInitialize {
tagging_method = "REFINE_BOXES"
RefineBoxes {
- // level_0 = [(0,0),(63,63)]
+ // level_0 = [(0,0),(15,15)]
level_0 = [(0,0),(3,3)]
level_1 = [(0,0),(7,7)]
level_2 = [(0,0),(15,15)]
- level_3 = [(0,0),(31,31)]
- level_4 = [(0,0),(63,63)]
- level_5 = [(0,0),(127,127)]
+ // level_3 = [(0,0),(31,31)]
+ // level_4 = [(0,0),(63,63)]
+ // level_5 = [(0,0),(127,127)]
// level_1 = [(2,2),(3,3)]
// level_2 = [(4,4),(5,5)]
// level_3 = [(8,8),(20,20)]
diff -r 351b8d159b53 -r 5816f25e3c94 main.C
--- a/main.C Wed Mar 09 00:23:36 2011 -0800
+++ b/main.C Thu Mar 10 16:19:05 2011 -0800
@@ -34,6 +34,8 @@ using namespace std;
#include "P_Boundary_Refine.h"
#include "V_Boundary_Refine.h"
#include "V_Coarsen.h"
+#include "Cell_Viscosity_Coarsen.h"
+#include "Edge_Viscosity_Coarsen.h"
#include "FACStokes.h"
@@ -153,8 +155,6 @@ int main(
(dim,
base_name + "CartesianGridGeometry",
input_db->getDatabase("CartesianGridGeometry")));
- // tbox::plog << "Cartesian Geometry:" << endl;
- // grid_geometry->printClassData(tbox::plog);
grid_geometry->addSpatialRefineOperator
(tbox::Pointer<SAMRAI::xfer::RefineOperator>
(new SAMRAI::geom::P_Refine(dim)));
@@ -189,6 +189,15 @@ int main(
input_db->isDatabase("FACStokes") ?
input_db->getDatabase("FACStokes") :
tbox::Pointer<tbox::Database>(NULL));
+
+ grid_geometry->addSpatialCoarsenOperator
+ (tbox::Pointer<SAMRAI::xfer::CoarsenOperator>
+ (new SAMRAI::geom::Cell_Viscosity_Coarsen
+ (dim,fac_stokes.edge_viscosity_id)));
+ grid_geometry->addSpatialCoarsenOperator
+ (tbox::Pointer<SAMRAI::xfer::CoarsenOperator>
+ (new SAMRAI::geom::Edge_Viscosity_Coarsen
+ (dim,fac_stokes.cell_viscosity_id)));
/*
* Create the tag-and-initializer, box-generator and load-balancer
diff -r 351b8d159b53 -r 5816f25e3c94 wscript
--- a/wscript Wed Mar 09 00:23:36 2011 -0800
+++ b/wscript Thu Mar 10 16:19:05 2011 -0800
@@ -12,6 +12,7 @@ def build(bld):
features = ['cxx','cprogram'],
source = ['main.C',
'FACStokes/FACStokes.C',
+ 'FACStokes/fix_viscosity.C',
'FACStokes/initializeLevelData.C',
'FACStokes/packDerivedDataIntoDoubleBuffer.C',
'FACStokes/resetHierarchyConfiguration.C',
More information about the CIG-COMMITS
mailing list