Skip to content

Commit a2e1284

Browse files
committed
added output_prefix for outline
1 parent 2a00a9c commit a2e1284

File tree

3 files changed

+115
-77
lines changed

3 files changed

+115
-77
lines changed

src/header/properties.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,8 @@ class OutLine
860860

861861
TiScale *scale;
862862

863+
std::string output_prefix;
864+
863865
//! this is the OutLine constructor it initializes the number of cells to zero
864866
OutLine();
865867

src/main/properties.C

Lines changed: 108 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
#include "../header/properties.h"
2020
#include "../header/hpfem.h"
2121

22+
23+
#include <sstream>
24+
2225
MapNames::MapNames()
2326
{
2427
gis_main = "";
@@ -660,6 +663,8 @@ OutLine::OutLine()
660663
use_DEM_resolution=false;
661664
max_linear_size=1024;
662665

666+
output_prefix="";
667+
663668
MPI_Comm_rank(MPI_COMM_WORLD, &myid);
664669
MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
665670

@@ -1180,103 +1185,130 @@ void OutLine::update_two_phases()
11801185
*/
11811186
void OutLine::output(MatProps* matprops_ptr, StatProps* statprops_ptr)
11821187
{
1183-
int ix, iy;
1184-
char filename[256];
1188+
double ENERGY_SCALE = matprops_ptr->scale.length * matprops_ptr->scale.gravity * matprops_ptr->scale.height;
11851189

11861190
// output max over time pile-height
1187-
sprintf(filename, "pileheightrecord.%06d", statprops_ptr->runid);
1188-
FILE *fp = fopen(filename, "w");
1189-
1190-
fprintf(fp, "Nx=%d: X={%20.14g,%20.14g}\n"
1191-
"Ny=%d: Y={%20.14g,%20.14g}\n"
1192-
"Pileheight=\n",
1193-
Nx, xminmax[0] * matprops_ptr->scale.length, xminmax[1] * matprops_ptr->scale.length, Ny,
1194-
yminmax[0] * matprops_ptr->scale.length, yminmax[1] * matprops_ptr->scale.length);
1195-
for(iy = 0; iy < Ny; iy++)
11961191
{
1197-
for(ix = 0; ix < Nx - 1; ix++)
1198-
fprintf(fp, "%g ", pileheight[iy*stride+ix] * matprops_ptr->scale.height);
1199-
fprintf(fp, "%g\n", pileheight[iy*stride+ix] * matprops_ptr->scale.height);
1192+
int ix, iy;
1193+
ostringstream filename;
1194+
1195+
filename<<output_prefix<<"pileheightrecord."<<setw(6)<< setfill('0') <<internal<<statprops_ptr->runid<<std::ends;
1196+
FILE *fp = fopen(filename.str().c_str(), "wt");
1197+
1198+
fprintf(fp, "Nx=%d: X={%20.14g,%20.14g}\n"
1199+
"Ny=%d: Y={%20.14g,%20.14g}\n"
1200+
"Pileheight=\n",
1201+
Nx, xminmax[0] * matprops_ptr->scale.length, xminmax[1] * matprops_ptr->scale.length, Ny,
1202+
yminmax[0] * matprops_ptr->scale.length, yminmax[1] * matprops_ptr->scale.length);
1203+
for(iy = 0; iy < Ny; iy++)
1204+
{
1205+
for(ix = 0; ix < Nx - 1; ix++)
1206+
fprintf(fp, "%g ", pileheight[iy*stride+ix] * matprops_ptr->scale.height);
1207+
fprintf(fp, "%g\n", pileheight[iy*stride+ix] * matprops_ptr->scale.height);
1208+
}
1209+
fclose(fp);
12001210
}
1201-
fclose(fp);
12021211

12031212
//output max over time kinetic energy
1204-
double ENERGY_SCALE = matprops_ptr->scale.length * matprops_ptr->scale.gravity * matprops_ptr->scale.height;
1205-
1206-
sprintf(filename, "maxkerecord.%06d", statprops_ptr->runid);
1207-
fp = fopen(filename, "w");
1208-
1209-
fprintf(fp, "Nx=%d: X={%20.14g,%20.14g}\n"
1210-
"Ny=%d: Y={%20.14g,%20.14g}\n"
1211-
"KineticEnergy=\n",
1212-
Nx, xminmax[0] * matprops_ptr->scale.length, xminmax[1] * matprops_ptr->scale.length, Ny,
1213-
yminmax[0] * matprops_ptr->scale.length, yminmax[1] * matprops_ptr->scale.length);
1214-
for(iy = 0; iy < Ny; iy++)
1213+
if(elementType==ElementType::SinglePhase)
12151214
{
1216-
for(ix = 0; ix < Nx - 1; ix++)
1217-
fprintf(fp, "%g ", max_kinergy[iy*stride+ix] * ENERGY_SCALE);
1218-
fprintf(fp, "%g\n", max_kinergy[iy*stride+ix] * ENERGY_SCALE);
1215+
int ix, iy;
1216+
ostringstream filename;
1217+
1218+
filename<<output_prefix<<"maxkerecord."<<setw(6)<< setfill('0') <<internal<<statprops_ptr->runid<<std::ends;
1219+
FILE *fp = fopen(filename.str().c_str(), "wt");
1220+
1221+
fprintf(fp, "Nx=%d: X={%20.14g,%20.14g}\n"
1222+
"Ny=%d: Y={%20.14g,%20.14g}\n"
1223+
"KineticEnergy=\n",
1224+
Nx, xminmax[0] * matprops_ptr->scale.length, xminmax[1] * matprops_ptr->scale.length, Ny,
1225+
yminmax[0] * matprops_ptr->scale.length, yminmax[1] * matprops_ptr->scale.length);
1226+
for(iy = 0; iy < Ny; iy++)
1227+
{
1228+
for(ix = 0; ix < Nx - 1; ix++)
1229+
fprintf(fp, "%g ", max_kinergy[iy*stride+ix] * ENERGY_SCALE);
1230+
fprintf(fp, "%g\n", max_kinergy[iy*stride+ix] * ENERGY_SCALE);
1231+
}
1232+
fclose(fp);
12191233
}
1220-
fclose(fp);
1221-
1222-
sprintf(filename, "max_dynamic_pressure_record.%06d", statprops_ptr->runid);
1223-
fp = fopen(filename, "w");
1224-
1225-
//!todo dynamic_pressure scale?
1226-
fprintf(fp, "Nx=%d: X={%20.14g,%20.14g}\n"
1227-
"Ny=%d: Y={%20.14g,%20.14g}\n"
1228-
"dynamic_pressure=\n",
1229-
Nx, xminmax[0] * matprops_ptr->scale.length, xminmax[1] * matprops_ptr->scale.length, Ny,
1230-
yminmax[0] * matprops_ptr->scale.length, yminmax[1] * matprops_ptr->scale.length);
1231-
for(iy = 0; iy < Ny; iy++)
1234+
1235+
//dynamic_pressure
1236+
if(elementType==ElementType::SinglePhase)
12321237
{
1233-
for(ix = 0; ix < Nx - 1; ix++)
1234-
fprintf(fp, "%g ", max_dynamic_pressure[iy*stride+ix] * ENERGY_SCALE/matprops_ptr->scale.length);
1235-
fprintf(fp, "%g\n", max_dynamic_pressure[iy*stride+ix] * ENERGY_SCALE/matprops_ptr->scale.length);
1238+
int ix, iy;
1239+
ostringstream filename;
1240+
1241+
filename<<output_prefix<<"max_dynamic_pressure_record."<<setw(6)<< setfill('0') <<internal<<statprops_ptr->runid<<std::ends;
1242+
FILE *fp = fopen(filename.str().c_str(), "wt");
1243+
1244+
//!todo dynamic_pressure scale?
1245+
fprintf(fp, "Nx=%d: X={%20.14g,%20.14g}\n"
1246+
"Ny=%d: Y={%20.14g,%20.14g}\n"
1247+
"dynamic_pressure=\n",
1248+
Nx, xminmax[0] * matprops_ptr->scale.length, xminmax[1] * matprops_ptr->scale.length, Ny,
1249+
yminmax[0] * matprops_ptr->scale.length, yminmax[1] * matprops_ptr->scale.length);
1250+
for(iy = 0; iy < Ny; iy++)
1251+
{
1252+
for(ix = 0; ix < Nx - 1; ix++)
1253+
fprintf(fp, "%g ", max_dynamic_pressure[iy*stride+ix] * ENERGY_SCALE/matprops_ptr->scale.length);
1254+
fprintf(fp, "%g\n", max_dynamic_pressure[iy*stride+ix] * ENERGY_SCALE/matprops_ptr->scale.length);
1255+
}
1256+
fclose(fp);
12361257
}
1237-
fclose(fp);
12381258

12391259
// output cummulative kinetic-energy
1240-
sprintf(filename, "cumkerecord.%06d", statprops_ptr->runid);
1241-
fp = fopen(filename, "w");
1242-
1243-
fprintf(fp, "Nx=%d: X={%20.14g,%20.14g}\n"
1244-
"Ny=%d: Y={%20.14g,%20.14g}\n"
1245-
"KineticEnergy=\n",
1246-
Nx, xminmax[0] * matprops_ptr->scale.length, xminmax[1] * matprops_ptr->scale.length, Ny,
1247-
yminmax[0] * matprops_ptr->scale.length, yminmax[1] * matprops_ptr->scale.length);
1248-
for(iy = 0; iy < Ny; iy++)
1260+
if(elementType==ElementType::SinglePhase)
12491261
{
1250-
for(ix = 0; ix < Nx - 1; ix++)
1251-
fprintf(fp, "%g ", cum_kinergy[iy*stride+ix] * ENERGY_SCALE);
1252-
fprintf(fp, "%g\n", cum_kinergy[iy*stride+ix] * ENERGY_SCALE);
1262+
int ix, iy;
1263+
ostringstream filename;
1264+
1265+
filename<<output_prefix<<"cumkerecord."<<setw(6)<< setfill('0') <<internal<<statprops_ptr->runid<<std::ends;
1266+
FILE *fp = fopen(filename.str().c_str(), "wt");
1267+
1268+
fprintf(fp, "Nx=%d: X={%20.14g,%20.14g}\n"
1269+
"Ny=%d: Y={%20.14g,%20.14g}\n"
1270+
"KineticEnergy=\n",
1271+
Nx, xminmax[0] * matprops_ptr->scale.length, xminmax[1] * matprops_ptr->scale.length, Ny,
1272+
yminmax[0] * matprops_ptr->scale.length, yminmax[1] * matprops_ptr->scale.length);
1273+
for(iy = 0; iy < Ny; iy++)
1274+
{
1275+
for(ix = 0; ix < Nx - 1; ix++)
1276+
fprintf(fp, "%g ", cum_kinergy[iy*stride+ix] * ENERGY_SCALE);
1277+
fprintf(fp, "%g\n", cum_kinergy[iy*stride+ix] * ENERGY_SCALE);
1278+
}
1279+
fclose(fp);
12531280
}
1254-
fclose(fp);
1255-
12561281
// output elevation data
1257-
fp = fopen("elevation.grid", "w");
1258-
fprintf(fp, "Nx=%d: X={%20.14g,%20.14g}\n"
1259-
"Ny=%d: Y={%20.14g,%20.14g}\n"
1260-
"Pileheight=\n",
1261-
Nx, xminmax[0] * matprops_ptr->scale.length, xminmax[1] * matprops_ptr->scale.length, Ny,
1262-
yminmax[0] * matprops_ptr->scale.length, yminmax[1] * matprops_ptr->scale.length);
1263-
1264-
double yy, xx, res = dx + dy, elevation;
1265-
int ierr;
1266-
for(iy = 0; iy < Ny; iy++)
12671282
{
1268-
yy = ((iy + 0.5) * dy + yminmax[0]) * matprops_ptr->scale.length;
1269-
for(ix = 0; ix < Nx - 1; ix++)
1283+
int ix, iy;
1284+
ostringstream filename;
1285+
1286+
filename<<output_prefix<<"elevation.grid"<<std::ends;
1287+
FILE *fp = fopen(filename.str().c_str(), "wt");
1288+
1289+
fprintf(fp, "Nx=%d: X={%20.14g,%20.14g}\n"
1290+
"Ny=%d: Y={%20.14g,%20.14g}\n"
1291+
"Pileheight=\n",
1292+
Nx, xminmax[0] * matprops_ptr->scale.length, xminmax[1] * matprops_ptr->scale.length, Ny,
1293+
yminmax[0] * matprops_ptr->scale.length, yminmax[1] * matprops_ptr->scale.length);
1294+
1295+
double yy, xx, res = dx + dy, elevation;
1296+
int ierr;
1297+
for(iy = 0; iy < Ny; iy++)
12701298
{
1299+
yy = ((iy + 0.5) * dy + yminmax[0]) * matprops_ptr->scale.length;
1300+
for(ix = 0; ix < Nx - 1; ix++)
1301+
{
1302+
xx = ((ix + 0.5) * dx + xminmax[0]) * matprops_ptr->scale.length;
1303+
ierr = Get_elevation(res, xx, yy, elevation);
1304+
fprintf(fp, "%g ", elevation);
1305+
}
12711306
xx = ((ix + 0.5) * dx + xminmax[0]) * matprops_ptr->scale.length;
12721307
ierr = Get_elevation(res, xx, yy, elevation);
1273-
fprintf(fp, "%g ", elevation);
1308+
fprintf(fp,"%g\n",elevation);
12741309
}
1275-
xx = ((ix + 0.5) * dx + xminmax[0]) * matprops_ptr->scale.length;
1276-
ierr = Get_elevation(res, xx, yy, elevation);
1277-
fprintf(fp,"%g\n",elevation);
1310+
fclose(fp);
12781311
}
1279-
fclose(fp);
12801312
return;
12811313
}
12821314

src/main/titan.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,8 +588,11 @@ def __init__(self,overwrite_output=False):
588588
'use_DEM_resolution':{'desc':'',
589589
'validator':VarType(bool).chk
590590
},
591+
'output_prefix':{'desc':'',
592+
'validator':VarTypeString
593+
},
591594
},
592-
defaultParameters={'enabled':True,'max_linear_size':1024, 'use_DEM_resolution':False}
595+
defaultParameters={'enabled':True,'max_linear_size':1024, 'use_DEM_resolution':False, 'output_prefix':''}
593596
)
594597
self.setOutlineProps(enabled=True)
595598
#addPile
@@ -1041,6 +1044,7 @@ def check_and_remove_filedir_by_wildcard(filename):
10411044
self.sim.get_outline().enabled=ui_OutlineProps['enabled']
10421045
self.sim.get_outline().use_DEM_resolution=ui_OutlineProps['use_DEM_resolution']
10431046
self.sim.get_outline().max_linear_size=ui_OutlineProps['max_linear_size']
1047+
self.sim.get_outline().output_prefix=ui_OutlineProps['output_prefix']
10441048

10451049
#######################################################################
10461050
# ui_Pile

0 commit comments

Comments
 (0)