def __init__(self, name=None, mshfile=None, bcs=None, cellzone=None, dimension=None, zip_opt=None, scale='1.0',interface=None,items=None): if items:# will be called for opening existing project storage.Storable.__init__(self, items=items) self.runs = {} for k in self.runpaths.keys(): items = storage.load(self.runpaths[k]) self.runs[k] = Run(project=self, items = items) if self.activerun: self.setActiveRun(self.activerun) else: rep = tools.getRepository()#this will be called only for new creation self.name = name self.mshfile = mshfile self.cellzone = cellzone self.dimension = dimension self.projectdir = os.path.join(rep, name) self.bcs = bcs # boundary conditions self.zip_opt=zip_opt self.runs = {} self.runpaths = {} self.activerun = None self.scale = scale self.interface=interface self.pfluid = "[Ff][Ll][Uu][Ii][Dd]" self.pwall = "[Ww][Aa][Ll]{2,2}" self.pinlet = "[Pp][Rr][Ee][Ss][Ss][Uu][Rr][Ee][-_ ][Ii][Nn][Ll][Ee][Tt]" try: os.mkdir(rep) except: pass os.mkdir(self.projectdir)
def getNewProjectName(basename): rep = tools.getRepository() print rep if not os.path.exists(os.path.join(rep, basename)): return basename i = 0 while os.path.exists(os.path.join(rep, basename+str(i))): i = i +1 return basename + str(i)
def testProjectSimple(self): name = "Dummy" p = Project(name, "/tmp/x.msh", bcs=[("Wall1","wall"), ("Wall2","wall"), ("Fluid1", "fluid")]) self.assertEqual(p['name'], name) rep = tools.getRepository() path = os.path.join(rep, name) self.assertEqual(p['projectdir'], path) self.assertTrue(os.path.exists(p['projectdir'])) p.createRun("SampleRun") self.assertTrue(os.path.exists(p['SampleRun']['path'])) treefile = os.path.join(p['SampleRun']['path'], "run.tree") wall1 = os.path.join(p['SampleRun']['path'], "config", "Wall1.conf") wall2 = os.path.join(p['SampleRun']['path'], "config", "Wall2.conf") fluid1 = os.path.join(p['SampleRun']['path'], "config", "Fluid1.conf") self.assertTrue(os.path.exists(treefile)) self.assertTrue(os.path.exists(wall1)) self.assertTrue(os.path.exists(wall2)) self.assertTrue(os.path.exists(fluid1)) p.delete()
def getRepository(): return tools.getRepository()