[cig-commits] r4414 - in mc/3D/CitcomS/trunk: CitcomS CitcomS/Solver bin

tan2 at geodynamics.org tan2 at geodynamics.org
Thu Aug 24 12:27:50 PDT 2006


Author: tan2
Date: 2006-08-24 12:27:49 -0700 (Thu, 24 Aug 2006)
New Revision: 4414

Added:
   mc/3D/CitcomS/trunk/CitcomS/BaseApplication.py
   mc/3D/CitcomS/trunk/CitcomS/Solver/CoupledFullSolver.py
   mc/3D/CitcomS/trunk/CitcomS/Solver/CoupledRegionalSolver.py
   mc/3D/CitcomS/trunk/CitcomS/Solver/CoupledSolver.py
   mc/3D/CitcomS/trunk/bin/coupledcitcoms.in
Modified:
   mc/3D/CitcomS/trunk/CitcomS/CoupledApp.py
   mc/3D/CitcomS/trunk/CitcomS/SimpleApp.py
   mc/3D/CitcomS/trunk/CitcomS/Solver/Solver.py
   mc/3D/CitcomS/trunk/CitcomS/Solver/__init__.py
   mc/3D/CitcomS/trunk/bin/Makefile.am
   mc/3D/CitcomS/trunk/bin/citcoms.in
Log:
* Refactored coupler-related codes from Solver.py to CoupledSolver.py
* Created CoupledFullSolver.py and CoupledRegionalSolver.py
* Refactored common codes between CoupledApp.py and SimpleApp.py to BaseApplication.py
* Changed the facility names in CoupledApp.py
* Created a coupledcitcoms script


Added: mc/3D/CitcomS/trunk/CitcomS/BaseApplication.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/BaseApplication.py	2006-08-24 18:35:59 UTC (rev 4413)
+++ mc/3D/CitcomS/trunk/CitcomS/BaseApplication.py	2006-08-24 19:27:49 UTC (rev 4414)
@@ -0,0 +1,146 @@
+#!/usr/bin/env python
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#<LicenseText>
+#
+# CitcomS.py by Eh Tan, Eun-seo Choi, and Pururav Thoutireddy.
+# Copyright (C) 2002-2005, California Institute of Technology.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#</LicenseText>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+
+
+from mpi.Application import Application
+import journal
+
+
+class BaseApplication(Application):
+
+
+    def __init__(self, name="CitcomS"):
+        Application.__init__(self, name)
+
+        self._info = journal.debug("application")
+        return
+
+
+
+    def main(self, *args, **kwds):
+        self.initialize()
+        self.reportConfiguration()
+        self.launch()
+        return
+
+
+
+    def launch(self):
+        self.controller.launch(self)
+
+        self.controller.march(steps=self.inventory.steps)
+        return
+
+
+
+    def usage(self):
+        print 'usage: citcoms [<property>=<value>] [<facility>.<property>=<value>] ...'
+        self.showUsage()
+        print """\
+For more information about a particular component:
+  --<facility>.help-properties
+  --<facility>.help-components
+where <facility> is the facility to which the component is bound; e.g.:
+  %(name)s --launcher.help-properties""" % locals()
+        return
+
+
+
+    def _getPrivateDepositoryLocations(self):
+        from os.path import dirname, isdir, join
+        list = []
+        etc = join(dirname(dirname(__file__)), 'etc')
+        if isdir(etc):
+            # The user is running directly from the source directory.
+            list.append(etc)
+        else:
+            try:
+                from config import makefile
+                pkgsysconfdir = makefile['pkgsysconfdir']
+                if isdir(pkgsysconfdir):
+                    list.append(pkgsysconfdir)
+            except ImportError, KeyError:
+                pass
+        return list
+
+
+
+    def initializeCurator(self, curator, registry):
+        from Components.CodecConfig import CodecConfig
+        cfg = CodecConfig()
+        curator.registerCodecs(cfg)
+        return super(BaseApplication, self).initializeCurator(curator, registry)
+
+
+
+    def collectUserInput(self, registry):
+        # read INI-style .cfg files
+        import journal
+        error = journal.error(self.name)
+        from Components.CodecConfig import CodecConfig
+        curator = self.getCurator()
+        configRegistry = curator.getTraits(self.name, extraDepositories=[], encoding='cfg')
+        self.updateConfiguration(configRegistry)
+        # read parameter files given on the command line
+        from os.path import isfile, splitext
+        for arg in self.argv:
+            if isfile(arg):
+                base, ext = splitext(arg)
+                encoding = ext[1:] # NYI: not quite
+                codec = self.getCurator().codecs.get(encoding)
+                if codec:
+                    shelf = codec.open(base)
+                    paramRegistry = shelf['inventory'].getFacility(self.name)
+                    if paramRegistry:
+                        self.updateConfiguration(paramRegistry)
+                else:
+                    error.log("unknown encoding: %s" % ext)
+            else:
+                error.log("cannot open '%s'" % arg)
+        return
+
+
+
+
+    class Inventory(Application.Inventory):
+
+        import pyre.inventory
+
+        import Controller
+        import Solver
+
+        launcher = pyre.inventory.facility("launcher", default="mpich")
+
+        steps = pyre.inventory.int("steps", default=1)
+
+
+
+# version
+__id__ = "$Id$"
+
+# End of file

