[cig-commits] r14642 - in mc/3D/CitcomS/trunk: CitcomS CitcomS/Solver bin lib module

tan2 at geodynamics.org tan2 at geodynamics.org
Wed Apr 8 16:39:50 PDT 2009


Author: tan2
Date: 2009-04-08 16:39:49 -0700 (Wed, 08 Apr 2009)
New Revision: 14642

Modified:
   mc/3D/CitcomS/trunk/CitcomS/BaseApplication.py
   mc/3D/CitcomS/trunk/CitcomS/Controller.py
   mc/3D/CitcomS/trunk/CitcomS/Solver/CoupledFullSolver.py
   mc/3D/CitcomS/trunk/CitcomS/Solver/CoupledRegionalSolver.py
   mc/3D/CitcomS/trunk/CitcomS/Solver/FullSolver.py
   mc/3D/CitcomS/trunk/CitcomS/Solver/RegionalSolver.py
   mc/3D/CitcomS/trunk/CitcomS/Solver/Solver.py
   mc/3D/CitcomS/trunk/bin/Citcom.c
   mc/3D/CitcomS/trunk/lib/Instructions.c
   mc/3D/CitcomS/trunk/lib/Viscosity_structures.c
   mc/3D/CitcomS/trunk/lib/citcom_init.h
   mc/3D/CitcomS/trunk/module/initial_conditions.c
Log:
Sync'ing C and Pyre and adding comments


Modified: mc/3D/CitcomS/trunk/CitcomS/BaseApplication.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/BaseApplication.py	2009-04-08 23:38:51 UTC (rev 14641)
+++ mc/3D/CitcomS/trunk/CitcomS/BaseApplication.py	2009-04-08 23:39:49 UTC (rev 14642)
@@ -39,6 +39,7 @@
         '''
         Application.__init__(self, name)
 
+        # channel for debugging output
         self._info = journal.debug("application")
         return
 
@@ -49,7 +50,10 @@
         '''
         Application._init(self)
 
-        # self.nodes is the # of CPUs for this simulation
+        # self.nodes is the # of CPUs for this simulation, used by the
+        # scheduler and launcher
+        #
+        # self.getNodes is defined in the child classes
         self.nodes = self.getNodes()
         return
 
@@ -58,6 +62,8 @@
     def main(self, *args, **kwds):
         '''The entry point, like main() in C.
         '''
+        # self.initialize and self.reportConfiguration are defined
+        # in the child classes
         self.initialize()
         self.reportConfiguration()
         self.launch()
@@ -68,8 +74,11 @@
     def launch(self):
         '''Start the computation.
         '''
+
+        # initial conditions and the 0th step
         self.controller.launch(self)
 
+        # subsequent steps
         self.controller.march(steps=self.inventory.steps)
         return
 

Modified: mc/3D/CitcomS/trunk/CitcomS/Controller.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/Controller.py	2009-04-08 23:38:51 UTC (rev 14641)
+++ mc/3D/CitcomS/trunk/CitcomS/Controller.py	2009-04-08 23:39:49 UTC (rev 14642)
@@ -62,7 +62,7 @@
     def launch(self, app):
         '''Setup initial conditions.
         '''
-        # 0th step
+        # initial conditions and 0th step
         self.solver.launch(app)
 
         # do io for 0th step
@@ -80,6 +80,8 @@
     def march(self, totalTime=0, steps=0):
         """explicit time loop"""
 
+        # special treatment for steps=1, where only 0th step is computed
+        # this means that one can never request a run with (0th, 1st) steps
         if (self.step + 1) >= steps:
             self.endSimulation()
             return

Modified: mc/3D/CitcomS/trunk/CitcomS/Solver/CoupledFullSolver.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/Solver/CoupledFullSolver.py	2009-04-08 23:38:51 UTC (rev 14641)
+++ mc/3D/CitcomS/trunk/CitcomS/Solver/CoupledFullSolver.py	2009-04-08 23:39:49 UTC (rev 14642)
@@ -27,14 +27,13 @@
 #
 
 from CoupledSolver import CoupledSolver
-import journal
 
-
 class CoupledFullSolver(CoupledSolver):
 
 
     def initializeSolver(self):
         from CitcomSLib import full_solver_init
+        # define common aliases for full/regional functions
         full_solver_init(self.all_variables)
 
 
@@ -56,6 +55,6 @@
 
 
 # version
