[cig-commits] commit: Reindent main.C
Mercurial
hg at geodynamics.org
Fri Feb 25 14:12:41 PST 2011
changeset: 11:38b782efefda
user: Walter Landry <wlandry at caltech.edu>
date: Fri Dec 31 11:50:47 2010 -0800
files: main.C
description:
Reindent main.C
diff -r 82ce4a4c3105 -r 38b782efefda main.C
--- a/main.C Fri Dec 31 11:36:52 2010 -0800
+++ b/main.C Fri Dec 31 11:50:47 2010 -0800
@@ -34,256 +34,255 @@ using namespace SAMRAI;
using namespace SAMRAI;
/*
- ************************************************************************
- * *
- * This is the driver program to demonstrate *
- * how to use the FAC Stokes solver. *
- * *
- * We set up the simple problem *
- * u + div(grad(u)) = sin(x)*sin(y) *
- * in the domain [0:1]x[0:1], with u=0 on the *
- * boundary. *
- * *
- * FACStokes is the primary object used to *
- * set up and solve the system. It maintains *
- * the data for the computed solution u, the *
- * exact solution, and the right hand side. *
- * *
- * The hierarchy created to solve this problem *
- * has only one level. (The FAC Stokes solver *
- * is a single-level solver.) *
- * *
- *************************************************************************
- */
+************************************************************************
+* *
+* This is the driver program to demonstrate *
+* how to use the FAC Stokes solver. *
+* *
+* We set up the simple problem *
+* u + div(grad(u)) = sin(x)*sin(y) *
+* in the domain [0:1]x[0:1], with u=0 on the *
+* boundary. *
+* *
+* FACStokes is the primary object used to *
+* set up and solve the system. It maintains *
+* the data for the computed solution u, the *
+* exact solution, and the right hand side. *
+* *
+* The hierarchy created to solve this problem *
+* has only one level. (The FAC Stokes solver *
+* is a single-level solver.) *
+* *
+*************************************************************************
+*/
int main(
- int argc,
- char* argv[])
+ int argc,
+ char* argv[])
{
- /*
- * Initialize MPI, SAMRAI.
- */
+ /*
+ * Initialize MPI, SAMRAI.
+ */
- tbox::SAMRAI_MPI::init(&argc, &argv);
- tbox::SAMRAIManager::initialize();
- tbox::SAMRAIManager::startup();
+ tbox::SAMRAI_MPI::init(&argc, &argv);
+ tbox::SAMRAIManager::initialize();
+ tbox::SAMRAIManager::startup();
- /*
- * Create block to force pointer deallocation. If this is not done
- * then there will be memory leaks reported.
- */
- {
- /*
- * Process command line arguments. For each run, the input
- * filename must be specified. Usage is:
- *
- * executable <input file name>
- *
- */
- string input_filename;
+ /*
+ * Create block to force pointer deallocation. If this is not done
+ * then there will be memory leaks reported.
+ */
+ {
+ /*
+ * Process command line arguments. For each run, the input
+ * filename must be specified. Usage is:
+ *
+ * executable <input file name>
+ *
+ */
+ string input_filename;
- if (argc != 2) {
- TBOX_ERROR("USAGE: " << argv[0] << " <input file> \n"
- << " options:\n"
- << " none at this time" << endl);
- } else {
- input_filename = argv[1];
- }
+ if (argc != 2) {
+ TBOX_ERROR("USAGE: " << argv[0] << " <input file> \n"
+ << " options:\n"
+ << " none at this time" << endl);
+ } else {
+ input_filename = argv[1];
+ }
- /*
- * Create input database and parse all data in input file.
- */
+ /*
+ * Create input database and parse all data in input file.
+ */
- tbox::Pointer<tbox::Database> input_db(new tbox::InputDatabase("input_db"));
- tbox::InputManager::getManager()->parseInputFile(input_filename, input_db);
+ tbox::Pointer<tbox::Database> input_db(new tbox::InputDatabase("input_db"));
+ tbox::InputManager::getManager()->parseInputFile(input_filename, input_db);
- /*
- * Set up the timer manager.
- */
- if (input_db->isDatabase("TimerManager")) {
- tbox::TimerManager::createManager(input_db->getDatabase("TimerManager"));
- }
+ /*
+ * Set up the timer manager.
+ */
+ if (input_db->isDatabase("TimerManager")) {
+ tbox::TimerManager::createManager(input_db->getDatabase("TimerManager"));
+ }
- /*
- * Retrieve "Main" section from input database.
- * The main database is used only in main().
- * The base_name variable is a base name for
- * all name strings in this program.
- */
+ /*
+ * Retrieve "Main" section from input database.
+ * The main database is used only in main().
+ * The base_name variable is a base name for
+ * all name strings in this program.
+ */
- tbox::Pointer<tbox::Database> main_db = input_db->getDatabase("Main");
+ tbox::Pointer<tbox::Database> main_db = input_db->getDatabase("Main");
- const tbox::Dimension dim(static_cast<unsigned short>(main_db->getInteger("dim")));
+ const tbox::Dimension dim(static_cast<unsigned short>(main_db->getInteger("dim")));
- string base_name = "unnamed";
- base_name = main_db->getStringWithDefault("base_name", base_name);
+ string base_name = "unnamed";
+ base_name = main_db->getStringWithDefault("base_name", base_name);
- /*
- * Start logging.
- */
- const string log_file_name = base_name + ".log";
- bool log_all_nodes = false;
- log_all_nodes = main_db->getBoolWithDefault("log_all_nodes",
- log_all_nodes);
- if (log_all_nodes) {
- tbox::PIO::logAllNodes(log_file_name);
- } else {
- tbox::PIO::logOnlyNodeZero(log_file_name);
- }
+ /*
+ * Start logging.
+ */
+ const string log_file_name = base_name + ".log";
+ bool log_all_nodes = false;
+ log_all_nodes = main_db->getBoolWithDefault("log_all_nodes",
+ log_all_nodes);
+ if (log_all_nodes) {
+ tbox::PIO::logAllNodes(log_file_name);
+ } else {
+ tbox::PIO::logOnlyNodeZero(log_file_name);
+ }
- /*
- * Create major algorithm and data objects which comprise application.
- * Each object will be initialized either from input data or restart
- * files, or a combination of both. Refer to each class constructor
- * for details. For more information on the composition of objects
- * for this application, see comments at top of file.
- */
+ /*
+ * Create major algorithm and data objects which comprise application.
+ * Each object will be initialized either from input data or restart
+ * files, or a combination of both. Refer to each class constructor
+ * for details. For more information on the composition of objects
+ * for this application, see comments at top of file.
+ */
- tbox::Pointer<geom::CartesianGridGeometry> grid_geometry(
- new geom::CartesianGridGeometry(dim,
- base_name + "CartesianGridGeometry",
- input_db->getDatabase("CartesianGridGeometry")));
- tbox::plog << "Cartesian Geometry:" << endl;
- grid_geometry->printClassData(tbox::plog);
+ tbox::Pointer<geom::CartesianGridGeometry>
+ grid_geometry(new geom::CartesianGridGeometry
+ (dim,
+ base_name + "CartesianGridGeometry",
+ input_db->getDatabase("CartesianGridGeometry")));
+ tbox::plog << "Cartesian Geometry:" << endl;
+ grid_geometry->printClassData(tbox::plog);
- tbox::Pointer<hier::PatchHierarchy> patch_hierarchy(
- new hier::PatchHierarchy(base_name + "::PatchHierarchy",
- grid_geometry,
- input_db->getDatabase("PatchHierarchy")));
+ tbox::Pointer<hier::PatchHierarchy>
+ patch_hierarchy(new hier::PatchHierarchy
+ (base_name + "::PatchHierarchy",
+ grid_geometry,
+ input_db->getDatabase("PatchHierarchy")));
- /*
- * The FACStokes object is the main user object specific to the
- * problem being solved. It provides the implementations for setting
- * up the grid and plotting data. It also wraps up the solve
- * process that includes making the initial guess, specifying the
- * boundary conditions and call the solver.
- */
- FACStokes fac_stokes(base_name + "::FACStokes",
- dim,
- input_db->isDatabase("FACStokes") ?
- input_db->getDatabase("FACStokes") :
- tbox::Pointer<tbox::Database>(NULL));
+ /*
+ * The FACStokes object is the main user object specific to the
+ * problem being solved. It provides the implementations for setting
+ * up the grid and plotting data. It also wraps up the solve
+ * process that includes making the initial guess, specifying the
+ * boundary conditions and call the solver.
+ */
+ FACStokes fac_stokes(base_name + "::FACStokes",
+ dim,
+ input_db->isDatabase("FACStokes") ?
+ input_db->getDatabase("FACStokes") :
+ tbox::Pointer<tbox::Database>(NULL));
- /*
- * Create the tag-and-initializer, box-generator and load-balancer
- * object references required by the gridding_algorithm object.
- */
- tbox::Pointer<mesh::StandardTagAndInitialize> tag_and_initializer(
- new mesh::StandardTagAndInitialize(
- dim,
- "CellTaggingMethod",
- tbox::Pointer<mesh::StandardTagAndInitStrategy>(&fac_stokes, false),
- input_db->getDatabase("StandardTagAndInitialize")
- ));
- tbox::Pointer<mesh::BergerRigoutsos> box_generator(
- new mesh::BergerRigoutsos(dim));
- tbox::Pointer<mesh::TreeLoadBalancer> load_balancer(
- new mesh::TreeLoadBalancer(dim,
- "load balancer",
- tbox::Pointer<tbox::Database>()));
- load_balancer->setSAMRAI_MPI(
- SAMRAI::tbox::SAMRAI_MPI::getSAMRAIWorld());
+ /*
+ * Create the tag-and-initializer, box-generator and load-balancer
+ * object references required by the gridding_algorithm object.
+ */
+ tbox::Pointer<mesh::StandardTagAndInitialize>
+ tag_and_initializer(new mesh::StandardTagAndInitialize
+ (dim,
+ "CellTaggingMethod",
+ tbox::Pointer<mesh::StandardTagAndInitStrategy>
+ (&fac_stokes, false),
+ input_db->getDatabase("StandardTagAndInitialize")
+ ));
+ tbox::Pointer<mesh::BergerRigoutsos>
+ box_generator(new mesh::BergerRigoutsos(dim));
+ tbox::Pointer<mesh::TreeLoadBalancer>
+ load_balancer(new mesh::TreeLoadBalancer
+ (dim,
+ "load balancer",
+ tbox::Pointer<tbox::Database>()));
+ load_balancer->setSAMRAI_MPI(SAMRAI::tbox::SAMRAI_MPI::getSAMRAIWorld());
- /*
- * Create the gridding algorithm used to generate the SAMR grid
- * and create the grid.
- */
- tbox::Pointer<mesh::GriddingAlgorithm> gridding_algorithm;
- gridding_algorithm =
- new mesh::GriddingAlgorithm(
- patch_hierarchy,
- "Gridding Algorithm",
- input_db->getDatabase("GriddingAlgorithm"),
- tag_and_initializer,
- box_generator,
- load_balancer);
- tbox::plog << "Gridding algorithm:" << endl;
- gridding_algorithm->printClassData(tbox::plog);
+ /*
+ * Create the gridding algorithm used to generate the SAMR grid
+ * and create the grid.
+ */
+ tbox::Pointer<mesh::GriddingAlgorithm> gridding_algorithm;
+ gridding_algorithm =
+ new mesh::GriddingAlgorithm(patch_hierarchy,
+ "Gridding Algorithm",
+ input_db->getDatabase("GriddingAlgorithm"),
+ tag_and_initializer,
+ box_generator,
+ load_balancer);
+ tbox::plog << "Gridding algorithm:" << endl;
+ gridding_algorithm->printClassData(tbox::plog);
- /*
- * Make the coarsest patch level where we will be solving.
- */
- gridding_algorithm->makeCoarsestLevel(0.0);
- bool done = false;
- for (int lnum = 0;
- patch_hierarchy->levelCanBeRefined(lnum) && !done; lnum++) {
- tbox::plog << "Adding finner levels with lnum = " << lnum << endl;
- gridding_algorithm->makeFinerLevel(
- 0.0,
- true,
- 0);
- tbox::plog << "Just added finer levels with lnum = " << lnum << endl;
- done = !(patch_hierarchy->finerLevelExists(lnum));
- }
+ /*
+ * Make the coarsest patch level where we will be solving.
+ */
+ gridding_algorithm->makeCoarsestLevel(0.0);
+ bool done = false;
+ for (int lnum = 0;
+ patch_hierarchy->levelCanBeRefined(lnum) && !done; lnum++) {
+ tbox::plog << "Adding finner levels with lnum = " << lnum << endl;
+ gridding_algorithm->makeFinerLevel(0.0,true,0);
+ tbox::plog << "Just added finer levels with lnum = " << lnum << endl;
+ done = !(patch_hierarchy->finerLevelExists(lnum));
+ }
- /*
- * Set up the plotter for the hierarchy just created.
- * The FACStokes object handles the data and has the
- * function setupExternalPlotter to register its data
- * with the plotter.
- */
- tbox::Array<string> vis_writer(1);
- vis_writer[0] = "Visit";
- if (main_db->keyExists("vis_writer")) {
- vis_writer = main_db->getStringArray("vis_writer");
- }
- bool use_visit = false;
- for (int i = 0; i < vis_writer.getSize(); i++) {
- if (vis_writer[i] == "VisIt") use_visit = true;
- }
+ /*
+ * Set up the plotter for the hierarchy just created.
+ * The FACStokes object handles the data and has the
+ * function setupExternalPlotter to register its data
+ * with the plotter.
+ */
+ tbox::Array<string> vis_writer(1);
+ vis_writer[0] = "Visit";
+ if (main_db->keyExists("vis_writer")) {
+ vis_writer = main_db->getStringArray("vis_writer");
+ }
+ bool use_visit = false;
+ for (int i = 0; i < vis_writer.getSize(); i++) {
+ if (vis_writer[i] == "VisIt") use_visit = true;
+ }
#ifdef HAVE_HDF5
- tbox::Pointer<appu::VisItDataWriter> visit_writer;
- string vis_filename =
- main_db->getStringWithDefault("vis_filename", base_name);
- if (use_visit) {
- visit_writer = new appu::VisItDataWriter(dim,
- "Visit Writer",
- vis_filename + ".visit");
- fac_stokes.setupPlotter(*visit_writer);
- }
+ tbox::Pointer<appu::VisItDataWriter> visit_writer;
+ string vis_filename =
+ main_db->getStringWithDefault("vis_filename", base_name);
+ if (use_visit) {
+ visit_writer = new appu::VisItDataWriter(dim,
+ "Visit Writer",
+ vis_filename + ".visit");
+ fac_stokes.setupPlotter(*visit_writer);
+ }
#endif
- /*
- * After creating all objects and initializing their state,
- * we print the input database and variable database contents
- * to the log file.
- */
- tbox::plog << "\nCheck input data and variables before simulation:"
- << endl;
- tbox::plog << "Input database..." << endl;
- input_db->printClassData(tbox::plog);
+ /*
+ * After creating all objects and initializing their state,
+ * we print the input database and variable database contents
+ * to the log file.
+ */
+ tbox::plog << "\nCheck input data and variables before simulation:"
+ << endl;
+ tbox::plog << "Input database..." << endl;
+ input_db->printClassData(tbox::plog);
- /*
- * Solve.
- */
- fac_stokes.solveStokes();
+ /*
+ * Solve.
+ */
+ fac_stokes.solveStokes();
#ifdef HAVE_HDF5
- /*
- * Plot.
- */
- if (use_visit) {
- visit_writer->writePlotData(patch_hierarchy, 0);
- }
+ /*
+ * Plot.
+ */
+ if (use_visit) {
+ visit_writer->writePlotData(patch_hierarchy, 0);
+ }
#endif
- /*
- * Deallocate objects when done.
- */
+ /*
+ * Deallocate objects when done.
+ */
- tbox::TimerManager::getManager()->print(tbox::plog);
- }
+ tbox::TimerManager::getManager()->print(tbox::plog);
+ }
- /*
- * This print is for the SAMRAI testing framework. Passing here
- * means application ran. A better test would actually test the
- * results.
- */
- tbox::pout << "\nPASSED: FAC" << endl;
+ /*
+ * This print is for the SAMRAI testing framework. Passing here
+ * means application ran. A better test would actually test the
+ * results.
+ */
+ tbox::pout << "\nPASSED: FAC" << endl;
- tbox::SAMRAIManager::shutdown();
- tbox::SAMRAIManager::finalize();
- tbox::SAMRAI_MPI::finalize();
+ tbox::SAMRAIManager::shutdown();
+ tbox::SAMRAIManager::finalize();
+ tbox::SAMRAI_MPI::finalize();
- return 0;
+ return 0;
}
More information about the CIG-COMMITS
mailing list