Refactoring + new color map for bathymetry

parent f5435947
...@@ -55,8 +55,8 @@ else: ...@@ -55,8 +55,8 @@ else:
for i in sourceFiles: for i in sourceFiles:
env.src_files.append(env.Object(i)) env.src_files.append(env.Object(i))
# SWE_Block is used in every implementation # SWE_Block and Logger is used in every implementation
sourceFiles = ['SWE_Block.cpp'] sourceFiles = ['SWE_Block.cpp', 'tools/Logger.cpp']
# OpenGL CPU-files # OpenGL CPU-files
if env['openGL'] == True: if env['openGL'] == True:
...@@ -66,6 +66,8 @@ if env['openGL'] == True: ...@@ -66,6 +66,8 @@ if env['openGL'] == True:
sourceFiles.append( ['opengl/controller.cpp'] ) sourceFiles.append( ['opengl/controller.cpp'] )
sourceFiles.append( ['opengl/shader.cpp'] ) sourceFiles.append( ['opengl/shader.cpp'] )
sourceFiles.append( ['opengl/visualization.cpp'] ) sourceFiles.append( ['opengl/visualization.cpp'] )
sourceFiles.append( ['opengl/vbo.cpp'] )
if env['openGL_instr'] == True:
sourceFiles.append( ['opengl/text.cpp'] ) sourceFiles.append( ['opengl/text.cpp'] )
# Asagi scenario # Asagi scenario
......
...@@ -31,13 +31,9 @@ ...@@ -31,13 +31,9 @@
#include "SWE_WavePropagationBlockCuda_kernels.hh" #include "SWE_WavePropagationBlockCuda_kernels.hh"
#include <cassert>
#ifndef STATICLOGGER
#define STATICLOGGER
#include "tools/Logger.hpp" #include "tools/Logger.hpp"
static tools::Logger s_sweLogger;
#endif #include <cassert>
// CUDA-C includes // CUDA-C includes
#include <cuda.h> #include <cuda.h>
...@@ -146,7 +142,7 @@ SWE_WavePropagationBlockCuda::~SWE_WavePropagationBlockCuda() { ...@@ -146,7 +142,7 @@ SWE_WavePropagationBlockCuda::~SWE_WavePropagationBlockCuda() {
cudaFree(hvNetUpdatesAboveD); cudaFree(hvNetUpdatesAboveD);
// reset the cuda device // reset the cuda device
s_sweLogger.printString("Resetting the CUDA devices"); tools::Logger::logger.printString("Resetting the CUDA devices");
cudaDeviceReset(); cudaDeviceReset();
} }
......
...@@ -37,8 +37,8 @@ ...@@ -37,8 +37,8 @@
#define SCREEN_WIDTH 800 #define SCREEN_WIDTH 800
#define SCREEN_HEIGHT 600 #define SCREEN_HEIGHT 600
// Number of nodes (not cells) of grid // Number of nodes (not cells) of grid
#define GRID_XSIZE 401 #define GRID_XSIZE 801
#define GRID_YSIZE 401 #define GRID_YSIZE 801
#define WINDOW_TITLE "Shallow Water Equations v1.2" #define WINDOW_TITLE "Shallow Water Equations v1.2"
/** /**
...@@ -81,7 +81,6 @@ int main(int argc, char *argv[]) ...@@ -81,7 +81,6 @@ int main(int argc, char *argv[])
// Initialize scenario: // Initialize scenario:
SWE_Scenario* scene = NULL; SWE_Scenario* scene = NULL;
SWE_VisInfo* visInfo = NULL;
SWE_BlockCUDA* splash = NULL; SWE_BlockCUDA* splash = NULL;
// If input file specified, then read from VTK file: // If input file specified, then read from VTK file:
...@@ -89,7 +88,6 @@ int main(int argc, char *argv[]) ...@@ -89,7 +88,6 @@ int main(int argc, char *argv[])
SWE_VtkScenarioVisInfo* newScene = SWE_VtkScenarioVisInfo::readVtkFile(argv[1]); SWE_VtkScenarioVisInfo* newScene = SWE_VtkScenarioVisInfo::readVtkFile(argv[1]);
// NOTE: Simulation uses a fixed resolution (independent of VTK file) // NOTE: Simulation uses a fixed resolution (independent of VTK file)
scene = newScene; scene = newScene;
visInfo = newScene;
printf("Scenario read from input file %s\n\n", argv[1]); printf("Scenario read from input file %s\n\n", argv[1]);
}; };
...@@ -113,9 +111,9 @@ int main(int argc, char *argv[]) ...@@ -113,9 +111,9 @@ int main(int argc, char *argv[])
// Initialize simulation // Initialize simulation
printf("Init simulation\n\n"); printf("Init simulation\n\n");
Simulation sim(nx,ny,dx,dy, scene, visInfo, splash); Simulation sim(nx,ny,dx,dy, scene, splash);
printf("Init visualisation\n\n"); printf("Init visualisation\n\n");
visualization.init(&sim); visualization.init(sim);
// Initialize controller // Initialize controller
Controller controller(&sim, &visualization); Controller controller(&sim, &visualization);
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "../scenarios/SWE_simple_scenarios_vis.h" #include "../scenarios/SWE_simple_scenarios_vis.h"
#ifdef ASAGI #ifdef ASAGI
#include "../scenarios/SWE_AsagiScenario.hpp" #include "../scenarios/SWE_AsagiScenario.hpp"
#include "../scenarios/SWE_AsagiScenario_vis.hpp"
#endif // ASAGI #endif // ASAGI
/** /**
...@@ -172,6 +173,14 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) { ...@@ -172,6 +173,14 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) {
// Pause/Resume // Pause/Resume
paused = !paused; paused = !paused;
break; break;
case SDLK_PLUS:
// Increase water scaling
visualization->modifyWaterScaling(1.5);
break;
case SDLK_MINUS:
// Decrease water scaling
visualization->modifyWaterScaling(1/1.5);
break;
case SDLK_1: case SDLK_1:
// Load scenario 1 // Load scenario 1
{ {
...@@ -187,8 +196,8 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) { ...@@ -187,8 +196,8 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) {
float dy = (newScene->getBoundaryPos(BND_TOP) - newScene->getBoundaryPos(BND_BOTTOM) )/SWE_Block::getNy(); float dy = (newScene->getBoundaryPos(BND_TOP) - newScene->getBoundaryPos(BND_BOTTOM) )/SWE_Block::getNy();
SWE_Block::initGridData(SWE_Block::getNx(),SWE_Block::getNy(),dx,dy); SWE_Block::initGridData(SWE_Block::getNx(),SWE_Block::getNy(),dx,dy);
simulation->loadNewScenario(newScene, NULL); simulation->loadNewScenario(newScene);
visualization->updateBathymetryVBO(simulation); visualization->init(*simulation);
} }
break; break;
case SDLK_2: case SDLK_2:
...@@ -208,8 +217,8 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) { ...@@ -208,8 +217,8 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) {
float dy = (newScene->getBoundaryPos(BND_TOP) - newScene->getBoundaryPos(BND_BOTTOM) )/SWE_Block::getNy(); float dy = (newScene->getBoundaryPos(BND_TOP) - newScene->getBoundaryPos(BND_BOTTOM) )/SWE_Block::getNy();
SWE_Block::initGridData(SWE_Block::getNx(),SWE_Block::getNy(),dx,dy); SWE_Block::initGridData(SWE_Block::getNx(),SWE_Block::getNy(),dx,dy);
simulation->loadNewScenario(newScene, visInfos[1]); simulation->loadNewScenario(newScene);
visualization->updateBathymetryVBO(simulation); visualization->init(*simulation, visInfos[1]);
} }
break; break;
case SDLK_3: case SDLK_3:
...@@ -227,8 +236,8 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) { ...@@ -227,8 +236,8 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) {
float dy = (newScene->getBoundaryPos(BND_TOP) - newScene->getBoundaryPos(BND_BOTTOM) )/SWE_Block::getNy(); float dy = (newScene->getBoundaryPos(BND_TOP) - newScene->getBoundaryPos(BND_BOTTOM) )/SWE_Block::getNy();
SWE_Block::initGridData(SWE_Block::getNx(),SWE_Block::getNy(),dx,dy); SWE_Block::initGridData(SWE_Block::getNx(),SWE_Block::getNy(),dx,dy);
simulation->loadNewScenario(newScene, NULL); simulation->loadNewScenario(newScene);
visualization->updateBathymetryVBO(simulation); visualization->init(*simulation);
} }
break; break;
#ifdef ASAGI #ifdef ASAGI
...@@ -257,8 +266,8 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) { ...@@ -257,8 +266,8 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) {
float dy = (newScene->getBoundaryPos(BND_TOP) - newScene->getBoundaryPos(BND_BOTTOM) )/SWE_Block::getNy(); float dy = (newScene->getBoundaryPos(BND_TOP) - newScene->getBoundaryPos(BND_BOTTOM) )/SWE_Block::getNy();
SWE_Block::initGridData(SWE_Block::getNx(),SWE_Block::getNy(),dx,dy); SWE_Block::initGridData(SWE_Block::getNx(),SWE_Block::getNy(),dx,dy);
simulation->loadNewScenario(newScene, NULL); simulation->loadNewScenario(newScene);
visualization->updateBathymetryVBO(simulation); visualization->init(*simulation);
} }
break; break;
case SDLK_5: case SDLK_5:
...@@ -277,6 +286,8 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) { ...@@ -277,6 +286,8 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) {
ASAGI_INPUT_DIR "tohoku_gebco_ucsb3_500m_hawaii_bath.nc", ASAGI_INPUT_DIR "tohoku_gebco_ucsb3_500m_hawaii_bath.nc",
ASAGI_INPUT_DIR "tohoku_gebco_ucsb3_500m_hawaii_displ.nc", ASAGI_INPUT_DIR "tohoku_gebco_ucsb3_500m_hawaii_displ.nc",
(float) 28800., simulationArea); (float) 28800., simulationArea);
visInfos[4] = new SWE_AsagiJapanSmallVisInfo();
} }
SWE_Scenario* newScene = scenarios[4]; SWE_Scenario* newScene = scenarios[4];
...@@ -286,8 +297,8 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) { ...@@ -286,8 +297,8 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) {
float dy = (newScene->getBoundaryPos(BND_TOP) - newScene->getBoundaryPos(BND_BOTTOM) )/SWE_Block::getNy(); float dy = (newScene->getBoundaryPos(BND_TOP) - newScene->getBoundaryPos(BND_BOTTOM) )/SWE_Block::getNy();
SWE_Block::initGridData(SWE_Block::getNx(),SWE_Block::getNy(),dx,dy); SWE_Block::initGridData(SWE_Block::getNx(),SWE_Block::getNy(),dx,dy);
simulation->loadNewScenario(newScene, NULL); simulation->loadNewScenario(newScene);
visualization->updateBathymetryVBO(simulation); visualization->init(*simulation, visInfos[4]);
} }
break; break;
case SDLK_6: case SDLK_6:
...@@ -315,8 +326,8 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) { ...@@ -315,8 +326,8 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) {
float dy = (newScene->getBoundaryPos(BND_TOP) - newScene->getBoundaryPos(BND_BOTTOM) )/SWE_Block::getNy(); float dy = (newScene->getBoundaryPos(BND_TOP) - newScene->getBoundaryPos(BND_BOTTOM) )/SWE_Block::getNy();
SWE_Block::initGridData(SWE_Block::getNx(),SWE_Block::getNy(),dx,dy); SWE_Block::initGridData(SWE_Block::getNx(),SWE_Block::getNy(),dx,dy);
simulation->loadNewScenario(newScene, NULL); simulation->loadNewScenario(newScene);
visualization->updateBathymetryVBO(simulation); visualization->init(*simulation);
} }
break; break;
case SDLK_7: case SDLK_7:
...@@ -344,8 +355,8 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) { ...@@ -344,8 +355,8 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) {
float dy = (newScene->getBoundaryPos(BND_TOP) - newScene->getBoundaryPos(BND_BOTTOM) )/SWE_Block::getNy(); float dy = (newScene->getBoundaryPos(BND_TOP) - newScene->getBoundaryPos(BND_BOTTOM) )/SWE_Block::getNy();
SWE_Block::initGridData(SWE_Block::getNx(),SWE_Block::getNy(),dx,dy); SWE_Block::initGridData(SWE_Block::getNx(),SWE_Block::getNy(),dx,dy);
simulation->loadNewScenario(newScene, NULL); simulation->loadNewScenario(newScene);
visualization->updateBathymetryVBO(simulation); visualization->init(*simulation);
} }
break; break;
#endif // ASAGI #endif // ASAGI
......
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
// This file is part of SWE_CUDA (see file SWE_Block.cu for details). // This file is part of SWE_CUDA (see file SWE_Block.cu for details).
// //
// Copyright (C) 2010,2011 Tobias Schnabel // Copyright (C) 2010,2011 Tobias Schnabel
// Copyright (C) 2012 Sebastian Rettenberger
// //
// SWE_CUDA is free software: you can redristribute it and/or modify // SWE_CUDA is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
...@@ -19,6 +20,8 @@ ...@@ -19,6 +20,8 @@
#include "shader.h" #include "shader.h"
#include "../tools/Logger.hpp"
/** /**
Constructor. Constructor.
Check whether shaders are supported. If yes, load vertex and fragment Check whether shaders are supported. If yes, load vertex and fragment
...@@ -30,14 +33,19 @@ ...@@ -30,14 +33,19 @@
shader code shader code
*/ */
Shader::Shader(char const * vertexShaderFile, char const * fragmentShaderFile) { Shader::Shader(char const * vertexShaderFile, char const * fragmentShaderFile)
{
if (!shdrSupport) {
// Shaders are either not supported or we did not try yet
// This if-statement makes sure, we only load the extensions once
shdrSupport = isExtensionSupported("GL_ARB_vertex_shader") shdrSupport = isExtensionSupported("GL_ARB_vertex_shader")
&& isExtensionSupported("GL_ARB_shader_objects") && isExtensionSupported("GL_ARB_shader_objects")
&& isExtensionSupported("GL_ARB_fragment_shader"); && isExtensionSupported("GL_ARB_fragment_shader");
shdrLoaded = false;
if (shdrSupport) { if (shdrSupport) {
tools::Logger::logger.printString("Shaders supported!");
// Load extensions // Load extensions
glCreateShader = (PFNGLCREATESHADERPROC) SDL_GL_GetProcAddress("glCreateShader"); glCreateShader = (PFNGLCREATESHADERPROC) SDL_GL_GetProcAddress("glCreateShader");
glCreateProgram = (PFNGLCREATEPROGRAMPROC) SDL_GL_GetProcAddress("glCreateProgram"); glCreateProgram = (PFNGLCREATEPROGRAMPROC) SDL_GL_GetProcAddress("glCreateProgram");
...@@ -49,11 +57,19 @@ Shader::Shader(char const * vertexShaderFile, char const * fragmentShaderFile) ...@@ -49,11 +57,19 @@ Shader::Shader(char const * vertexShaderFile, char const * fragmentShaderFile)
glLinkProgram = (PFNGLLINKPROGRAMPROC)SDL_GL_GetProcAddress("glLinkProgram"); glLinkProgram = (PFNGLLINKPROGRAMPROC)SDL_GL_GetProcAddress("glLinkProgram");
glShaderSource = (PFNGLSHADERSOURCEPROC)SDL_GL_GetProcAddress("glShaderSource"); glShaderSource = (PFNGLSHADERSOURCEPROC)SDL_GL_GetProcAddress("glShaderSource");
glDeleteProgram = (PFNGLDELETEPROGRAMPROC)SDL_GL_GetProcAddress("glDeleteProgram"); glDeleteProgram = (PFNGLDELETEPROGRAMPROC)SDL_GL_GetProcAddress("glDeleteProgram");
glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) SDL_GL_GetProcAddress("glGetUniformLocation");
glUniform1f = (PFNGLUNIFORM1FPROC) SDL_GL_GetProcAddress("glUniform1f");
glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) SDL_GL_GetProcAddress("glGetObjectParameterivARB"); glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) SDL_GL_GetProcAddress("glGetObjectParameterivARB");
glGetShaderiv = (PFNGLGETSHADERIVPROC) SDL_GL_GetProcAddress("glGetShaderiv"); glGetShaderiv = (PFNGLGETSHADERIVPROC) SDL_GL_GetProcAddress("glGetShaderiv");
glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) SDL_GL_GetProcAddress("glGetShaderInfoLog"); glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) SDL_GL_GetProcAddress("glGetShaderInfoLog");
glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) SDL_GL_GetProcAddress("glGetProgramInfoLog"); glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) SDL_GL_GetProcAddress("glGetProgramInfoLog");
} else
tools::Logger::logger.printString("Shaders are NOT supported! Normal rendering mode");
}
shdrLoaded = false;
if (shdrSupport) {
// Read shader files // Read shader files
bool readSuccess = false; bool readSuccess = false;
vertexShaderSource = NULL; vertexShaderSource = NULL;
...@@ -84,7 +100,6 @@ Shader::Shader(char const * vertexShaderFile, char const * fragmentShaderFile) ...@@ -84,7 +100,6 @@ Shader::Shader(char const * vertexShaderFile, char const * fragmentShaderFile)
shdrLoaded = true; shdrLoaded = true;
} else { } else {
// Errors while compiling shaders // Errors while compiling shaders
shdrSupport = false;
glDeleteShader(vertexShader); glDeleteShader(vertexShader);
delete[] vertexShaderSource; delete[] vertexShaderSource;
glDeleteShader(fragmentShader); glDeleteShader(fragmentShader);
...@@ -135,13 +150,6 @@ void Shader::disableShader() { ...@@ -135,13 +150,6 @@ void Shader::disableShader() {
} }
} }
/**
Returns, whether shaders are supported by graphics hardware
*/
bool Shader::shadersSupported() {
return shdrSupport;
}
/** /**
Returns, whether shaders could by loaded successfully Returns, whether shaders could by loaded successfully
...@@ -333,3 +341,23 @@ bool Shader::isProgramLinked(GLuint program, char const * prefix) ...@@ -333,3 +341,23 @@ bool Shader::isProgramLinked(GLuint program, char const * prefix)
return (linked != 0); return (linked != 0);
} }
bool Shader::shdrSupport = false;
PFNGLCREATESHADERPROC Shader::glCreateShader;
PFNGLCREATEPROGRAMPROC Shader::glCreateProgram;
PFNGLATTACHSHADERPROC Shader::glAttachShader;
PFNGLCOMPILESHADERPROC Shader::glCompileShader;
PFNGLUSEPROGRAMPROC Shader::glUseProgram;
PFNGLDETACHSHADERPROC Shader::glDetachShader;
PFNGLDELETESHADERPROC Shader::glDeleteShader;
PFNGLLINKPROGRAMPROC Shader::glLinkProgram;
PFNGLSHADERSOURCEPROC Shader::glShaderSource;
PFNGLDELETEPROGRAMPROC Shader::glDeleteProgram;
PFNGLGETUNIFORMLOCATIONPROC Shader::glGetUniformLocation;
PFNGLUNIFORM1FPROC Shader::glUniform1f;
PFNGLGETOBJECTPARAMETERIVARBPROC Shader::glGetObjectParameterivARB;
PFNGLGETSHADERIVPROC Shader::glGetShaderiv;
PFNGLGETSHADERINFOLOGPROC Shader::glGetShaderInfoLog;
PFNGLGETPROGRAMINFOLOGPROC Shader::glGetProgramInfoLog;
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
// This file is part of SWE_CUDA (see file SWE_Block.cu for details). // This file is part of SWE_CUDA (see file SWE_Block.cu for details).
// //
// Copyright (C) 2010,2011 Tobias Schnabel // Copyright (C) 2010,2011 Tobias Schnabel
// Copyright (C) 2012 Sebastian Rettenberger
// //
// SWE_CUDA is free software: you can redristribute it and/or modify // SWE_CUDA is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
...@@ -30,17 +31,35 @@ public: ...@@ -30,17 +31,35 @@ public:
Shader(char const * vertexShaderFile, char const * fragmentShaderFile) ; Shader(char const * vertexShaderFile, char const * fragmentShaderFile) ;
~Shader(); ~Shader();
// Check if shaders are supported // Check if shaders are loaded
bool shadersSupported();
bool shadersLoaded(); bool shadersLoaded();
// Shader control // Shader control
void enableShader(); void enableShader();
void disableShader(); void disableShader();
/**
* @return Location of the uniform variable
*/
GLint getUniformLocation(const char* name)
{
if (!shdrLoaded)
return -1;
return glGetUniformLocation(program, name);
}
/**
* Set a uniform variable in the shader
*/
void setUniform(GLint location, GLfloat value)
{
if (location < 0)
return;
glUniform1f(location, value);
}
private: private:
// State flags // State flags
bool shdrSupport;
bool shdrLoaded; bool shdrLoaded;
// Helper functions // Helper functions
...@@ -62,23 +81,27 @@ private: ...@@ -62,23 +81,27 @@ private:
// Shaders id // Shaders id
GLuint program; GLuint program;
/** Are shaders supported */
static bool shdrSupport;
// Shader extension function pointers // Shader extension function pointers
PFNGLCREATESHADERPROC glCreateShader; static PFNGLCREATESHADERPROC glCreateShader;
PFNGLCREATEPROGRAMPROC glCreateProgram; static PFNGLCREATEPROGRAMPROC glCreateProgram;
PFNGLATTACHSHADERPROC glAttachShader; static PFNGLATTACHSHADERPROC glAttachShader;
PFNGLCOMPILESHADERPROC glCompileShader; static PFNGLCOMPILESHADERPROC glCompileShader;
PFNGLUSEPROGRAMPROC glUseProgram; static PFNGLUSEPROGRAMPROC glUseProgram;
PFNGLDETACHSHADERPROC glDetachShader; static PFNGLDETACHSHADERPROC glDetachShader;
PFNGLDELETESHADERPROC glDeleteShader; static PFNGLDELETESHADERPROC glDeleteShader;
PFNGLLINKPROGRAMPROC glLinkProgram; static PFNGLLINKPROGRAMPROC glLinkProgram;
PFNGLSHADERSOURCEPROC glShaderSource; static PFNGLSHADERSOURCEPROC glShaderSource;
PFNGLDELETEPROGRAMPROC glDeleteProgram; static PFNGLDELETEPROGRAMPROC glDeleteProgram;
static PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
static PFNGLUNIFORM1FPROC glUniform1f;
// Shader objects extension pointers // Shader objects extension pointers
PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB; static PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB;
PFNGLGETSHADERIVPROC glGetShaderiv; static PFNGLGETSHADERIVPROC glGetShaderiv;
PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog; static PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;
PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog; static PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
}; };
#endif #endif
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// along with SWE_CUDA. If not, see <http://www.gnu.org/licenses/>. // along with SWE_CUDA. If not, see <http://www.gnu.org/licenses/>.
// ===================================================================== // =====================================================================
#include "simulation.h" #include "simulation.h"
#include <stdlib.h> #include <cstring>
#include "../SWE_BlockCUDA.hh" #include "../SWE_BlockCUDA.hh"
// Taken form FWaveCuda.h // Taken form FWaveCuda.h
...@@ -37,14 +37,13 @@ const float dryTol = 100.; ...@@ -37,14 +37,13 @@ const float dryTol = 100.;
*/ */
Simulation::Simulation (int nx, int ny, float dx, float dy, Simulation::Simulation (int nx, int ny, float dx, float dy,
SWE_Scenario* scene, SWE_VisInfo* visInfo, SWE_Scenario* scene, SWE_BlockCUDA* _splash)
SWE_BlockCUDA* _splash)
: maxDim( (nx > ny) ? nx : ny ), : maxDim( (nx > ny) ? nx : ny ),
maxCellSize( (dx > dy) ? dx : dy ), maxCellSize( (dx > dy) ? dx : dy ),
splash(_splash), splash(_splash),
fileNumber(0) fileNumber(0)
{ {
loadNewScenario(scene, visInfo); loadNewScenario(scene);
} }
/** /**
...@@ -53,19 +52,12 @@ Simulation::Simulation (int nx, int ny, float dx, float dy, ...@@ -53,19 +52,12 @@ Simulation::Simulation (int nx, int ny, float dx, float dy,
Simulation::~Simulation () { Simulation::~Simulation () {
} }
void Simulation::loadNewScenario(SWE_Scenario* scene, SWE_VisInfo* visInfo) { void Simulation::loadNewScenario(SWE_Scenario* scene) {
myScenario = scene; myScenario = scene;
curTime = 0.0f; curTime = 0.0f;
isFirstStep = 1; isFirstStep = 1;
useFileInput = false; useFileInput = false;
Simulation::initBoundaries(myScenario); initBoundaries(myScenario);
if (visInfo != NULL) {
wScale = visInfo->waterVerticalScaling();
bScale = visInfo->bathyVerticalScaling();
bOffset = visInfo->bathyVerticalOffset();
} else {
getScalingApproximation(splash->getWaterHeight(), splash->getBathymetry());
}
} }
/** /**
...@@ -79,7 +71,7 @@ void Simulation::runCuda(struct cudaGraphicsResource **vbo_resource, struct cuda ...@@ -79,7 +71,7 @@ void Simulation::runCuda(struct cudaGraphicsResource **vbo_resource, struct cuda
{ {
// map OpenGL buffer object for writing from CUDA // map OpenGL buffer object for writing from CUDA
float3 *dptr, *dptr2; float3 *dptr, *dptr2;
size_t num_bytes, num_bytes2; std::size_t num_bytes, num_bytes2;
cudaGraphicsMapResources(1, vbo_resource, 0); cudaGraphicsMapResources(1, vbo_resource, 0);
cudaGraphicsResourceGetMappedPointer((void **)&dptr, &num_bytes, cudaGraphicsResourceGetMappedPointer((void **)&dptr, &num_bytes,
...@@ -155,7 +147,7 @@ void Simulation::setBathBuffer(float* bath) { ...@@ -155,7 +147,7 @@ void Simulation::setBathBuffer(float* bath) {
for (int j=0; j<ny+1;j++) { for (int j=0; j<ny+1;j++) {
for (int i=0;i<nx+1;i++) { for (int i=0;i<nx+1;i++) {
bath[(j*(ny+1) + i)*6] = (float) i; bath[(j*(ny+1) + i)*6] = (float) i;
bath[(j*(ny+1) + i)*6 + 1]= bScale * 0.25f * (b[i][j]+b[i+1][j]+b[i][j+1]+b[i+1][j+1]) + bOffset; bath[(j*(ny+1) + i)*6 + 1]= 0.25f * (b[i][j]+b[i+1][j]+b[i][j+1]+b[i+1][j+1]);
bath[(j*(ny+1) + i)*6 + 2] = (float) j; bath[(j*(ny+1) + i)*6 + 2] = (float) j;
bath[(j*(ny+1) + i)*6 + 3] = 0.0f; bath[(j*(ny+1) + i)*6 + 3] = 0.0f;
bath[(j*(ny+1) + i)*6 + 4] = 0.0f; bath[(j*(ny+1) + i)*6 + 4] = 0.0f;
...@@ -248,11 +240,12 @@ void Simulation::calculateWaterSurface(float3* destBuffer) { ...@@ -248,11 +240,12 @@ void Simulation::calculateWaterSurface(float3* destBuffer) {
Gets called before simulation starts and determines the average, Gets called before simulation starts and determines the average,
mininimum and maximum values of the bathymetry and water surface data. mininimum and maximum values of the bathymetry and water surface data.
Uses latter values to estimate the scaling factors. Uses latter values to estimate the scaling factors.
@param h Fload2D array that holds water height
@param b Fload2D array that holds bathymetry data
*/ */
void Simulation::getScalingApproximation(const Float2D& h, const Float2D& b) void Simulation::getScalingApproximation(float &bScale, float &bOffset, float &wScale)
{ {
const Float2D &h = splash->getWaterHeight();
const Float2D &b = splash->getBathymetry();
// Minimum values // Minimum values
float minB, minH; float minB, minH;
// Maximum values // Maximum values
...@@ -282,7 +275,7 @@ void Simulation::getScalingApproximation(const Float2D& h, const Float2D& b) ...@@ -282,7 +275,7 @@ void Simulation::getScalingApproximation(const Float2D& h, const Float2D& b)
} }
} }
bOffset = 0; // This should be !=0 only in some artificial scenarios bOffset = 0; // This should be !=0 only in some artificial scenarios
bScale = -50/minB; bScale = -100/minB;
cout << "Scaling of bathymetry: " << bScale << endl; cout << "Scaling of bathymetry: " << bScale << endl;
if ((maxH - minH) < 0.0001f) { if ((maxH - minH) < 0.0001f) {
...@@ -290,7 +283,7 @@ void Simulation::getScalingApproximation(const Float2D& h, const Float2D& b) ...@@ -290,7 +283,7 @@ void Simulation::getScalingApproximation(const Float2D& h, const Float2D& b)
} else { } else {
wScale = 1.0f; wScale = 1.0f;
} }
wScale = (maxDim/40.0)*wScale; wScale = (maxDim/50.0)*wScale;
cout << "Scaling of water level: " << wScale << endl; cout << "Scaling of water level: " << wScale << endl;
} }
...@@ -353,7 +346,7 @@ float scaleFunction(float val, float scale) { ...@@ -353,7 +346,7 @@ float scaleFunction(float val, float scale) {
*/ */
__global__ __global__
void kernelCalcVisBuffer(float3* visBuffer, const float* hd, const float* bd, void kernelCalcVisBuffer(float3* visBuffer, const float* hd, const float* bd,
int nx, int ny, float scale) int nx, int ny)
{ {
int i = TILE_SIZE*blockIdx.x + threadIdx.x; int i = TILE_SIZE*blockIdx.x + threadIdx.x;
int j = TILE_SIZE*blockIdx.y + threadIdx.y; int j = TILE_SIZE*blockIdx.y + threadIdx.y;
...@@ -368,7 +361,7 @@ void kernelCalcVisBuffer(float3* visBuffer, const float* hd, const float* bd, ...@@ -368,7 +361,7 @@ void kernelCalcVisBuffer(float3* visBuffer, const float* hd, const float* bd,
else else
visBuffer[j*(ny+1) + i] = make_float3( visBuffer[j*(ny+1) + i] = make_float3(
i, i,
scale * 0.25 * ( 0.25 * (
hd[index]+hd[index + 1]+ hd[index2] + hd[index2 + 1] + hd[index]+hd[index + 1]+ hd[index2] + hd[index2 + 1] +
bd[index]+bd[index + 1]+ bd[index2] + bd[index2 + 1]), bd[index]+bd[index + 1]+ bd[index2] + bd[index2 + 1]),
j); j);
...@@ -397,7 +390,7 @@ void Simulation::updateVisBuffer(float3* _visBuffer) { ...@@ -397,7 +390,7 @@ void Simulation::updateVisBuffer(float3* _visBuffer) {
// Interpolate cell centered h-values // Interpolate cell centered h-values
dim3 dimBlock(TILE_SIZE,TILE_SIZE); dim3 dimBlock(TILE_SIZE,TILE_SIZE);
dim3 dimGrid((nx+TILE_SIZE)/TILE_SIZE,(ny+TILE_SIZE)/TILE_SIZE); dim3 dimGrid((nx+TILE_SIZE)/TILE_SIZE,(ny+TILE_SIZE)/TILE_SIZE);
kernelCalcVisBuffer<<<dimGrid,dimBlock>>>(_visBuffer, hd, bd, nx, ny, wScale); kernelCalcVisBuffer<<<dimGrid,dimBlock>>>(_visBuffer, hd, bd, nx, ny);
} }
/** /**
Function used for debugging. Outputs the current visBuffer Function used for debugging. Outputs the current visBuffer
......
...@@ -33,13 +33,13 @@ class Simulation { ...@@ -33,13 +33,13 @@ class Simulation {
public: public:
// Constructor + Destructor // Constructor + Destructor
Simulation (int nx, int ny, float dx, float dy, Simulation (int nx, int ny, float dx, float dy,
SWE_Scenario* scene, SWE_VisInfo* visInfo, SWE_BlockCUDA* init_splash); SWE_Scenario* scene, SWE_BlockCUDA* init_splash);
~Simulation(); ~Simulation();
// Restart simulation // Restart simulation
void restart(); void restart();
// Load new scenario after initialization // Load new scenario after initialization
void loadNewScenario(SWE_Scenario* scene, SWE_VisInfo* visInfo); void loadNewScenario(SWE_Scenario* scene);
// Save simulation state to file // Save simulation state to file
void saveToFile(); void saveToFile();
// Return the bathymetry data // Return the bathymetry data
...@@ -51,6 +51,7 @@ class Simulation { ...@@ -51,6 +51,7 @@ class Simulation {
void writeDebugOutput(float3* destBuffer = NULL); void writeDebugOutput(float3* destBuffer = NULL);
protected: protected:
public:
// Instance of SWE_BlockCUDA // Instance of SWE_BlockCUDA
SWE_BlockCUDA* splash; SWE_BlockCUDA* splash;
...@@ -63,8 +64,6 @@ class Simulation { ...@@ -63,8 +64,6 @@ class Simulation {
int isFirstStep; int isFirstStep;
// Maximum of cell sizes // Maximum of cell sizes
float maxCellSize; float maxCellSize;
// Scaling factors used by visualization
float bScale, bOffset, wScale;
// Initialize boundaries defined by the scene // Initialize boundaries defined by the scene
void initBoundaries(SWE_Scenario* scene); void initBoundaries(SWE_Scenario* scene);
// Initialize boundaries defined by an input file // Initialize boundaries defined by an input file
...@@ -79,7 +78,7 @@ class Simulation { ...@@ -79,7 +78,7 @@ class Simulation {
// Compute normals of the water surface for shading // Compute normals of the water surface for shading
void calculateNormals(float3* vertexBuffer, float3* destBuffer); void calculateNormals(float3* vertexBuffer, float3* destBuffer);
void getScalingApproximation(const Float2D& h, const Float2D& b); void getScalingApproximation(float &bScale, float &bOffset, float &wScale);
void updateVisBuffer(float3* _visBuffer); void updateVisBuffer(float3* _visBuffer);
void debugVisBuffer(float3* _visBuffer); void debugVisBuffer(float3* _visBuffer);
......
...@@ -89,7 +89,7 @@ public: ...@@ -89,7 +89,7 @@ public:
glGenTextures(1, &texture); glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture); glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, 4, surf->w, surf->h, 0, GL_BGRA, glTexImage2D(GL_TEXTURE_2D, 0, 4, surf->w, surf->h, 0, GL_BGRA,
GL_UNSIGNED_BYTE, surf->pixels ); GL_UNSIGNED_BYTE, surf->pixels);
/* GL_NEAREST looks horrible, if scaled... */ /* GL_NEAREST looks horrible, if scaled... */
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
......
/**
* @file
* This file is part of SWE.
*
* @author Sebastian Rettenberger (rettenbs AT in.tum.de, http://www5.in.tum.de/wiki/index.php/Sebastian_Rettenberger,_M.Sc.)
*
* @section LICENSE
*
* SWE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SWE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SWE. If not, see <http://www.gnu.org/licenses/>.
*/
#include "vbo.h"
#include "visualization.h"
void VBO::init()
{
if (glGenBuffers == 0L) {
// Load vbo extension
// Check OpenGL extension(s)
if (!Visualization::isExtensionSupported("GL_ARB_vertex_buffer_object")) {
tools::Logger::logger.printString("Vertex Buffer Objects Extension not supported! Exit..\n");
SDL_Quit();
exit(1);
}
// Load Vertex Buffer Extension
glGenBuffers = (PFNGLGENBUFFERSARBPROC) SDL_GL_GetProcAddress("glGenBuffersARB");
glBindBuffer = (PFNGLBINDBUFFERARBPROC) SDL_GL_GetProcAddress("glBindBufferARB");
glBufferData = (PFNGLBUFFERDATAARBPROC) SDL_GL_GetProcAddress("glBufferDataARB");
glDeleteBuffers = (PFNGLDELETEBUFFERSARBPROC) SDL_GL_GetProcAddress("glDeleteBuffersARB");
}
glGenBuffers(1, &name);
}
PFNGLGENBUFFERSARBPROC VBO::glGenBuffers = 0L;
PFNGLBINDBUFFERARBPROC VBO::glBindBuffer = 0L;
PFNGLBUFFERDATAARBPROC VBO::glBufferData = 0L;
PFNGLDELETEBUFFERSARBPROC VBO::glDeleteBuffers = 0L;
/**
* @file
* This file is part of SWE.
*
* @author Sebastian Rettenberger (rettenbs AT in.tum.de, http://www5.in.tum.de/wiki/index.php/Sebastian_Rettenberger,_M.Sc.)
*
* @section LICENSE
*
* SWE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SWE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SWE. If not, see <http://www.gnu.org/licenses/>.
*
*
* @section DESCRIPTION
*
* Handles a VertexBufferObject.
*/
#ifndef VBO_H
#define VBO_H
#include "../tools/Logger.hpp"
#include <SDL_opengl.h>
class VBO
{
private:
/** OpenGL name of the object */
GLuint name;
public:
VBO()
: name(0)
{}
/**
* Initializes the object
*/
void init();
/**
* @return The OpenGL name of the buffer
*/
GLuint getName()
{
return name;
}
void setBufferData(GLsizei size, const void* data,
GLenum target = GL_ARRAY_BUFFER,
GLenum usage = GL_STATIC_DRAW)
{
glBindBuffer(target, name);
glBufferData(target, size, data, usage);
glBindBuffer(target, 0);
}
void bindBuffer(GLenum target = GL_ARRAY_BUFFER)
{
glBindBuffer(target, name);
}
/**
* Frees all associated memory
*/
void finialize()
{
if (name) {
glDeleteBuffers(1, &name);
name = 0;
}
}
private:
// VBO Extension Function Pointers
static PFNGLGENBUFFERSARBPROC glGenBuffers; // VBO Name Generation Procedure
static PFNGLBINDBUFFERARBPROC glBindBuffer; // VBO Bind Procedure
static PFNGLBUFFERDATAARBPROC glBufferData; // VBO Data Loading Procedure
static PFNGLDELETEBUFFERSARBPROC glDeleteBuffers; // VBO Deletion Procedure
};
#endif // VBO_H
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
// along with SWE_CUDA. If not, see <http://www.gnu.org/licenses/>. // along with SWE_CUDA. If not, see <http://www.gnu.org/licenses/>.
// ===================================================================== // =====================================================================
uniform float scale = 10;
varying vec3 N; varying vec3 N;
varying vec4 ambient; varying vec4 ambient;
varying vec4 worldCoordinates; varying vec4 worldCoordinates;
...@@ -34,7 +35,7 @@ void main() ...@@ -34,7 +35,7 @@ void main()
N = normalize(gl_NormalMatrix * gl_Normal); N = normalize(gl_NormalMatrix * gl_Normal);
// Save world coordinates // Save world coordinates
worldCoordinates = gl_Vertex; worldCoordinates = gl_Vertex * scale;
// Compute vertex position via internal transform function // Compute vertex position via internal transform function
gl_Position = ftransform(); gl_Position = ftransform();
......
This diff is collapsed.
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#include "camera.h" #include "camera.h"
#include "simulation.h" #include "simulation.h"
#include "shader.h" #include "shader.h"
#include "vbo.h"
#include "../scenarios/SWE_VisInfo.h"
#ifdef USESDLTTF #ifdef USESDLTTF
#include "text.h" #include "text.h"
#endif // USESDLTTF #endif // USESDLTTF
...@@ -40,7 +42,8 @@ public: ...@@ -40,7 +42,8 @@ public:
// Constructor and Destructor // Constructor and Destructor
Visualization(int windowWidth, int windowHeight, const char* window_title, int _grid_xsize, int _grid_ysize); Visualization(int windowWidth, int windowHeight, const char* window_title, int _grid_xsize, int _grid_ysize);
~Visualization(); ~Visualization();
void init(Simulation* sim);
void init(Simulation &sim, SWE_VisInfo *visInfo = 0L);
void cleanUp(); void cleanUp();
Camera* camera; Camera* camera;
...@@ -51,49 +54,60 @@ public: ...@@ -51,49 +54,60 @@ public:
// Main rendering function // Main rendering function
void renderDisplay(); void renderDisplay();
// Rescale water
void modifyWaterScaling(float factor);
// Helper functions // Helper functions
void setRenderingMode(RenderMode mode); void setRenderingMode(RenderMode mode);
void updateBathymetryVBO(Simulation* sim);
void toggleRenderingMode(); void toggleRenderingMode();
int resizeWindow(int newWidth, int newHeight); int resizeWindow(int newWidth, int newHeight);
static bool isExtensionSupported(const char* szTargetExtension );
private: private:
// Init helper functions // Init helper functions
void initSDL(int windowWidth, int windowHeight); void initSDL(int windowWidth, int windowHeight);
void initGLWindow(int width, int height); void initGLWindow(int width, int height);
void initGLDefaults(); void initGLDefaults();
void initCUDA(); void initCUDA();
bool IsExtensionSupported(const char* szTargetExtension );
void updateBathymetryVBO(Simulation &sim);
// Drawing functions // Drawing functions
void DrawWaterSurface(GLuint vboID, GLuint vboNormals, GLuint verticesIndex); void DrawWaterSurface();
void DrawBathymetry(GLuint vboID, GLuint verticesIndex); void DrawBathymetry();
void DrawBottom(); void DrawBottom();
int grid_xsize; int grid_xsize;
int grid_ysize; int grid_ysize;
// Vertex Buffer objects // Vertex Buffer objects
GLuint vboBathymetry; VBO vboBathymetry;
GLuint verticesIndex; VBO vboVerticesIndex;
GLuint vboWaterSurface; VBO vboWaterSurface;
GLuint vboNormals; VBO vboNormals;
// Bathymetry color
VBO vboBathColor;
struct cudaGraphicsResource* cuda_vbo_watersurface; struct cudaGraphicsResource* cuda_vbo_watersurface;
struct cudaGraphicsResource* cuda_vbo_normals; struct cudaGraphicsResource* cuda_vbo_normals;
// VBO management functions // VBO management functions
void createIndicesVBO(GLuint* vboID, int xsize, int ysize); void createIndicesVBO(int xsize, int ysize);
void createVertexVBO(GLuint* vboID, int size); void createVertexVBO(VBO &vbo, struct cudaGraphicsResource *&vbo_res,
void createBathymetryVBO(GLuint* vboID, int size, Simulation* sim);
void createVertexVBO(GLuint* vboID, int size, struct cudaGraphicsResource **vbo_res,
unsigned int vbo_res_flags); unsigned int vbo_res_flags);
void deleteVBO(GLuint* vbo);
void deleteVBO(GLuint* vbo, struct cudaGraphicsResource *vbo_res); void deleteCudaResource(struct cudaGraphicsResource *&vbo_res);
// Rendering mode // Rendering mode
RenderMode renderMode; RenderMode renderMode;
// Shader helper class // Water/Bathymetry scaling/offset
Shader* shaders; float wScale, bScale, bOffset;
/** Location of the water scaling in the shader */
GLint wScaleLocation;
// Shaders
Shader* waterShader;
#ifdef USESDLTTF #ifdef USESDLTTF
// Text helper class // Text helper class
...@@ -104,10 +118,10 @@ private: ...@@ -104,10 +118,10 @@ private:
// Helper function // Helper function
int coord(int x, int y, int width = -1); int coord(int x, int y, int width = -1);
// VBO Extension Function Pointers static void height2Color(float height, GLfloat *color);
PFNGLGENBUFFERSARBPROC glGenBuffers; // VBO Name Generation Procedure static GLfloat mix(GLfloat a, GLfloat b, float factor)
PFNGLBINDBUFFERARBPROC glBindBuffer; // VBO Bind Procedure {
PFNGLBUFFERDATAARBPROC glBufferData; // VBO Data Loading Procedure return a * (1-factor) + b * factor;
PFNGLDELETEBUFFERSARBPROC glDeleteBuffers; // VBO Deletion Procedure }
}; };
#endif #endif
/**
* @file
* This file is part of SWE.
*
* @author Sebastian Rettenberger (rettenbs AT in.tum.de, http://www5.in.tum.de/wiki/index.php/Sebastian_Rettenberger,_M.Sc.)
*
* @section LICENSE
*
* SWE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SWE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SWE. If not, see <http://www.gnu.org/licenses/>.
*
*
* @section DESCRIPTION
*
* Rescale water height in small Japan scenario
*/
#ifndef SWEASAGISCENARIO_VIS_HPP_
#define SWEASAGISCENARIO_VIS_HPP_
#include "SWE_VisInfo.h"
class SWE_AsagiJapanSmallVisInfo : public SWE_VisInfo
{
public:
virtual float waterVerticalScaling() { return 4.0f; };
virtual float bathyVerticalScaling() { return 0.010313f; };
};
#endif // SWEASAGISCENARIO_VIS_HPP_
...@@ -28,7 +28,8 @@ ...@@ -28,7 +28,8 @@
* Set bathymetry offset hence it is visible in the screen * Set bathymetry offset hence it is visible in the screen
*/ */
class SWE_BathymetryDamBreakVisInfo : public SWE_VisInfo { class SWE_BathymetryDamBreakVisInfo : public SWE_VisInfo {
float bathyVerticalOffset() { return 2500.0f; }; public:
float bathyVerticalOffset() { return 2450.0f; };
}; };
#endif #endif
/**
* @file
* This file is part of SWE.
*
* @author Sebastian Rettenberger (rettenbs AT in.tum.de, http://www5.in.tum.de/wiki/index.php/Sebastian_Rettenberger,_M.Sc.)
*
* @section LICENSE
*
* SWE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SWE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SWE. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Logger.hpp"
tools::Logger tools::Logger::logger;
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* This file is part of SWE. * This file is part of SWE.
* *
* @author Alexander Breuer (breuera AT in.tum.de, http://www5.in.tum.de/wiki/index.php/Dipl.-Math._Alexander_Breuer) * @author Alexander Breuer (breuera AT in.tum.de, http://www5.in.tum.de/wiki/index.php/Dipl.-Math._Alexander_Breuer)
* @author Sebastian Rettenberger (rettenbs AT in.tum.de, http://www5.in.tum.de/wiki/index.php/Sebastian_Rettenberger,_M.Sc.)
* *
* @section LICENSE * @section LICENSE
* *
...@@ -152,7 +153,7 @@ class tools::Logger { ...@@ -152,7 +153,7 @@ class tools::Logger {
* @param i_largeDelimiter definition of the large delimiter. * @param i_largeDelimiter definition of the large delimiter.
* @param i_indentation definition of the indentation (used in all messages, except welcome, start and finish). * @param i_indentation definition of the indentation (used in all messages, except welcome, start and finish).
*/ */
Logger( const int i_processRank = 0, Logger( const int i_processRank = -1,
const std::string i_programName = "SWE", const std::string i_programName = "SWE",
const std::string i_welcomeMessage = "Welcome to", const std::string i_welcomeMessage = "Welcome to",
const std::string i_copyRights = "\n\nSWE Copyright (C) 2012\n" const std::string i_copyRights = "\n\nSWE Copyright (C) 2012\n"
...@@ -180,9 +181,13 @@ class tools::Logger { ...@@ -180,9 +181,13 @@ class tools::Logger {
//set time to zero //set time to zero
cpuTime = cpuCommTime = wallClockTime = 0.; cpuTime = cpuCommTime = wallClockTime = 0.;
#ifndef USEMPI #ifdef USEMPI
// determine local MPI rank
MPI_Comm_rank(MPI_COMM_WORLD, &processRank);
#else
processRank = 0;
printWelcomeMessage(); printWelcomeMessage();
#endif #endif
} }
/** /**
...@@ -503,6 +508,10 @@ class tools::Logger { ...@@ -503,6 +508,10 @@ class tools::Logger {
<< i_cpuCommunicationTimeMessage << ": " << i_cpuCommunicationTimeMessage << ": "
<< cpuCommTime << " seconds"<< std::endl; << cpuCommTime << " seconds"<< std::endl;
} }
public:
/** The logger all classes shoud use */
static Logger logger;
}; };
......
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