Modified: mc/3D/CitcomS/trunk/CitcomS/CoupledApp.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/CoupledApp.py	2006-08-24 18:35:59 UTC (rev 4413)
+++ mc/3D/CitcomS/trunk/CitcomS/CoupledApp.py	2006-08-24 19:27:49 UTC (rev 4414)
@@ -26,15 +26,15 @@
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 #
 
-from SimpleApp import SimpleApp
+from BaseApplication import BaseApplication
 import journal
 
 
-class CoupledApp(SimpleApp):
+class CoupledApp(BaseApplication):
 
 
     def __init__(self, name="CitcomS"):
-        SimpleApp.__init__(self, name)
+        BaseApplication.__init__(self, name)
 
         self.solver = None
         self.solverCommunicator = None
@@ -44,8 +44,6 @@
         self.comm = None
         self.rank = 0
         self.nodes = 0
-
-        self._info = journal.debug("application")
         return
 
 
@@ -65,16 +63,16 @@
     def findLayout(self, layout):
 
         if layout.coarse:
-            self.controller = self.inventory.coarseController
-            self.solver = self.inventory.coarse
-            self.exchanger = self.inventory.cge
+            self.controller = self.inventory.controller1
+            self.solver = self.inventory.solver1
+            self.coupler = self.inventory.coupler1
             self.solverCommunicator = layout.coarse
             self.myPlus = layout.coarsePlus
             self.remotePlus = layout.finePlus
         elif layout.fine:
-            self.controller = self.inventory.fineController
-            self.solver = self.inventory.fine
-            self.exchanger = self.inventory.fge
+            self.controller = self.inventory.controller2
+            self.solver = self.inventory.solver2
+            self.coupler = self.inventory.coupler2
             self.solverCommunicator = layout.fine
             self.myPlus = layout.finePlus
             self.remotePlus = layout.coarsePlus
@@ -107,20 +105,19 @@
         self._info.line("    journal: %r" % self.inventory.journal.name)
         self._info.line("    launcher: %r" % self.inventory.launcher.name)
 
-        self._info.line("    coarse: %r" % self.inventory.coarse.name)
-        self._info.line("    fine: %r" % self.inventory.fine.name)
-        self._info.line("    cge: %r" % self.inventory.cge.name)
-        self._info.line("    fge: %r" % self.inventory.fge.name)
-        self._info.line("    coarseController: %r" % self.inventory.coarseController.name)
-        self._info.line("    fineController: %r" % self.inventory.fineController.name)
-        self._info.line("    coupler: %r" % self.inventory.coupler.name)
+        self._info.line("    solver1: %r" % self.inventory.solver1.name)
+        self._info.line("    solver2: %r" % self.inventory.solver2.name)
+        self._info.line("    controller1: %r" % self.inventory.controller1.name)
+        self._info.line("    controller2: %r" % self.inventory.controller2.name)
+        self._info.line("    coupler1: %r" % self.inventory.coupler1.name)
+        self._info.line("    coupler2: %r" % self.inventory.coupler2.name)
         self._info.line("    layout: %r" % self.inventory.layout.name)
 
         return
 
 
 
-    class Inventory(SimpleApp.Inventory):
+    class Inventory(BaseApplication.Inventory):
 
         import pyre.inventory
 
