[cig-commits] commit: Make xeqScheduleGhostFill work with p and v, and update compositeComputeResidualOnLevel. It only works if the fine grid covers the entire region (e.g. you are doing multigrid)
Mercurial
hg at geodynamics.org
Fri Feb 25 14:14:06 PST 2011
changeset: 34:a2e84a92deb1
user: Walter Landry <wlandry at caltech.edu>
date: Fri Jan 07 16:41:05 2011 -0800
files: Makefile StokesFACOps.h StokesFACOps/StokesFACOps.C StokesFACOps/computeCompositeResidualOnLevel.C StokesFACOps/computeResidualOnPatch.C StokesFACOps/deallocateOperatorState.C StokesFACOps/initializeOperatorState.C StokesFACOps/restrictSolution.C StokesFACOps/smoothErrorByRedBlack.C StokesFACOps/xeqScheduleGhostFill.C
description:
Make xeqScheduleGhostFill work with p and v, and update compositeComputeResidualOnLevel. It only works if the fine grid covers the entire region (e.g. you are doing multigrid)
diff -r 7eb3182b8f20 -r a2e84a92deb1 Makefile
--- a/Makefile Fri Jan 07 16:33:07 2011 -0800
+++ b/Makefile Fri Jan 07 16:41:05 2011 -0800
@@ -35,7 +35,6 @@ CXX_OBJS = main.o FACStokes/FACStok
StokesFACOps/computeCompositeResidualOnLevel.o \
StokesFACOps/computeFluxOnPatch.o \
StokesFACOps/computeResidualNorm.o \
- StokesFACOps/computeResidualOnPatch.o \
StokesFACOps/computeVectorWeights.o \
StokesFACOps/deallocateOperatorState.o \
StokesFACOps/ewingFixFlux.o \
diff -r 7eb3182b8f20 -r a2e84a92deb1 StokesFACOps.h
--- a/StokesFACOps.h Fri Jan 07 16:33:07 2011 -0800
+++ b/StokesFACOps.h Fri Jan 07 16:41:05 2011 -0800
@@ -550,24 +550,6 @@ private:
const hier::IntVector& ratio_to_coarser) const;
/*!
- * @brief AMR-unaware function to compute residual on a single patch,
- * with variable scalar field.
- *
- * @param patch patch
- * @param flux_data side-centered flux data
- * @param soln_data cell-centered solution data
- * @param rhs_data cell-centered rhs data
- * @param residual_data cell-centered residual data
- */
- void
- computeResidualOnPatch(
- const hier::Patch& patch,
- const pdat::SideData<double>& flux_data,
- const pdat::CellData<double>& soln_data,
- const pdat::CellData<double>& rhs_data,
- pdat::CellData<double>& residual_data) const;
-
- /*!
* @brief AMR-unaware function to red or black smoothing on a single patch,
* for variable diffusion coefficient and variable scalar field.
*
@@ -633,11 +615,11 @@ private:
* d_flux_coarsen_operator,
* d_flux_coarsen_schedules.
* <li> xeqScheduleGhostFill():
- * d_ghostfill_refine_operator,
- * d_ghostfill_refine_schedules.
+ * ghostfill_refine_operator,
+ * ghostfill_refine_schedules.
* <li> xeqScheduleGhostFillNoCoarse():
- * d_ghostfill_nocoarse_refine_operator,
- * d_ghostfill_nocoarse_refine_schedules.
+ * ghostfill_nocoarse_refine_operator,
+ * ghostfill_nocoarse_refine_schedules.
* </ol>
*
* @return refinement schedule for prolongation
@@ -702,9 +684,7 @@ private:
* and physical bc.
*/
void
- xeqScheduleGhostFill(
- int dst_id,
- int dest_ln);
+ xeqScheduleGhostFill(int p_id, int v_id, int dest_ln);
/*!
* @brief Execute schedule for filling ghosts on the specified
@@ -721,8 +701,7 @@ private:
* and physical bc.
*/
void
- xeqScheduleGhostFillNoCoarse(int p_id, int v_id,
- int dest_ln);
+ xeqScheduleGhostFillNoCoarse(int p_id, int v_id, int dest_ln);
//@}
@@ -969,18 +948,18 @@ private:
tbox::Array<tbox::Pointer<xfer::CoarsenSchedule> >
d_flux_coarsen_schedules;
- //! @brief Refine operator for cell-like data from coarser level.
- tbox::Pointer<xfer::RefineOperator> d_ghostfill_refine_operator;
- tbox::Pointer<xfer::RefineAlgorithm> d_ghostfill_refine_algorithm;
+ //! @brief Refine operator for data from coarser level.
+ tbox::Pointer<xfer::RefineOperator> p_ghostfill_refine_operator;
+ tbox::Pointer<xfer::RefineAlgorithm> p_ghostfill_refine_algorithm;
tbox::Array<tbox::Pointer<xfer::RefineSchedule> >
- d_ghostfill_refine_schedules;
+ p_ghostfill_refine_schedules;
- //! @brief Refine operator for cell-like data from same level.
- tbox::Pointer<xfer::RefineOperator> d_ghostfill_nocoarse_refine_operator;
- tbox::Pointer<xfer::RefineAlgorithm> d_ghostfill_nocoarse_refine_algorithm;
+ tbox::Pointer<xfer::RefineOperator> v_ghostfill_refine_operator;
+ tbox::Pointer<xfer::RefineAlgorithm> v_ghostfill_refine_algorithm;
tbox::Array<tbox::Pointer<xfer::RefineSchedule> >
- d_ghostfill_nocoarse_refine_schedules;
+ v_ghostfill_refine_schedules;
+ //! @brief Refine operator for data from same level.
tbox::Pointer<xfer::RefineOperator> p_nocoarse_refine_operator;
tbox::Pointer<xfer::RefineAlgorithm> p_nocoarse_refine_algorithm;
tbox::Array<tbox::Pointer<xfer::RefineSchedule> >
diff -r 7eb3182b8f20 -r a2e84a92deb1 StokesFACOps/StokesFACOps.C
--- a/StokesFACOps/StokesFACOps.C Fri Jan 07 16:33:07 2011 -0800
+++ b/StokesFACOps/StokesFACOps.C Fri Jan 07 16:41:05 2011 -0800
@@ -124,12 +124,12 @@ namespace SAMRAI {
d_flux_coarsen_operator(),
d_flux_coarsen_algorithm(),
d_flux_coarsen_schedules(),
- d_ghostfill_refine_operator(),
- d_ghostfill_refine_algorithm(),
- d_ghostfill_refine_schedules(),
- d_ghostfill_nocoarse_refine_operator(),
- d_ghostfill_nocoarse_refine_algorithm(),
- d_ghostfill_nocoarse_refine_schedules(),
+ p_ghostfill_refine_operator(),
+ p_ghostfill_refine_algorithm(),
+ p_ghostfill_refine_schedules(),
+ v_ghostfill_refine_operator(),
+ v_ghostfill_refine_algorithm(),
+ v_ghostfill_refine_schedules(),
p_nocoarse_refine_operator(),
p_nocoarse_refine_algorithm(),
p_nocoarse_refine_schedules(),
diff -r 7eb3182b8f20 -r a2e84a92deb1 StokesFACOps/computeCompositeResidualOnLevel.C
--- a/StokesFACOps/computeCompositeResidualOnLevel.C Fri Jan 07 16:33:07 2011 -0800
+++ b/StokesFACOps/computeCompositeResidualOnLevel.C Fri Jan 07 16:41:05 2011 -0800
@@ -71,11 +71,10 @@ void SAMRAI::solv::StokesFACOps::compute
* Set up the bc helper so that when we use a refine schedule
* to fill ghosts, the correct data is operated on.
*/
- const int soln_id = solution.getComponentDescriptorIndex(0);
- d_bc_helper.setTargetDataId(soln_id);
- d_bc_helper.setHomogeneousBc(error_equation_indicator);
-
- const int flux_id = (d_flux_id != -1) ? d_flux_id : d_flux_scratch_id;
+ const int p_id = solution.getComponentDescriptorIndex(0);
+ const int v_id = solution.getComponentDescriptorIndex(1);
+ // d_bc_helper.setTargetDataId(soln_id);
+ // d_bc_helper.setHomogeneousBc(error_equation_indicator);
/*
* Assumptions:
@@ -98,104 +97,281 @@ void SAMRAI::solv::StokesFACOps::compute
* S4. Compute residual data from flux.
*/
+
+ // /*
+ // * For the whole level, make sure the internal
+ // * side-centered data is allocated and note
+ // * whether that data should be deallocated when done.
+ // * We do this for the whole level because the data
+ // * undergoes transfer operations which require the
+ // * whole level data.
+ // */
+ // bool deallocate_flux_data_when_done = false;
+ // if (flux_id == d_flux_scratch_id) {
+ // if (!level->checkAllocated(flux_id)) {
+ // level->allocatePatchData(flux_id);
+ // deallocate_flux_data_when_done = true;
+ // }
+
/* S1. Fill solution ghost data. */
- {
- tbox::Pointer<xfer::RefineSchedule> ln_refine_schedule;
- if (ln > d_ln_min) {
- /* Fill from current, next coarser level and physical boundary */
- xeqScheduleGhostFill(soln_id, ln);
- } else {
- /* Fill from current and physical boundary */
- abort();
- // xeqScheduleGhostFillNoCoarse(soln_id, ln);
- }
+ if (ln > d_ln_min) {
+ /* Fill from current, next coarser level and physical boundary */
+ xeqScheduleGhostFill(p_id, v_id, ln);
+ } else {
+ /* Fill from current and physical boundary */
+ xeqScheduleGhostFillNoCoarse(p_id, v_id, ln);
}
- /*
- * For the whole level, make sure the internal
- * side-centered data is allocated and note
- * whether that data should be deallocated when done.
- * We do this for the whole level because the data
- * undergoes transfer operations which require the
- * whole level data.
- */
- bool deallocate_flux_data_when_done = false;
- if (flux_id == d_flux_scratch_id) {
- if (!level->checkAllocated(flux_id)) {
- level->allocatePatchData(flux_id);
- deallocate_flux_data_when_done = true;
- }
- }
+ // /*
+ // * S2. Compute flux on patches in level.
+ // */
+ // for (hier::PatchLevel::Iterator pi(*level); pi; pi++) {
+ // tbox::Pointer<hier::Patch> patch = *pi;
- /*
- * S2. Compute flux on patches in level.
- */
- for (hier::PatchLevel::Iterator pi(*level); pi; pi++) {
- tbox::Pointer<hier::Patch> patch = *pi;
+ // tbox::Pointer<pdat::CellData<double> >
+ // soln_data = solution.getComponentPatchData(0, *patch);
+ // tbox::Pointer<pdat::CellData<double> >
+ // rhs_data = rhs.getComponentPatchData(0, *patch);
+ // tbox::Pointer<pdat::CellData<double> >
+ // residual_data = residual.getComponentPatchData(0, *patch);
+ // tbox::Pointer<pdat::SideData<double> >
+ // flux_data = patch->getPatchData(flux_id);
+ // computeFluxOnPatch(
+ // *patch,
+ // level->getRatioToCoarserLevel(),
+ // *soln_data,
+ // *flux_data);
- tbox::Pointer<pdat::CellData<double> >
- soln_data = solution.getComponentPatchData(0, *patch);
- tbox::Pointer<pdat::CellData<double> >
- rhs_data = rhs.getComponentPatchData(0, *patch);
- tbox::Pointer<pdat::CellData<double> >
- residual_data = residual.getComponentPatchData(0, *patch);
- tbox::Pointer<pdat::SideData<double> >
- flux_data = patch->getPatchData(flux_id);
- computeFluxOnPatch(
- *patch,
- level->getRatioToCoarserLevel(),
- *soln_data,
- *flux_data);
+ // }
- }
-
- /*
- * S3. Coarsen oflux data from next finer level so that
- * the computed flux becomes the composite grid flux.
- */
- if (ln < d_ln_max) {
- xeqScheduleFluxCoarsen(flux_id, d_oflux_scratch_id, ln);
- }
+ // /*
+ // * S3. Coarsen oflux data from next finer level so that
+ // * the computed flux becomes the composite grid flux.
+ // */
+ // if (ln < d_ln_max) {
+ // xeqScheduleFluxCoarsen(flux_id, d_oflux_scratch_id, ln);
+ // }
/*
* S4. Compute residual on patches in level.
*/
+ double viscosity=1;
+
for (hier::PatchLevel::Iterator pi(*level); pi; pi++) {
tbox::Pointer<hier::Patch> patch = *pi;
tbox::Pointer<pdat::CellData<double> >
- soln_data = solution.getComponentPatchData(0, *patch);
+ p = solution.getComponentPatchData(0, *patch);
+ tbox::Pointer<pdat::SideData<double> >
+ v = solution.getComponentPatchData(1, *patch);
tbox::Pointer<pdat::CellData<double> >
- rhs_data = rhs.getComponentPatchData(0, *patch);
+ p_rhs = rhs.getComponentPatchData(0, *patch);
+ tbox::Pointer<pdat::SideData<double> >
+ v_rhs = rhs.getComponentPatchData(1, *patch);
tbox::Pointer<pdat::CellData<double> >
- residual_data = residual.getComponentPatchData(0, *patch);
+ p_resid = residual.getComponentPatchData(0, *patch);
tbox::Pointer<pdat::SideData<double> >
- flux_data = patch->getPatchData(flux_id);
- computeResidualOnPatch(*patch,
- *flux_data,
- *soln_data,
- *rhs_data,
- *residual_data);
+ v_resid = residual.getComponentPatchData(1, *patch);
- if (ln > d_ln_min) {
- /*
- * Save outerflux data so that next coarser level
- * can compute its coarse-fine composite flux.
- * This is not strictly needed in this "compute residual"
- * loop through the patches, but we put it here to
- * avoid writing another loop for it.
- */
- tbox::Pointer<pdat::OutersideData<double> >
- oflux_data = patch->getPatchData(d_oflux_scratch_id);
+ hier::Box pbox=patch->getBox();
+ tbox::Pointer<geom::CartesianPatchGeometry> geom = patch->getPatchGeometry();
+ double dx = *(geom->getDx());
+ double dy = *(geom->getDx());
- TBOX_ASSERT(oflux_data);
+ for(int j=pbox.lower(1); j<=pbox.upper(1)+1; ++j)
+ {
+ for(int i=pbox.lower(0); i<=pbox.upper(0)+1; ++i)
+ {
+ pdat::CellIndex center(tbox::Dimension(2));
+ center[0]=i;
+ center[1]=j;
- oflux_data->copy(*flux_data);
- }
+ pdat::CellIndex up(center), down(center), right(center),
+ left(center);
+
+ ++up[1];
+ --down[1];
+ ++right[0];
+ --left[0];
+
+ /* p */
+ if(i!=pbox.upper(0)+1 && j!=pbox.upper(1)+1)
+ {
+ double dvx_dx=
+ ((*v)(pdat::SideIndex(center,pdat::SideIndex::X,
+ pdat::SideIndex::Upper))
+ - (*v)(pdat::SideIndex(center,pdat::SideIndex::X,
+ pdat::SideIndex::Lower)))/dx;
+ double dvy_dy=
+ ((*v)(pdat::SideIndex(center,pdat::SideIndex::Y,
+ pdat::SideIndex::Upper))
+ - (*v)(pdat::SideIndex(center,pdat::SideIndex::Y,
+ pdat::SideIndex::Lower)))/dy;
+ (*p_resid)(center)=(*p_rhs)(center) - dvx_dx - dvy_dy;
+ }
+
+ /* vx */
+ if(j!=pbox.upper(1)+1)
+ {
+ /* If x==0 */
+ if((center[0]==pbox.lower(0)
+ && geom->getTouchesRegularBoundary(0,0))
+ || (center[0]==pbox.upper(0)+1
+ && geom->getTouchesRegularBoundary(0,1)))
+ {
+ (*v_resid)(pdat::SideIndex(center,pdat::SideIndex::X,
+ pdat::SideIndex::Lower))=0;
+ }
+ else
+ {
+ double dp_dx, d2vx_dxx, d2vx_dyy, C_vx;
+ /* If y==0 */
+ if(center[1]==pbox.lower(1)
+ && geom->getTouchesRegularBoundary(1,0))
+ {
+ d2vx_dyy=
+ ((*v)(pdat::SideIndex(up,pdat::SideIndex::X,
+ pdat::SideIndex::Lower))
+ - (*v)(pdat::SideIndex(center,pdat::SideIndex::X,
+ pdat::SideIndex::Lower)))
+ /(dy*dy);
+ C_vx=-viscosity*(2/(dx*dx) + 1/(dy*dy));
+ }
+ /* If y==max_y */
+ else if(center[1]==pbox.upper(1)
+ && geom->getTouchesRegularBoundary(1,1))
+ {
+ d2vx_dyy=
+ (-(*v)(pdat::SideIndex(center,pdat::SideIndex::X,
+ pdat::SideIndex::Lower))
+ + (*v)(pdat::SideIndex(down,pdat::SideIndex::X,
+ pdat::SideIndex::Lower)))
+ /(dy*dy);
+ C_vx=-viscosity*(2/(dx*dx) + 1/(dy*dy));
+ // tbox::plog << "vx y1 boundary ";
+ }
+ else
+ {
+ d2vx_dyy=
+ ((*v)(pdat::SideIndex(up,pdat::SideIndex::X,
+ pdat::SideIndex::Lower))
+ - 2*(*v)(pdat::SideIndex(center,pdat::SideIndex::X,
+ pdat::SideIndex::Lower))
+ + (*v)(pdat::SideIndex(down,pdat::SideIndex::X,
+ pdat::SideIndex::Lower)))
+ /(dy*dy);
+
+ C_vx=-2*viscosity*(1/(dx*dx) + 1/(dy*dy));
+ }
+ d2vx_dxx=((*v)(pdat::SideIndex(left,pdat::SideIndex::X,
+ pdat::SideIndex::Lower))
+ - 2*(*v)(pdat::SideIndex(center,pdat::SideIndex::X,
+ pdat::SideIndex::Lower))
+ + (*v)(pdat::SideIndex(right,pdat::SideIndex::X,
+ pdat::SideIndex::Lower)))
+ /(dx*dx);
+
+ dp_dx=((*p)(center)-(*p)(left))/dx;
+
+ (*v_resid)(pdat::SideIndex(center,pdat::SideIndex::X,
+ pdat::SideIndex::Lower))=
+ (*v_rhs)(pdat::SideIndex(center,pdat::SideIndex::X,
+ pdat::SideIndex::Lower))
+ - viscosity*(d2vx_dxx + d2vx_dyy) + dp_dx;
+ }
+ }
+
+ /* vy */
+ if(i!=pbox.upper(0)+1)
+ {
+ /* If y==0 */
+ if((center[1]==pbox.lower(1)
+ && geom->getTouchesRegularBoundary(1,0))
+ || (center[1]==pbox.upper(1)+1
+ && geom->getTouchesRegularBoundary(1,1)))
+ {
+ (*v_resid)(pdat::SideIndex(center,pdat::SideIndex::Y,
+ pdat::SideIndex::Lower))=0;
+ }
+ else
+ {
+ double dp_dy, d2vy_dxx, d2vy_dyy, C_vy;
+ /* If x==0 */
+ if(center[0]==pbox.lower(0)
+ && geom->getTouchesRegularBoundary(0,0))
+ {
+ d2vy_dxx=
+ ((*v)(pdat::SideIndex(right,pdat::SideIndex::Y,
+ pdat::SideIndex::Lower))
+ - (*v)(pdat::SideIndex(center,pdat::SideIndex::Y,
+ pdat::SideIndex::Lower)))
+ /(dx*dx);
+ C_vy=-viscosity*(1/(dx*dx) + 2/(dy*dy));
+ }
+ /* If x==max_x */
+ else if(center[0]==pbox.upper(0)
+ && geom->getTouchesRegularBoundary(0,1))
+ {
+ d2vy_dxx=
+ ((*v)(pdat::SideIndex(left,pdat::SideIndex::Y,
+ pdat::SideIndex::Lower))
+ - (*v)(pdat::SideIndex(center,pdat::SideIndex::Y,
+ pdat::SideIndex::Lower)))
+ /(dx*dx);
+ C_vy=-viscosity*(1/(dx*dx) + 2/(dy*dy));
+ }
+ else
+ {
+ d2vy_dxx=
+ ((*v)(pdat::SideIndex(left,pdat::SideIndex::Y,
+ pdat::SideIndex::Lower))
+ - 2*(*v)(pdat::SideIndex(center,pdat::SideIndex::Y,
+ pdat::SideIndex::Lower))
+ + (*v)(pdat::SideIndex(right,pdat::SideIndex::Y,
+ pdat::SideIndex::Lower)))
+ /(dx*dx);
+
+ C_vy=-2*viscosity*(1/(dx*dx) + 1/(dy*dy));
+ }
+ d2vy_dyy=((*v)(pdat::SideIndex(up,pdat::SideIndex::Y,
+ pdat::SideIndex::Lower))
+ - 2*(*v)(pdat::SideIndex(center,pdat::SideIndex::Y,
+ pdat::SideIndex::Lower))
+ + (*v)(pdat::SideIndex(down,pdat::SideIndex::Y,
+ pdat::SideIndex::Lower)))
+ /(dy*dy);
+
+ dp_dy=((*p)(center)-(*p)(down))/dy;
+
+ (*v_resid)(pdat::SideIndex(center,pdat::SideIndex::Y,
+ pdat::SideIndex::Lower))=
+ (*v_rhs)(pdat::SideIndex(center,pdat::SideIndex::Y,
+ pdat::SideIndex::Lower))
+ - viscosity*(d2vy_dxx + d2vy_dyy) + dp_dy;
+ }
+ }
+ }
+ }
+
+ // if (ln > d_ln_min) {
+ // /*
+ // * Save outerflux data so that next coarser level
+ // * can compute its coarse-fine composite flux.
+ // * This is not strictly needed in this "compute residual"
+ // * loop through the patches, but we put it here to
+ // * avoid writing another loop for it.
+ // */
+ // tbox::Pointer<pdat::OutersideData<double> >
+ // oflux_data = patch->getPatchData(d_oflux_scratch_id);
+
+ // TBOX_ASSERT(oflux_data);
+
+ // oflux_data->copy(*flux_data);
+ // }
}
- if (deallocate_flux_data_when_done) {
- level->deallocatePatchData(flux_id);
- }
+ // if (deallocate_flux_data_when_done) {
+ // level->deallocatePatchData(flux_id);
+ // }
t_compute_composite_residual->stop();
}
diff -r 7eb3182b8f20 -r a2e84a92deb1 StokesFACOps/computeResidualOnPatch.C
--- a/StokesFACOps/computeResidualOnPatch.C Fri Jan 07 16:33:07 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,309 +0,0 @@
-/*************************************************************************
- *
- * 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: Operator class for cell-centered scalar Stokes using FAC
- *
- ************************************************************************/
-#include "StokesFACOps.h"
-
-#include IOMANIP_HEADER_FILE
-
-#include "SAMRAI/hier/BoundaryBoxUtils.h"
-#include "SAMRAI/geom/CartesianGridGeometry.h"
-#include "SAMRAI/geom/CartesianPatchGeometry.h"
-#include "SAMRAI/hier/Index.h"
-#include "SAMRAI/hier/Variable.h"
-#include "SAMRAI/hier/VariableDatabase.h"
-#include "SAMRAI/pdat/CellDoubleConstantRefine.h"
-#include "SAMRAI/pdat/CellVariable.h"
-#include "SAMRAI/pdat/OutersideData.h"
-#include "SAMRAI/pdat/OutersideVariable.h"
-#include "SAMRAI/hier/PatchData.h"
-#include "SAMRAI/pdat/SideVariable.h"
-#include "SAMRAI/solv/FACPreconditioner.h"
-#include "StokesHypreSolver.h"
-#include "SAMRAI/tbox/Array.h"
-#include "SAMRAI/tbox/MathUtilities.h"
-#include "SAMRAI/tbox/StartupShutdownManager.h"
-#include "SAMRAI/tbox/Timer.h"
-#include "SAMRAI/tbox/TimerManager.h"
-#include "SAMRAI/tbox/Utilities.h"
-#include "SAMRAI/tbox/MathUtilities.h"
-#include "SAMRAI/xfer/CoarsenAlgorithm.h"
-#include "SAMRAI/xfer/CoarsenOperator.h"
-#include "SAMRAI/xfer/CoarsenSchedule.h"
-#include "SAMRAI/xfer/RefineAlgorithm.h"
-#include "SAMRAI/xfer/RefineOperator.h"
-#include "SAMRAI/xfer/RefineSchedule.h"
-#include "SAMRAI/xfer/PatchLevelFullFillPattern.h"
-
-namespace SAMRAI {
- namespace solv {
-
-extern "C" {
-void F77_FUNC(compresvarsca2d, COMPRESVARSCA2D) (
- const double* xflux,
- const double* yflux,
- const int* fluxgi,
- const int* fluxgj,
- const double* rhs,
- const int* rhsgi,
- const int* rhsgj,
- double* residual,
- const int* residualgi,
- const int* residualgj,
- const double* scalar_field,
- const int* scalar_field_gi,
- const int* scalar_field_gj,
- const double* soln,
- const int* solngi,
- const int* solngj,
- const int* ifirst,
- const int* ilast,
- const int* jfirst,
- const int* jlast,
- const double* dx);
-void F77_FUNC(compresconsca2d, COMPRESCONSCA2D) (
- const double* xflux,
- const double* yflux,
- const int* fluxgi,
- const int* fluxgj,
- const double* rhs,
- const int* rhsgi,
- const int* rhsgj,
- double* residual,
- const int* residualgi,
- const int* residualgj,
- const double & scalar_field,
- const double* soln,
- const int* solngi,
- const int* solngj,
- const int* ifirst,
- const int* ilast,
- const int* jfirst,
- const int* jlast,
- const double* dx);
-void F77_FUNC(compresvarsca3d, COMPRESVARSCA3D) (
- const double* xflux,
- const double* yflux,
- const double* zflux,
- const int* fluxgi,
- const int* fluxgj,
- const int* fluxgk,
- const double* rhs,
- const int* rhsgi,
- const int* rhsgj,
- const int* rhsgk,
- double* residual,
- const int* residualgi,
- const int* residualgj,
- const int* residualgk,
- const double* scalar_field,
- const int* scalar_field_gi,
- const int* scalar_field_gj,
- const int* scalar_field_gk,
- const double* soln,
- const int* solngi,
- const int* solngj,
- const int* solngk,
- const int* ifirst,
- const int* ilast,
- const int* jfirst,
- const int* jlast,
- const int* kfirst,
- const int* klast,
- const double* dx);
-void F77_FUNC(compresconsca3d, COMPRESCONSCA3D) (
- const double* xflux,
- const double* yflux,
- const double* zflux,
- const int* fluxgi,
- const int* fluxgj,
- const int* fluxgk,
- const double* rhs,
- const int* rhsgi,
- const int* rhsgj,
- const int* rhsgk,
- double* residual,
- const int* residualgi,
- const int* residualgj,
- const int* residualgk,
- const double & scalar_field,
- const double* soln,
- const int* solngi,
- const int* solngj,
- const int* solngk,
- const int* ifirst,
- const int* ilast,
- const int* jfirst,
- const int* jlast,
- const int* kfirst,
- const int* klast,
- const double* dx);
-}
-
- void StokesFACOps::computeResidualOnPatch(
- const hier::Patch& patch,
- const pdat::SideData<double>& flux_data,
- const pdat::CellData<double>& soln_data,
- const pdat::CellData<double>& rhs_data,
- pdat::CellData<double>& residual_data) const
- {
- TBOX_DIM_ASSERT_CHECK_DIM_ARGS5(d_dim, patch, flux_data, soln_data, rhs_data,
- residual_data);
-
- tbox::Pointer<geom::CartesianPatchGeometry> patch_geom =
- patch.getPatchGeometry();
- const hier::Box& box = patch.getBox();
- const int* lower = &box.lower()[0];
- const int* upper = &box.upper()[0];
- const double* dx = patch_geom->getDx();
-
- tbox::Pointer<pdat::CellData<double> > scalar_field_data;
- double scalar_field_constant;
- if (d_stokes_spec.cIsVariable()) {
- scalar_field_data =
- patch.getPatchData(d_stokes_spec.getCPatchDataId());
- if (d_dim == tbox::Dimension(2)) {
- F77_FUNC(compresvarsca2d, COMPRESVARSCA2D) (
- flux_data.getPointer(0),
- flux_data.getPointer(1),
- &flux_data.getGhostCellWidth()[0],
- &flux_data.getGhostCellWidth()[1],
- rhs_data.getPointer(),
- &rhs_data.getGhostCellWidth()[0],
- &rhs_data.getGhostCellWidth()[1],
- residual_data.getPointer(),
- &residual_data.getGhostCellWidth()[0],
- &residual_data.getGhostCellWidth()[1],
- scalar_field_data->getPointer(),
- &scalar_field_data->getGhostCellWidth()[0],
- &scalar_field_data->getGhostCellWidth()[1],
- soln_data.getPointer(),
- &soln_data.getGhostCellWidth()[0],
- &soln_data.getGhostCellWidth()[1],
- &lower[0], &upper[0], &lower[1], &upper[1],
- dx);
- } else if (d_dim == tbox::Dimension(3)) {
- F77_FUNC(compresvarsca3d, COMPRESVARSCA3D) (
- flux_data.getPointer(0),
- flux_data.getPointer(1),
- flux_data.getPointer(2),
- &flux_data.getGhostCellWidth()[0],
- &flux_data.getGhostCellWidth()[1],
- &flux_data.getGhostCellWidth()[2],
- rhs_data.getPointer(),
- &rhs_data.getGhostCellWidth()[0],
- &rhs_data.getGhostCellWidth()[1],
- &rhs_data.getGhostCellWidth()[2],
- residual_data.getPointer(),
- &residual_data.getGhostCellWidth()[0],
- &residual_data.getGhostCellWidth()[1],
- &residual_data.getGhostCellWidth()[2],
- scalar_field_data->getPointer(),
- &scalar_field_data->getGhostCellWidth()[0],
- &scalar_field_data->getGhostCellWidth()[1],
- &scalar_field_data->getGhostCellWidth()[2],
- soln_data.getPointer(),
- &soln_data.getGhostCellWidth()[0],
- &soln_data.getGhostCellWidth()[1],
- &soln_data.getGhostCellWidth()[2],
- &lower[0], &upper[0], &lower[1], &upper[1], &lower[2], &upper[2],
- dx);
- }
- } else if (d_stokes_spec.cIsConstant()) {
- scalar_field_constant = d_stokes_spec.getCConstant();
- if (d_dim == tbox::Dimension(2)) {
- F77_FUNC(compresconsca2d, COMPRESCONSCA2D) (
- flux_data.getPointer(0),
- flux_data.getPointer(1),
- &flux_data.getGhostCellWidth()[0],
- &flux_data.getGhostCellWidth()[1],
- rhs_data.getPointer(),
- &rhs_data.getGhostCellWidth()[0],
- &rhs_data.getGhostCellWidth()[1],
- residual_data.getPointer(),
- &residual_data.getGhostCellWidth()[0],
- &residual_data.getGhostCellWidth()[1],
- scalar_field_constant,
- soln_data.getPointer(),
- &soln_data.getGhostCellWidth()[0],
- &soln_data.getGhostCellWidth()[1],
- &lower[0], &upper[0], &lower[1], &upper[1],
- dx);
- } else if (d_dim == tbox::Dimension(3)) {
- F77_FUNC(compresconsca3d, COMPRESCONSCA3D) (
- flux_data.getPointer(0),
- flux_data.getPointer(1),
- flux_data.getPointer(2),
- &flux_data.getGhostCellWidth()[0],
- &flux_data.getGhostCellWidth()[1],
- &flux_data.getGhostCellWidth()[2],
- rhs_data.getPointer(),
- &rhs_data.getGhostCellWidth()[0],
- &rhs_data.getGhostCellWidth()[1],
- &rhs_data.getGhostCellWidth()[2],
- residual_data.getPointer(),
- &residual_data.getGhostCellWidth()[0],
- &residual_data.getGhostCellWidth()[1],
- &residual_data.getGhostCellWidth()[2],
- scalar_field_constant,
- soln_data.getPointer(),
- &soln_data.getGhostCellWidth()[0],
- &soln_data.getGhostCellWidth()[1],
- &soln_data.getGhostCellWidth()[2],
- &lower[0], &upper[0], &lower[1], &upper[1], &lower[2], &upper[2],
- dx);
- }
- } else {
- scalar_field_constant = 0.0;
- if (d_dim == tbox::Dimension(2)) {
- F77_FUNC(compresconsca2d, COMPRESCONSCA2D) (
- flux_data.getPointer(0),
- flux_data.getPointer(1),
- &flux_data.getGhostCellWidth()[0],
- &flux_data.getGhostCellWidth()[1],
- rhs_data.getPointer(),
- &rhs_data.getGhostCellWidth()[0],
- &rhs_data.getGhostCellWidth()[1],
- residual_data.getPointer(),
- &residual_data.getGhostCellWidth()[0],
- &residual_data.getGhostCellWidth()[1],
- 0.0,
- soln_data.getPointer(),
- &soln_data.getGhostCellWidth()[0],
- &soln_data.getGhostCellWidth()[1],
- &lower[0], &upper[0], &lower[1], &upper[1],
- dx);
- } else if (d_dim == tbox::Dimension(3)) {
- F77_FUNC(compresconsca3d, COMPRESCONSCA3D) (
- flux_data.getPointer(0),
- flux_data.getPointer(1),
- flux_data.getPointer(2),
- &flux_data.getGhostCellWidth()[0],
- &flux_data.getGhostCellWidth()[1],
- &flux_data.getGhostCellWidth()[2],
- rhs_data.getPointer(),
- &rhs_data.getGhostCellWidth()[0],
- &rhs_data.getGhostCellWidth()[1],
- &rhs_data.getGhostCellWidth()[2],
- residual_data.getPointer(),
- &residual_data.getGhostCellWidth()[0],
- &residual_data.getGhostCellWidth()[1],
- &residual_data.getGhostCellWidth()[2],
- 0.0,
- soln_data.getPointer(),
- &soln_data.getGhostCellWidth()[0],
- &soln_data.getGhostCellWidth()[1],
- &soln_data.getGhostCellWidth()[2],
- &lower[0], &upper[0], &lower[1], &upper[1], &lower[2], &upper[2],
- dx);
- }
- }
- }
-
- }
-}
diff -r 7eb3182b8f20 -r a2e84a92deb1 StokesFACOps/deallocateOperatorState.C
--- a/StokesFACOps/deallocateOperatorState.C Fri Jan 07 16:33:07 2011 -0800
+++ b/StokesFACOps/deallocateOperatorState.C Fri Jan 07 16:41:05 2011 -0800
@@ -79,11 +79,11 @@ namespace SAMRAI {
d_flux_coarsen_algorithm.setNull();
d_flux_coarsen_schedules.setNull();
- d_ghostfill_refine_algorithm.setNull();
- d_ghostfill_refine_schedules.setNull();
+ p_ghostfill_refine_algorithm.setNull();
+ p_ghostfill_refine_schedules.setNull();
- d_ghostfill_nocoarse_refine_algorithm.setNull();
- d_ghostfill_nocoarse_refine_schedules.setNull();
+ v_ghostfill_refine_algorithm.setNull();
+ v_ghostfill_refine_schedules.setNull();
p_nocoarse_refine_algorithm.setNull();
p_nocoarse_refine_schedules.setNull();
diff -r 7eb3182b8f20 -r a2e84a92deb1 StokesFACOps/initializeOperatorState.C
--- a/StokesFACOps/initializeOperatorState.C Fri Jan 07 16:33:07 2011 -0800
+++ b/StokesFACOps/initializeOperatorState.C Fri Jan 07 16:41:05 2011 -0800
@@ -245,15 +245,16 @@ void SAMRAI::solv::StokesFACOps::initial
"CONSERVATIVE_COARSEN");
vdb->mapIndexToVariable(d_cell_scratch_id, variable);
- d_ghostfill_refine_operator =
+ p_ghostfill_refine_operator =
geometry->lookupRefineOperator(variable,
d_cf_discretization == "Ewing" ?
"CONSTANT_REFINE" : d_cf_discretization);
- vdb->mapIndexToVariable(d_cell_scratch_id, variable);
- d_ghostfill_nocoarse_refine_operator =
+ vdb->mapIndexToVariable(d_side_scratch_id, variable);
+ v_ghostfill_refine_operator =
geometry->lookupRefineOperator(variable,
- "CONSTANT_REFINE");
+ d_cf_discretization == "Ewing" ?
+ "CONSTANT_REFINE" : d_cf_discretization);
vdb->mapIndexToVariable(d_cell_scratch_id, variable);
p_nocoarse_refine_operator =
@@ -282,11 +283,11 @@ void SAMRAI::solv::StokesFACOps::initial
TBOX_ERROR(d_object_name
<< ": Cannot find flux coarsening operator");
}
- if (!d_ghostfill_refine_operator) {
+ if (!p_ghostfill_refine_operator) {
TBOX_ERROR(d_object_name
<< ": Cannot find ghost filling refinement operator");
}
- if (!d_ghostfill_nocoarse_refine_operator) {
+ if (!v_ghostfill_refine_operator) {
TBOX_ERROR(d_object_name
<< ": Cannot find ghost filling refinement operator");
}
@@ -311,8 +312,8 @@ void SAMRAI::solv::StokesFACOps::initial
* because we have deallocated the solver state above.
*/
d_prolongation_refine_schedules.resizeArray(d_ln_max + 1);
- d_ghostfill_refine_schedules.resizeArray(d_ln_max + 1);
- d_ghostfill_nocoarse_refine_schedules.resizeArray(d_ln_max + 1);
+ p_ghostfill_refine_schedules.resizeArray(d_ln_max + 1);
+ v_ghostfill_refine_schedules.resizeArray(d_ln_max + 1);
p_nocoarse_refine_schedules.resizeArray(d_ln_max + 1);
v_nocoarse_refine_schedules.resizeArray(d_ln_max + 1);
d_urestriction_coarsen_schedules.resizeArray(d_ln_max + 1);
@@ -323,8 +324,8 @@ void SAMRAI::solv::StokesFACOps::initial
d_urestriction_coarsen_algorithm = new xfer::CoarsenAlgorithm(d_dim);
d_rrestriction_coarsen_algorithm = new xfer::CoarsenAlgorithm(d_dim);
d_flux_coarsen_algorithm = new xfer::CoarsenAlgorithm(d_dim);
- d_ghostfill_refine_algorithm = new xfer::RefineAlgorithm(d_dim);
- d_ghostfill_nocoarse_refine_algorithm = new xfer::RefineAlgorithm(d_dim);
+ p_ghostfill_refine_algorithm = new xfer::RefineAlgorithm(d_dim);
+ v_ghostfill_refine_algorithm = new xfer::RefineAlgorithm(d_dim);
p_nocoarse_refine_algorithm = new xfer::RefineAlgorithm(d_dim);
v_nocoarse_refine_algorithm = new xfer::RefineAlgorithm(d_dim);
@@ -341,20 +342,20 @@ void SAMRAI::solv::StokesFACOps::initial
registerCoarsen(rhs.getComponentDescriptorIndex(0),
rhs.getComponentDescriptorIndex(0),
d_rrestriction_coarsen_operator);
- d_ghostfill_refine_algorithm->
+ p_ghostfill_refine_algorithm->
registerRefine(solution.getComponentDescriptorIndex(0),
solution.getComponentDescriptorIndex(0),
solution.getComponentDescriptorIndex(0),
- d_ghostfill_refine_operator);
+ p_ghostfill_refine_operator);
+ v_ghostfill_refine_algorithm->
+ registerRefine(solution.getComponentDescriptorIndex(1),
+ solution.getComponentDescriptorIndex(1),
+ solution.getComponentDescriptorIndex(1),
+ v_ghostfill_refine_operator);
d_flux_coarsen_algorithm->
registerCoarsen(((d_flux_id != -1) ? d_flux_id : d_flux_scratch_id),
d_oflux_scratch_id,
d_flux_coarsen_operator);
- d_ghostfill_nocoarse_refine_algorithm->
- registerRefine(solution.getComponentDescriptorIndex(0),
- solution.getComponentDescriptorIndex(0),
- solution.getComponentDescriptorIndex(0),
- d_ghostfill_nocoarse_refine_operator);
p_nocoarse_refine_algorithm->
registerRefine(solution.getComponentDescriptorIndex(0),
solution.getComponentDescriptorIndex(0),
@@ -382,25 +383,25 @@ void SAMRAI::solv::StokesFACOps::initial
TBOX_ERROR(d_object_name
<< ": Cannot create a refine schedule for prolongation!\n");
}
- d_ghostfill_refine_schedules[dest_ln] =
- d_ghostfill_refine_algorithm->
+ p_ghostfill_refine_schedules[dest_ln] =
+ p_ghostfill_refine_algorithm->
createSchedule(d_hierarchy->getPatchLevel(dest_ln),
dest_ln - 1,
d_hierarchy,
&d_bc_helper);
- if (!d_ghostfill_refine_schedules[dest_ln]) {
+ if (!p_ghostfill_refine_schedules[dest_ln]) {
TBOX_ERROR(d_object_name
<< ": Cannot create a refine schedule for ghost filling!\n");
}
- d_ghostfill_nocoarse_refine_schedules[dest_ln] =
- d_ghostfill_nocoarse_refine_algorithm->
+ v_ghostfill_refine_schedules[dest_ln] =
+ v_ghostfill_refine_algorithm->
createSchedule(d_hierarchy->getPatchLevel(dest_ln),
+ dest_ln - 1,
+ d_hierarchy,
&d_bc_helper);
- if (!d_ghostfill_nocoarse_refine_schedules[dest_ln]) {
- TBOX_ERROR(
- d_object_name
- <<
- ": Cannot create a refine schedule for ghost filling on bottom level!\n");
+ if (!v_ghostfill_refine_schedules[dest_ln]) {
+ TBOX_ERROR(d_object_name
+ << ": Cannot create a refine schedule for ghost filling!\n");
}
p_nocoarse_refine_schedules[dest_ln] =
p_nocoarse_refine_algorithm->
@@ -449,16 +450,6 @@ void SAMRAI::solv::StokesFACOps::initial
<< ": Cannot create a coarsen schedule for flux transfer!\n");
}
}
- d_ghostfill_nocoarse_refine_schedules[d_ln_min] =
- d_ghostfill_nocoarse_refine_algorithm->
- createSchedule(d_hierarchy->getPatchLevel(d_ln_min),
- &d_bc_helper);
- if (!d_ghostfill_nocoarse_refine_schedules[d_ln_min]) {
- TBOX_ERROR(
- d_object_name
- <<
- ": Cannot create a refine schedule for ghost filling on bottom level!\n");
- }
p_nocoarse_refine_schedules[d_ln_min] =
p_nocoarse_refine_algorithm->
createSchedule(d_hierarchy->getPatchLevel(d_ln_min),
diff -r 7eb3182b8f20 -r a2e84a92deb1 StokesFACOps/restrictSolution.C
--- a/StokesFACOps/restrictSolution.C Fri Jan 07 16:33:07 2011 -0800
+++ b/StokesFACOps/restrictSolution.C Fri Jan 07 16:41:05 2011 -0800
@@ -70,8 +70,9 @@ namespace SAMRAI {
// dest_ln);
abort();
} else {
- xeqScheduleGhostFill(d.getComponentDescriptorIndex(0),
- dest_ln);
+ // xeqScheduleGhostFill(d.getComponentDescriptorIndex(0),
+ // dest_ln);
+ abort();
}
t_restrict_solution->stop();
diff -r 7eb3182b8f20 -r a2e84a92deb1 StokesFACOps/smoothErrorByRedBlack.C
--- a/StokesFACOps/smoothErrorByRedBlack.C Fri Jan 07 16:33:07 2011 -0800
+++ b/StokesFACOps/smoothErrorByRedBlack.C Fri Jan 07 16:41:05 2011 -0800
@@ -81,7 +81,8 @@ void SAMRAI::solv::StokesFACOps::smoothE
* to fill ghost boundaries that will not change through
* the smoothing loop.
*/
- xeqScheduleGhostFill(data_id, ln);
+ // xeqScheduleGhostFill(data_id, ln);
+ abort();
}
/*
diff -r 7eb3182b8f20 -r a2e84a92deb1 StokesFACOps/xeqScheduleGhostFill.C
--- a/StokesFACOps/xeqScheduleGhostFill.C Fri Jan 07 16:33:07 2011 -0800
+++ b/StokesFACOps/xeqScheduleGhostFill.C Fri Jan 07 16:41:05 2011 -0800
@@ -40,21 +40,43 @@
#include "SAMRAI/xfer/RefineSchedule.h"
#include "SAMRAI/xfer/PatchLevelFullFillPattern.h"
-void SAMRAI::solv::StokesFACOps::xeqScheduleGhostFill(int dst_id,
+void SAMRAI::solv::StokesFACOps::xeqScheduleGhostFill(int p_id, int v_id,
int dest_ln)
{
- if (!d_ghostfill_refine_schedules[dest_ln]) {
- TBOX_ERROR("Expected schedule not found.");
+ /* p */
+ {
+ if (!p_ghostfill_refine_schedules[dest_ln]) {
+ TBOX_ERROR("Expected schedule not found.");
+ }
+ xfer::RefineAlgorithm refiner(d_dim);
+ refiner.
+ registerRefine(p_id,
+ p_id,
+ p_id,
+ p_ghostfill_refine_operator);
+ refiner.
+ resetSchedule(p_ghostfill_refine_schedules[dest_ln]);
+ p_ghostfill_refine_schedules[dest_ln]->fillData(0.0);
+ p_ghostfill_refine_algorithm->
+ resetSchedule(p_ghostfill_refine_schedules[dest_ln]);
}
- xfer::RefineAlgorithm refiner(d_dim);
- refiner.
- registerRefine(dst_id,
- dst_id,
- dst_id,
- d_ghostfill_refine_operator);
- refiner.
- resetSchedule(d_ghostfill_refine_schedules[dest_ln]);
- d_ghostfill_refine_schedules[dest_ln]->fillData(0.0);
- d_ghostfill_refine_algorithm->
- resetSchedule(d_ghostfill_refine_schedules[dest_ln]);
+
+ /* v */
+ {
+ if (!v_ghostfill_refine_schedules[dest_ln]) {
+ TBOX_ERROR("Expected schedule not found.");
+ }
+ xfer::RefineAlgorithm refiner(d_dim);
+ refiner.
+ registerRefine(v_id,
+ v_id,
+ v_id,
+ v_ghostfill_refine_operator);
+ refiner.
+ resetSchedule(v_ghostfill_refine_schedules[dest_ln]);
+ v_ghostfill_refine_schedules[dest_ln]->fillData(0.0);
+ v_ghostfill_refine_algorithm->
+ resetSchedule(v_ghostfill_refine_schedules[dest_ln]);
+ }
}
+
More information about the CIG-COMMITS
mailing list