[cig-commits] r4416 - mc/3D/CitcomS/trunk/CitcomS/Coupler

tan2 at geodynamics.org tan2 at geodynamics.org
Thu Aug 24 12:34:48 PDT 2006


Author: tan2
Date: 2006-08-24 12:34:48 -0700 (Thu, 24 Aug 2006)
New Revision: 4416

Added:
   mc/3D/CitcomS/trunk/CitcomS/Coupler/ContainingCoupler.py
   mc/3D/CitcomS/trunk/CitcomS/Coupler/Coupler.py
   mc/3D/CitcomS/trunk/CitcomS/Coupler/EmbeddedCoupler.py
Removed:
   mc/3D/CitcomS/trunk/CitcomS/Coupler/CoarseGridExchanger.py
   mc/3D/CitcomS/trunk/CitcomS/Coupler/Exchanger.py
   mc/3D/CitcomS/trunk/CitcomS/Coupler/FineGridExchanger.py
Log:
Renamed *Exchanger.py to *Coupler.py

Deleted: mc/3D/CitcomS/trunk/CitcomS/Coupler/CoarseGridExchanger.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/Coupler/CoarseGridExchanger.py	2006-08-24 19:31:54 UTC (rev 4415)
+++ mc/3D/CitcomS/trunk/CitcomS/Coupler/CoarseGridExchanger.py	2006-08-24 19:34:48 UTC (rev 4416)
@@ -1,224 +0,0 @@
-#!/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 Exchanger import Exchanger
-
-class CoarseGridExchanger(Exchanger):
-
-
-    def __init__(self, name, facility):
-        Exchanger.__init__(self, name, facility)
-
-        # exchanged information is non-dimensional
-        self.inventory.dimensional = False
-        # exchanged information is in spherical coordinate
-        self.inventory.transformational = False
-
-        return
-
-
-    def initialize(self, solver):
-        Exchanger.initialize(self, solver)
-
-	# restart and use temperautre field of previous run?
-
-        self.restart = solver.restart
-        if self.restart:
-            self.ic_initTemperature = solver.ic_initTemperature
-
-	self.all_variables = solver.all_variables
-        self.boundary = range(self.numSrc)
-        self.source["BC"] = range(self.numSrc)
-        self.BC = range(self.numSrc)
-
-        self.module.initConvertor(self.inventory.dimensional,
-                                  self.inventory.transformational,
-                                  self.all_variables)
-
-        return
-
-
-    def createMesh(self):
-        self.globalBBox = self.module.createGlobalBoundedBox(self.all_variables)
-        self.remoteBBox = self.module.exchangeBoundedBox(
-                                          self.globalBBox,
-                                          self.communicator.handle(),
-                                          self.srcComm[0].handle(),
-                                          self.srcComm[0].size - 1)
-        self.interior, self.myBBox = self.module.createInterior(
-                                                     self.remoteBBox,
-                                                     self.all_variables)
-        for i in range(len(self.boundary)):
-            self.boundary[i] = self.module.createEmptyBoundary()
-
-        return
-
-
-    def createSourceSink(self):
-        self.createSource()
-
-        if self.inventory.two_way_communication:
-            self.createSink()
-        return
-
-
-    def createSource(self):
-        for i, comm, b in zip(range(self.numSrc),
-                              self.srcComm,
-                              self.boundary):
-            # sink is always in the last rank of a communicator
-            sinkRank = comm.size - 1
-            self.source["BC"][i] = self.module.CitcomSource_create(comm.handle(),
-                                                                   sinkRank,
-                                                                   b,
-                                                                   self.myBBox,
-                                                                   self.all_variables)
-
-        return
-
-
-    def createSink(self):
-        self.sink["Intr"] = self.module.Sink_create(self.sinkComm.handle(),
-                                                    self.numSrc,
-                                                    self.interior)
-        return
-
-
-    def createBC(self):
-        import Outlet
-        for i, src in zip(range(self.numSrc),
-                          self.source["BC"]):
-            self.BC[i] = Outlet.SVTOutlet(src,
-                                          self.all_variables)
-        return
-
-
-    def createII(self):
-        import Inlet
-        self.II = Inlet.TInlet(self.interior,
-                               self.sink["Intr"],
-                               self.all_variables)
-        return
-
-
-    def initTemperature(self):
-        if self.restart:
-            # read-in restarted temperature field
-            self.ic_initTemperature()
-            del self.ic_initTemperature
-            # send temperature to FGE and postprocess
-            self.restartTemperature()
-        else:
-            self.module.initTemperature(self.remoteBBox,
-                                        self.all_variables)
-        return
-
-
-    def restartTemperature(self):
-        interior = range(self.numSrc)
-        source = range(self.numSrc)
-
-        for i in range(len(interior)):
-            interior[i] = self.module.createEmptyInterior()
-
-        for i, comm, b in zip(range(self.numSrc),
-                              self.srcComm,
-                              interior):
-            # sink is always in the last rank of a communicator
-            sinkRank = comm.size - 1
-            source[i] = self.module.CitcomSource_create(comm.handle(),
-                                                        sinkRank,
-                                                        b,
-                                                        self.myBBox,
-                                                        self.all_variables)
-
-        import Outlet
-        for i, src in zip(range(self.numSrc), source):
-            outlet = Outlet.TOutlet(src, self.all_variables)
-            outlet.send()
-
-        # Any modification of read-in temperature is done here
-        # Note: modifyT is called after sending unmodified T to FGE.
-        # If T is modified before sending, FGE's T will lose sharp feature.
-        # FGE has to call modifyT too to ensure consistent T field.
-        self.modifyT(self.remoteBBox)
-
-        return
-
-
-    def postVSolverRun(self):
-        self.applyBoundaryConditions()
-        return
-
-
-    def NewStep(self):
-        if self.inventory.two_way_communication:
-            # receive temperture field from FGE
-            self.II.recv()
-            self.II.impose()
-        return
-
-
-    def applyBoundaryConditions(self):
-        for bc in self.BC:
-            bc.send()
-        return
-
-
-    def stableTimestep(self, dt):
-        new_dt = self.module.exchangeTimestep(dt,
-                                              self.communicator.handle(),
-                                              self.srcComm[0].handle(),
-                                              self.srcComm[0].size - 1)
-        #print "%s - old dt = %g   exchanged dt = %g" % (
-        #       self.__class__, dt, new_dt)
-        return dt
-
-
-    def exchangeSignal(self, signal):
-        newsgnl = self.module.exchangeSignal(signal,
-                                             self.communicator.handle(),
-                                             self.srcComm[0].handle(),
-                                             self.srcComm[0].size - 1)
-        return newsgnl
-
-
-
-    class Inventory(Exchanger.Inventory):
-
-        import pyre.inventory as prop
-
-
-
-
-
-
-# version
-__id__ = "$Id$"
-
-# End of file

