Skip to content

Commit

Permalink
replaced use_DEM_resolution argument for setOutlineProps with init_si…
Browse files Browse the repository at this point in the history
…ze which can be AMR or DEM; runid member of StatProp now can be set by python's setStatProps
  • Loading branch information
nsimakov committed Feb 25, 2016
1 parent a2e1284 commit d27b139
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/header/hd5calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ hid_t GH5_createdataset(hid_t gid, hid_t spcid, const char *dsetname, unsigned t
#include <assert.h>
extern H5::EnumType datatypeElementType;
extern H5::EnumType datatypePileType;

extern H5::EnumType datatypeOutLineInitSize;

/**
* initialize all hdf5 enum datatypes
Expand Down
4 changes: 3 additions & 1 deletion src/header/properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,8 @@ class MatPropsTwoPhases: public MatProps
class OutLine
{
public:
enum OutLineInitSize {AMR=1, DEM=2};

//geometric id of temporary arrays
int conformation;
// the least squares interpolated height didn't work for some reason
Expand Down Expand Up @@ -855,7 +857,7 @@ class OutLine
//! do the calculations
bool enabled;

bool use_DEM_resolution;
OutLineInitSize init_size;
int max_linear_size;

TiScale *scale;
Expand Down
6 changes: 3 additions & 3 deletions src/main/datread.C
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#endif

#include "../header/hpfem.h"

#include "../header/properties.h"
#ifdef SUNOS
extern "C" void initial_(int*, double*, double*);
#endif
Expand Down Expand Up @@ -313,7 +313,7 @@ void Read_grid(int myid, int numprocs, NodeHashTable** NodeTable, ElementsHashTa
}

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

outline_ptr->init_DEM_resolution(resx, resy, xminmax, yminmax);
}
else
else if(outline_ptr->init_size==OutLine::AMR)
{
outline_ptr->init(dx, REFINE_LEVEL - Quad9P->generation(), xminmax, yminmax);
}
Expand Down
14 changes: 7 additions & 7 deletions src/main/properties.C
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ OutLine::OutLine()
elementType=ElementType::SinglePhase;

enabled=true;
use_DEM_resolution=false;
init_size=AMR;
max_linear_size=1024;

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

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

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

TiH5_writeBoolAttribute(group, enabled);
TiH5_writeBoolAttribute(group, use_DEM_resolution);
TiH5_writeScalarDataTypeAttribute(group,init_size,datatypeOutLineInitSize);
TiH5_writeIntAttribute(group, max_linear_size);

TiH5_writeStringAttribute(group, output_prefix);
if(enabled)
{
TiH5_writeArray2DDataSet(group, pileheight,Ny,stride);
Expand Down Expand Up @@ -1415,9 +1415,9 @@ void OutLine::h5read(const H5::CommonFG *parent, const string group_name)
TiH5_readDoubleAttribute(group, yminmax[2]);

TiH5_readBoolAttribute(group, enabled);
TiH5_readBoolAttribute(group, use_DEM_resolution);
TiH5_readScalarDataTypeAttribute(group,init_size,datatypeOutLineInitSize);
TiH5_readIntAttribute(group, max_linear_size);

TiH5_readStringAttribute(group, output_prefix);
if(enabled)
{
alloc_arrays();
Expand Down
18 changes: 13 additions & 5 deletions src/main/titan.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ class TitanSimulationBase(object):
'None':0,
'DragBased':1
}
possible_outline_init_size={
'AMR':OutLine.AMR,
'DEM':OutLine.DEM,
}
default_GIS={
'gis_format':possible_gis_formats['GIS_GRASS'],
'gis_main':None,
Expand Down Expand Up @@ -570,8 +574,11 @@ def __init__(self,overwrite_output=False):
'test_location':{'desc':'',
'validator':VarTypeTuple(float,N=2,CanBeNone=True).chk
},
'runid':{'desc':'',
'validator':VarType(int).chk
},
},
defaultParameters={'edge_height':None, 'test_height':None, 'test_location':None}
defaultParameters={'edge_height':None, 'test_height':None, 'test_location':None, 'runid':-1}
)
self.setStatProps()
#setOutlineProps
Expand All @@ -585,14 +592,14 @@ def __init__(self,overwrite_output=False):
'max_linear_size':{'desc':'',
'validator':VarType(int,conditions=[{'f':lambda v: v > 0,'msg':'should be positive!'}]).chk
},
'use_DEM_resolution':{'desc':'',
'validator':VarType(bool).chk
'init_size':{'desc':'',
'validator':VarTypeDictConvert(TitanSimulationBase.possible_outline_init_size).chk
},
'output_prefix':{'desc':'',
'validator':VarTypeString
},
},
defaultParameters={'enabled':True,'max_linear_size':1024, 'use_DEM_resolution':False, 'output_prefix':''}
defaultParameters={'enabled':True,'max_linear_size':1024, 'init_size':'AMR', 'output_prefix':''}
)
self.setOutlineProps(enabled=True)
#addPile
Expand Down Expand Up @@ -1038,12 +1045,13 @@ def check_and_remove_filedir_by_wildcard(filename):
self.sim.get_statprops().set(
ui_StatProps['edge_height'], ui_StatProps['test_height'],
ui_StatProps['test_location'][0], ui_StatProps['test_location'][1])
self.sim.get_statprops().runid=ui_StatProps['runid']

#######################################################################
# ui_OutlineProps
self.sim.get_outline().enabled=ui_OutlineProps['enabled']
self.sim.get_outline().use_DEM_resolution=ui_OutlineProps['use_DEM_resolution']
self.sim.get_outline().max_linear_size=ui_OutlineProps['max_linear_size']
self.sim.get_outline().init_size=ui_OutlineProps['init_size']
self.sim.get_outline().output_prefix=ui_OutlineProps['output_prefix']

#######################################################################
Expand Down
8 changes: 8 additions & 0 deletions src/main/titan2d_utils.C
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

H5::EnumType datatypeElementType;
H5::EnumType datatypePileType;
H5::EnumType datatypeOutLineInitSize;

vector<string> coord_names;
vector<string> SinglePhaseVarNames;
Expand Down Expand Up @@ -62,6 +63,13 @@ void init_TiH5()
pile_type=PileProps::ID2;
datatypePileType.insert("ID2",&pile_type);

datatypeOutLineInitSize=H5::EnumType(sizeof(OutLine::OutLineInitSize));
OutLine::OutLineInitSize init_size;
init_size=OutLine::AMR;
datatypeOutLineInitSize.insert("AMR",&init_size);
init_size=OutLine::DEM;
datatypeOutLineInitSize.insert("DEM",&init_size);

//init indexes to char* conversions
coord_names.push_back("X");
coord_names.push_back("Y");
Expand Down
3 changes: 2 additions & 1 deletion src/main/titan_simulation.C
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ void cxxTitanSimulation::process_input(bool start_from_restart)
}
}
#endif
statprops_ptr->runid = statprops_ptr->lhs.runid;
if(statprops_ptr->lhs.runid>=0)
statprops_ptr->runid = statprops_ptr->lhs.runid;

/*************************************************************************/
double TIME_SCALE;
Expand Down

0 comments on commit d27b139

Please sign in to comment.