@@ -128,19 +125,29 @@
         import Solver
         import Coupler
         import Layout
-        import CitcomS.Components.Exchanger as Exchanger
 
+        controller1 = pyre.inventory.facility(name="controller1",
+                                              factory=Controller.controller,
+                                              args=("ccontroller","controller1"))
+        controller2 = pyre.inventory.facility(name="controller2",
+                                              factory=Controller.controller,
+                                              args=("econtroller","controller2"))
+        coupler1 = pyre.inventory.facility("coupler1",
+                                           factory=Coupler.containingcoupler,
+                                           args=("ccoupler","coupler1"))
+        coupler2 = pyre.inventory.facility("coupler2",
+                                           factory=Coupler.embeddedcoupler,
+                                           args=("ecoupler","coupler2"))
 
-        coarseController = pyre.inventory.facility(name="coarseController", factory=Controller.controller, args=("coarseController",))
-        fineController = pyre.inventory.facility(name="fineController", factory=Controller.controller, args=("fineController",))
-        coupler = pyre.inventory.facility("coupler", factory=Coupler.coupler)
+        solver1 = pyre.inventory.facility("solver1",
+                                          factory=Solver.coupledRegionalSolver,
+                                          args=("csolver", "solver1"))
+        solver2 = pyre.inventory.facility("solver2",
+                                       factory=Solver.coupledRegionalSolver,
+                                       args=("esolver", "solver2"))
+
         layout = pyre.inventory.facility("layout", factory=Layout.layout)
 
-        coarse = pyre.inventory.facility("coarse", factory=Solver.fullSolver, args=("coarse", "coarse"))
-        fine = pyre.inventory.facility("fine", factory=Solver.regionalSolver, args=("fine", "fine"))
-        cge = pyre.inventory.facility("cge", factory=Exchanger.coarsegridexchanger)
-        fge = pyre.inventory.facility("fge", factory=Exchanger.finegridexchanger)
-
         steps = pyre.inventory.int("steps", default=1)
 
 

Modified: mc/3D/CitcomS/trunk/CitcomS/SimpleApp.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/SimpleApp.py	2006-08-24 18:35:59 UTC (rev 4413)
+++ mc/3D/CitcomS/trunk/CitcomS/SimpleApp.py	2006-08-24 19:27:49 UTC (rev 4414)
@@ -27,31 +27,22 @@
 #
 
 
-from mpi.Application import Application
+from BaseApplication import BaseApplication
 import journal
 
 
-class SimpleApp(Application):
+class SimpleApp(BaseApplication):
 
 
     def __init__(self, name="CitcomS"):
-        Application.__init__(self, name)
+        BaseApplication.__init__(self, name)
 
         self.solver = None
         self.solverCommunicator = None
-        self._info = journal.debug("application")
         return
 
 
 
-    def main(self, *args, **kwds):
-        self.initialize()
-        self.reportConfiguration()
-        self.launch()
-        return
-
-
-
     def initialize(self):
         layout = self.findLayout()
 
@@ -60,14 +51,6 @@
 
 
 
-    def launch(self):
-        self.controller.launch(self)
-
-        self.controller.march(steps=self.inventory.steps)
-        return
-
-
-
     def findLayout(self):
         self.controller = self.inventory.controller
         self.solver = self.inventory.solver
@@ -100,85 +83,19 @@
         return
 
 
-    def usage(self):
-        print 'usage: citcoms [<property>=<value>] [<facility>.<property>=<value>] ...'
-        self.showUsage()
-        print """\
-For more information about a particular component:
-  --<facility>.help-properties
-  --<facility>.help-components
-where <facility> is the facility to which the component is bound; e.g.:
-  %(name)s --launcher.help-properties""" % locals()
-        return
+    class Inventory(BaseApplication.Inventory):
 
-
-    class Inventory(Application.Inventory):
-
         import pyre.inventory
 
         import Controller
         import Solver
 
-        launcher = pyre.inventory.facility("launcher", default="mpich")
-
         controller = pyre.inventory.facility("controller", factory=Controller.controller)
         solver = pyre.inventory.facility("solver", factory=Solver.regionalSolver)
 
