|
19 | 19 | #include "../header/properties.h" |
20 | 20 | #include "../header/hpfem.h" |
21 | 21 |
|
| 22 | + |
| 23 | +#include <sstream> |
| 24 | + |
22 | 25 | MapNames::MapNames() |
23 | 26 | { |
24 | 27 | gis_main = ""; |
@@ -660,6 +663,8 @@ OutLine::OutLine() |
660 | 663 | use_DEM_resolution=false; |
661 | 664 | max_linear_size=1024; |
662 | 665 |
|
| 666 | + output_prefix=""; |
| 667 | + |
663 | 668 | MPI_Comm_rank(MPI_COMM_WORLD, &myid); |
664 | 669 | MPI_Comm_size(MPI_COMM_WORLD, &numprocs); |
665 | 670 |
|
@@ -1180,103 +1185,130 @@ void OutLine::update_two_phases() |
1180 | 1185 | */ |
1181 | 1186 | void OutLine::output(MatProps* matprops_ptr, StatProps* statprops_ptr) |
1182 | 1187 | { |
1183 | | - int ix, iy; |
1184 | | - char filename[256]; |
| 1188 | + double ENERGY_SCALE = matprops_ptr->scale.length * matprops_ptr->scale.gravity * matprops_ptr->scale.height; |
1185 | 1189 |
|
1186 | 1190 | // 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++) |
1196 | 1191 | { |
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); |
1200 | 1210 | } |
1201 | | - fclose(fp); |
1202 | 1211 |
|
1203 | 1212 | //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) |
1215 | 1214 | { |
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); |
1219 | 1233 | } |
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) |
1232 | 1237 | { |
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); |
1236 | 1257 | } |
1237 | | - fclose(fp); |
1238 | 1258 |
|
1239 | 1259 | // 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) |
1249 | 1261 | { |
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); |
1253 | 1280 | } |
1254 | | - fclose(fp); |
1255 | | - |
1256 | 1281 | // 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++) |
1267 | 1282 | { |
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++) |
1270 | 1298 | { |
| 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 | + } |
1271 | 1306 | xx = ((ix + 0.5) * dx + xminmax[0]) * matprops_ptr->scale.length; |
1272 | 1307 | ierr = Get_elevation(res, xx, yy, elevation); |
1273 | | - fprintf(fp, "%g ", elevation); |
| 1308 | + fprintf(fp,"%g\n",elevation); |
1274 | 1309 | } |
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); |
1278 | 1311 | } |
1279 | | - fclose(fp); |
1280 | 1312 | return; |
1281 | 1313 | } |
1282 | 1314 |
|
|
0 commit comments