-__id__ = "$Id: /local/coupler/CitcomS/Solver/FullSolver.py 995 2006-07-07T22:35:14.359825Z leif  $"
+__id__ = "$Id$"
 
 # End of file

Modified: mc/3D/CitcomS/trunk/CitcomS/Solver/CoupledRegionalSolver.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/Solver/CoupledRegionalSolver.py	2009-04-08 23:38:51 UTC (rev 14641)
+++ mc/3D/CitcomS/trunk/CitcomS/Solver/CoupledRegionalSolver.py	2009-04-08 23:39:49 UTC (rev 14642)
@@ -27,14 +27,13 @@
 #
 
 from CoupledSolver import CoupledSolver
-from CitcomSLib import regional_solver_init
-import journal
 
-
 class CoupledRegionalSolver(CoupledSolver):
 
 
     def initializeSolver(self):
+        from CitcomSLib import regional_solver_init
+        # define common aliases for full/regional functions
         regional_solver_init(self.all_variables)
 
 
@@ -56,6 +55,6 @@
 
 
 # version
-__id__ = "$Id: /local/coupler/CitcomS/Solver/RegionalSolver.py 995 2006-07-07T22:35:14.359825Z leif  $"
+__id__ = "$Id$"
 
 # End of file

Modified: mc/3D/CitcomS/trunk/CitcomS/Solver/FullSolver.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/Solver/FullSolver.py	2009-04-08 23:38:51 UTC (rev 14641)
+++ mc/3D/CitcomS/trunk/CitcomS/Solver/FullSolver.py	2009-04-08 23:39:49 UTC (rev 14642)
@@ -27,14 +27,13 @@
 #
 
 from Solver import Solver
-import journal
 
-
 class FullSolver(Solver):
 
 
     def initializeSolver(self):
         from CitcomSLib import full_solver_init
+        # define common aliases for full/regional functions
         full_solver_init(self.all_variables)
 
 

Modified: mc/3D/CitcomS/trunk/CitcomS/Solver/RegionalSolver.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/Solver/RegionalSolver.py	2009-04-08 23:38:51 UTC (rev 14641)
+++ mc/3D/CitcomS/trunk/CitcomS/Solver/RegionalSolver.py	2009-04-08 23:39:49 UTC (rev 14642)
@@ -27,14 +27,13 @@
 #
 
 from Solver import Solver
-from CitcomSLib import regional_solver_init
-import journal
 
-
 class RegionalSolver(Solver):
 
 
     def initializeSolver(self):
+        from CitcomSLib import regional_solver_init
+        # define common aliases for full/regional functions
         regional_solver_init(self.all_variables)
 
 

Modified: mc/3D/CitcomS/trunk/CitcomS/Solver/Solver.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/Solver/Solver.py	2009-04-08 23:38:51 UTC (rev 14641)
+++ mc/3D/CitcomS/trunk/CitcomS/Solver/Solver.py	2009-04-08 23:39:49 UTC (rev 14642)
@@ -68,19 +68,26 @@
     def initialize(self, application):
         from CitcomSLib import citcom_init, global_default_values, set_signal
 
+        # initialize the "struct All_variables E" in C
         comm = application.solverCommunicator
         all_variables = citcom_init(comm.handle())
         self.communicator = comm
         self.all_variables = all_variables
 
+        # defined in child classes
         self.initializeSolver()
 
         # information about clock time
         self.start_cpu_time = CPU_time()
 
+        # global interuption handling routine defined once here
         set_signal()
+
+        # default values for various parameters
         global_default_values(self.all_variables)
 
+
+        # read input parameters from file(s) and command line
         inv = self.inventory
 
         inv.mesher.initialize(all_variables)
@@ -114,9 +121,10 @@
                 application.controller.inventory.checkpointFrequency)
             print >> stream
 
+        # passing the parameters to C
         self.setProperties(stream)
 
-        self._setup()
+        self.initial_setup()
 
         return
 
@@ -151,7 +159,7 @@
         return
 
 
-    def _setup(self):
+    def initial_setup(self):
         mesher = self.inventory.mesher
         vsolver = self.inventory.vsolver
         tsolver = self.inventory.tsolver

