[cig-commits] r7674 - in mc/3D/CitcomS/trunk/CitcomS: . Coupler

hlin at geodynamics.org hlin at geodynamics.org
Mon Jul 16 14:21:10 PDT 2007


Author: hlin
Date: 2007-07-16 14:21:10 -0700 (Mon, 16 Jul 2007)
New Revision: 7674

Modified:
   mc/3D/CitcomS/trunk/CitcomS/Coupler/MultiC_Coupler.py
   mc/3D/CitcomS/trunk/CitcomS/MultiLayout.py
Log:
M    CitcomS/MultiLayout.py
trivial comment change

M    CitcomS/Coupler/MultiC_Coupler.py
a nearly complete version. Although I am not sure how most of the things works
, I managed to create a copy of everything.initTemperature, restartTemperature
, and modifyT not defined.
  


Modified: mc/3D/CitcomS/trunk/CitcomS/Coupler/MultiC_Coupler.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/Coupler/MultiC_Coupler.py	2007-07-16 20:40:46 UTC (rev 7673)
+++ mc/3D/CitcomS/trunk/CitcomS/Coupler/MultiC_Coupler.py	2007-07-16 21:21:10 UTC (rev 7674)
@@ -26,9 +26,9 @@
         # number of processors in the remote solver2
         self.remoteSize2 = len(self.srcCommList2)
 
-#?        # only one of remotePlus2 is sinkComm2 
-#?        self.sinkComm2 = solver.remotePlus2[self.communicator.rank]
-        
+        # only one of remotePlus2 is sinkComm2 
+        self.sinkComm2 = solver.remotePlus2[self.communicator.rank]
+                
         # allocate space
         self.remoteBdryList2 = range(self.remoteSize2)
         self.sourceList2 = range(self.remoteSize2)
@@ -41,8 +41,8 @@
     def createMesh(self):
         # Create BoundedMesh objects.
 
-        ContainingCouple.createMesh(self)
-        '''
+        ContainingCoupler.createMesh(self)
+        
         # the bounding box of the mesh on remote solver2
         self.remoteBBox2 = \
                          exchangeBoundedBox(self.globalBBox,
@@ -60,12 +60,179 @@
         for i in range(self.remoteSize2):
             self.remoteBdryList2[i] = createEmptyBoundary()
     
-        '''
+        
         return
+
+
+    def createSource(self):
+
+        ContainingCoupler.createSource(self)
+        
+        # the source objects will send boundary conditions to remote sink2
+        from ExchangerLib import CitcomSource_create
+        for i, comm, b in zip(range(self.remoteSize2),
+                              self.srcCommList2,
+                              self.remoteBdryList2):
+            # sink is always in the last rank of a communicator
+            sinkRank2 = comm.size - 1
+
+            # the sources will communicate with the sink in EmbeddedCoupler
+            # during creation stage
+            self.sourceList2[i] = CitcomSource_create(comm.handle(),
+                                                     sinkRank2,
+                                                     b,
+                                                     self.myBBox2,
+                                                     self.all_variables)
+        
+        return
+
+
+    def createSink(self):
+
+        ContainingCoupler.createSink(self)
+
+        # the sink obj. will receive interior
+        # temperature from remote sources
+        from ExchangerLib import Sink_create
+
+        # the sink will communicate with the source in EmbeddedCoupler
+        # during creation stage
+        self.sink2 = Sink_create(self.sinkComm2.handle(),
+                                self.remoteSize2,
+                                self.interior2)
+        return
+
     