Copied: mc/3D/CitcomS/trunk/CitcomS/Coupler/ContainingCoupler.py (from rev 4415, mc/3D/CitcomS/trunk/CitcomS/Coupler/CoarseGridExchanger.py)

Copied: mc/3D/CitcomS/trunk/CitcomS/Coupler/Coupler.py (from rev 4415, mc/3D/CitcomS/trunk/CitcomS/Coupler/Exchanger.py)

Copied: mc/3D/CitcomS/trunk/CitcomS/Coupler/EmbeddedCoupler.py (from rev 4415, mc/3D/CitcomS/trunk/CitcomS/Coupler/FineGridExchanger.py)

Deleted: mc/3D/CitcomS/trunk/CitcomS/Coupler/Exchanger.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/Coupler/Exchanger.py	2006-08-24 19:31:54 UTC (rev 4415)
+++ mc/3D/CitcomS/trunk/CitcomS/Coupler/Exchanger.py	2006-08-24 19:34:48 UTC (rev 4416)
@@ -1,150 +0,0 @@
-#!/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 pyre.components.Component import Component
-
-
-class Exchanger(Component):
-
-
-    def __init__(self, name, facility):
-        Component.__init__(self, name, facility)
-
-        self.module = None
-        self.mesh = None
-        self.all_variables = None
-        self.communicator = None
-        self.srcComm = []
-        self.sinkComm = None
-        self.numSrc = 0
-
-        self.sink = {}
-        self.source = {}
-
-        self.catchup = True
-        self.done = False
-        self.coupled_steps = 1
-        return
-
-
-    def initialize(self, solver):
-        self.selectModule()
-        self.communicator = solver.communicator
-        self.srcComm = solver.myPlus
-        self.numSrc = len(self.srcComm)
-
-        # only one of remotePlus is sinkComm
-        self.sinkComm = solver.remotePlus[self.communicator.rank]
-        return
-
-
-    def launch(self, solver):
-        self.createMesh()
-        self.createSourceSink()
-        self.createBC()
-
-        if self.inventory.two_way_communication:
-            self.createII()
-        return
-
-
-    def selectModule(self):
-        import ExchangerLib
-        self.module = ExchangerLib
-        return
-
-
-    def modifyT(self, bbox):
-        self.module.modifyT(bbox, self.all_variables)
-        return
-
-
-    def preVSolverRun(self):
-        # do nothing, overridden by FGE
-        return
-
-
-    def postVSolverRun(self):
-        # do nothing, overridden by CGE
-        return
-
-
-    def endTimestep(self, steps, done):
-        KEEP_WAITING_SIGNAL = 0
-        NEW_STEP_SIGNAL = 1
-        END_SIMULATION_SIGNAL = 2
-
-        if done:
-            sent = END_SIMULATION_SIGNAL
-        elif self.catchup:
-            sent = NEW_STEP_SIGNAL
-        else:
-            sent = KEEP_WAITING_SIGNAL
-
-        while 1:
-            signal = self.exchangeSignal(sent)
-
-            if done or (signal == END_SIMULATION_SIGNAL):
-                done = True
-                break
-            elif signal == KEEP_WAITING_SIGNAL:
-                pass
-            elif signal == NEW_STEP_SIGNAL:
-                if self.catchup:
-                    #print self.name, 'exchanging timestep =', steps
-                    self.coupled_steps = self.exchangeSignal(steps)
-                    #print self.name, 'exchanged timestep =', self.coupled_steps
-                break
-            else:
-                raise ValueError, \
-                      "Unexpected signal value, singnal = %d" % signal
-
-        return done
-
-
-
-    class Inventory(Component.Inventory):
-
-        import pyre.inventory as prop
-
-
-
-        two_way_communication = prop.bool("two_way_communication", default=True)
-
-        # if dimensional is True, quantities exchanged are dimensional
-        dimensional = prop.bool("dimensional", default=True)
-        # if transformational is True, quantities exchanged are in standard coordiate system
-        transformational = prop.bool("transformational", default=True)
-
-
-
-
-# version
-__id__ = "$Id$"
-
-# End of file

