Skip to content

Commit

Permalink
Fix initial min dt and fix xllcorner for asci input
Browse files Browse the repository at this point in the history
  • Loading branch information
CyprienBosserelle committed Nov 25, 2021
1 parent 29ac2ed commit 9575295
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/Mainloop.cu
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ template <class T> void MainLoop(Param &XParam, Forcing<float> XForcing, Model<T

// Time keeping
XLoop.totaltime = XLoop.totaltime + XLoop.dt;
log("timestep = " + std::to_string(XLoop.totaltime));
//log("timestep = " + std::to_string(XLoop.totaltime));

// Apply tsunami deformation if any (this needs to happen after totaltime has been incremented)
deformstep(XParam, XLoop, XForcing.deform, XModel, XModel_g);
Expand Down Expand Up @@ -384,7 +384,12 @@ template <class T> __host__ double initdt(Param XParam, Loop<T> XLoop, Model<T>
{
XLoop.dtmax = XParam.dtinit / 1.5;
}

else
{
// WARNING here we specify at least an initial time step if there was 10.0m of water at the highest resolution cell.
// The modle will recalculate the optimal dt in subsequent step;
XLoop.dtmax = calcres(XParam.dx, XParam.maxlevel) / (sqrt(XParam.g * 10.0));
}
BlockP<T> XBlock = XModel.blocks;

/*
Expand Down
13 changes: 11 additions & 2 deletions src/ReadForcing.cu
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,8 @@ void readbathyASCHead(std::string filename, int &nx, int &ny, double &dx, double
//std::getline(fs, line);
int linehead = 0;

bool pixelreg = true;

while (linehead < 6)
{
std::getline(fs, line);
Expand Down Expand Up @@ -1441,15 +1443,15 @@ void readbathyASCHead(std::string filename, int &nx, int &ny, double &dx, double
}
if (left.compare("yllcenter") == 0) // found the parameter
{

pixelreg = false;
//
yo = std::stod(right);

}
//if gridnode registration this should happen
if (left.compare("xllcorner") == 0) // found the parameter
{

pixelreg = false;
//
xo = std::stod(right);

Expand All @@ -1467,6 +1469,13 @@ void readbathyASCHead(std::string filename, int &nx, int &ny, double &dx, double
linehead++;
}
}

if (!pixelreg)
{
xo = xo + 0.5 * dx;
yo = yo + 0.5 * dx;
}

grdalpha = 0.0;
fs.close();

Expand Down

0 comments on commit 9575295

Please sign in to comment.