-        steps = pyre.inventory.int("steps", default=1)
 
 
-    def _getPrivateDepositoryLocations(self):
-        from os.path import dirname, isdir, join
-        list = []
-        etc = join(dirname(dirname(__file__)), 'etc')
-        if isdir(etc):
-            # The user is running directly from the source directory.
-            list.append(etc)
-        else:
-            try:
-                from config import makefile
-                pkgsysconfdir = makefile['pkgsysconfdir']
-                if isdir(pkgsysconfdir):
-                    list.append(pkgsysconfdir)
-            except ImportError, KeyError:
-                pass
-        return list
 
-
-    def initializeCurator(self, curator, registry):
-        from Components.CodecConfig import CodecConfig
-        cfg = CodecConfig()
-        curator.registerCodecs(cfg)
-        return super(SimpleApp, self).initializeCurator(curator, registry)
-        
-
-    def collectUserInput(self, registry):
-        # read INI-style .cfg files
-        import journal
-        error = journal.error(self.name)
-        from Components.CodecConfig import CodecConfig
-        curator = self.getCurator()
-        configRegistry = curator.getTraits(self.name, extraDepositories=[], encoding='cfg')
-        self.updateConfiguration(configRegistry)
-        # read parameter files given on the command line
-        from os.path import isfile, splitext
-        for arg in self.argv:
-            if isfile(arg):
-                base, ext = splitext(arg)
-                encoding = ext[1:] # NYI: not quite
-                codec = self.getCurator().codecs.get(encoding)
-                if codec:
-                    shelf = codec.open(base)
-                    paramRegistry = shelf['inventory'].getFacility(self.name)
-                    if paramRegistry:
-                        self.updateConfiguration(paramRegistry)
-                else:
-                    error.log("unknown encoding: %s" % ext)
-            else:
-                error.log("cannot open '%s'" % arg)
-        return
-
-
 # main
 if __name__ == "__main__":
 

Added: mc/3D/CitcomS/trunk/CitcomS/Solver/CoupledFullSolver.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/Solver/CoupledFullSolver.py	2006-08-24 18:35:59 UTC (rev 4413)
+++ mc/3D/CitcomS/trunk/CitcomS/Solver/CoupledFullSolver.py	2006-08-24 19:27:49 UTC (rev 4414)
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#<LicenseText>
+#
+# CitcomS.py by Eh Tan, Eun-seo Choi, and Pururav Thoutireddy.
+# Copyright (C) 2002-2005, California Institute of Technology.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#</LicenseText>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+
+from CoupledSolver import CoupledSolver
+import journal
+
+
+class CoupledFullSolver(CoupledSolver):
+
+
+    def initializeSolver(self):
+        from CitcomSLib import full_solver_init
+        full_solver_init(self.all_variables)
+
+
+
+    class Inventory(CoupledSolver.Inventory):
+
+        import pyre.inventory
+
+        # component modules
+        import CitcomS.Components.Sphere as Sphere
+
+
+        mesher = pyre.inventory.facility("mesher", factory=Sphere.fullSphere, args=("full-sphere",))
+
+        datafile = pyre.inventory.str("datafile", default="fulltest")
+        datafile_old = pyre.inventory.str("datafile_old", default="fulltest")
+
+
+
+
+# version
+__id__ = "$Id: /local/coupler/CitcomS/Solver/FullSolver.py 995 2006-07-07T22:35:14.359825Z leif  $"
+
+# End of file

Added: mc/3D/CitcomS/trunk/CitcomS/Solver/CoupledRegionalSolver.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/Solver/CoupledRegionalSolver.py	2006-08-24 18:35:59 UTC (rev 4413)
+++ mc/3D/CitcomS/trunk/CitcomS/Solver/CoupledRegionalSolver.py	2006-08-24 19:27:49 UTC (rev 4414)
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#<LicenseText>
+#
+# CitcomS.py by Eh Tan, Eun-seo Choi, and Pururav Thoutireddy.
+# Copyright (C) 2002-2005, California Institute of Technology.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#</LicenseText>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+
+from CoupledSolver import CoupledSolver
+from CitcomSLib import regional_solver_init
+import journal
+
+
+class CoupledRegionalSolver(CoupledSolver):
+
+
+    def initializeSolver(self):
+        regional_solver_init(self.all_variables)
+
+
+
+    class Inventory(CoupledSolver.Inventory):
+
+        import pyre.inventory
+
+        # component modules
+        import CitcomS.Components.Sphere as Sphere
+
+
+        mesher = pyre.inventory.facility("mesher", factory=Sphere.regionalSphere, args=("regional-sphere",))
+
+        datafile = pyre.inventory.str("datafile", default="regtest")
+        datafile_old = pyre.inventory.str("datafile_old", default="regtest")
+
+
+
+
+# version
+__id__ = "$Id: /local/coupler/CitcomS/Solver/RegionalSolver.py 995 2006-07-07T22:35:14.359825Z leif  $"
+
+# End of file

