Skip to content
Snippets Groups Projects
Commit d2454796 authored by Christopher Subich's avatar Christopher Subich
Browse files

Fixed "automatic" grid calculation error for wave_reader

The "automatic" (unmapped) grid calculation used by wave_reader
(automatic_grid in BaseCase.cpp) was in error for grids of
Chebyshev-type.  Instead of computing:

z = -Lz/2 + Lz/2*cos(pi*(0:(N-1))/(N-1))

it instead computed

z = -Lz/2 + Lz/2*cos(pi*(0:(N-1))/N)

(to use matlab-style notation).  This caused the written-out zgrid to be
in error near the bottom (max z-index) boundary.  Files using a
chebyshev-type unmapped x-coordinate would see the error as well in the
x-grid (max x-index).

This error affects only processing that uses the grid variables itself.
Within wave_reader where this was used, the automatic-generated grids
were used only for writing out; the input velocities and density were
read directly in from their corresponding files.  Likewise, SPINS
performed the "correct" differentiation internally without reference to
the grid coordinate.
parent 982acc11
No related branches found
No related tags found
No related merge requests found
...@@ -175,13 +175,13 @@ void BaseCase::automatic_grid(double MinX,double MinY,double MinZ) { ...@@ -175,13 +175,13 @@ void BaseCase::automatic_grid(double MinX,double MinY,double MinZ) {
// Generate 1D arrays // Generate 1D arrays
if (type_x() == NO_SLIP) { if (type_x() == NO_SLIP) {
xx = MinX+length_x()*(0.5+0.5*cos(M_PI*ii/size_x())); xx = MinX+length_x()*(0.5+0.5*cos(M_PI*ii/(size_x()-1)));
} else { } else {
xx = MinX + length_x()*(ii+0.5)/size_x(); xx = MinX + length_x()*(ii+0.5)/size_x();
} }
yy = MinY + length_y()*(ii+0.5)/size_y(); yy = MinY + length_y()*(ii+0.5)/size_y();
if (type_z() == NO_SLIP) { if (type_z() == NO_SLIP) {
zz = MinZ+length_z()*(0.5+0.5*cos(M_PI*ii/size_z())); zz = MinZ+length_z()*(0.5+0.5*cos(M_PI*ii/(size_z()-1)));
} else { } else {
zz = MinZ + length_z()*(0.5+ii)/size_z(); zz = MinZ + length_z()*(0.5+ii)/size_z();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment