Commit 1ac02e05 authored by Christopher Subich's avatar Christopher Subich
Browse files

Fix compilation of automatic_grid

The automatic_grid() helper function in BaseCase was not properly
functional if called without supplied arguments for the 1D grids
xx/yy/zz.  Now, if these arguments are null or not supplied, the
function will do its grid generation using temporarily-allocated
internal 1D arrays, deleted at the end of its execution.
parent 5c13e0d9
...@@ -179,8 +179,21 @@ void BaseCase::analysis(double t, DTArray & u, DTArray & v, DTArray & w, ...@@ -179,8 +179,21 @@ void BaseCase::analysis(double t, DTArray & u, DTArray & v, DTArray & w,
} }
void BaseCase::automatic_grid(double MinX, double MinY, double MinZ, void BaseCase::automatic_grid(double MinX, double MinY, double MinZ,
Array<double,1> * xx=0, Array<double,1> * yy=0, Array<double,1> * zz = 0){ Array<double,1> * xx, Array<double,1> * yy, Array<double,1> * zz){
//Array<double,1> xx(split_range(size_x())), yy(size_y()), zz(size_z()); //Array<double,1> xx(split_range(size_x())), yy(size_y()), zz(size_z());
bool xxa = false, yya = false, zza = false;
if (!xx) {
xxa = true; // Delete xx when returning
xx = new Array<double,1>(split_range(size_x()));
}
if (!yy) {
yya = true;
yy = new Array<double,1>(size_y());
}
if (!zz) {
zza = true;
zz = new Array<double,1>(size_z());
}
Array<double,3> grid(alloc_lbound(size_x(),size_y(),size_z()), Array<double,3> grid(alloc_lbound(size_x(),size_y(),size_z()),
alloc_extent(size_x(),size_y(),size_z()), alloc_extent(size_x(),size_y(),size_z()),
alloc_storage(size_x(),size_y(),size_z())); alloc_storage(size_x(),size_y(),size_z()));
...@@ -215,6 +228,11 @@ void BaseCase::automatic_grid(double MinX, double MinY, double MinZ, ...@@ -215,6 +228,11 @@ void BaseCase::automatic_grid(double MinX, double MinY, double MinZ,
grid = 0*ii + 0*jj + (*zz)(kk); grid = 0*ii + 0*jj + (*zz)(kk);
write_array(grid,"zgrid"); write_array(grid,"zgrid");
write_reader(grid,"zgrid",false); write_reader(grid,"zgrid",false);
// Clean up
if (xxa) delete xx;
if (yya) delete yy;
if (zza) delete zz;
} }
/* Read velocities from regular output */ /* Read velocities from regular output */
......
...@@ -160,7 +160,7 @@ class BaseCase { ...@@ -160,7 +160,7 @@ class BaseCase {
// Generate an automatic grid for unmapped cases // Generate an automatic grid for unmapped cases
virtual void automatic_grid(double MinX, double MinY, double MinZ, virtual void automatic_grid(double MinX, double MinY, double MinZ,
Array<double,1> *xx, Array<double,1> *yy, Array<double,1> *zz); Array<double,1> *xx=0, Array<double,1> *yy=0, Array<double,1> *zz=0);
}; };
extern template class FluidEvolve<BaseCase>; extern template class FluidEvolve<BaseCase>;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment