Skip to content

Commit

Permalink
foam*Initialization: use 1st order interpolation on input speed and d…
Browse files Browse the repository at this point in the history
…irection grids
  • Loading branch information
nwagenbrenner committed Oct 13, 2017
1 parent fda246c commit 5dc43f2
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 4 deletions.
28 changes: 26 additions & 2 deletions src/ninja/foamDomainAverageInitialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,32 @@ void foamDomainAverageInitialization::setWn2dGrids(WindNinjaInputs &input)
CPLDebug("NINJA", "Buffering in foamDomainAverageInitialization...");
}

//convert speed/dir to u/v for direction interpolation
AsciiGrid<double> inputUGrid;
AsciiGrid<double> inputVGrid;
inputUGrid.set_headerData(inputVelocityGrid);
inputVGrid.set_headerData(inputVelocityGrid);

for(int i=0; i<inputVelocityGrid.get_nRows(); i++) {
for(int j=0; j<inputVelocityGrid.get_nCols(); j++) {
wind_sd_to_uv(inputVelocityGrid(i,j), inputAngleGrid(i,j),
&(inputUGrid)(i,j), &(inputVGrid)(i,j));
}
}

//Interpolate from input grids to dem coincident grids
speedInitializationGrid.interpolateFromGrid(inputVelocityGrid, AsciiGrid<double>::order0);
dirInitializationGrid.interpolateFromGrid(inputAngleGrid, AsciiGrid<double>::order0);
uInitializationGrid.interpolateFromGrid(inputUGrid, AsciiGrid<double>::order1);
vInitializationGrid.interpolateFromGrid(inputVGrid, AsciiGrid<double>::order1);

inputUGrid.deallocate();
inputVGrid.deallocate();

//fill the speed and dir initialization grids
for(int i=0; i<speedInitializationGrid.get_nRows(); i++) {
for(int j=0; j<speedInitializationGrid.get_nCols(); j++) {
wind_uv_to_sd(uInitializationGrid(i,j), vInitializationGrid(i,j),
&(speedInitializationGrid)(i,j), &(dirInitializationGrid)(i,j));
}
}
}

28 changes: 26 additions & 2 deletions src/ninja/foamWxModelInitialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,31 @@ void foamWxModelInitialization::setWn2dGrids(WindNinjaInputs &input)
CPLDebug("NINJA", "Buffering in foamWxModelInitialization...");
}

//convert speed/dir to u/v for direction interpolation
AsciiGrid<double> inputUGrid;
AsciiGrid<double> inputVGrid;
inputUGrid.set_headerData(inputVelocityGrid);
inputVGrid.set_headerData(inputVelocityGrid);

for(int i=0; i<inputVelocityGrid.get_nRows(); i++) {
for(int j=0; j<inputVelocityGrid.get_nCols(); j++) {
wind_sd_to_uv(inputVelocityGrid(i,j), inputAngleGrid(i,j),
&(inputUGrid)(i,j), &(inputVGrid)(i,j));
}
}

//Interpolate from input grids to dem coincident grids
speedInitializationGrid.interpolateFromGrid(inputVelocityGrid, AsciiGrid<double>::order0);
dirInitializationGrid.interpolateFromGrid(inputAngleGrid, AsciiGrid<double>::order0);
uInitializationGrid.interpolateFromGrid(inputUGrid, AsciiGrid<double>::order1);
vInitializationGrid.interpolateFromGrid(inputVGrid, AsciiGrid<double>::order1);

inputUGrid.deallocate();
inputVGrid.deallocate();

//fill the speed and dir initialization grids
for(int i=0; i<speedInitializationGrid.get_nRows(); i++) {
for(int j=0; j<speedInitializationGrid.get_nCols(); j++) {
wind_uv_to_sd(uInitializationGrid(i,j), vInitializationGrid(i,j),
&(speedInitializationGrid)(i,j), &(dirInitializationGrid)(i,j));
}
}
}

0 comments on commit 5dc43f2

Please sign in to comment.