[cig-commits] commit: Make prolong work with p and v
Mercurial
hg at geodynamics.org
Fri Feb 25 14:14:22 PST 2011
changeset: 39:86a46f2d024d
user: Walter Landry <wlandry at caltech.edu>
date: Sat Jan 08 06:51:04 2011 -0800
files: StokesFACOps.I StokesFACOps.h StokesFACOps/StokesFACOps.C StokesFACOps/deallocateOperatorState.C StokesFACOps/initializeOperatorState.C StokesFACOps/prolongErrorAndCorrect.C StokesFACOps/xeqScheduleProlongation.C
description:
Make prolong work with p and v
diff -r 36404d272d27 -r 86a46f2d024d StokesFACOps.I
--- a/StokesFACOps.I Sat Jan 08 06:27:14 2011 -0800
+++ b/StokesFACOps.I Sat Jan 08 06:51:04 2011 -0800
@@ -206,7 +206,8 @@ void StokesFACOps::setProlongationMethod
<< "causes a corruption in the state.\n");
}
#endif
- d_prolongation_method = prolongation_method;
+ p_prolongation_method = prolongation_method;
+ v_prolongation_method = prolongation_method;
}
}
diff -r 36404d272d27 -r 86a46f2d024d StokesFACOps.h
--- a/StokesFACOps.h Sat Jan 08 06:27:14 2011 -0800
+++ b/StokesFACOps.h Sat Jan 08 06:51:04 2011 -0800
@@ -603,8 +603,8 @@ private:
* they manipulate are as follows:
* <ol>
* <li> xeqScheduleProlongation():
- * d_prolongation_refine_operator
- * d_prolongation_refine_schedules
+ * prolongation_refine_operator
+ * prolongation_refine_schedules
* <li> xeqScheduleURestriction():
* d_restriction_coarsen_operator,
* urestriction_coarsen_schedules.
@@ -625,11 +625,9 @@ private:
* @return refinement schedule for prolongation
*/
void
- xeqScheduleProlongation(
- int dst_id,
- int src_id,
- int scr_id,
- int dest_ln);
+ xeqScheduleProlongation(int p_dst, int p_src, int p_scr,
+ int v_dst, int v_src, int v_scr,
+ int dest_ln);
/*!
* @brief Execute schedule for restricting solution to the specified
@@ -806,7 +804,8 @@ private:
*
* @see setProlongationMethod()
*/
- std::string d_prolongation_method;
+ std::string p_prolongation_method;
+ std::string v_prolongation_method;
/*!
* @brief Tolerance specified to coarse solver
@@ -889,7 +888,7 @@ private:
* Scratch data is allocated and removed as needed
* to reduce memory usage.
*/
- int d_cell_scratch_id;
+ int d_cell_scratch_id, d_side_scratch_id;
/*!
* @brief ID of the side-centered scratch data.
@@ -902,7 +901,6 @@ private:
* immediately after use.
*/
int d_flux_scratch_id;
- int d_side_scratch_id;
/*!
* @brief ID of the outerside-centered scratch data.
@@ -921,10 +919,15 @@ private:
*/
//! @brief Error prolongation (refinement) operator.
- tbox::Pointer<xfer::RefineOperator> d_prolongation_refine_operator;
- tbox::Pointer<xfer::RefineAlgorithm> d_prolongation_refine_algorithm;
+ tbox::Pointer<xfer::RefineOperator> p_prolongation_refine_operator;
+ tbox::Pointer<xfer::RefineAlgorithm> p_prolongation_refine_algorithm;
tbox::Array<tbox::Pointer<xfer::RefineSchedule> >
- d_prolongation_refine_schedules;
+ p_prolongation_refine_schedules;
+
+ tbox::Pointer<xfer::RefineOperator> v_prolongation_refine_operator;
+ tbox::Pointer<xfer::RefineAlgorithm> v_prolongation_refine_algorithm;
+ tbox::Array<tbox::Pointer<xfer::RefineSchedule> >
+ v_prolongation_refine_schedules;
//! @brief Solution restriction (coarsening) operator.
tbox::Pointer<xfer::CoarsenOperator> p_urestriction_coarsen_operator;
diff -r 36404d272d27 -r 86a46f2d024d StokesFACOps/StokesFACOps.C
--- a/StokesFACOps/StokesFACOps.C Sat Jan 08 06:27:14 2011 -0800
+++ b/StokesFACOps/StokesFACOps.C Sat Jan 08 06:51:04 2011 -0800
@@ -72,8 +72,7 @@ namespace SAMRAI {
* Constructor. *
********************************************************************
*/
- StokesFACOps::StokesFACOps(
- const tbox::Dimension& dim,
+ StokesFACOps::StokesFACOps(const tbox::Dimension& dim,
const std::string& object_name,
tbox::Pointer<tbox::Database> database):
d_dim(dim),
@@ -93,7 +92,8 @@ namespace SAMRAI {
),
d_cf_discretization("Ewing"),
- d_prolongation_method("CONSTANT_REFINE"),
+ p_prolongation_method("CONSTANT_REFINE"),
+ v_prolongation_method("CONSTANT_REFINE"),
d_coarse_solver_tolerance(1.e-8),
d_coarse_solver_max_iterations(10),
d_residual_tolerance_during_smoothing(-1.0),
@@ -109,12 +109,15 @@ namespace SAMRAI {
d_context(hier::VariableDatabase::getDatabase()
->getContext(object_name + "::PRIVATE_CONTEXT")),
d_cell_scratch_id(-1),
+ d_side_scratch_id(-1),
d_flux_scratch_id(-1),
- d_side_scratch_id(-1),
d_oflux_scratch_id(-1),
- d_prolongation_refine_operator(),
- d_prolongation_refine_algorithm(),
- d_prolongation_refine_schedules(),
+ p_prolongation_refine_operator(),
+ p_prolongation_refine_algorithm(),
+ p_prolongation_refine_schedules(),
+ v_prolongation_refine_operator(),
+ v_prolongation_refine_algorithm(),
+ v_prolongation_refine_schedules(),
p_urestriction_coarsen_operator(),
p_urestriction_coarsen_algorithm(),
p_urestriction_coarsen_schedules(),
@@ -231,9 +234,13 @@ namespace SAMRAI {
database->getStringWithDefault("cf_discretization",
d_cf_discretization);
- d_prolongation_method =
+ p_prolongation_method =
database->getStringWithDefault("prolongation_method",
- d_prolongation_method);
+ p_prolongation_method);
+
+ v_prolongation_method =
+ database->getStringWithDefault("prolongation_method",
+ v_prolongation_method);
d_enable_logging =
database->getBoolWithDefault("enable_logging",
diff -r 36404d272d27 -r 86a46f2d024d StokesFACOps/deallocateOperatorState.C
--- a/StokesFACOps/deallocateOperatorState.C Sat Jan 08 06:27:14 2011 -0800
+++ b/StokesFACOps/deallocateOperatorState.C Sat Jan 08 06:51:04 2011 -0800
@@ -67,8 +67,11 @@ namespace SAMRAI {
d_ln_min = -1;
d_ln_max = -1;
- d_prolongation_refine_algorithm.setNull();
- d_prolongation_refine_schedules.setNull();
+ p_prolongation_refine_algorithm.setNull();
+ p_prolongation_refine_schedules.setNull();
+
+ v_prolongation_refine_algorithm.setNull();
+ v_prolongation_refine_schedules.setNull();
p_urestriction_coarsen_algorithm.setNull();
p_urestriction_coarsen_schedules.setNull();
diff -r 36404d272d27 -r 86a46f2d024d StokesFACOps/initializeOperatorState.C
--- a/StokesFACOps/initializeOperatorState.C Sat Jan 08 06:27:14 2011 -0800
+++ b/StokesFACOps/initializeOperatorState.C Sat Jan 08 06:51:04 2011 -0800
@@ -229,9 +229,14 @@ void SAMRAI::solv::StokesFACOps::initial
tbox::Pointer<hier::Variable> variable;
vdb->mapIndexToVariable(d_cell_scratch_id, variable);
- d_prolongation_refine_operator =
+ p_prolongation_refine_operator =
geometry->lookupRefineOperator(variable,
- d_prolongation_method);
+ p_prolongation_method);
+
+ vdb->mapIndexToVariable(d_side_scratch_id, variable);
+ v_prolongation_refine_operator =
+ geometry->lookupRefineOperator(variable,
+ v_prolongation_method);
vdb->mapIndexToVariable(d_cell_scratch_id, variable);
p_urestriction_coarsen_operator =
@@ -273,9 +278,13 @@ void SAMRAI::solv::StokesFACOps::initial
"CONSTANT_REFINE");
#ifdef DEBUG_CHECK_ASSERTIONS
- if (!d_prolongation_refine_operator) {
+ if (!p_prolongation_refine_operator) {
TBOX_ERROR(d_object_name
- << ": Cannot find prolongation refine operator");
+ << ": Cannot find p prolongation refine operator");
+ }
+ if (!v_prolongation_refine_operator) {
+ TBOX_ERROR(d_object_name
+ << ": Cannot find v prolongation refine operator");
}
if (!p_urestriction_coarsen_operator) {
TBOX_ERROR(d_object_name
@@ -325,7 +334,8 @@ void SAMRAI::solv::StokesFACOps::initial
* There is no need to delete the old schedules first
* because we have deallocated the solver state above.
*/
- d_prolongation_refine_schedules.resizeArray(d_ln_max + 1);
+ p_prolongation_refine_schedules.resizeArray(d_ln_max + 1);
+ v_prolongation_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);
@@ -336,7 +346,8 @@ void SAMRAI::solv::StokesFACOps::initial
v_rrestriction_coarsen_schedules.resizeArray(d_ln_max + 1);
d_flux_coarsen_schedules.resizeArray(d_ln_max + 1);
- d_prolongation_refine_algorithm = new xfer::RefineAlgorithm(d_dim);
+ p_prolongation_refine_algorithm = new xfer::RefineAlgorithm(d_dim);
+ v_prolongation_refine_algorithm = new xfer::RefineAlgorithm(d_dim);
p_urestriction_coarsen_algorithm = new xfer::CoarsenAlgorithm(d_dim);
p_rrestriction_coarsen_algorithm = new xfer::CoarsenAlgorithm(d_dim);
v_urestriction_coarsen_algorithm = new xfer::CoarsenAlgorithm(d_dim);
@@ -347,11 +358,16 @@ void SAMRAI::solv::StokesFACOps::initial
p_nocoarse_refine_algorithm = new xfer::RefineAlgorithm(d_dim);
v_nocoarse_refine_algorithm = new xfer::RefineAlgorithm(d_dim);
- d_prolongation_refine_algorithm->
+ p_prolongation_refine_algorithm->
registerRefine(d_cell_scratch_id,
solution.getComponentDescriptorIndex(0),
d_cell_scratch_id,
- d_prolongation_refine_operator);
+ p_prolongation_refine_operator);
+ v_prolongation_refine_algorithm->
+ registerRefine(d_side_scratch_id,
+ solution.getComponentDescriptorIndex(1),
+ d_side_scratch_id,
+ v_prolongation_refine_operator);
p_urestriction_coarsen_algorithm->
registerCoarsen(solution.getComponentDescriptorIndex(0),
solution.getComponentDescriptorIndex(0),
@@ -395,19 +411,31 @@ void SAMRAI::solv::StokesFACOps::initial
for (int dest_ln = d_ln_min + 1; dest_ln <= d_ln_max; ++dest_ln) {
- tbox::Pointer<xfer::PatchLevelFullFillPattern> fill_pattern(
- new xfer::PatchLevelFullFillPattern());
- d_prolongation_refine_schedules[dest_ln] =
- d_prolongation_refine_algorithm->
+ tbox::Pointer<xfer::PatchLevelFullFillPattern>
+ fill_pattern(new xfer::PatchLevelFullFillPattern());
+ p_prolongation_refine_schedules[dest_ln] =
+ p_prolongation_refine_algorithm->
createSchedule(fill_pattern,
d_hierarchy->getPatchLevel(dest_ln),
tbox::Pointer<hier::PatchLevel>(),
dest_ln - 1,
d_hierarchy,
&d_bc_helper);
- if (!d_prolongation_refine_schedules[dest_ln]) {
+ if (!p_prolongation_refine_schedules[dest_ln]) {
TBOX_ERROR(d_object_name
- << ": Cannot create a refine schedule for prolongation!\n");
+ << ": Cannot create a refine schedule for p prolongation!\n");
+ }
+ v_prolongation_refine_schedules[dest_ln] =
+ v_prolongation_refine_algorithm->
+ createSchedule(fill_pattern,
+ d_hierarchy->getPatchLevel(dest_ln),
+ tbox::Pointer<hier::PatchLevel>(),
+ dest_ln - 1,
+ d_hierarchy,
+ &d_bc_helper);
+ if (!v_prolongation_refine_schedules[dest_ln]) {
+ TBOX_ERROR(d_object_name
+ << ": Cannot create a refine schedule for v prolongation!\n");
}
p_ghostfill_refine_schedules[dest_ln] =
p_ghostfill_refine_algorithm->
diff -r 36404d272d27 -r 86a46f2d024d StokesFACOps/prolongErrorAndCorrect.C
--- a/StokesFACOps/prolongErrorAndCorrect.C Sat Jan 08 06:27:14 2011 -0800
+++ b/StokesFACOps/prolongErrorAndCorrect.C Sat Jan 08 06:51:04 2011 -0800
@@ -40,10 +40,7 @@
#include "SAMRAI/xfer/RefineSchedule.h"
#include "SAMRAI/xfer/PatchLevelFullFillPattern.h"
-namespace SAMRAI {
- namespace solv {
-
- /*
+/*
***********************************************************************
* FACOperatorStrategy virtual prolongErrorAndCorrect function. *
* After the prolongation, we set the physical boundary condition *
@@ -52,59 +49,61 @@ namespace SAMRAI {
***********************************************************************
*/
- void StokesFACOps::prolongErrorAndCorrect(
- const SAMRAIVectorReal<double>& s,
- SAMRAIVectorReal<double>& d,
- int dest_ln) {
-
- t_prolong->start();
+void SAMRAI::solv::StokesFACOps::prolongErrorAndCorrect
+(const SAMRAIVectorReal<double>& s,
+ SAMRAIVectorReal<double>& d,
+ int dest_ln)
+{
+ t_prolong->start();
#ifdef DEBUG_CHECK_ASSERTIONS
- if (s.getPatchHierarchy() != d_hierarchy
- || d.getPatchHierarchy() != d_hierarchy) {
- TBOX_ERROR(d_object_name << ": Vector hierarchy does not match\n"
- "internal state hierarchy.");
- }
+ if (s.getPatchHierarchy() != d_hierarchy
+ || d.getPatchHierarchy() != d_hierarchy) {
+ TBOX_ERROR(d_object_name << ": Vector hierarchy does not match\n"
+ "internal state hierarchy.");
+ }
#endif
- tbox::Pointer<hier::PatchLevel> coarse_level =
- d_hierarchy->getPatchLevel(dest_ln - 1);
- tbox::Pointer<hier::PatchLevel> fine_level =
- d_hierarchy->getPatchLevel(dest_ln);
+ tbox::Pointer<hier::PatchLevel> coarse_level =
+ d_hierarchy->getPatchLevel(dest_ln - 1);
+ tbox::Pointer<hier::PatchLevel> fine_level =
+ d_hierarchy->getPatchLevel(dest_ln);
- /*
- * Data is prolonged into the scratch space corresponding
- * to index d_cell_scratch_id and allocated here.
- */
- fine_level->allocatePatchData(d_cell_scratch_id);
+ /*
+ * Data is prolonged into the scratch space corresponding
+ * to index d_cell_scratch_id and allocated here.
+ */
+ fine_level->allocatePatchData(d_cell_scratch_id);
+ fine_level->allocatePatchData(d_side_scratch_id);
- /*
- * Refine solution into scratch space to fill the fine level
- * interior in the scratch space, then use that refined data
- * to correct the fine level error.
- */
- d_bc_helper.setTargetDataId(d_cell_scratch_id);
- d_bc_helper.setHomogeneousBc(true);
- const int src_index = s.getComponentDescriptorIndex(0);
- xeqScheduleProlongation(d_cell_scratch_id,
- src_index,
- d_cell_scratch_id,
- dest_ln);
+ /*
+ * Refine solution into scratch space to fill the fine level
+ * interior in the scratch space, then use that refined data
+ * to correct the fine level error.
+ */
+ // d_bc_helper.setTargetDataId(d_cell_scratch_id);
+ // d_bc_helper.setHomogeneousBc(true);
+ xeqScheduleProlongation(d_cell_scratch_id,
+ s.getComponentDescriptorIndex(0),
+ d_cell_scratch_id,
+ d_side_scratch_id,
+ s.getComponentDescriptorIndex(1),
+ d_side_scratch_id,
+ dest_ln);
- /*
- * Add the refined error in the scratch space
- * to the error currently residing in the destination level.
- */
- math::HierarchyCellDataOpsReal<double>
- hierarchy_math_ops(d_hierarchy, dest_ln, dest_ln);
- const int dst_index = d.getComponentDescriptorIndex(0);
- hierarchy_math_ops.add(dst_index, dst_index, d_cell_scratch_id);
+ /*
+ * Add the refined error in the scratch space to the error currently
+ * residing in the destination level.
+ */
+ math::HierarchyCellDataOpsReal<double>
+ hierarchy_math_ops(d_hierarchy, dest_ln, dest_ln);
+ const int p_dst = d.getComponentDescriptorIndex(0);
+ hierarchy_math_ops.add(p_dst, p_dst, d_cell_scratch_id);
+ const int v_dst = d.getComponentDescriptorIndex(1);
+ hierarchy_math_ops.add(v_dst, v_dst, d_side_scratch_id);
- fine_level->deallocatePatchData(d_cell_scratch_id);
+ fine_level->deallocatePatchData(d_cell_scratch_id);
+ fine_level->deallocatePatchData(d_side_scratch_id);
- t_prolong->stop();
-
- }
-
- }
+ t_prolong->stop();
}
diff -r 36404d272d27 -r 86a46f2d024d StokesFACOps/xeqScheduleProlongation.C
--- a/StokesFACOps/xeqScheduleProlongation.C Sat Jan 08 06:27:14 2011 -0800
+++ b/StokesFACOps/xeqScheduleProlongation.C Sat Jan 08 06:51:04 2011 -0800
@@ -40,31 +40,33 @@
#include "SAMRAI/xfer/RefineSchedule.h"
#include "SAMRAI/xfer/PatchLevelFullFillPattern.h"
-namespace SAMRAI {
- namespace solv {
+void SAMRAI::solv::StokesFACOps::xeqScheduleProlongation
+(int p_dst, int p_src, int p_scr, int v_dst, int v_src, int v_scr,
+ int dest_ln)
+{
+ /* p */
+ {
+ if (!p_prolongation_refine_schedules[dest_ln]) {
+ TBOX_ERROR("Expected schedule not found.");
+ }
+ xfer::RefineAlgorithm refiner(d_dim);
+ refiner.registerRefine(p_dst, p_src, p_scr, p_prolongation_refine_operator);
+ refiner.resetSchedule(p_prolongation_refine_schedules[dest_ln]);
+ p_prolongation_refine_schedules[dest_ln]->fillData(0.0);
+ p_prolongation_refine_algorithm->
+ resetSchedule(p_prolongation_refine_schedules[dest_ln]);
+ }
- void
- StokesFACOps::xeqScheduleProlongation(
- int dst_id,
- int src_id,
- int scr_id,
- int dest_ln)
- {
- if (!d_prolongation_refine_schedules[dest_ln]) {
- TBOX_ERROR("Expected schedule not found.");
- }
- xfer::RefineAlgorithm refiner(d_dim);
- refiner.
- registerRefine(dst_id,
- src_id,
- scr_id,
- d_prolongation_refine_operator);
- refiner.
- resetSchedule(d_prolongation_refine_schedules[dest_ln]);
- d_prolongation_refine_schedules[dest_ln]->fillData(0.0);
- d_prolongation_refine_algorithm->
- resetSchedule(d_prolongation_refine_schedules[dest_ln]);
+ /* v */
+ {
+ if (!v_prolongation_refine_schedules[dest_ln]) {
+ TBOX_ERROR("Expected schedule not found.");
}
-
+ xfer::RefineAlgorithm refiner(d_dim);
+ refiner.registerRefine(v_dst, v_src, v_scr, v_prolongation_refine_operator);
+ refiner.resetSchedule(v_prolongation_refine_schedules[dest_ln]);
+ v_prolongation_refine_schedules[dest_ln]->fillData(0.0);
+ v_prolongation_refine_algorithm->
+ resetSchedule(v_prolongation_refine_schedules[dest_ln]);
}
}
More information about the CIG-COMMITS
mailing list