[cig-commits] commit: Make prolongation work with v.
Mercurial
hg at geodynamics.org
Fri Feb 25 14:14:49 PST 2011
changeset: 47:291fbe064ab0
user: Walter Landry <wlandry at caltech.edu>
date: Tue Jan 11 22:16:01 2011 -0800
files: Makefile StokesFACOps/StokesFACOps.C V_Refine.C V_Refine.h main.C
description:
Make prolongation work with v.
diff -r a1351946da69 -r 291fbe064ab0 Makefile
--- a/Makefile Tue Jan 11 22:13:52 2011 -0800
+++ b/Makefile Tue Jan 11 22:16:01 2011 -0800
@@ -30,7 +30,7 @@ CXX_OBJS = main.o FACStokes/FACStok
FACStokes/resetHierarchyConfiguration.o \
FACStokes/setupPlotter.o \
FACStokes/solveStokes.o \
- P_Refine.o \
+ P_Refine.o V_Refine.o \
StokesFACOps/StokesFACOps.o \
StokesFACOps/checkInputPatchDataIndices.o \
StokesFACOps/computeCompositeResidualOnLevel.o \
diff -r a1351946da69 -r 291fbe064ab0 StokesFACOps/StokesFACOps.C
--- a/StokesFACOps/StokesFACOps.C Tue Jan 11 22:13:52 2011 -0800
+++ b/StokesFACOps/StokesFACOps.C Tue Jan 11 22:16:01 2011 -0800
@@ -93,7 +93,7 @@ namespace SAMRAI {
),
d_cf_discretization("Ewing"),
p_prolongation_method("P_REFINE"),
- v_prolongation_method("CONSERVATIVE_LINEAR_REFINE"),
+ v_prolongation_method("V_REFINE"),
d_coarse_solver_tolerance(1.e-8),
d_coarse_solver_max_iterations(10),
d_residual_tolerance_during_smoothing(-1.0),
diff -r a1351946da69 -r 291fbe064ab0 V_Refine.C
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/V_Refine.C Tue Jan 11 22:16:01 2011 -0800
@@ -0,0 +1,181 @@
+/*************************************************************************
+ *
+ * This file is part of the SAMRAI distribution. For full copyright
+ * information, see COPYRIGHT and COPYING.LESSER.
+ *
+ * Copyright: (c) 1997-2010 Lawrence Livermore National Security, LLC
+ * Description: Linear refine operator for side-centered double data on
+ * a Cartesian mesh.
+ *
+ ************************************************************************/
+
+#ifndef included_geom_V_Refine_C
+#define included_geom_V_Refine_C
+
+#include "V_Refine.h"
+
+#include <float.h>
+#include <math.h>
+#include "SAMRAI/geom/CartesianPatchGeometry.h"
+#include "SAMRAI/hier/Index.h"
+#include "SAMRAI/pdat/SideData.h"
+#include "SAMRAI/pdat/SideVariable.h"
+#include "SAMRAI/tbox/Utilities.h"
+
+void SAMRAI::geom::V_Refine::refine(
+ hier::Patch& fine,
+ const hier::Patch& coarse,
+ const int dst_component,
+ const int src_component,
+ const hier::BoxOverlap& fine_overlap,
+ const hier::IntVector& ratio) const
+{
+ const pdat::SideOverlap* t_overlap =
+ dynamic_cast<const pdat::SideOverlap *>(&fine_overlap);
+
+ TBOX_ASSERT(t_overlap != NULL);
+
+ for(int axis=0; axis<getDim().getValue(); ++axis)
+ {
+ const hier::BoxList& boxes = t_overlap->getDestinationBoxList(axis);
+ for (hier::BoxList::Iterator b(boxes); b; b++)
+ {
+ refine(fine,coarse,dst_component,src_component,b(),ratio,axis);
+ }
+ }
+}
+
+void SAMRAI::geom::V_Refine::refine(hier::Patch& fine,
+ const hier::Patch& coarse,
+ const int dst_component,
+ const int src_component,
+ const hier::Box& fine_box,
+ const hier::IntVector& ratio,
+ const int &axis) const
+{
+ const tbox::Dimension& dim(getDim());
+ TBOX_DIM_ASSERT_CHECK_DIM_ARGS4(dim, fine, coarse, fine_box, ratio);
+
+ tbox::Pointer<pdat::SideData<double> >
+ v = coarse.getPatchData(src_component);
+ tbox::Pointer<pdat::SideData<double> >
+ v_fine = fine.getPatchData(dst_component);
+#ifdef DEBUG_CHECK_ASSERTIONS
+ TBOX_ASSERT(!v.isNull());
+ TBOX_ASSERT(!v_fine.isNull());
+ TBOX_ASSERT(v->getDepth() == v_fine->getDepth());
+#endif
+
+ hier::Box coarse_box=coarse.getBox();
+ tbox::Pointer<geom::CartesianPatchGeometry>
+ geom = coarse.getPatchGeometry();
+
+ for(int j=fine_box.lower(1); j<=fine_box.upper(1); ++j)
+ for(int i=fine_box.lower(0); i<=fine_box.upper(0); ++i)
+ {
+ pdat::SideIndex fine(hier::Index(i,j),axis,pdat::SideIndex::Lower);
+
+ hier::Index ip(1,0), jp(0,1);
+ pdat::SideIndex center(fine);
+ center[0]/=2;
+ center[1]/=2;
+
+ if(axis==0)
+ {
+ double dvx_dy;
+
+ if(i%2==0)
+ {
+ if(center[1]==coarse_box.lower(1)
+ && geom->getTouchesRegularBoundary(1,0))
+ {
+ dvx_dy=((*v)(center+jp)-(*v)(center))/4;
+ }
+ else if(center[1]==coarse_box.upper(1)
+ && geom->getTouchesRegularBoundary(1,1))
+ {
+ dvx_dy=((*v)(center)-(*v)(center-jp))/4;
+ }
+ else
+ {
+ dvx_dy=((*v)(center+jp)-(*v)(center-jp))/8;
+ }
+
+ (*v_fine)(fine)=(*v)(center)
+ + ((j%2==0) ? (-dvx_dy) : dvx_dy);
+ }
+ else
+ {
+ if(center[1]==coarse_box.lower(1)
+ && geom->getTouchesRegularBoundary(1,0))
+ {
+ dvx_dy=((*v)(center+jp)-(*v)(center)
+ + (*v)(center+ip+jp)-(*v)(center+ip))/4;
+ }
+ else if(center[1]==coarse_box.upper(1)
+ && geom->getTouchesRegularBoundary(1,1))
+ {
+ dvx_dy=((*v)(center)-(*v)(center-jp)
+ + (*v)(center+ip)-(*v)(center+ip-jp))/4;
+ }
+ else
+ {
+ dvx_dy=((*v)(center+jp)-(*v)(center-jp)
+ + (*v)(center+ip+jp)-(*v)(center+ip-jp))/8;
+ }
+
+ (*v_fine)(fine)=((*v)(center) + (*v)(center+ip)
+ + ((j%2==0) ? (-dvx_dy) : dvx_dy))/2;
+ }
+ }
+ else
+ {
+ double dvy_dx;
+
+ if(j%2==0)
+ {
+ if(center[0]==coarse_box.lower(0)
+ && geom->getTouchesRegularBoundary(0,0))
+ {
+ dvy_dx=((*v)(center+ip)-(*v)(center))/4;
+ }
+ else if(center[0]==coarse_box.upper(0)
+ && geom->getTouchesRegularBoundary(0,1))
+ {
+ dvy_dx=((*v)(center)-(*v)(center-ip))/4;
+ }
+ else
+ {
+ dvy_dx=((*v)(center+ip)-(*v)(center-ip))/8;
+ }
+
+ (*v_fine)(fine)=(*v)(center)
+ + ((i%2==0) ? (-dvy_dx) : dvy_dx);
+ }
+ else
+ {
+ if(center[0]==coarse_box.lower(0)
+ && geom->getTouchesRegularBoundary(0,0))
+ {
+ dvy_dx=((*v)(center+ip)-(*v)(center)
+ + (*v)(center+jp+ip)-(*v)(center+jp))/4;
+ }
+ else if(center[0]==coarse_box.upper(0)
+ && geom->getTouchesRegularBoundary(0,1))
+ {
+ dvy_dx=((*v)(center)-(*v)(center-ip)
+ + (*v)(center+jp)-(*v)(center+jp-ip))/4;
+ }
+ else
+ {
+ dvy_dx=((*v)(center+ip)-(*v)(center-ip)
+ + (*v)(center+jp+ip)-(*v)(center+jp-ip))/8;
+ }
+
+ (*v_fine)(fine)=((*v)(center) + (*v)(center+jp)
+ + ((i%2==0) ? (-dvy_dx) : dvy_dx))/2;
+ }
+ }
+ }
+}
+#endif
diff -r a1351946da69 -r 291fbe064ab0 V_Refine.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/V_Refine.h Tue Jan 11 22:16:01 2011 -0800
@@ -0,0 +1,143 @@
+/*************************************************************************
+ *
+ * This file is part of the SAMRAI distribution. For full copyright
+ * information, see COPYRIGHT and COPYING.LESSER.
+ *
+ * Copyright: (c) 1997-2010 Lawrence Livermore National Security, LLC
+ * Description: Linear refine operator for side-centered double data on
+ * a Cartesian mesh.
+ *
+ ************************************************************************/
+
+#ifndef included_geom_V_Refine
+#define included_geom_V_Refine
+
+#include "SAMRAI/SAMRAI_config.h"
+
+#include "SAMRAI/xfer/RefineOperator.h"
+#include "SAMRAI/hier/Box.h"
+#include "SAMRAI/hier/IntVector.h"
+#include "SAMRAI/hier/Patch.h"
+#include "SAMRAI/tbox/Pointer.h"
+#include "SAMRAI/pdat/SideVariable.h"
+
+#include <string>
+
+namespace SAMRAI {
+namespace geom {
+
+/**
+ * Class V_Refine implements linear
+ * interpolation for side-centered double patch data defined over a Cartesian
+ * mesh. It is derived from the xfer::RefineOperator base class.
+ * CartesianSideDoubleConservativeLinearRefine does not handle the
+ * boundary for the velocity correctly, so use this instead for
+ * velocity.
+ *
+ * The findRefineOperator() operator function returns true if the input
+ * variable is side-centered double, and the std::string is "V_REFINE".
+ *
+ * @see xfer::RefineOperator
+ */
+
+class V_Refine:
+ public xfer::RefineOperator
+{
+public:
+ /**
+ * Uninteresting default constructor.
+ */
+ explicit V_Refine(const tbox::Dimension& dim):
+ xfer::RefineOperator(dim, "V_REFINE")
+ {
+ d_name_id = "V_REFINE";
+ }
+
+
+ /**
+ * Uninteresting virtual destructor.
+ */
+ virtual ~V_Refine(){}
+
+ /**
+ * Return true if the variable and name std::string match side-centered
+ * double linear interpolation; otherwise, return false.
+ */
+ bool findRefineOperator(const tbox::Pointer<hier::Variable>& var,
+ const std::string& op_name) const
+ {
+ TBOX_DIM_ASSERT_CHECK_ARGS2(*this, *var);
+
+ const tbox::Pointer<pdat::SideVariable<double> > cast_var(var);
+ if (!cast_var.isNull() && (op_name == d_name_id)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ /**
+ * Return name std::string identifier of this refinement operator.
+ */
+ const std::string& getOperatorName() const
+ {
+ return d_name_id;
+ }
+
+ /**
+ * The priority of side-centered double linear interpolation is 0.
+ * It will be performed before any user-defined interpolation operations.
+ */
+ int getOperatorPriority() const
+ {
+ return 0;
+ }
+
+ /**
+ * The stencil width of the linear interpolation operator is the vector
+ * of ones. That is, its stencil extends one side outside the fine box.
+ */
+ hier::IntVector getStencilWidth() const
+ {
+ return hier::IntVector::getOne(getDim());
+ }
+
+ /**
+ * Refine the source component on the coarse patch to the destination
+ * component on the fine patch using the side-centered double linear
+ * interpolation operator. Interpolation is performed on the intersection
+ * of the destination patch and the boxes contained in fine_overlap
+ * It is assumed that the coarse patch contains sufficient data for the
+ * stencil width of the refinement operator.
+ */
+ void refine(hier::Patch& fine,
+ const hier::Patch& coarse,
+ const int dst_component,
+ const int src_component,
+ const hier::BoxOverlap& fine_overlap,
+ const hier::IntVector& ratio) const;
+
+ /**
+ * Refine the source component on the coarse patch to the destination
+ * component on the fine patch using the side-centered double linear
+ * interpolation operator. Interpolation is performed on the intersection
+ * of the destination patch and the fine box. It is assumed that the
+ * coarse patch contains sufficient data for the stencil width of the
+ * refinement operator. This differs from the above refine() method
+ * only in that it operates on a single fine box instead of a BoxOverlap.
+ */
+ void refine(hier::Patch& fine,
+ const hier::Patch& coarse,
+ const int dst_component,
+ const int src_component,
+ const hier::Box& fine_box,
+ const hier::IntVector& ratio,
+ const int &axis) const;
+
+private:
+ std::string d_name_id;
+
+};
+
+}
+}
+#endif
diff -r a1351946da69 -r 291fbe064ab0 main.C
--- a/main.C Tue Jan 11 22:13:52 2011 -0800
+++ b/main.C Tue Jan 11 22:16:01 2011 -0800
@@ -30,6 +30,7 @@ using namespace std;
#include "SAMRAI/appu/VisItDataWriter.h"
#include "SAMRAI/xfer/RefineOperator.h"
#include "P_Refine.h"
+#include "V_Refine.h"
#include "FACStokes.h"
@@ -151,6 +152,7 @@ int main(
tbox::plog << "Cartesian Geometry:" << endl;
grid_geometry->printClassData(tbox::plog);
grid_geometry->addSpatialRefineOperator(tbox::Pointer<SAMRAI::xfer::RefineOperator>(new SAMRAI::geom::P_Refine(dim)));
+ grid_geometry->addSpatialRefineOperator(tbox::Pointer<SAMRAI::xfer::RefineOperator>(new SAMRAI::geom::V_Refine(dim)));
More information about the CIG-COMMITS
mailing list