Added: mc/3D/CitcomS/trunk/CitcomS/Solver/CoupledSolver.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/Solver/CoupledSolver.py	2006-08-24 18:35:59 UTC (rev 4413)
+++ mc/3D/CitcomS/trunk/CitcomS/Solver/CoupledSolver.py	2006-08-24 19:27:49 UTC (rev 4414)
@@ -0,0 +1,141 @@
+#!/usr/bin/env python
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#<LicenseText>
+#
+# CitcomS.py by Eh Tan, Eun-seo Choi, and Pururav Thoutireddy.
+# Copyright (C) 2002-2005, California Institute of Technology.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#</LicenseText>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+
+from CitcomSLib import output, output_time
+from Solver import Solver
+import journal
+
+
+
+class CoupledSolver(Solver):
+
+    def __init__(self, name, facility="solver"):
+        Solver.__init__(self, name, facility)
+
+        self.coupler = None
+        self.myPlus = []
+        self.remotePlus = []
+        return
+
+
+    def initialize(self, application):
+        Solver.initialize(self, application)
+
+        self.coupler = application.coupler
+        self.myPlus = application.myPlus
+        self.remotePlus = application.remotePlus
+
+        self.coupler.initialize(self)
+        return
+
+
+    def launch(self, application):
+        self._setup()
+
+        self.coupler.launch(self)
+
+        ic = self.inventory.ic
+        if not (ic.inventory.restart or ic.inventory.post_p):
+            # switch the default initTemperature to coupled version
+            ic.initTemperature = self.exchanger.initTemperature
+
+        # initial conditions
+        ic.launch()
+
+        self.solveVelocities()
+        return
+
+
+
+    def solveVelocities(self):
+        vsolver = self.inventory.vsolver
+        self.coupler.preVSolverRun()
+        vsolver.run()
+        self.coupler.postVSolverRun()
+        return
+
+
+
+    def solveAdditional(self):
+        # override Solver.solveAdditional, since tracer module
+        # doesn't work in coupled run
+        return
+
+
+
+    def newStep(self):
+        Solver.newStep(self)
+        self.coupler.newStep()
+        return
+
+
+
+    def stableTimestep(self):
+        dt = Solver.stableTimestep(self)
+
+        # negotiate with other solver(s)
+        dt = self.coupler.stableTimestep(dt)
+        return dt
+
+
+    def endTimestep(self, done):
+        done = Solver.endTimestep(self, done)
+
+        # check with other solver, are we done?
+        done = self.coupler.endTimestep(self.step, done)
+        return done
+
+
+    def endSimulation(self):
+        self._avgCPUTime()
+        # write even if not sync'd
+        output(self.all_variables, step)
+        self.finalize()
+        return
+
+
+
+    def save(self, monitoringFrequency):
+        step = self.step
+
+        # for coupled run, output spacing is determined by coupled_steps
+        if (not (step % monitoringFrequency)) or (
+            not (self.coupler.exchanger.coupled_steps % monitoringFrequency)):
+            output(self.all_variables, step)
+
+        output_time(self.all_variables, step)
+        return
+
+
+
+
+
+# version
+__id__ = "$Id$"
+
+# End of file

Modified: mc/3D/CitcomS/trunk/CitcomS/Solver/Solver.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/Solver/Solver.py	2006-08-24 18:35:59 UTC (rev 4413)
+++ mc/3D/CitcomS/trunk/CitcomS/Solver/Solver.py	2006-08-24 19:27:49 UTC (rev 4414)
@@ -39,12 +39,6 @@
 
         self.all_variables = None
         self.communicator = None
-
-        self.coupler = None
-        self.exchanger = None
-        self.myPlus = []
-        self.remotePlus = []
-
 	self.start_cpu_time = 0
         return
 
