Skip to content

Commit 945cf9c

Browse files
committed
some fixes
1 parent 75b00b5 commit 945cf9c

File tree

7 files changed

+62
-64
lines changed

7 files changed

+62
-64
lines changed

src/header/extfun.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ extern void output_stoch_stats(MatProps* matprops, StatProps* statprops);
141141

142142
//! this function writes text tecplot output files in the tecplxxxxxxxx.plt format. Keith rewrote this function to eliminate a lot of bugs shortly after he started the project, since then files were 1/3 the size they were previously.
143143
extern void tecplotter(ElementType elementType, ElementsHashTable* HT_Elem_Ptr, NodeHashTable* HT_Node_Ptr, MatProps* matprops, TimeProps* timeprops,
144-
MapNames* mapnames, double v_star);
144+
MapNames* mapnames, double v_star, const char * output_prefix);
145145

146146
//! this function writes text tecplot output files in the mshplxxxxxxxx.plt format. This is largely untouched since before I (Keith) joined the GMFG, just minor changes. This is the preferred (by Professor Patra) format of output for debugging purposes even though tecplxxxxxxxx.plt create nicer images.
147147
extern void meshplotter(ElementsHashTable* HT_Elem_Ptr, NodeHashTable* HT_Node_Ptr, MatProps* matprops, TimeProps* timeprops,
148-
MapNames* mapnames, double v_star);
148+
MapNames* mapnames, double v_star, const char * output_prefix);
149149

150150
//! one of "pady's" output functions, since Keith never met "pady" this is probably long out of date
151151
extern void vizplotter(ElementsHashTable* HT_Elem_Ptr, NodeHashTable* HT_Node_Ptr, MatProps* matprops, TimeProps* timeprops);
@@ -181,11 +181,11 @@ void web_simplify(TimeProps* timeprops);
181181
void web_correct(TimeProps* timeprops);
182182

183183
//! this function writes the header for grass sites style output, the grass sites output format is correct and works, but importing the data into GIS packages such as ARCGIS is non trivial until you know the trick to it. Keith does not know the trick, I just wrote this in the format Alex Sorokine specified.
184-
void grass_sites_header_output(TimeProps* timeprops);
184+
void grass_sites_header_output(TimeProps* timeprops, const char * output_prefix);
185185

186186
//! this function writes one processors grass sites style output, the grass sites output format is correct and works, but importing the data into GIS packages such as ARCGIS is non trivial until you know the trick to it. Keith does not know the trick, I (Keith) just wrote this in the format Alex Sorokine specified.
187187
void grass_sites_proc_output(ElementsHashTable* HT_Elem_Ptr, NodeHashTable* HT_Node_Ptr, int myid, MatProps* matprops,
188-
TimeProps* timeprops);
188+
TimeProps* timeprops, const char * output_prefix);
189189

190190
//! this function is legacy, it is not defined in the finite difference/volume version of titan
191191
extern void check_p_order(ElementsHashTable* HT_Elem_Ptr, NodeHashTable* HT_Node_Ptr);

src/main/titan.C

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ extern "C" void init_cxxtitan();
4646

4747
int main(int argc, char *argv[])
4848
{
49-
printf("Titan2d\n");
5049
int myid, master, numprocs;
5150
int namelen;
5251

src/main/titan.py

Lines changed: 41 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -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+"\ncheck 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

864832
class 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()

src/main/titan_simulation.C

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -740,10 +740,10 @@ void cxxTitanSimulation::save_vizoutput_file(const int mode)
740740
output_summary(&timeprops, statprops, savefileflag);
741741

742742
if(vizoutput & 1)
743-
tecplotter(elementType, ElemTable, NodeTable, matprops, &timeprops, &mapnames, statprops->vstar);
743+
tecplotter(elementType, ElemTable, NodeTable, matprops, &timeprops, &mapnames, statprops->vstar,vizoutput_prefix.c_str());
744744

745745
if(vizoutput & 2)
746-
meshplotter(ElemTable, NodeTable, matprops, &timeprops, &mapnames, statprops->vstar);
746+
meshplotter(ElemTable, NodeTable, matprops, &timeprops, &mapnames, statprops->vstar,vizoutput_prefix.c_str());
747747

748748
#if HAVE_LIBHDF5
749749
if(vizoutput & 4)
@@ -764,8 +764,8 @@ void cxxTitanSimulation::save_vizoutput_file(const int mode)
764764
if(vizoutput & 8)
765765
{
766766
if(myid == 0)
767-
grass_sites_header_output(&timeprops);
768-
grass_sites_proc_output(ElemTable, NodeTable, myid, matprops, &timeprops);
767+
grass_sites_header_output(&timeprops,vizoutput_prefix.c_str());
768+
grass_sites_proc_output(ElemTable, NodeTable, myid, matprops, &timeprops,vizoutput_prefix.c_str());
769769
}
770770
}
771771

src/tecplot/grassout.C

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include "../header/hpfem.h"
22

3-
void grass_sites_header_output(TimeProps* timeprops)
3+
void grass_sites_header_output(TimeProps* timeprops, const char * output_prefix)
44
{
55
char filename[24];
66

7-
sprintf(filename, "grass_sites%08d.hdr", timeprops->iter);
7+
sprintf(filename, "%s/grass_sites%08d.hdr", output_prefix, timeprops->iter);
88
FILE *fp = fopen(filename, "w");
99

1010
fprintf(fp, "name|titangrassout.site\n");
@@ -18,7 +18,7 @@ void grass_sites_header_output(TimeProps* timeprops)
1818
}
1919

