[cig-commits] commit: Reformatting
Mercurial
hg at geodynamics.org
Fri Feb 25 14:15:54 PST 2011
changeset: 69:817017ebaf83
user: Walter Landry <wlandry at caltech.edu>
date: Wed Jan 26 12:02:22 2011 -0800
files: FACStokes/solveStokes.C StokesFACSolver/initializeSolverState.C StokesFACSolver/solveSystem.C
description:
Reformatting
diff -r f3de0ab9c0d4 -r 817017ebaf83 FACStokes/solveStokes.C
--- a/FACStokes/solveStokes.C Wed Jan 26 11:56:20 2011 -0800
+++ b/FACStokes/solveStokes.C Wed Jan 26 12:02:22 2011 -0800
@@ -21,75 +21,72 @@
#include "SAMRAI/hier/Variable.h"
#include "SAMRAI/hier/VariableDatabase.h"
-namespace SAMRAI {
-
- /*
+/*
*************************************************************************
* Set up the initial guess and problem parameters *
* and solve the Stokes problem. We explicitly initialize and *
* deallocate the solver state in this example. *
*************************************************************************
*/
- int FACStokes::solveStokes()
- {
+int SAMRAI::FACStokes::solveStokes()
+{
- if (d_hierarchy.isNull()) {
- TBOX_ERROR(d_object_name
- << "Cannot solve using an uninitialized object.\n");
- }
-
- int ln;
- /*
- * Fill in the initial guess.
- */
- for (ln = 0; ln <= d_hierarchy->getFinestLevelNumber(); ++ln) {
- tbox::Pointer<hier::PatchLevel> level = d_hierarchy->getPatchLevel(ln);
- hier::PatchLevel::Iterator ip(*level);
- for ( ; ip; ip++) {
- tbox::Pointer<hier::Patch> patch = *ip;
- tbox::Pointer<pdat::CellData<double> >
- pdata = patch->getPatchData(p_id);
- pdata->fill(0.0);
- tbox::Pointer<pdat::SideData<double> >
- vdata = patch->getPatchData(v_id);
- vdata->fill(0.0);
- }
- }
-
- /*
- * Set the parameters for the Stokes equation.
- * See classes solv::StokesFACSolver or
- * solv::StokesSpecifications.
- * (D is the diffusion coefficient.
- * C is the source term which is not used in this example.)
- */
- d_stokes_fac_solver.setDConstant(1.0);
- d_stokes_fac_solver.setCConstant(0.0);
-
- d_stokes_fac_solver.initializeSolverState
- (p_id,p_rhs_id,v_id,v_rhs_id,d_hierarchy,0,
- d_hierarchy->getFinestLevelNumber());
-
- tbox::plog << "solving..." << std::endl;
- int solver_ret;
- solver_ret = d_stokes_fac_solver.solveSystem(p_id,p_rhs_id,v_id,v_rhs_id);
- /*
- * Present data on the solve.
- */
- double avg_factor, final_factor;
- // d_stokes_fac_solver.getConvergenceFactors(avg_factor, final_factor);
- // tbox::plog << "\t" << (solver_ret ? "" : "NOT ") << "converged " << "\n"
- // << " iterations: "
- // << d_stokes_fac_solver.getNumberOfIterations() << "\n"
- // << " residual: "<< d_stokes_fac_solver.getResidualNorm()
- // << "\n"
- // << " average convergence: "<< avg_factor << "\n"
- // << " final convergence: "<< final_factor << "\n"
- // << std::flush;
-
- d_stokes_fac_solver.deallocateSolverState();
-
- return 0;
+ if (d_hierarchy.isNull()) {
+ TBOX_ERROR(d_object_name
+ << "Cannot solve using an uninitialized object.\n");
}
+ int ln;
+ /*
+ * Fill in the initial guess.
+ */
+ for (ln = 0; ln <= d_hierarchy->getFinestLevelNumber(); ++ln) {
+ tbox::Pointer<hier::PatchLevel> level = d_hierarchy->getPatchLevel(ln);
+ hier::PatchLevel::Iterator ip(*level);
+ for ( ; ip; ip++) {
+ tbox::Pointer<hier::Patch> patch = *ip;
+ tbox::Pointer<pdat::CellData<double> >
+ pdata = patch->getPatchData(p_id);
+ pdata->fill(0.0);
+ tbox::Pointer<pdat::SideData<double> >
+ vdata = patch->getPatchData(v_id);
+ vdata->fill(0.0);
+ /* This implicitly sets boundary conditions for v as well */
+ }
+ }
+
+ /*
+ * Set the parameters for the Stokes equation.
+ * See classes solv::StokesFACSolver or
+ * solv::StokesSpecifications.
+ * (D is the diffusion coefficient.
+ * C is the source term which is not used in this example.)
+ */
+ d_stokes_fac_solver.setDConstant(1.0);
+ d_stokes_fac_solver.setCConstant(0.0);
+
+ d_stokes_fac_solver.initializeSolverState
+ (p_id,p_rhs_id,v_id,v_rhs_id,d_hierarchy,0,
+ d_hierarchy->getFinestLevelNumber());
+
+ tbox::plog << "solving..." << std::endl;
+ int solver_ret;
+ solver_ret = d_stokes_fac_solver.solveSystem(p_id,p_rhs_id,v_id,v_rhs_id);
+ /*
+ * Present data on the solve.
+ */
+ double avg_factor, final_factor;
+ // d_stokes_fac_solver.getConvergenceFactors(avg_factor, final_factor);
+ // tbox::plog << "\t" << (solver_ret ? "" : "NOT ") << "converged " << "\n"
+ // << " iterations: "
+ // << d_stokes_fac_solver.getNumberOfIterations() << "\n"
+ // << " residual: "<< d_stokes_fac_solver.getResidualNorm()
+ // << "\n"
+ // << " average convergence: "<< avg_factor << "\n"
+ // << " final convergence: "<< final_factor << "\n"
+ // << std::flush;
+
+ d_stokes_fac_solver.deallocateSolverState();
+
+ return 0;
}
diff -r f3de0ab9c0d4 -r 817017ebaf83 StokesFACSolver/initializeSolverState.C
--- a/StokesFACSolver/initializeSolverState.C Wed Jan 26 11:56:20 2011 -0800
+++ b/StokesFACSolver/initializeSolverState.C Wed Jan 26 12:02:22 2011 -0800
@@ -15,10 +15,7 @@
#include IOMANIP_HEADER_FILE
-namespace SAMRAI {
- namespace solv {
-
- /*
+/*
*************************************************************************
* *
* Prepare internal data for solve. *
@@ -31,84 +28,82 @@ namespace SAMRAI {
*************************************************************************
*/
- 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)
- {
- TBOX_ASSERT(!hierarchy.isNull());
- TBOX_DIM_ASSERT_CHECK_DIM_ARGS1(d_dim, *hierarchy);
+void SAMRAI::solv::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)
+{
+ TBOX_ASSERT(!hierarchy.isNull());
+ TBOX_DIM_ASSERT_CHECK_DIM_ARGS1(d_dim, *hierarchy);
- if (d_bc_object == NULL) {
- TBOX_ERROR(
- d_object_name << ": No BC coefficient strategy object!\n"
- <<
- "Use either setBoundaries or setPhysicalBcCoefObject\n"
- << "to specify the boundary conidition.\n");
- }
+ if (d_bc_object == NULL) {
+ TBOX_ERROR(
+ d_object_name << ": No BC coefficient strategy object!\n"
+ <<
+ "Use either setBoundaries or setPhysicalBcCoefObject\n"
+ << "to specify the boundary conidition.\n");
+ }
#ifdef DEBUG_CHECK_ASSERTIONS
- if (p < 0 || p_rhs < 0) {
- TBOX_ERROR(d_object_name << ": Bad patch data id.\n");
- }
+ if (p < 0 || p_rhs < 0) {
+ TBOX_ERROR(d_object_name << ": Bad patch data id.\n");
+ }
#endif
#ifdef DEBUG_CHECK_ASSERTIONS
- if (!hierarchy) {
- TBOX_ERROR(d_object_name << ": NULL hierarchy pointer not allowed\n"
- << "in inititialization.");
- }
+ if (!hierarchy) {
+ TBOX_ERROR(d_object_name << ": NULL hierarchy pointer not allowed\n"
+ << "in inititialization.");
+ }
#endif
- d_hierarchy = hierarchy;
+ d_hierarchy = hierarchy;
- d_ln_min = coarse_level;
- d_ln_max = fine_level;
- if (d_ln_min == -1) {
- d_ln_min = 0;
- }
- if (d_ln_max == -1) {
- d_ln_max = d_hierarchy->getFinestLevelNumber();
- }
+ d_ln_min = coarse_level;
+ d_ln_max = fine_level;
+ if (d_ln_min == -1) {
+ d_ln_min = 0;
+ }
+ if (d_ln_max == -1) {
+ d_ln_max = d_hierarchy->getFinestLevelNumber();
+ }
#ifdef DEBUG_CHECK_ASSERTIONS
- if (d_ln_min < 0 || d_ln_max < 0 || d_ln_min > d_ln_max) {
- TBOX_ERROR(d_object_name << ": Bad range of levels in\n"
- << "inititialization.\n");
- }
+ if (d_ln_min < 0 || d_ln_max < 0 || d_ln_min > d_ln_max) {
+ TBOX_ERROR(d_object_name << ": Bad range of levels in\n"
+ << "inititialization.\n");
+ }
#endif
- int ln;
- for (ln = d_ln_min; ln <= d_ln_max; ++ln) {
- d_hierarchy->getPatchLevel(ln)->allocatePatchData(s_weight_id[d_dim.getValue() - 1]);
- }
+ int ln;
+ for (ln = d_ln_min; ln <= d_ln_max; ++ln) {
+ d_hierarchy->getPatchLevel(ln)->allocatePatchData(s_weight_id[d_dim.getValue() - 1]);
+ }
- d_fac_ops.computeVectorWeights(d_hierarchy,
- s_weight_id[d_dim.getValue() - 1],
- d_ln_min,
- d_ln_max);
-
- if (d_bc_object == &d_simple_bc) {
- d_simple_bc.setHierarchy(d_hierarchy,
+ d_fac_ops.computeVectorWeights(d_hierarchy,
+ s_weight_id[d_dim.getValue() - 1],
d_ln_min,
d_ln_max);
- if (d_stokes_spec.dIsConstant()) {
- d_simple_bc.setDiffusionCoefConstant(d_stokes_spec.getDConstant());
- } else {
- d_simple_bc.setDiffusionCoefId(d_stokes_spec.getDPatchDataId());
- }
- }
- d_fac_ops.setStokesSpecifications(d_stokes_spec);
+ if (d_bc_object == &d_simple_bc) {
+ d_simple_bc.setHierarchy(d_hierarchy,
+ d_ln_min,
+ d_ln_max);
+ if (d_stokes_spec.dIsConstant()) {
+ d_simple_bc.setDiffusionCoefConstant(d_stokes_spec.getDConstant());
+ } else {
+ d_simple_bc.setDiffusionCoefId(d_stokes_spec.getDPatchDataId());
+ }
+ }
- createVectorWrappers(p, p_rhs, v, v_rhs);
+ d_fac_ops.setStokesSpecifications(d_stokes_spec);
- d_fac_precond.initializeSolverState(*d_uv, *d_fv);
+ createVectorWrappers(p, p_rhs, v, v_rhs);
- d_solver_is_initialized = true;
- }
+ d_fac_precond.initializeSolverState(*d_uv, *d_fv);
- }
+ d_solver_is_initialized = true;
}
diff -r f3de0ab9c0d4 -r 817017ebaf83 StokesFACSolver/solveSystem.C
--- a/StokesFACSolver/solveSystem.C Wed Jan 26 11:56:20 2011 -0800
+++ b/StokesFACSolver/solveSystem.C Wed Jan 26 12:02:22 2011 -0800
@@ -15,12 +15,7 @@
#include IOMANIP_HEADER_FILE
-namespace SAMRAI {
- namespace solv {
-
-
-
- /*
+/*
*************************************************************************
* *
* Solve the linear system and report whether iteration converged. *
@@ -33,48 +28,48 @@ namespace SAMRAI {
*************************************************************************
*/
- bool StokesFACSolver::solveSystem(const int p, const int p_rhs,
- const int v, const int v_rhs)
- {
+bool SAMRAI::solv::StokesFACSolver::solveSystem(const int p, const int p_rhs,
+ const int v, const int v_rhs)
+{
#ifdef DEBUG_CHECK_ASSERTIONS
- if (!d_solver_is_initialized) {
- TBOX_ERROR(
- d_object_name << ".solveSystem(int,int): uninitialized\n"
- <<
- "solver state. You must call initializeSolverState()\n"
- <<
- "before using this function. Or you can use\n"
- <<
- "solveSystem(int,int,...) to initialize the solver,\n"
- << "solve and deallocate the solver.\n");
- }
- if (p < 0 || p_rhs < 0 || v < 0 || v_rhs < 0) {
- TBOX_ERROR(d_object_name << ": Bad patch data id.\n");
- }
+ if (!d_solver_is_initialized) {
+ TBOX_ERROR(
+ d_object_name << ".solveSystem(int,int): uninitialized\n"
+ <<
+ "solver state. You must call initializeSolverState()\n"
+ <<
+ "before using this function. Or you can use\n"
+ <<
+ "solveSystem(int,int,...) to initialize the solver,\n"
+ << "solve and deallocate the solver.\n");
+ }
+ if (p < 0 || p_rhs < 0 || v < 0 || v_rhs < 0) {
+ TBOX_ERROR(d_object_name << ": Bad patch data id.\n");
+ }
#endif
- if (d_bc_object == &d_simple_bc) {
- /*
- * Knowing that we are using the SimpelCellRobinBcCoefsX
- * implementation of RobinBcCoefStrategy, we must save
- * the ghost data in u before solving.
- * The solver overwrites it, but SimpleCellRobinBcCoefs
- * needs to get to access it repeatedly.
- */
- d_simple_bc.cacheDirichletData(p);
- }
+ if (d_bc_object == &d_simple_bc) {
+ /*
+ * Knowing that we are using the SimpelCellRobinBcCoefsX
+ * implementation of RobinBcCoefStrategy, we must save
+ * the ghost data in u before solving.
+ * The solver overwrites it, but SimpleCellRobinBcCoefs
+ * needs to get to access it repeatedly.
+ */
+ d_simple_bc.cacheDirichletData(p);
+ }
- createVectorWrappers(p, p_rhs, v, v_rhs);
- bool solver_rval;
+ 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, 100, 1.0);
- solver_rval = d_fac_precond.solveSystem(*d_uv, *d_fv);
+ // 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, 100, 1.0);
+ solver_rval = d_fac_precond.solveSystem(*d_uv, *d_fv);
- return solver_rval;
- }
+ return solver_rval;
+}
- /*
+/*
*************************************************************************
* *
* Solve the linear system and report whether iteration converged. *
@@ -87,47 +82,46 @@ namespace SAMRAI {
*************************************************************************
*/
- bool StokesFACSolver::solveSystem(const int p,
- const int p_rhs,
- const int v,
- const int v_rhs,
- tbox::Pointer<hier::PatchHierarchy>
- hierarchy,
- int coarse_ln,
- int fine_ln)
- {
- TBOX_ASSERT(!hierarchy.isNull());
- TBOX_DIM_ASSERT_CHECK_DIM_ARGS1(d_dim, *hierarchy);
+bool SAMRAI::solv::StokesFACSolver::solveSystem
+(const int p,
+ const int p_rhs,
+ const int v,
+ const int v_rhs,
+ tbox::Pointer<hier::PatchHierarchy>
+ hierarchy,
+ int coarse_ln,
+ int fine_ln)
+{
+ TBOX_ASSERT(!hierarchy.isNull());
+ TBOX_DIM_ASSERT_CHECK_DIM_ARGS1(d_dim, *hierarchy);
- if (d_enable_logging) {
- tbox::plog << "StokesFACSolver::solveSystem (" << d_object_name
- << ")\n";
- d_stokes_spec.printClassData(tbox::plog);
- }
+ if (d_enable_logging) {
+ tbox::plog << "StokesFACSolver::solveSystem (" << d_object_name
+ << ")\n";
+ d_stokes_spec.printClassData(tbox::plog);
+ }
#ifdef DEBUG_CHECK_ASSERTIONS
- if (d_solver_is_initialized) {
- TBOX_ERROR(
- d_object_name << ".solveSystem(int,int,...): initialized\n"
- <<
- "solver state. This function can only used when the\n"
- <<
- "solver state is uninitialized. You should deallocate\n"
- <<
- "the solver state or use solveSystem(int,int).\n");
- }
- if (!hierarchy) {
- TBOX_ERROR(d_object_name << ".solveSystem(): Null hierarchy\n"
- << "specified.\n");
- }
+ if (d_solver_is_initialized) {
+ TBOX_ERROR(
+ d_object_name << ".solveSystem(int,int,...): initialized\n"
+ <<
+ "solver state. This function can only used when the\n"
+ <<
+ "solver state is uninitialized. You should deallocate\n"
+ <<
+ "the solver state or use solveSystem(int,int).\n");
+ }
+ if (!hierarchy) {
+ TBOX_ERROR(d_object_name << ".solveSystem(): Null hierarchy\n"
+ << "specified.\n");
+ }
#endif
- initializeSolverState(p, p_rhs, v, v_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);
+ bool solver_rval;
+ solver_rval = solveSystem(p, p_rhs, v, v_rhs);
- deallocateSolverState();
+ deallocateSolverState();
- return solver_rval;
- }
- }
+ return solver_rval;
}
More information about the CIG-COMMITS
mailing list