@@ -107,23 +101,21 @@
         self.restart = self.inventory.ic.inventory.restart
 
         self.ic_initTemperature = self.inventory.ic.initTemperature
+        return
 
-        # if there is a coupler, initialize it
-        try:
-            application.inventory.coupler
-        except AttributeError:
-            pass
-        else:
-            self.myPlus = application.myPlus
-            self.remotePlus = application.remotePlus
-            self.exchanger = application.exchanger
-            self.coupler = application.inventory.coupler
-            self.coupler.initialize(self)
 
+    def launch(self, application):
+        self._setup()
+
+        # initial conditions
+        ic = self.inventory.ic
+        ic.launch()
+
+        self.solveVelocities()
         return
 
 
-    def launch(self, application):
+    def _setup(self):
         mesher = self.inventory.mesher
         mesher.setup()
 
@@ -136,37 +128,15 @@
         # create mesh
         mesher.run()
 
-        ic = self.inventory.ic
-
-        # if there is a coupler, launch it
-        if self.coupler:
-            self.coupler.launch(self)
-
-            if not (ic.inventory.restart or ic.inventory.post_p):
-                # switch the default initTemperature to coupled version
-                ic.initTemperature = self.exchanger.initTemperature
-
-        # initial conditions
-        ic.launch()
-
         # initialize const. related to mesh
         vsolver.launch()
         tsolver.launch()
-
-        self.solveVelocities()
-
         return
 
 
-
     def solveVelocities(self):
         vsolver = self.inventory.vsolver
-        if self.coupler:
-            self.coupler.preVSolverRun()
-            vsolver.run()
-            self.coupler.postVSolverRun()
-        else:
-            vsolver.run()
+        vsolver.run()
         return
 
 
@@ -179,35 +149,19 @@
 
 
     def solveAdditional(self):
-        if not self.coupler:
-            # tracer module doesn't work with exchanger module
-            self.inventory.tracer.run()
+        self.inventory.tracer.run()
         return
 
 
 
     def newStep(self):
-        if self.coupler:
-            self.coupler.newStep()
         return
 
 
 
-    #def applyBoundaryConditions(self):
-        #if self.coupler:
-        #    self.coupler.applyBoundaryConditions()
-        #return
-
-
-
     def stableTimestep(self):
         tsolver = self.inventory.tsolver
         dt = tsolver.stable_timestep()
-
-        if self.coupler:
-            # negotiate with other solver(s)
-            dt = self.coupler.stableTimestep(dt)
-
         return dt
 
 
@@ -216,51 +170,41 @@
         self.solveTemperature(dt)
         self.solveVelocities()
         self.solveAdditional()
-
         return
 
 
-
     def endTimestep(self, done):
         self.inventory.visc.updateMaterial()
         self.inventory.bc.updatePlateVelocity()
-
-        if self.coupler:
-            done = self.coupler.endTimestep(self.step, done)
-
         return done
 
 
     def endSimulation(self):
+        self._avgCPUTime()
+        self.finalize()
+        return
+
+
+    def _avgCPUTime(self):
         step = self.step
         total_cpu_time = CPU_time() - self.start_cpu_time
 
         rank = self.communicator.rank
         if not rank:
             import sys
-            print >> sys.stderr, "Average cpu time taken for velocity step = %f" % (
-                total_cpu_time / (step+1) )
-
-        if self.coupler:
-            output(self.all_variables, step)
-
-        self.finalize()
+            sys.stderr.write("Average cpu time taken for velocity step = %f\n"
+                             % (total_cpu_time / (step+1)) )
         return
 
 
-
     def save(self, monitoringFrequency):
         step = self.step
 
-        # for non-coupled run, output spacing is 'monitoringFrequency'
+        # output spacing is 'monitoringFrequency'
         if not (step % monitoringFrequency):
             output(self.all_variables, step)
-        elif self.coupler and not (self.coupler.exchanger.coupled_steps % monitoringFrequency):
-            print self.coupler.exchanger.coupled_steps, monitoringFrequency
-            output(self.all_variables, step)
 
         output_time(self.all_variables, step)
-
         return
 
 

