/[escript]/trunk/modellib/py_src/crustal/mines.py
ViewVC logotype

Diff of /trunk/modellib/py_src/crustal/mines.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 985 by gross, Mon Feb 19 23:55:52 2007 UTC revision 986 by gross, Tue Feb 20 06:18:52 2007 UTC
# Line 148  class MiningArea(BoxInTheCrust): Line 148  class MiningArea(BoxInTheCrust):
148          self.__mines=mines          self.__mines=mines
149       def getStartOfRecords(self):       def getStartOfRecords(self):
150           return min([ m.getStartOfRecords() for m in self.__mines ])           return min([ m.getStartOfRecords() for m in self.__mines ])
151         def getMassChanges(self,t):
152             out={}
153             for m in self.__mines: out[m.getName()]=m.getMassChanges(t)
154             return out
155         def getNextTimeMarker(self,t):
156             return min([ m.getNextTimeMarker(t) for m in self.__mines ])
157              
158       def fillDesign(self,design):       def fillDesign(self,design):
159           """           """
160           this puts the mining area and all the mines into the given design           this puts the mining area and all the mines into the given design
# Line 215  class MiningArea(BoxInTheCrust): Line 222  class MiningArea(BoxInTheCrust):
222                 mboxes.append(-mb)                 mboxes.append(-mb)
223                 props.append(PropertySet(m.getName(),Volume(mb)))                 props.append(PropertySet(m.getName(),Volume(mb)))
224           design.addItems(*tuple(props))           design.addItems(*tuple(props))
          design.addItems(Volume(bb, holes= mboxes))  
225           long=self.getLongitudeLength()           long=self.getLongitudeLength()
226           lat=self.getLatitudeLength()           lat=self.getLatitudeLength()
227           dep=self.getDepth()           dep=self.getDepth()
# Line 246  class MiningArea(BoxInTheCrust): Line 252  class MiningArea(BoxInTheCrust):
252           left=PlaneSurface(CurveLoop(l11,-l42,-l41,l40))           left=PlaneSurface(CurveLoop(l11,-l42,-l41,l40))
253           right=PlaneSurface(CurveLoop(-l21,l20,l31,-l22))           right=PlaneSurface(CurveLoop(-l21,l20,l31,-l22))
254           dom=SurfaceLoop(bottom,top,front,back,left,right,-bb_bottom,-bb_front,-bb_back,-bb_left,-bb_right)           dom=SurfaceLoop(bottom,top,front,back,left,right,-bb_bottom,-bb_front,-bb_back,-bb_left,-bb_right)
255           design.addItems(Volume(dom))           design.addItems(PropertySet("matrix",Volume(bb, holes= mboxes), Volume(dom)))
256           return           return
257    
258  class Mine(BoxInTheCrust):  class Mine(BoxInTheCrust):
# Line 276  class Mine(BoxInTheCrust): Line 282  class Mine(BoxInTheCrust):
282               return self.__record[0][0]               return self.__record[0][0]
283            else:            else:
284               raise ValueError("empty record of %s mine."%self.getName())               raise ValueError("empty record of %s mine."%self.getName())
285         def getMassChanges(self,t):
286             m0=0.
287             t0=self.getStartOfRecords()
288             if t<=t0:
289                return 0.
290             for y, e in self.__record:
291                   return sum(e.values())
292             return 0.
293         def getNextTimeMarker(self,t):
294             for y, e in self.__record:
295               if y>t: return y
296             else:
297               return 999999999
298    
299    
300  def _parse(root):  def _parse(root):
# Line 456  def parse(xml): Line 475  def parse(xml):
475    
476            
477  if __name__ == "__main__":  if __name__ == "__main__":
478        from optparse import OptionParser
479      FILE="newcastle_mining.xml"      parser = OptionParser(usage = "usage: %prog [options] filename")
480        parser.add_option("-g", "--geo", dest="geofile", type="string", action = "store", default=None,
481                            help="geometry file (output)")
482        parser.add_option("-m", "--msh", dest="mshfile", type="string", action = "store", default=None,
483                            help="mesh file (output)")
484        parser.add_option("-t", "--tag", dest="tagfile", type="string", action = "store", default=None,
485                            help="tags file (output)")
486        parser.add_option("-s", "--size", dest="rel_size", type="float", action = "store", default=0.2,
487                            help="relative mesh size")
488        (options, args) = parser.parse_args()
489        if not len(args)==1:
490            raise parser.error("input file missing.")
491        FILE=args[0]
492      mine=parse(open(FILE,'r'))      mine=parse(open(FILE,'r'))
493      dsgn=Design(element_size=mine.getDiameter()*.2)      dsgn=Design(element_size=mine.getDiameter()*options.rel_size)
494        if not options.geofile == None:
495            dsgn.setScriptFileName(options.geofile)
496        if not options.mshfile == None:
497            dsgn.setMeshFileName(options.mshfile)
498      mine.fillDesign(dsgn)      mine.fillDesign(dsgn)
     dsgn.setScriptFileName("newcastle_mines.geo")  
     dsgn.setMeshFileName("newcastle_mines.msh")  
499      print dsgn.getCommandString()      print dsgn.getCommandString()
500      print "start of records = ",mine.getStartOfRecords()      print "mesh in gmsh format is written to ",dsgn.getMeshHandler()
501      dsgn.getMeshHandler()      if not options.tagfile == None:
502            dsgn.getVolumeTagMap().writeXML(open(options.tagfile,"w"))
503            print "volume tag map written to %s."%options.tagfile

Legend:
Removed from v.985  
changed lines
  Added in v.986

  ViewVC Help
Powered by ViewVC 1.1.26