2020
void grass_sites_proc_output(ElementsHashTable* HT_Elem_Ptr, NodeHashTable* HT_Node_Ptr, int myid, MatProps* matprops,
21-
TimeProps* timeprops)
21+
TimeProps* timeprops, const char * output_prefix)
2222
{
2323
int no_of_buckets = HT_Elem_Ptr->get_no_of_buckets();
2424
vector<HashEntryLine> &bucket=HT_Elem_Ptr->bucket;
@@ -29,7 +29,7 @@ void grass_sites_proc_output(ElementsHashTable* HT_Elem_Ptr, NodeHashTable* HT_N
2929

3030
char filename[24];
3131

32-
sprintf(filename, "grass_sites%08d.%03d", timeprops->iter, myid);
32+
sprintf(filename, "%s/grass_sites%08d.%03d", output_prefix, timeprops->iter, myid);
3333
FILE *fp = fopen(filename, "w");
3434

3535
/***************************************************************/

src/tecplot/tecplot.C

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void testkey2(ElementsHashTable * El_Table)
7171
}
7272

7373
void tecplotter(ElementType elementType,ElementsHashTable * El_Table, NodeHashTable * NodeTable, MatProps * matprops, TimeProps * timeprops,
74-
MapNames * mapnames, double v_star)
74+
MapNames * mapnames, double v_star, const char * output_prefix)
7575
{
7676
int i_buck, i_neigh; //indices
7777
int xp, xm, yp, ym; //x plus, x minus, y plus, y minus directions
@@ -173,8 +173,8 @@ void tecplotter(ElementType elementType,ElementsHashTable * El_Table, NodeHashTa
173173
int num_tec_elem = num_tec_quad + num_tec_tri;
174174
int num_tec_elem2 = 0;
175175

176-
char filename[20];
177-
sprintf(filename, "tecpl%02d%08d.tec", myid, timeprops->iter);
176+
char filename[256];
177+
sprintf(filename, "%s/tecpl%02d%08d.tec",output_prefix, myid, timeprops->iter);
178178
FILE *fp = fopen(filename, "w");
179179

180180
//print the tecplot header
@@ -751,7 +751,7 @@ void viz_output(ElementType elementType,ElementsHashTable * El_Table, NodeHashTa
751751
**************************************
752752
*************************************/
753753
void meshplotter(ElementsHashTable * El_Table, NodeHashTable * NodeTable, MatProps * matprops, TimeProps * timeprops,
754-
MapNames * mapnames, double v_star)
754+
MapNames * mapnames, double v_star, const char * output_prefix)
755755
{
756756
int myid, i;
757757
int numprocs;
@@ -776,7 +776,7 @@ void meshplotter(ElementsHashTable * El_Table, NodeHashTable * NodeTable, MatPro
776776
}
777777
IF_MPI(MPI_Barrier (MPI_COMM_WORLD));
778778

779-
sprintf(filename, "mshpl%02d%08d.tec", myid, timeprops->iter);
779+
sprintf(filename, "%s/mshpl%02d%08d.tec",output_prefix, myid, timeprops->iter);
780780

781781
int order;
782782

src/tecplot/xdfm_write.C

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ int write_xdmf_two_phases(ElementsHashTable *El_Table, NodeHashTable *NodeTable,
104104
/*
105105
* Write HDF5 File
106106
*/
107-
char hdf5file[64];
107+
char hdf5file[256];
108108
sprintf(hdf5file, "%s/xdmf_p%04d_i%08d.h5", output_prefix, myid, timeprops_ptr->iter);
109109
hid_t h5fid = GH5_fopen(hdf5file, 'n');
110110

@@ -154,7 +154,7 @@ int write_xdmf_two_phases(ElementsHashTable *El_Table, NodeHashTable *NodeTable,
154154

155155
/* generate XML file if required */
156156
ofstream xmlf;
157-
char filename[20];
157+
char filename[256];
158158
sprintf(filename, "%s_xdmf_p%04d.xmf", output_prefix,myid);
159159
if(mode == XDMF_NEW)
160160
xdmf_fopen(filename);
@@ -225,7 +225,7 @@ int write_xdmf_single_phase(ElementsHashTable *El_Table, NodeHashTable *NodeTabl
225225
int myid;
226226
MPI_Comm_rank(MPI_COMM_WORLD, &myid);
227227
ofstream xmlf;
228-
char filename[64];
228+
char filename[256];
229229
sprintf(filename, "%s_xdmf_p%04d.xmf", output_prefix,myid);
230230
if(mode == XDMF_NEW)
231231
xdmf_fopen(filename);
@@ -335,7 +335,7 @@ int write_xdmf_single_phase(ElementsHashTable *El_Table, NodeHashTable *NodeTabl
335335
/*
336336
* Write HDF5 File
337337
*/
338-
char hdf5file[64];
338+
char hdf5file[256];
339339
sprintf(hdf5file, "%s/xdmf_p%04d_i%08d.h5", output_prefix, myid, timeprops_ptr->iter);
340340
hid_t h5fid = GH5_fopen(hdf5file, 'n');
341341

0 commit comments

Comments
 (0)