Modified: mc/3D/CitcomS/trunk/CitcomS/Solver/__init__.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/Solver/__init__.py	2006-08-24 18:35:59 UTC (rev 4413)
+++ mc/3D/CitcomS/trunk/CitcomS/Solver/__init__.py	2006-08-24 19:27:49 UTC (rev 4414)
@@ -28,6 +28,18 @@
 
 
 
+def coupledFullSolver(name, facility):
+    from CoupledFullSolver import CoupledFullSolver
+    return CoupledFullSolver(name, facility)
+
+
+
+def coupledRegionalSolver(name, facility):
+    from CoupledRegionalSolver import CoupledRegionalSolver
+    return CoupledRegionalSolver(name, facility)
+
+
+
 def fullSolver(name='full', facility='solver'):
     from FullSolver import FullSolver
     return FullSolver(name, facility)

Modified: mc/3D/CitcomS/trunk/bin/Makefile.am
===================================================================
--- mc/3D/CitcomS/trunk/bin/Makefile.am	2006-08-24 18:35:59 UTC (rev 4413)
+++ mc/3D/CitcomS/trunk/bin/Makefile.am	2006-08-24 19:27:49 UTC (rev 4414)
@@ -32,7 +32,7 @@
 
 if COND_PYRE
 
-bin_SCRIPTS += citcoms
+bin_SCRIPTS += citcoms coupledcitcoms
 
 if COND_EMBEDDING
     bin_PROGRAMS += pycitcoms
@@ -81,6 +81,9 @@
 citcoms: $(srcdir)/citcoms.in Makefile
 	$(do_build) < $(srcdir)/citcoms.in > $@ || (rm -f $@ && exit 1)
 	chmod +x $@
+coupledcitcoms: $(srcdir)/coupledcitcoms.in Makefile
+	$(do_build) < $(srcdir)/coupledcitcoms.in > $@ || (rm -f $@ && exit 1)
+	chmod +x $@
 install-binSCRIPTS: $(bin_SCRIPTS)
 	@$(NORMAL_INSTALL)
 	test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"

Modified: mc/3D/CitcomS/trunk/bin/citcoms.in
===================================================================
--- mc/3D/CitcomS/trunk/bin/citcoms.in	2006-08-24 18:35:59 UTC (rev 4413)
+++ mc/3D/CitcomS/trunk/bin/citcoms.in	2006-08-24 19:27:49 UTC (rev 4414)
@@ -46,15 +46,9 @@
         MPI_Init(sys.argv)
         break
 
-if len(sys.argv) > 1 and sys.argv[1] == "--coupled":
-    del sys.argv[1]
-    from CitcomS.CoupledApp import CoupledApp
-    app = CoupledApp()
-    app.run()
-else:
-    from CitcomS.SimpleApp import SimpleApp
-    app = SimpleApp()
-    app.run()
+from CitcomS.SimpleApp import SimpleApp
+app = SimpleApp()
+app.run()
 
 if inParallel:
     MPI_Finalize()

Added: mc/3D/CitcomS/trunk/bin/coupledcitcoms.in
===================================================================
--- mc/3D/CitcomS/trunk/bin/coupledcitcoms.in	2006-08-24 18:35:59 UTC (rev 4413)
+++ mc/3D/CitcomS/trunk/bin/coupledcitcoms.in	2006-08-24 19:27:49 UTC (rev 4414)
@@ -0,0 +1,56 @@
+#!@INTERPRETER@
+# -*- Python -*-
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#<LicenseText>
+#
+# CitcomS.py by Eh Tan, Eun-seo Choi, and Pururav Thoutireddy.
+# Copyright (C) 2002-2005, California Institute of Technology.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#</LicenseText>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+
+
+# re-create the PYTHONPATH at 'configure' time
+import os.path, sys
+path = '@PYTHONPATH@'.split(':')
+path.reverse()
+for directory in path:
+    if directory:
+        directory = os.path.abspath(directory)
+        sys.path.insert(1, directory)
+
+from PyxMPI import MPI_Init, MPI_Finalize
+
+inParallel = False
+for arg in sys.argv:
+    if arg == "--mode=worker":
+        inParallel = True
+        MPI_Init(sys.argv)
+        break
+
+from CitcomS.CoupledApp import CoupledApp
+app = CoupledApp()
+app.run()
+
+if inParallel:
+    MPI_Finalize()
+
+#  end of file 



More information about the cig-commits mailing list