Skip to content

Commit d27b139

Browse files
committed
replaced use_DEM_resolution argument for setOutlineProps with init_size which can be AMR or DEM; runid member of StatProp now can be set by python's setStatProps
1 parent a2e1284 commit d27b139

File tree

7 files changed

+37
-18
lines changed

7 files changed

+37
-18
lines changed

src/header/hd5calls.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ hid_t GH5_createdataset(hid_t gid, hid_t spcid, const char *dsetname, unsigned t
109109
#include <assert.h>
110110
extern H5::EnumType datatypeElementType;
111111
extern H5::EnumType datatypePileType;
112-
112+
extern H5::EnumType datatypeOutLineInitSize;
113113

114114
/**
115115
* initialize all hdf5 enum datatypes

src/header/properties.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,8 @@ class MatPropsTwoPhases: public MatProps
808808
class OutLine
809809
{
810810
public:
811+
enum OutLineInitSize {AMR=1, DEM=2};
812+
811813
//geometric id of temporary arrays
812814
int conformation;
813815
// the least squares interpolated height didn't work for some reason
@@ -855,7 +857,7 @@ class OutLine
855857
//! do the calculations
856858
bool enabled;
857859

858-
bool use_DEM_resolution;
860+
OutLineInitSize init_size;
859861
int max_linear_size;
860862

861863
TiScale *scale;

src/main/datread.C

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#endif
2121

2222
#include "../header/hpfem.h"
23-
23+
#include "../header/properties.h"
2424
#ifdef SUNOS
2525
extern "C" void initial_(int*, double*, double*);
2626
#endif
@@ -313,7 +313,7 @@ void Read_grid(int myid, int numprocs, NodeHashTable** NodeTable, ElementsHashTa
313313
}
314314

315315
#ifdef MAX_DEPTH_MAP
316-
if(outline_ptr->use_DEM_resolution)
316+
if(outline_ptr->init_size==OutLine::DEM)
317317
{
318318
double ewresol;
319319
double nsresol;
@@ -329,7 +329,7 @@ void Read_grid(int myid, int numprocs, NodeHashTable** NodeTable, ElementsHashTa
329329

330330
outline_ptr->init_DEM_resolution(resx, resy, xminmax, yminmax);
331331
}
332-
else
332+
else if(outline_ptr->init_size==OutLine::AMR)
333333
{
334334
outline_ptr->init(dx, REFINE_LEVEL - Quad9P->generation(), xminmax, yminmax);
335335
}

src/main/properties.C

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ OutLine::OutLine()
660660
elementType=ElementType::SinglePhase;
661661

662662
enabled=true;
663-
use_DEM_resolution=false;
663+
init_size=AMR;
664664
max_linear_size=1024;
665665

666666
output_prefix="";
@@ -751,7 +751,7 @@ void OutLine::init(const double *dxy, int power, double *XRange, double *YRange)
751751
if(myid==0 && enabled)
752752
{
753753
printf("Outline init: Nx=%d Ny=%d dx=%.5g dy=%.5g\n", Nx, Ny, dx*scale->length, dy*scale->length);
754-
printf("Outline init: temporary arrays for %d threads\n", Nx, Ny, Nx * Ny,threads_number);
754+
printf("Outline init: temporary arrays for %d threads\n", threads_number);
755755
}
756756
size=Ny*stride;
757757

@@ -792,7 +792,7 @@ void OutLine::init_DEM_resolution(double resx, double resy, double *XRange, doub
792792
if(myid==0 && enabled)
793793
{
794794
printf("Outline init: Nx=%d Ny=%d dx=%.5g dy=%.5g\n", Nx, Ny, dx*scale->length, dy*scale->length);
795-
printf("Outline init: temporary arrays for %d threads\n", Nx, Ny, Nx * Ny,threads_number);
795+
printf("Outline init: temporary arrays for %d threads\n", threads_number);
796796
}
797797

798798
size=Ny*stride;
@@ -1384,9 +1384,9 @@ void OutLine::h5write(H5::CommonFG *parent, string group_name)
13841384
TiH5_writeDoubleAttribute(group, yminmax[2]);
13851385

13861386
TiH5_writeBoolAttribute(group, enabled);
1387-
TiH5_writeBoolAttribute(group, use_DEM_resolution);
1387+
TiH5_writeScalarDataTypeAttribute(group,init_size,datatypeOutLineInitSize);
13881388
TiH5_writeIntAttribute(group, max_linear_size);
1389-
1389+
TiH5_writeStringAttribute(group, output_prefix);
13901390
if(enabled)
13911391
{
13921392
TiH5_writeArray2DDataSet(group, pileheight,Ny,stride);
@@ -1415,9 +1415,9 @@ void OutLine::h5read(const H5::CommonFG *parent, const string group_name)
14151415
TiH5_readDoubleAttribute(group, yminmax[2]);
14161416

14171417
TiH5_readBoolAttribute(group, enabled);
1418-
TiH5_readBoolAttribute(group, use_DEM_resolution);
1418+
TiH5_readScalarDataTypeAttribute(group,init_size,datatypeOutLineInitSize);
14191419
TiH5_readIntAttribute(group, max_linear_size);
1420-
1420+
TiH5_readStringAttribute(group, output_prefix);
14211421
if(enabled)
14221422
{
14231423
alloc_arrays();

src/main/titan.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@ class TitanSimulationBase(object):
314314
'None':0,
315315
'DragBased':1
316316
}
317+
possible_outline_init_size={
318+
'AMR':OutLine.AMR,
319+
'DEM':OutLine.DEM,
320+
}
317321
default_GIS={
318322
'gis_format':possible_gis_formats['GIS_GRASS'],
319323
'gis_main':None,
@@ -570,8 +574,11 @@ def __init__(self,overwrite_output=False):
570574
'test_location':{'desc':'',
571575
'validator':VarTypeTuple(float,N=2,CanBeNone=True).chk
572576
},
577+
'runid':{'desc':'',
578+
'validator':VarType(int).chk
579+
},
573580
},
574-
defaultParameters={'edge_height':None, 'test_height':None, 'test_location':None}
581+
defaultParameters={'edge_height':None, 'test_height':None, 'test_location':None, 'runid':-1}
575582
)
576583
self.setStatProps()
577584
#setOutlineProps
@@ -585,14 +592,14 @@ def __init__(self,overwrite_output=False):
585592
'max_linear_size':{'desc':'',
586593
'validator':VarType(int,conditions=[{'f':lambda v: v > 0,'msg':'should be positive!'}]).chk
587594
},
588-
'use_DEM_resolution':{'desc':'',
589-
'validator':VarType(bool).chk
595+
'init_size':{'desc':'',
596+
'validator':VarTypeDictConvert(TitanSimulationBase.possible_outline_init_size).chk
590597
},
591598
'output_prefix':{'desc':'',
592599
'validator':VarTypeString
593600
},
594601
},
595-
defaultParameters={'enabled':True,'max_linear_size':1024, 'use_DEM_resolution':False, 'output_prefix':''}
602+
defaultParameters={'enabled':True,'max_linear_size':1024, 'init_size':'AMR', 'output_prefix':''}
596603
)
597604
self.setOutlineProps(enabled=True)
598605
#addPile
@@ -1038,12 +1045,13 @@ def check_and_remove_filedir_by_wildcard(filename):
10381045
self.sim.get_statprops().set(
10391046
ui_StatProps['edge_height'], ui_StatProps['test_height'],
10401047
ui_StatProps['test_location'][0], ui_StatProps['test_location'][1])
1048+
self.sim.get_statprops().runid=ui_StatProps['runid']
10411049

10421050
#######################################################################
10431051
# ui_OutlineProps
10441052
self.sim.get_outline().enabled=ui_OutlineProps['enabled']
1045-
self.sim.get_outline().use_DEM_resolution=ui_OutlineProps['use_DEM_resolution']
10461053
self.sim.get_outline().max_linear_size=ui_OutlineProps['max_linear_size']
1054+
self.sim.get_outline().init_size=ui_OutlineProps['init_size']
10471055
self.sim.get_outline().output_prefix=ui_OutlineProps['output_prefix']
10481056

10491057
#######################################################################

src/main/titan2d_utils.C

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
H5::EnumType datatypeElementType;
2929
H5::EnumType datatypePileType;
30+
H5::EnumType datatypeOutLineInitSize;
3031

3132
vector<string> coord_names;
3233
vector<string> SinglePhaseVarNames;
@@ -62,6 +63,13 @@ void init_TiH5()
6263
pile_type=PileProps::ID2;
6364
datatypePileType.insert("ID2",&pile_type);
6465

66+
datatypeOutLineInitSize=H5::EnumType(sizeof(OutLine::OutLineInitSize));
67+
OutLine::OutLineInitSize init_size;
68+
init_size=OutLine::AMR;
69+
datatypeOutLineInitSize.insert("AMR",&init_size);
70+
init_size=OutLine::DEM;
71+
datatypeOutLineInitSize.insert("DEM",&init_size);
72+
6573
//init indexes to char* conversions
6674
coord_names.push_back("X");
6775
coord_names.push_back("Y");

src/main/titan_simulation.C

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ void cxxTitanSimulation::process_input(bool start_from_restart)
244244
}
245245
}
246246
#endif
247-
statprops_ptr->runid = statprops_ptr->lhs.runid;
247+
if(statprops_ptr->lhs.runid>=0)
248+
statprops_ptr->runid = statprops_ptr->lhs.runid;
248249

249250
/*************************************************************************/
250251
double TIME_SCALE;

0 commit comments

Comments
 (0)