+    def createBC(self):
+
+        ContainingCoupler.createBC(self)
+
+        # boundary conditions will be sent by SVTOutlet, which sends
+        # stress, velocity, and temperature
+        import Outlet
+        for i, src in zip(range(self.remoteSize2),
+                          self.sourceList2):
+            self.outletList2[i] = Outlet.SVTOutlet(src, self.all_variables)
+        return
+
+     def createII(self):
+
+        ContainingCoupler.createII(self)
+
+
+        # interior temperature will be received by TInlet
+        import Inlet
+        self.inlet2 = Inlet.TInlet(self.interior2,
+                                  self.sink2,
+                                  self.all_variables)
+        return
+   
+
+    # initTemperature
+
+    # restartTemperature
+
+    # modifyT
+    
+    def postVSolverRun(self):
+
+        ContainingCoupler.postVSolverRun(self)
+
+        # send computed velocity to ECPLR2 for its BCs
+        for outlet in self.outletList2:
+            outlet.send()
+        return
+
+    
+    def newStep(self):
+
+        ContainingCoupler.newStep(self)
+
+        # update the temperature field in the overlapping region
+        if self.inventory.two_way_communication:
+            # receive temperture field from EmbeddedCoupler
+            self.inlet2.recv()
+            self.inlet2.impose()
+        return
+    
+    def stableTimestep(self, dt):
+        #used by controller
+
+        from ExchangerLib import exchangeTimestep
+        remote_dt = exchangeTimestep(dt,
+                                     self.communicator.handle(),
+                                     self.srcCommList[0].handle(),
+                                     self.srcCommList[0].size - 1)
+        remote_dt2 = exchangeTimestep(dt,
+                                     self.communicator.handle(),
+                                     self.srcCommList2[0].handle(),
+                                     self.srcCommList2[0].size - 1)
+
+        assert remote_dt < dt, \
+               'Size of dt in the esolver is greater than dt in the csolver!'
+        assert remote_dt2 < dt, \
+               'Size of dt in the esolver is greater than dt in the csolver2!'
+
+        #print "%s - old dt = %g   exchanged dt = %g" % (
+        #       self.__class__, dt, remote_dt)
+        return dt
+
+    def exchangeSignal2(self, signal):
+        from ExchangerLib import exchangeSignal
+        newsgnl = exchangeSignal(signal,
+                                 self.communicator.handle(),
+                                 self.srcCommList2[0].handle(),
+                                 self.srcCommList2[0].size - 1)
+        return newsgnl
+
+    def endTimestep(self, steps, done):
+        #########################################
+        ##  fundamentally changed revision
+        #########################################
+
+        # exchange predefined signal btwn couplers
+        # the signal is used to sync the timesteps
+        KEEP_WAITING_SIGNAL = 0
+        NEW_STEP_SIGNAL = 1
+        END_SIMULATION_SIGNAL = 2
+
+        if done:
+            sent = END_SIMULATION_SIGNAL
+        elif self.synchronized:
+            sent = NEW_STEP_SIGNAL
+        else:
+            sent = KEEP_WAITING_SIGNAL
+
+        while 1:
+            recv = self.exchangeSignal(sent)
+            recv2= self.exchangeSignal2sent)
+
+            if done or (recv == END_SIMULATION_SIGNAL)
+            or (recv == END_SIMULATION_SIGNAL):
+                done = True
+                break
+            elif (recv == KEEP_WAITING_SIGNAL)
+            or(recv2 == KEEP_WAITING_SIGNAL):
+                pass
+            elif (recv == NEW_STEP_SIGNAL)
+            and (recv == NEW_STEP_SIGNAL):
+                if self.synchronized:
+                    #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" % recv
+
+        return done
+    
+    class Inventory(ContainingCoupler.Inventory):
+
+        
 # version
 
-__id__="$Id:$"
+__id__ = "$Id:$"
 
 # End of file
 

Modified: mc/3D/CitcomS/trunk/CitcomS/MultiLayout.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/MultiLayout.py	2007-07-16 20:40:46 UTC (rev 7673)
+++ mc/3D/CitcomS/trunk/CitcomS/MultiLayout.py	2007-07-16 21:21:10 UTC (rev 7674)
@@ -14,15 +14,12 @@
     def __init__(self, name, facility):
         Layout.__init__(self, name, facility)
 
-        # flag indicating that we are using
         # containing communicator
         self.ccomm = None
 
-        # flag indicating that we are using
         # embedded comminicator1
         self.ecomm1 = None
 
-        # flag indicating that we are using
         # embedded comminicator2
         self.ecomm2 = None
 



More information about the cig-commits mailing list