@@ -404,15 +404,16 @@ def __init__(self,overwrite_output=False):
404404 'short_speed' :{'desc' :'' ,
405405 'validator' :VarType (bool ).chk
406406 },
407- }
407+ },
408+ defaultParameters = {'short_speed' :False ,'geoflow_tiny' :0.0001 }
408409 )
409410 #setMatModel
410411 self .ui_MatModel = None
411412 self .chk_MatModel = TiArgCheckerAndSetter (
412413 sectionName = "setMatModel" ,
413414 levelZeroParameters = {
414415 },
415- defaultParameters = {'use_gis_matmap' :False , 'geoflow_tiny' : 0.0001 , 'short_speed' : False , },
416+ defaultParameters = {'use_gis_matmap' :False },
416417 switchArguments = {
417418 'use_gis_matmap' :
418419 {
@@ -464,7 +465,7 @@ def __init__(self,overwrite_output=False):
464465 ),
465466 'Maeno' :TiArgCheckerAndSetter (
466467 levelZeroParameters = {
467- 'phi1 ' :{'validator' :VarType (float ,conditions = [{'f' :lambda v : v > 0 ,'msg' :'should be positive!' }]).chk ,'desc' :'' },
468+ 'phis ' :{'validator' :VarType (float ,conditions = [{'f' :lambda v : v > 0 ,'msg' :'should be positive!' }]).chk ,'desc' :'' },
468469 'phi2' :{'validator' :VarType (float ,conditions = [{'f' :lambda v : v > 0 ,'msg' :'should be positive!' }]).chk ,'desc' :'' },
469470 'partdiam' :{'validator' :VarType (float ,conditions = [{'f' :lambda v : v > 0 ,'msg' :'should be positive!' }]).chk ,'desc' :'' },
470471 'I_not' :{'validator' :VarType (float ,conditions = [{'f' :lambda v : v > 0 ,'msg' :'should be positive!' }]).chk ,'desc' :'' },
@@ -748,11 +749,9 @@ def setTimeSeriesOutput(self,**kwarg):
748749 if self .ui_TimeSeriesOutput ['diter' ]== None :
749750 self .ui_TimeSeriesOutput ['diter' ]= - 1
750751 def setStatProps (self ,enabled ,** kwarg ):
751- args = copy .deepcopy (kwarg )
752- args ['enabled' ]= enabled
753- ui = self .chk_StatProps .process (args )
752+ ui = self .chk_StatProps .process (kwarg )
754753
755- #Test if flow reaches height [m] ...
754+ #Test if flow reaches height [m] ...
756755 if ui ['edge_height' ] == None :
757756 ui ['edge_height' ] = - 1.0
758757 else :
@@ -774,9 +773,7 @@ def setStatProps(self,enabled,**kwarg):
774773 raise ValueError ('TitanSimulation::test_location should be set if test_height>0\n ' )
775774 self .ui_StatProps = ui
776775 def setOutlineProps (self ,enabled ,** kwarg ):
777- args = copy .deepcopy (kwarg )
778- args ['enabled' ]= enabled
779- self .ui_OutlineProps = self .chk_OutlineProps .process (args )
776+ self .ui_OutlineProps = self .chk_OutlineProps .process (kwarg )
780777 def addPile (self ,** kwarg ):
781778 self .ui_Pile .append (self .chk_Pile .process (kwarg ))
782779 def addFluxSource (self ,** kwarg ):
@@ -807,7 +804,7 @@ def _validate(self):
807804 else :
808805 for pile in self .ui_Pile :
809806 if 'vol_fract' in pile :
810- raise ValueError ('TitanSimulation:addFluxSource: Siogle phases model is set, addPile should not have vol_fract argument!' )
807+ raise ValueError ('TitanSimulation:addFluxSource: Single phase model is set, addPile should not have vol_fract argument!' )
811808
812809 #######################################################################
813810 #check satisfaction of integrator
@@ -830,36 +827,7 @@ def _validate(self):
830827 raise ValueError ("Can not find suitable integrator, here is the hint\n " + msg + "\n check the manual." )
831828 self .integratorConstructor = integrator
832829
833- #######################################################################
834- #check the presence of output files and delete them if nessesary also create directory for some outputs
835- def check_and_remove_filedir (filename ):
836- if os .path .exists (filename ):
837- if self .overwrite_output :
838- if os .path .isfile (filename ):
839- os .remove (filename )
840- if os .path .isdir (filename ):
841- shutil .rmtree (filename )
842- else :
843- raise IOError ("Output file or directory exists (" + filename + "). Remove it manually or set overwrite_output to True or change output prefix." )
844- def check_and_remove_filedir_by_wildcard (filename ):
845- files = glob .glob (filename )
846- print filename ,files
847- if not self .overwrite_output and len (files )> 0 :
848- raise IOError ("Output files or directories exists (" + "," .join (files )+ "). Remove it manually or set overwrite_output to True or change output prefix." )
849- for f in files :
850- check_and_remove_filedir (f )
851- #restarts
852- output_prefix = self .ui_RestartOutput ['output_prefix' ]
853- check_and_remove_filedir (output_prefix )
854- check_and_remove_filedir_by_wildcard ("%s_Quad[49]_p[0-9][0-9][0-9][0-9].xmf" % (output_prefix ,));
855-
856- os .mkdir (output_prefix )
857- #visoutput
858- output_prefix = self .ui_TimeSeriesOutput ['output_prefix' ]
859- check_and_remove_filedir (output_prefix )
860- check_and_remove_filedir_by_wildcard ("%s_xdmf_p[0-9][0-9][0-9][0-9].xmf" % (output_prefix ,));
861-
862- os .mkdir (output_prefix )
830+
863831
864832class TitanSimulation (TitanSimulationBase ):
865833 def __init__ (self ,overwrite_output = False ):
@@ -869,7 +837,7 @@ def __init__(self,overwrite_output=False):
869837
870838 def _setCxxTitanSimulation (self ):
871839 """initiate and set all parameters of cxxTitanSimulation"""
872- if 1 :
840+ if 0 :
873841 print self .ui_GIS
874842 print self .ui_Scale
875843 print self .ui_NumProp
@@ -902,6 +870,36 @@ def _setCxxTitanSimulation(self):
902870
903871 self .sim = cxxTitanSimulation ()
904872 self .sim .overwrite_output = self .overwrite_output
873+ #######################################################################
874+ #check the presence of output files and delete them if nessesary also create directory for some outputs
875+ if self .sim .myid == 0 :
876+ def check_and_remove_filedir (filename ):
877+ if os .path .exists (filename ):
878+ if self .overwrite_output :
879+ if os .path .isfile (filename ):
880+ os .remove (filename )
881+ if os .path .isdir (filename ):
882+ shutil .rmtree (filename )
883+ else :
884+ raise IOError ("Output file or directory exists (" + filename + "). Remove it manually or set overwrite_output to True or change output prefix." )
885+ def check_and_remove_filedir_by_wildcard (filename ):
886+ files = glob .glob (filename )
887+ if not self .overwrite_output and len (files )> 0 :
888+ raise IOError ("Output files or directories exists (" + "," .join (files )+ "). Remove it manually or set overwrite_output to True or change output prefix." )
889+ for f in files :
890+ check_and_remove_filedir (f )
891+ #restarts
892+ output_prefix = self .ui_RestartOutput ['output_prefix' ]
893+ check_and_remove_filedir (output_prefix )
894+ check_and_remove_filedir_by_wildcard ("%s_Quad[49]_p[0-9][0-9][0-9][0-9].xmf" % (output_prefix ,));
895+
896+ os .mkdir (output_prefix )
897+ #visoutput
898+ output_prefix = self .ui_TimeSeriesOutput ['output_prefix' ]
899+ check_and_remove_filedir (output_prefix )
900+ check_and_remove_filedir_by_wildcard ("%s_xdmf_p[0-9][0-9][0-9][0-9].xmf" % (output_prefix ,));
901+
902+ os .mkdir (output_prefix )
905903
906904 #######################################################################
907905 #Set GIS
@@ -1077,6 +1075,7 @@ def _preproc(self):
10771075
10781076 def run (self ):
10791077 """Perform simulation"""
1078+
10801079 self ._validate ()
10811080 #by this time all values should be sanitized
10821081 self ._setCxxTitanSimulation ()
0 commit comments