Modified: mc/3D/CitcomS/trunk/bin/Citcom.c
===================================================================
--- mc/3D/CitcomS/trunk/bin/Citcom.c	2009-04-08 23:38:51 UTC (rev 14641)
+++ mc/3D/CitcomS/trunk/bin/Citcom.c	2009-04-08 23:39:49 UTC (rev 14642)
@@ -49,31 +49,24 @@
 {	/* Functions called by main*/
   void general_stokes_solver();
   void general_stokes_solver_pseudo_surf();
+  void global_default_values();
   void read_instructions();
   void initial_setup();
   void initial_conditions();
-  void solve_constrained_flow();
-  void solve_derived_velocities();
-  void process_temp_field();
   void post_processing();
-  void vcopy();
-  void construct_mat_group();
   void read_velocity_boundary_from_file();
   void read_rayleigh_from_file();
   void read_mat_from_file();
   void read_temperature_boundary_from_file();
 
-  void open_time();
   void output_finalize();
-  void PG_timestep_init();
   void tracer_advection();
   void heat_flux();
 
-  float dot();
   float cpu_time_on_vp_it;
 
   int cpu_total_seconds,k,need_init_sol;
-  double CPU_time0(),time,initial_time,start_time,avaimem();
+  double CPU_time0(),time,initial_time,start_time;
 
   struct All_variables *E;
   MPI_Comm world;
@@ -88,14 +81,26 @@
 
 
   /* this section reads input, allocates memory, and set some initial values;
-   *  replaced by CitcomS.Controller.initialize() */
+   * replaced by CitcomS.Controller.initialize() and
+   * CitcomS.Solver.initialize() in Pyre. */
   world = MPI_COMM_WORLD;
   E = citcom_init(&world); /* allocate global E and do initializaion here */
 
+  /* define common aliases for full/regional functions */
   solver_init(E);
 
   start_time = time = CPU_time0();
+
+  /* Global interuption handling routine defined once here */
+  set_signal();
+
+  /* default values for various parameters */
+  global_default_values(E);
+
+  /* read input parameters from file */
   read_instructions(E, argv[1]);
+
+  /* create mesh, setup solvers etc. */
   initial_setup(E);
 
   cpu_time_on_vp_it = CPU_time0();
@@ -110,7 +115,8 @@
 
 
   /* this section sets the initial condition;
-   * replaced by CitcomS.Controller.launch() */
+   * replaced by CitcomS.Controller.launch() ->
+   * CitcomS.Solver.launch() in Pyre. */
   if (E->control.post_p) {
       /* the initial condition is from previous checkpoint */
       read_checkpoint(E);
@@ -183,7 +189,7 @@
  
 
   /* this section advances the time step;
-   * replaced by CitcomS.Controller.march() */
+   * replaced by CitcomS.Controller.march() in Pyre. */
   while ( E->control.keep_going   &&  (Emergency_stop == 0) ) {
 
     /* The next few lines of code were replaced by

Modified: mc/3D/CitcomS/trunk/lib/Instructions.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Instructions.c	2009-04-08 23:38:51 UTC (rev 14641)
+++ mc/3D/CitcomS/trunk/lib/Instructions.c	2009-04-08 23:39:49 UTC (rev 14642)
@@ -49,7 +49,6 @@
 #include "parallel_related.h"
 #include "parsing.h"
 #include "phase_change.h"
-#include "interuption.h"
 
 void parallel_process_termination();
 void allocate_common_vars(struct All_variables*);
@@ -196,28 +195,20 @@
 }
 
 
+/* This function is replaced by CitcomS.*.setProperties() in Pyre. */
 void read_instructions(struct All_variables *E, char *filename)
 {
     void read_initial_settings();
-    void global_default_values();
 
     void setup_parser();
     void shutdown_parser();
 
-    /* =====================================================
-       Global interuption handling routine defined once here
-       =====================================================  */
-
-    set_signal();
-
     /* ==================================================
        Initialize from the command line
        from startup files. (See Parsing.c).
        ==================================================  */
 
     setup_parser(E,filename);
-
-    global_default_values(E);
     read_initial_settings(E);
     shutdown_parser(E);
 
@@ -225,7 +216,7 @@
 }
 
 
-/* This function is replaced by CitcomS.Solver._setup() */
+/* This function is replaced by CitcomS.Solver.initial_setup() in Pyre. */
 void initial_setup(struct All_variables *E)
 {
     void general_stokes_solver_setup();
@@ -236,8 +227,6 @@
     general_stokes_solver_setup(E);
 
     (E->next_buoyancy_field_init)(E);
-    if (E->parallel.me==0) fprintf(stderr,"time=%f\n",
-                                   CPU_time0()-E->monitor.cpu_time_at_start);
 
     return;
 }
@@ -1210,7 +1199,8 @@
 
     E->control.record_all_until = 10000000;
 
-  return;  }
+  return;
+}
 
 
 /* =============================================================
@@ -1320,15 +1310,10 @@
 {
     void initial_pressure();
     void initial_velocity();
-    /*void read_viscosity_option();*/
     void initial_viscosity();
 
-    report(E,"Initialize pressure field");
     initial_pressure(E);
-    report(E,"Initialize velocity field");
     initial_velocity(E);
-    report(E,"Initialize viscosity field");
-    /*get_viscosity_option(E);*/
     initial_viscosity(E);
 
     return;
@@ -1341,6 +1326,7 @@
      struct All_variables *E;
 {
     int i,m;
+    report(E,"Initialize pressure field");
 
   for (m=1;m<=E->sphere.caps_per_proc;m++)
     for(i=1;i<=E->lmesh.npno;i++)
@@ -1353,6 +1339,7 @@
      struct All_variables *E;
 {
     int i,m;
+    report(E,"Initialize velocity field");
 
   for (m=1;m<=E->sphere.caps_per_proc;m++)
     for(i=1;i<=E->lmesh.nnov;i++)   {

Modified: mc/3D/CitcomS/trunk/lib/Viscosity_structures.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Viscosity_structures.c	2009-04-08 23:38:51 UTC (rev 14641)
+++ mc/3D/CitcomS/trunk/lib/Viscosity_structures.c	2009-04-08 23:39:49 UTC (rev 14642)
@@ -253,6 +253,10 @@
 
 void initial_viscosity(struct All_variables *E)
 {
+    void report(struct All_variables*, char*);
+
+    report(E,"Initialize viscosity field");
+
     if (E->viscosity.FROM_SYSTEM)
         get_system_viscosity(E,1,E->EVI[E->mesh.levmax],E->VI[E->mesh.levmax]);
 

Modified: mc/3D/CitcomS/trunk/lib/citcom_init.h
===================================================================
--- mc/3D/CitcomS/trunk/lib/citcom_init.h	2009-04-08 23:38:51 UTC (rev 14641)
+++ mc/3D/CitcomS/trunk/lib/citcom_init.h	2009-04-08 23:39:49 UTC (rev 14642)
@@ -36,7 +36,7 @@
 #endif
 
 extern struct All_variables* citcom_init(MPI_Comm *world);
-    void citcom_finalize(struct All_variables *E, int status);
+void citcom_finalize(struct All_variables *E, int status);
 
 #ifdef __cplusplus
 }

Modified: mc/3D/CitcomS/trunk/module/initial_conditions.c
===================================================================
--- mc/3D/CitcomS/trunk/module/initial_conditions.c	2009-04-08 23:38:51 UTC (rev 14641)
+++ mc/3D/CitcomS/trunk/module/initial_conditions.c	2009-04-08 23:39:49 UTC (rev 14642)
@@ -26,7 +26,6 @@
 */
 
 #include <Python.h>
-#include "exceptions.h"
 #include "initial_conditions.h"
 
 #include "global_defs.h"
@@ -39,7 +38,6 @@
 void initial_velocity(struct All_variables*);
 void initial_viscosity(struct All_variables*);
 void post_processing(struct All_variables*);
-void report(struct All_variables*, char* str);
 void read_checkpoint(struct All_variables*);
 
 char pyCitcom_ic_initialize_material__doc__[] = "";
@@ -123,7 +121,6 @@
 
     E = (struct All_variables*)(PyCObject_AsVoidPtr(obj));
 
-    report(E,"Initialize pressure field");
     initial_pressure(E);
 
     Py_INCREF(Py_None);
@@ -145,7 +142,6 @@
 
     E = (struct All_variables*)(PyCObject_AsVoidPtr(obj));
 
-    report(E,"Initialize velocity field");
     initial_velocity(E);
 
     Py_INCREF(Py_None);
@@ -167,7 +163,6 @@
 
     E = (struct All_variables*)(PyCObject_AsVoidPtr(obj));
 
-    report(E,"Initialize viscosity field");
     initial_viscosity(E);
 
     Py_INCREF(Py_None);



More information about the CIG-COMMITS mailing list