Quick implementation for dynamic displacements

parent a9769f3f
...@@ -94,6 +94,8 @@ vars.AddVariables( ...@@ -94,6 +94,8 @@ vars.AddVariables(
allowed_values=('rusanov', 'fwave', 'augrie', 'hybrid', 'fwavevec') allowed_values=('rusanov', 'fwave', 'augrie', 'hybrid', 'fwavevec')
), ),
BoolVariable( 'dynamicDispl', 'support dynamic displacement files with ASAGI', False ),
BoolVariable( 'vectorize', 'add pragmas to help vectorization (release only)', True ), BoolVariable( 'vectorize', 'add pragmas to help vectorization (release only)', True ),
BoolVariable( 'showVectorization', 'show loop vectorization (Intel compiler only)', False ), BoolVariable( 'showVectorization', 'show loop vectorization (Intel compiler only)', False ),
...@@ -219,6 +221,10 @@ elif env['solver'] == 'hybrid': ...@@ -219,6 +221,10 @@ elif env['solver'] == 'hybrid':
elif env['solver'] == 'fwavevec': elif env['solver'] == 'fwavevec':
env.Append(CPPDEFINES=['WAVE_PROPAGATION_SOLVER=4']) env.Append(CPPDEFINES=['WAVE_PROPAGATION_SOLVER=4'])
# Dynamic displacement?
if env['dynamicDispl']:
env.Append(CPPDEFINES=['DYNAMIC_DISPLACEMENTS'])
# set the precompiler flags for CUDA # set the precompiler flags for CUDA
if env['parallelization'] in ['cuda', 'mpi_with_cuda']: if env['parallelization'] in ['cuda', 'mpi_with_cuda']:
env.Append(CPPDEFINES=['CUDA']) env.Append(CPPDEFINES=['CUDA'])
......
...@@ -256,7 +256,7 @@ void SWE_WavePropagationBlock::updateUnknowns(float dt) { ...@@ -256,7 +256,7 @@ void SWE_WavePropagationBlock::updateUnknowns(float dt) {
* @param i_asagiScenario the corresponding ASAGI-scenario * @param i_asagiScenario the corresponding ASAGI-scenario
*/ */
#ifdef DYNAMIC_DISPLACEMENTS #ifdef DYNAMIC_DISPLACEMENTS
bool SWE_WavePropagationBlock::updateBathymetryWithDynamicDisplacement(scenarios::Asagi &i_asagiScenario, const float i_time) { bool SWE_WavePropagationBlock::updateBathymetryWithDynamicDisplacement(SWE_AsagiScenario &i_asagiScenario, const float i_time) {
if (!i_asagiScenario.dynamicDisplacementAvailable(i_time)) if (!i_asagiScenario.dynamicDisplacementAvailable(i_time))
return false; return false;
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include "tools/help.hh" #include "tools/help.hh"
#include "SWE_Block.hh" #include "SWE_Block.hh"
#ifdef DYNAMIC_DISPLACEMENTS #ifdef DYNAMIC_DISPLACEMENTS
#include "scenarios/Asagi.hpp" #include "scenarios/SWE_AsagiScenario.hpp"
#endif #endif
//which wave propagation solver should be used //which wave propagation solver should be used
...@@ -136,7 +136,7 @@ class SWE_WavePropagationBlock: public SWE_Block { ...@@ -136,7 +136,7 @@ class SWE_WavePropagationBlock: public SWE_Block {
//updates the bathymetry with the current displacment values //updates the bathymetry with the current displacment values
#ifdef DYNAMIC_DISPLACEMENTS #ifdef DYNAMIC_DISPLACEMENTS
bool updateBathymetryWithDynamicDisplacement(scenarios::Asagi &i_asagiScenario, float time); bool updateBathymetryWithDynamicDisplacement(SWE_AsagiScenario &i_asagiScenario, float time);
#endif #endif
//get hybrid statistics //get hybrid statistics
......
...@@ -206,8 +206,8 @@ int main( int argc, char** argv ) { ...@@ -206,8 +206,8 @@ int main( int argc, char** argv ) {
simulationArea[3] = 1450000; simulationArea[3] = 1450000;
SWE_AsagiScenario l_scenario( ASAGI_INPUT_DIR "tohoku_gebco_ucsb3_500m_hawaii_bath.nc", SWE_AsagiScenario l_scenario( ASAGI_INPUT_DIR "tohoku_gebco_ucsb3_500m_hawaii_bath.nc",
ASAGI_INPUT_DIR "tohoku_gebco_ucsb3_500m_hawaii_displ.nc", ASAGI_INPUT_DIR "tohoku_percy_500m_displ.nc",
(float) 14400., simulationArea); (float) 14400., simulationArea, true);
#else #else
// create a simple artificial scenario // create a simple artificial scenario
SWE_BathymetryDamBreakScenario l_scenario; SWE_BathymetryDamBreakScenario l_scenario;
...@@ -415,6 +415,8 @@ int main( int argc, char** argv ) { ...@@ -415,6 +415,8 @@ int main( int argc, char** argv ) {
unsigned int l_iterations = 0; unsigned int l_iterations = 0;
bool displAvail = true;
// loop over checkpoints // loop over checkpoints
for(int c=1; c<=l_numberOfCheckPoints; c++) { for(int c=1; c<=l_numberOfCheckPoints; c++) {
...@@ -453,6 +455,10 @@ int main( int argc, char** argv ) { ...@@ -453,6 +455,10 @@ int main( int argc, char** argv ) {
// determine smallest time step of all blocks // determine smallest time step of all blocks
MPI_Allreduce(&l_maxTimeStepWidth, &l_maxTimeStepWidthGlobal, 1, MPI_FLOAT, MPI_MIN, MPI_COMM_WORLD); MPI_Allreduce(&l_maxTimeStepWidth, &l_maxTimeStepWidthGlobal, 1, MPI_FLOAT, MPI_MIN, MPI_COMM_WORLD);
if (displAvail)
// Minimum available time step in dynamic displacements = 1.65
l_maxTimeStepWidthGlobal = std::min(l_maxTimeStepWidthGlobal, 1.65f);
// reset the cpu time // reset the cpu time
tools::Logger::logger.resetCpuClockToCurrentTime(); tools::Logger::logger.resetCpuClockToCurrentTime();
...@@ -467,6 +473,9 @@ int main( int argc, char** argv ) { ...@@ -467,6 +473,9 @@ int main( int argc, char** argv ) {
l_t += l_maxTimeStepWidthGlobal; l_t += l_maxTimeStepWidthGlobal;
l_iterations++; l_iterations++;
// Update displacement
displAvail = l_wavePropgationBlock.updateBathymetryWithDynamicDisplacement(l_scenario, l_t);
// print the current simulation time // print the current simulation time
progressBar.clear(); progressBar.clear();
tools::Logger::logger.printSimulationTime(l_t); tools::Logger::logger.printSimulationTime(l_t);
......
...@@ -47,7 +47,7 @@ private: ...@@ -47,7 +47,7 @@ private:
public: public:
SWE_AsagiGrid() SWE_AsagiGrid()
{ {
_grid = asagi::Grid::create(); _grid = asagi::Grid::create(asagi::Grid::FLOAT);
_refCount = 0; _refCount = 0;
} }
...@@ -240,6 +240,9 @@ class SWE_AsagiScenario: public SWE_Scenario { ...@@ -240,6 +240,9 @@ class SWE_AsagiScenario: public SWE_Scenario {
//assert(dynamicDisplacement == false); //assert(dynamicDisplacement == false);
// no assertation for compability // no assertation for compability
if (dynamicDisplacement)
return 0;
return getBathymetryAndDynamicDisplacement(i_positionX, i_positionY, 0); return getBathymetryAndDynamicDisplacement(i_positionX, i_positionY, 0);
} }
......
Markdown is supported
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