Deleted: mc/3D/CitcomS/trunk/CitcomS/Coupler/FineGridExchanger.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/Coupler/FineGridExchanger.py	2006-08-24 19:31:54 UTC (rev 4415)
+++ mc/3D/CitcomS/trunk/CitcomS/Coupler/FineGridExchanger.py	2006-08-24 19:34:48 UTC (rev 4416)
@@ -1,263 +0,0 @@
-#!/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 Exchanger import Exchanger
-
-class FineGridExchanger(Exchanger):
-
-
-    def __init__(self, name, facility):
-        Exchanger.__init__(self, name, facility)
-        self.cge_t = 0
-        self.fge_t = 0
-        self.toApplyBC = True
-
-        # exchanged information is non-dimensional
-        self.inventory.dimensional = False
-        # exchanged information is in spherical coordinate
-        self.inventory.transformational = False
-        return
-
-
-    def initialize(self, solver):
-        Exchanger.initialize(self, solver)
-
-	# restart and use temperautre field of previous run?
-        self.restart = solver.restart
-        if self.restart:
-            self.ic_initTemperature = solver.ic_initTemperature
-
-	self.all_variables = solver.all_variables
-        self.interior = range(self.numSrc)
-        self.source["Intr"] = range(self.numSrc)
-        self.II = range(self.numSrc)
-
-        self.module.initConvertor(self.inventory.dimensional,
-                                  self.inventory.transformational,
-                                  self.all_variables)
-
-        return
-
-
-    def createMesh(self):
-        inv = self.inventory
-        self.globalBBox = self.module.createGlobalBoundedBox(self.all_variables)
-        mycomm = self.communicator
-        self.remoteBBox = self.module.exchangeBoundedBox(self.globalBBox,
-                                                         mycomm.handle(),
-                                                         self.sinkComm.handle(),
-                                                         0)
-        self.boundary, self.myBBox = self.module.createBoundary(
-                                                     self.all_variables,
-                                                     inv.excludeTop,
-                                                     inv.excludeBottom)
-
-        if inv.two_way_communication:
-            for i in range(len(self.interior)):
-                self.interior[i] = self.module.createEmptyInterior()
-
-        return
-
-
-    def createSourceSink(self):
-        self.createSink()
-
-        if self.inventory.two_way_communication:
-            self.createSource()
-        return
-
-
-    def createSink(self):
-        self.sink["BC"] = self.module.Sink_create(self.sinkComm.handle(),
-                                                  self.numSrc,
-                                                  self.boundary)
-        return
-
-
-    def createSource(self):
-        for i, comm, b in zip(range(self.numSrc),
-                              self.srcComm,
-                              self.interior):
-            # sink is always in the last rank of a communicator
-            sinkRank = comm.size - 1
-            self.source["Intr"][i] = self.module.CitcomSource_create(
-                                                     comm.handle(),
-                                                     sinkRank,
-                                                     b,
-                                                     self.myBBox,
-                                                     self.all_variables)
-
-        return
-
-
-    def createBC(self):
-        import Inlet
-        self.BC = Inlet.SVTInlet(self.boundary,
-                                 self.sink["BC"],
-                                 self.all_variables)
-        '''
-        if self.inventory.incompressibility:
-            self.BC = Inlet.BoundaryVTInlet(self.communicator,
-                                            self.boundary,
-                                            self.sink["BC"],
-                                            self.all_variables,
-                                            "VT")
-            import journal
-            journal.info("incompressibility").activate()
-        else:
-            self.BC = Inlet.SVTInlet(self.boundary,
-                                    self.sink["BC"],
-                                    self.all_variables)
-        '''
-        return
-
-
-    def createII(self):
-        import Outlet
-        for i, src in zip(range(self.numSrc),
-                          self.source["Intr"]):
-            self.II[i] = Outlet.TOutlet(src,
-                                        self.all_variables)
-        return
-
-
-    def initTemperature(self):
-        if self.restart:
-            # receive temperature from CGE and postprocess
-            self.restartTemperature()
-        else:
-            self.module.initTemperature(self.globalBBox,
-                                        self.all_variables)
-        return
-
-
-    def restartTemperature(self):
-        interior, bbox = self.module.createInterior(self.remoteBBox,
-                                                    self.all_variables)
-        sink = self.module.Sink_create(self.sinkComm.handle(),
-                                       self.numSrc,
-                                       interior)
-        import Inlet
-        inlet = Inlet.TInlet(interior, sink, self.all_variables)
-        inlet.recv()
-        inlet.impose()
-
-        # Any modification of read-in temperature is done here
-        # Note: modifyT is called after receiving unmodified T from CGE.
-        # If T is modified before sending, FGE's T will lose sharp feature.
-        # CGE has to call modifyT too to ensure consistent T field.
-        self.modifyT(self.globalBBox)
-
-        return
-
-
-    def preVSolverRun(self):
-        self.applyBoundaryConditions()
-        return
-
-
-    def NewStep(self):
-        if self.inventory.two_way_communication:
-            if self.catchup:
-                # send temperture field to CGE
-                for ii in self.II:
-                    ii.send()
-
-        return
-
-
-    def applyBoundaryConditions(self):
-        if self.toApplyBC:
-            self.BC.recv()
-
-            self.toApplyBC = False
-
-        self.BC.impose()
-
-        # applyBC only when previous step is a catchup step
-        if self.catchup:
-            self.toApplyBC = True
-
-        return
-
-
-    def stableTimestep(self, dt):
-        if self.catchup:
-            mycomm = self.communicator
-            self.cge_t = self.module.exchangeTimestep(dt,
-                                                      mycomm.handle(),
-                                                      self.sinkComm.handle(),
-                                                      0)
-            self.fge_t = 0
-            self.catchup = False
-
-        self.fge_t += dt
-        old_dt = dt
-
-        if self.fge_t >= self.cge_t:
-            dt = dt - (self.fge_t - self.cge_t)
-            self.fge_t = self.cge_t
-            self.catchup = True
-            #print "FGE: CATCHUP!"
-
-        # store timestep for interpolating boundary velocities
-        self.BC.storeTimestep(self.fge_t, self.cge_t)
-
-        #print "%s - old dt = %g   exchanged dt = %g" % (
-        #       self.__class__, old_dt, dt)
-        #print "cge_t = %g  fge_t = %g" % (self.cge_t, self.fge_t)
-        return dt
-
-
-    def exchangeSignal(self, signal):
-        mycomm = self.communicator
-        newsgnl = self.module.exchangeSignal(signal,
-                                             mycomm.handle(),
-                                             self.sinkComm.handle(),
-                                             0)
-        return newsgnl
-
-
-
-    class Inventory(Exchanger.Inventory):
-
-        import pyre.inventory as prop
-
-
-
-        excludeTop = prop.bool("excludeTop", default=False)
-        excludeBottom = prop.bool("excludeBottom", default=False)
-        incompressibility = prop.bool("incompressibility", default=True)
-
-
-
-
-# version
-__id__ = "$Id$"
-
-# End of file



More information about the cig-commits mailing list