[cig-commits] commit: Make the FAC preconditioner use red/black by default. Associate v and v_rhs with a SAMRAI vector.
Mercurial
hg at geodynamics.org
Fri Feb 25 14:13:22 PST 2011
changeset: 23:b111e7f5295b
user: Walter Landry <wlandry at caltech.edu>
date: Sun Jan 02 19:52:18 2011 -0800
files: FACStokes/solveStokes.C StokesFACSolver.h StokesFACSolver/StokesFACSolver.C StokesFACSolver/createVectorWrappers.C StokesFACSolver/initializeSolverState.C StokesFACSolver/solveSystem.C
description:
Make the FAC preconditioner use red/black by default. Associate v and v_rhs with a SAMRAI vector.
diff -r fa9412f95188 -r b111e7f5295b FACStokes/solveStokes.C
--- a/FACStokes/solveStokes.C Sun Jan 02 17:56:57 2011 -0800
+++ b/FACStokes/solveStokes.C Sun Jan 02 19:52:18 2011 -0800
@@ -67,7 +67,7 @@ namespace SAMRAI {
d_stokes_fac_solver.setCConstant(0.0);
d_stokes_fac_solver.initializeSolverState
- (p_id,p_rhs_id,d_hierarchy,0,
+ (p_id,p_rhs_id,v_id,v_rhs_id,d_hierarchy,0,
d_hierarchy->getFinestLevelNumber());
tbox::plog << "solving..." << std::endl;
diff -r fa9412f95188 -r b111e7f5295b StokesFACSolver.h
--- a/StokesFACSolver.h Sun Jan 02 17:56:57 2011 -0800
+++ b/StokesFACSolver.h Sun Jan 02 19:52:18 2011 -0800
@@ -500,12 +500,13 @@ public:
* @param fine_level The finest level in the solve
*/
void
- initializeSolverState(
- const int solution,
- const int rhs,
- tbox::Pointer<hier::PatchHierarchy> hierarchy,
- const int coarse_level = -1,
- const int fine_level = -1);
+ initializeSolverState(const int p,
+ const int p_rhs,
+ const int v,
+ const int v_rhs,
+ tbox::Pointer<hier::PatchHierarchy> hierarchy,
+ const int coarse_level = -1,
+ const int fine_level = -1);
/*!
* @brief Remove the solver's internal state data
@@ -574,9 +575,7 @@ private:
* specified by patch data indices u and f.
*/
void
- createVectorWrappers(
- int u,
- int f);
+ createVectorWrappers(int p, int p_rhs, int v, int v_rhs);
/*
* @brief Destroy vector wrappers referenced to by @c d_uv and @c d_fv.
diff -r fa9412f95188 -r b111e7f5295b StokesFACSolver/StokesFACSolver.C
--- a/StokesFACSolver/StokesFACSolver.C Sun Jan 02 17:56:57 2011 -0800
+++ b/StokesFACSolver/StokesFACSolver.C Sun Jan 02 19:52:18 2011 -0800
@@ -84,16 +84,16 @@ namespace SAMRAI {
setPresmoothingSweeps(1);
setPostsmoothingSweeps(1);
setCoarseFineDiscretization("Ewing");
-#ifdef HAVE_HYPRE
- setCoarsestLevelSolverChoice("hypre");
- setCoarsestLevelSolverTolerance(1e-10);
- setCoarsestLevelSolverMaxIterations(20);
- setUseSMG(true);
-#else
+// #ifdef HAVE_HYPRE
+// setCoarsestLevelSolverChoice("hypre");
+// setCoarsestLevelSolverTolerance(1e-10);
+// setCoarsestLevelSolverMaxIterations(20);
+// setUseSMG(true);
+// #else
setCoarsestLevelSolverChoice("redblack");
setCoarsestLevelSolverTolerance(1e-8);
setCoarsestLevelSolverMaxIterations(500);
-#endif
+// #endif
/*
* Construct integer tag variables and add to variable database. Note that
@@ -105,18 +105,36 @@ namespace SAMRAI {
*/
hier::VariableDatabase* var_db = hier::VariableDatabase::getDatabase();
- static std::string weight_variable_name("StokesFACSolver_weight");
+ {
+ static std::string cell_weight_name("StokesFACSolver_cell_weight");
- tbox::Pointer<pdat::CellVariable<double> >
- weight = var_db->getVariable(weight_variable_name);
- if (weight.isNull()) {
- weight = new pdat::CellVariable<double>(d_dim, weight_variable_name, 1);
+ tbox::Pointer<pdat::CellVariable<double> >
+ weight = var_db->getVariable(cell_weight_name);
+ if (weight.isNull()) {
+ weight = new pdat::CellVariable<double>(d_dim, cell_weight_name, 1);
+ }
+
+ if (s_weight_id[d_dim.getValue() - 1] < 0) {
+ s_weight_id[d_dim.getValue() - 1] =
+ var_db->registerInternalSAMRAIVariable
+ (weight,hier::IntVector::getZero(d_dim));
+ }
}
- if (s_weight_id[d_dim.getValue() - 1] < 0) {
- s_weight_id[d_dim.getValue() - 1] =
- var_db->registerInternalSAMRAIVariable
- (weight,hier::IntVector::getZero(d_dim));
+ {
+ static std::string side_weight_name("StokesFACSolver_side_weight");
+
+ tbox::Pointer<pdat::SideVariable<double> >
+ weight = var_db->getVariable(side_weight_name);
+ if (weight.isNull()) {
+ weight = new pdat::SideVariable<double>(d_dim, side_weight_name, 1);
+ }
+
+ if (s_weight_id[d_dim.getValue() - 2] < 0) {
+ s_weight_id[d_dim.getValue() - 2] =
+ var_db->registerInternalSAMRAIVariable
+ (weight,hier::IntVector::getZero(d_dim));
+ }
}
/*
diff -r fa9412f95188 -r b111e7f5295b StokesFACSolver/createVectorWrappers.C
--- a/StokesFACSolver/createVectorWrappers.C Sun Jan 02 17:56:57 2011 -0800
+++ b/StokesFACSolver/createVectorWrappers.C Sun Jan 02 19:52:18 2011 -0800
@@ -15,57 +15,83 @@
#include IOMANIP_HEADER_FILE
-namespace SAMRAI {
- namespace solv {
+void SAMRAI::solv::StokesFACSolver::createVectorWrappers(int p, int p_rhs,
+ int v, int v_rhs) {
- void StokesFACSolver::createVectorWrappers(
- int u,
- int f) {
+ hier::VariableDatabase& vdb(*hier::VariableDatabase::getDatabase());
+ tbox::Pointer<hier::Variable> variable;
- hier::VariableDatabase& vdb(*hier::VariableDatabase::getDatabase());
- tbox::Pointer<hier::Variable> variable;
+ if (!d_uv || d_uv->getComponentDescriptorIndex(0) != p) {
+ d_uv.setNull();
+ d_uv = new SAMRAIVectorReal<double>(d_object_name + "::uv",
+ d_hierarchy,
+ d_ln_min,
+ d_ln_max);
+ /* Add p */
+ vdb.mapIndexToVariable(p, variable);
+#ifdef DEBUG_CHECK_ASSERTIONS
+ if (!variable) {
+ TBOX_ERROR(d_object_name << ": No variable for patch data index "
+ << p << "\n");
+ }
+ tbox::Pointer<pdat::CellVariable<double> > cell_variable = variable;
+ if (!cell_variable) {
+ TBOX_ERROR(d_object_name << ": hier::Patch data index " << p
+ << " is not a cell-double variable.\n");
+ }
+#endif
+ d_uv->addComponent(variable, p, s_weight_id[d_dim.getValue() - 1]);
- if (!d_uv || d_uv->getComponentDescriptorIndex(0) != u) {
- d_uv.setNull();
- d_uv = new SAMRAIVectorReal<double>(d_object_name + "::uv",
- d_hierarchy,
- d_ln_min,
- d_ln_max);
- vdb.mapIndexToVariable(u, variable);
+ /* Add v */
+ vdb.mapIndexToVariable(v, variable);
#ifdef DEBUG_CHECK_ASSERTIONS
- if (!variable) {
- TBOX_ERROR(d_object_name << ": No variable for patch data index "
- << u << "\n");
- }
- tbox::Pointer<pdat::CellVariable<double> > cell_variable = variable;
- if (!cell_variable) {
- TBOX_ERROR(d_object_name << ": hier::Patch data index " << u
- << " is not a cell-double variable.\n");
- }
+ if (!variable) {
+ TBOX_ERROR(d_object_name << ": No variable for patch data index "
+ << v << "\n");
+ }
+ tbox::Pointer<pdat::SideVariable<double> > side_variable = variable;
+ if (!side_variable) {
+ TBOX_ERROR(d_object_name << ": hier::Patch data index " << v
+ << " is not a side-double variable.\n");
+ }
#endif
- d_uv->addComponent(variable, u, s_weight_id[d_dim.getValue() - 1]);
- }
+ d_uv->addComponent(variable, v, s_weight_id[d_dim.getValue() - 2]);
+ }
- if (!d_fv || d_fv->getComponentDescriptorIndex(0) != f) {
- d_fv.setNull();
- d_fv = new SAMRAIVectorReal<double>(d_object_name + "::fv",
- d_hierarchy,
- d_ln_min,
- d_ln_max);
- vdb.mapIndexToVariable(f, variable);
+ if (!d_fv || d_fv->getComponentDescriptorIndex(0) != p_rhs) {
+ d_fv.setNull();
+ d_fv = new SAMRAIVectorReal<double>(d_object_name + "::fv",
+ d_hierarchy,
+ d_ln_min,
+ d_ln_max);
+ /* Add p_rhs */
+ vdb.mapIndexToVariable(p_rhs, variable);
#ifdef DEBUG_CHECK_ASSERTIONS
- if (!variable) {
- TBOX_ERROR(d_object_name << ": No variable for patch data index "
- << f << "\n");
- }
- tbox::Pointer<pdat::CellVariable<double> > cell_variable = variable;
- if (!cell_variable) {
- TBOX_ERROR(d_object_name << ": hier::Patch data index " << f
- << " is not a cell-double variable.\n");
- }
+ if (!variable) {
+ TBOX_ERROR(d_object_name << ": No variable for patch data index "
+ << p_rhs << "\n");
+ }
+ tbox::Pointer<pdat::CellVariable<double> > cell_variable = variable;
+ if (!cell_variable) {
+ TBOX_ERROR(d_object_name << ": hier::Patch data index " << p_rhs
+ << " is not a cell-double variable.\n");
+ }
#endif
- d_fv->addComponent(variable, f, s_weight_id[d_dim.getValue() - 1]);
- }
+ d_fv->addComponent(variable, p_rhs, s_weight_id[d_dim.getValue() - 1]);
+
+ /* Add v_rhs */
+ vdb.mapIndexToVariable(v_rhs, variable);
+#ifdef DEBUG_CHECK_ASSERTIONS
+ if (!variable) {
+ TBOX_ERROR(d_object_name << ": No variable for patch data index "
+ << v_rhs << "\n");
}
+ tbox::Pointer<pdat::SideVariable<double> > side_variable = variable;
+ if (!side_variable) {
+ TBOX_ERROR(d_object_name << ": hier::Patch data index " << v_rhs
+ << " is not a cell-double variable.\n");
+ }
+#endif
+ d_fv->addComponent(variable, v_rhs, s_weight_id[d_dim.getValue() - 2]);
}
}
diff -r fa9412f95188 -r b111e7f5295b StokesFACSolver/initializeSolverState.C
--- a/StokesFACSolver/initializeSolverState.C Sun Jan 02 17:56:57 2011 -0800
+++ b/StokesFACSolver/initializeSolverState.C Sun Jan 02 19:52:18 2011 -0800
@@ -31,8 +31,10 @@ namespace SAMRAI {
*************************************************************************
*/
- void StokesFACSolver::initializeSolverState(const int solution,
- const int rhs,
+ void StokesFACSolver::initializeSolverState(const int p,
+ const int p_rhs,
+ const int v,
+ const int v_rhs,
tbox::Pointer<hier::PatchHierarchy> hierarchy,
const int coarse_level,
const int fine_level)
@@ -49,7 +51,7 @@ namespace SAMRAI {
}
#ifdef DEBUG_CHECK_ASSERTIONS
- if (solution < 0 || rhs < 0) {
+ if (p < 0 || p_rhs < 0) {
TBOX_ERROR(d_object_name << ": Bad patch data id.\n");
}
#endif
@@ -101,7 +103,7 @@ namespace SAMRAI {
d_fac_ops.setStokesSpecifications(d_stokes_spec);
- createVectorWrappers(solution, rhs);
+ createVectorWrappers(p, p_rhs, v, v_rhs);
d_fac_precond.initializeSolverState(*d_uv, *d_fv);
diff -r fa9412f95188 -r b111e7f5295b StokesFACSolver/solveSystem.C
--- a/StokesFACSolver/solveSystem.C Sun Jan 02 17:56:57 2011 -0800
+++ b/StokesFACSolver/solveSystem.C Sun Jan 02 19:52:18 2011 -0800
@@ -63,22 +63,13 @@ namespace SAMRAI {
d_simple_bc.cacheDirichletData(p);
}
- createVectorWrappers(p, p_rhs);
+ createVectorWrappers(p, p_rhs, v, v_rhs);
bool solver_rval;
// d_fac_ops.relax(*d_uv, *d_fv, 0, 5, 1.0, p, p_rhs, v, v_rhs);
// d_fac_ops.relax(*d_uv, *d_fv, 1, 5, 1.0, p, p_rhs, v, v_rhs);
d_fac_ops.relax(*d_uv, *d_fv, 2, 10, 1.0, p, p_rhs, v, v_rhs);
// solver_rval = d_fac_precond.solveSystem(*d_uv, *d_fv);
-
- // if (d_bc_object == &d_simple_bc) {
- // /*
- // * Restore the Dirichlet cell data that were overwritten by the
- // * solve process. We do this to be backward compatible with the
- // * user code.
- // */
- // d_simple_bc.restoreDirichletData(p);
- // }
return solver_rval;
}
@@ -129,7 +120,7 @@ namespace SAMRAI {
<< "specified.\n");
}
#endif
- initializeSolverState(p, p_rhs, hierarchy, coarse_ln, fine_ln);
+ initializeSolverState(p, p_rhs, v, v_rhs, hierarchy, coarse_ln, fine_ln);
bool solver_rval;
solver_rval = solveSystem(p, p_rhs, v, v_rhs);
More information about the CIG-COMMITS
mailing list