Commit 2d03faab authored by bader's avatar bader

added scenarios for SWE-OpenGL version

parent 1ed5fdb6
#ifndef __SWE_VISINFO_H
#define __SWE_VISINFO_H
// =====================================================================
// This file is part of SWE_CUDA (see file SWE_Block.cu for details).
//
// Copyright (C) 2010,2011 Michael Bader, Kaveh Rahnema, Tobias Schnabel
//
// SWE_CUDA is free software: you can redristribute 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_CUDA 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_CUDA. If not, see <http://www.gnu.org/licenses/>.
// =====================================================================
/**
* SWE_VisInfo defines an interface that can be used for online
* visualisation of a shallow water simulation.
* In particular, it provides information required for proper
* scaling of the involved variables.
*/
class SWE_VisInfo {
public:
// Scaling factors for custom visualization
// virtual bool useCustomScaling() { return false; };
virtual float waterHeightAtRest() { return 10.0f; };
virtual float waterDistanceFromGround() { return 10.0f; };
virtual float waterVerticalScaling() { return 10.0f; };
virtual float bathyVerticalCenter() { return 0.0f; };
virtual float bathyDistanceFromGround() { return 0.0f; };
virtual float bathyVerticalScaling() { return 10.0f; };
};
#endif
#include "SWE_VtkScenario.h"
#include <fstream>
#include <algorithm>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
/**
* Protected Constructor for class SWE_VtkScenario:
* called by readVtkFile to create an object of correct size
* NOTE: the provided number of cells in x and y direction includes ghost cells
* @param nx cells in x direction
* @param ny cells in y direction
*/
SWE_VtkScenario::SWE_VtkScenario(int nx, int ny)
: h(nx,ny),u(nx,ny),v(nx,ny),b(nx,ny)
{
cout << "Create VtkScenario of size " << nx << 'x' << ny << endl;
// set illegal value for dx and dy
// -> to be overwritten by readVtkFile
dx = -1.0; dy = -1.0;
}
/**
* get water height at specified position (piecewise constant interpolation);
* @param x position x-coordinate
* @param y position y-coordinate
*/
float SWE_VtkScenario::getWaterHeight(float x, float y)
{
if (x<0 || x >1) std::cout << "ERROR in x coordinate: " << x << endl << flush;
if (y<0 || y >1) std::cout << "ERROR in y coordinate: " << y << endl << flush;
int i = int((x-bndPos[BND_LEFT])/dx);
int j = int((y-bndPos[BND_BOTTOM])/dy);
if (i<0 || i >h.getCols())
std::cout << "ERROR in i coordinate: " << i
<< " with x coordinate: " << x
<< " offset " << (x-bndPos[BND_LEFT]) << '/' << dx << endl << flush;
if (j<0 || j >h.getRows()) std::cout << "ERROR in j coordinate: " << j
<< " with y coordinate: " << y << endl << flush;
return h[i][j];
}
/**
* get velocity (x-direction) at specified position (piecewise constant interpolation);
* @param x position x-coordinate
* @param y position y-coordinate
*/
float SWE_VtkScenario::getVeloc_u(float x, float y)
{
int i = int((x-bndPos[BND_LEFT])/dx);
int j = int((y-bndPos[BND_BOTTOM])/dy);
return u[i][j];
}
/**
* get velocity (x-direction) at specified position (piecewise constant interpolation);
* @param x position x-coordinate
* @param y position y-coordinate
*/
float SWE_VtkScenario::getVeloc_v(float x, float y)
{
int i = int((x-bndPos[BND_LEFT])/dx);
int j = int((y-bndPos[BND_BOTTOM])/dy);
return v[i][j];
}
/**
* get bathymetry at specified position (piecewise constant interpolation);
* @param x position x-coordinate
* @param y position y-coordinate
*/
float SWE_VtkScenario::getBathymetry(float x, float y)
{
int i,j;
if (x<0) {
std::cout << "request left of boundary" << x << endl << flush;
i = 0;
} else if (x >1) {
std::cout << "request right of boundary" << x << endl << flush;
i = b.getCols()-1;
} else {
i = int((x-bndPos[BND_LEFT])/dx);
};
if (y<0) {
std::cout << "request below boundary" << y << endl << flush;
j = 0;
} else if (y>1) {
std::cout << "request above boundary" << y << endl << flush;
j = b.getRows()-1;
} else {
j = int((y-bndPos[BND_BOTTOM])/dy);
};
return b[i][j];
}
/**
* Read VTK file which was written by SWE_Block.
* Use finite state automaton to parse input data.
* @param filename input filename
*/
SWE_VtkScenario* SWE_VtkScenario::readVtkFile(char const * filename)
{
// Helper variables
string line;
int state = 0;
int lineCount = 0;
int totalLines = 0;
int offsetCount = 0;
int dimx, dimy;
SWE_VtkScenario* scene;
float* h = NULL;
float* u = NULL;
float* v = NULL;
float* b = NULL;
int i,j;
int lastElem = 0;
size_t found;
vector<string> values;
// Open file
ifstream file(filename, ios::in);
if (!file.good()) {
std::cout << "Couldn't open file: " << filename << "\n";
return NULL;
}
// Count lines
totalLines = std::count(std::istreambuf_iterator<char>(file),
std::istreambuf_iterator<char>(), '\n');
file.seekg (0, ios::beg);
// Read line by line
while (std::getline(file,line)) {
// Skip empty lines
lineCount++;
if (! line.length()) continue;
// Convert to lower case
std::transform(line.begin(), line.end(),line.begin(), ::tolower);
// Output progress
if (lineCount % 10000 == 0 || lineCount == totalLines) {
std::cout << "\r" << "Reading input file: " <<
(lineCount*100)/totalLines << "% completed. " << flush;
}
switch(state)
{
// Header part
case 0:
found = line.find("# vtk datafile");
if (found!=string::npos) {
state = 1;
}
break;
case 1:
state = 2;
break;
case 2:
if (line.find("ascii") == 0) {
state = 3;
}
break;
case 3:
if (line.find("dataset structured_grid") == 0) {
state = 4;
}
break;
case 4:
found = line.find("dimensions");
if (found!=string::npos) {
stringExplode(line," ", &values);
if (values.size() != 4) {
state = -1;
} else {
dimx = atoi(values[1].c_str()) - 1;
dimy = atoi(values[2].c_str()) - 1;
cout << "Read grid dimensions " << dimx << 'x' << dimy << endl;
scene = new SWE_VtkScenario(dimx,dimy);
h = scene->h.elemVector();
u = scene->u.elemVector();
v = scene->v.elemVector();
b = scene->b.elemVector();
lastElem = dimx*dimy-1;
state = 5;
}
}
break;
// Data part
case 5:
// read grid data stored in VTK file
found = line.find(" 0 ");
if (found != string::npos && scene->dx <= 0.0f) {
stringExplode(line," ", &values);
scene->dx = (float) atof(values[0].c_str());
// TODO:
// --> this will change, if VTK files can have other origins than (0,0)
scene->bndPos[BND_BOTTOM] = 0.0;
scene->bndPos[BND_TOP] = dimx*scene->dx;
}
if (line.substr(0,2) == "0 " && scene->dy <= 0.0f) {
stringExplode(line," ", &values);
scene->dy = (float) atof(values[1].c_str());
// TODO:
// --> this will change, if VTK files can have other origins than (0,0)
scene->bndPos[BND_LEFT] = 0.0;
scene->bndPos[BND_RIGHT] = dimy*scene->dy;
}
found = line.find("scalars h");
if (found != string::npos) {
state = 10;
}
break;
case 10:
found = line.find("lookup_table");
if (found!=string::npos) {
state = 11;
offsetCount = 0;
}
break;
case 11:
// Read h-values
i = offsetCount%dimx; j= offsetCount/dimx;
h[i*dimy+j] = (float) atof(line.c_str());
if (offsetCount < lastElem)
offsetCount++;
else
state = 12;
break;
case 12:
found = line.find("scalars u");
if (found!=string::npos) {
state = 20;
}
break;
case 20:
found = line.find("lookup_table");
if (found!=string::npos) {
state = 21;
offsetCount = 0;
}
break;
case 21:
// Read u-values
i = offsetCount%dimx; j= offsetCount/dimx;
u[i*dimy+j] = (float) atof(line.c_str());
if (offsetCount < lastElem)
offsetCount++;
else
state = 22;
break;
case 22:
found = line.find("scalars v");
if (found!=string::npos) {
state = 30;
}
break;
case 30:
found = line.find("lookup_table");
if (found!=string::npos) {
state = 31;
offsetCount = 0;
}
break;
case 31:
// Read v-values
i = offsetCount%dimx; j= offsetCount/dimx;
v[i*dimy+j] = (float) atof(line.c_str());
if (offsetCount < lastElem)
offsetCount++;
else
state = 32;
break;
case 32:
found = line.find("scalars b");
if (found!=string::npos) {
state = 40;
}
break;
case 40:
found = line.find("lookup_table");
if (found!=string::npos) {
state = 41;
offsetCount = 0;
}
break;
case 41:
// Read b-values
i = offsetCount%dimx; j= offsetCount/dimx;
i = i*dimy+j;
b[i] = (float) atof(line.c_str());
h[i] = h[i] - b[i];
if (offsetCount < lastElem)
offsetCount++;
else
state = 42;
break;
default:
break;
}
}
std::cout << std::endl;
// Close file
file.close();
// delete allocated scene object
if (state >= 5 && state < 42)
delete scene;
// return NULL pointer in case of error
if (state < 42) {
std::cout << "Parsing Error " << state << " -> Omitting input file." << std::endl;
return NULL;
}
cout << "Read input data into scenario: " << endl
<< (*scene) << endl;
scene->computeHeightAtRest();
// return pointer to scene, if everything went OK
return scene;
}
/**
* Computes an estimate of the water height at rest
* (considering water height h plus bathymetry b)
* -> average value of h+b (considering only cells with h>0).
* Value is stored in member variable heightAtRest
*/
void SWE_VtkScenario::computeHeightAtRest()
{
float havg = 0.0;
int cnt = 0;
for(int i=0;i<h.getRows();i++)
for(int j=0;j<h.getCols();j++)
if (h[i][j] > 0.0f) {
havg += h[i][j] + b[i][j];
cnt++;
};
heightAtRest = havg/cnt;
}
/**
Split a string by seperator into substrings and return them as
an array
@param str string to split
@param separator delimiter string
@return results array containing all substrings
*/
void SWE_VtkScenario::stringExplode(string str, string separator, vector<string>* results){
size_t found;
results->clear();
found = str.find_first_of(separator);
while(found != string::npos){
if(found > 0){
results->push_back(str.substr(0,found));
}
str = str.substr(found+1);
found = str.find_first_of(separator);
}
if(str.length() > 0){
results->push_back(str);
}
}
//==================================================================
// external class-related methods
//==================================================================
/**
* overload operator<< such that data can be written via cout <<
* -> needs to be declared as friend to be allowed to access private data
*/
ostream& operator<<(ostream& os, SWE_VtkScenario& scene) {
int nx = scene.h.getCols();
int ny = scene.h.getRows();
os << "Gitterzellen: " << nx << "x" << ny << endl;
cout << "Wellenhoehe:" << endl;
for(int i=0; i<nx; i++) {
for(int j=0; j<ny; j++) {
os << scene.h[i][j] << " ";
};
os << endl;
};
cout << "Geschwindigkeit in x-Richtung:" << endl;
for(int i=0; i<nx; i++) {
for(int j=0; j<ny; j++) {
os << scene.u[i][j] << " ";
};
os << endl;
};
cout << "Geschwindigkeit in y-Richtung:" << endl;
for(int i=0; i<nx; i++) {
for(int j=0; j<ny; j++) {
os << scene.v[i][j] << " ";
};
os << endl;
};
cout << "Bathymetry:" << endl;
for(int i=0; i<nx; i++) {
for(int j=0; j<ny; j++) {
os << scene.b[i][j] << " ";
};
os << endl;
};
os << flush;
return os;
}
#ifndef __SWE_VTK_SCENARIO_H
#define __SWE_VTK_SCENARIO_H
// =====================================================================
// This file is part of SWE_CUDA (see file SWE_Block.cu for details).
//
// Copyright (C) 2010,2011 Michael Bader, Kaveh Rahnema, Tobias Schnabel
//
// SWE_CUDA is free software: you can redristribute 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_CUDA 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_CUDA. If not, see <http://www.gnu.org/licenses/>.
// =====================================================================
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <string>
#include <vector>
#include "../tools/help.hh"
#include "SWE_Scenario.h"
using namespace std;
/**
* Scenario "VTK File":
* the object will read the values stored in a VTK file
* (i.e., use such a visualisation file as checkpoint for restarting a simulation)
*
* Note: - Boundary Conditions are NOT stored in a VTK file;
* OUTFLOW conditions are assumed at all boundaries
* - similar, 0.1 is always returnedby function endSimulation()
*
* TODO: Option to read a VTK container file
* (for example: read by different MPI processes, such that each MPI process
* will represent one of the container's VTK files)
*/
class SWE_VtkScenario : public SWE_Scenario {
public:
// SWE_VtkScenario does not offer a public constructor
// -> use this method to create a SWE_VtkScenario object
static SWE_VtkScenario* readVtkFile(char const * filename);
virtual float getWaterHeight(float x, float y);
virtual float getVeloc_u(float x, float y);
virtual float getVeloc_v(float x, float y);
virtual float getBathymetry(float x, float y);
virtual float waterHeightAtRest() { return heightAtRest; };
virtual void setWaterHeightAtRest(float whar) { heightAtRest = whar; };
virtual BoundaryType getBoundaryType(BoundaryEdge edge) { return OUTFLOW; };
virtual float getBoundaryPos(BoundaryEdge edge) { return bndPos[edge]; };
protected:
SWE_VtkScenario(int nx, int ny);
Float2D h;
Float2D u;
Float2D v;
Float2D b;
float heightAtRest;
float bndPos[4];
float dx;
float dy;
void computeHeightAtRest();
static void stringExplode(string str, string separator, vector<string>* results);
friend ostream& operator<< (ostream& os, SWE_VtkScenario& scene);
};
ostream& operator<< (ostream& os, const SWE_VtkScenario& scene);
#endif
#include "SWE_VtkScenarioVisInfo.h"
#include <fstream>
#include <algorithm>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
using namespace std;
/**
* Protected Constructor for class SWE_VtkScenarioVisInfo:
* called by readVtkFile to create an object of correct size;
* only calls constructor of SWE_VtkScenario
* NOTE: the provided number of cells in x and y direction includes ghost cells
* @param nx cells in x direction
* @param ny cells in y direction
*/
SWE_VtkScenarioVisInfo::SWE_VtkScenarioVisInfo(int nx, int ny)
: SWE_VtkScenario(nx,ny)
{
}
/**
* Read VTK file which was written by SWE_Block.
* Use finite state automaton to parse input data.
* @param filename input filename
*/
SWE_VtkScenarioVisInfo* SWE_VtkScenarioVisInfo::readVtkFile(char const * filename)
{
// Helper variables
string line;
int state = 0;
int lineCount = 0;
int totalLines = 0;
int offsetCount = 0;
int dimx, dimy;
SWE_VtkScenarioVisInfo* scene;
float* h = NULL;
float* u = NULL;
float* v = NULL;
float* b = NULL;
size_t found;
vector<string> values;
// Open file
ifstream file(filename, ios::in);
if (!file.good()) {
std::cout << "Couldn't open file: " << filename << "\n";
return NULL;
}
// Count lines
totalLines = std::count(std::istreambuf_iterator<char>(file),
std::istreambuf_iterator<char>(), '\n');
file.seekg (0, ios::beg);
// Read line by line
while (std::getline(file,line)) {
// Skip empty lines
lineCount++;
if (! line.length()) continue;
// Convert to lower case
offsetCount++;
std::transform(line.begin(), line.end(),line.begin(), ::tolower);
// Output progress
if (lineCount % 10000 == 0 || lineCount == totalLines) {
std::cout << "\r" << "Reading input file: " <<
(lineCount*100)/totalLines << "% completed. " << flush;
}
switch(state)
{
// Header part
case 0:
found = line.find("# vtk datafile");
if (found!=string::npos) {
state = 1;
}
break;
case 1:
state = 2;
break;
case 2:
if (line.find("ascii") == 0) {
state = 3;
}
break;
case 3:
if (line.find("dataset structured_grid") == 0) {
state = 4;
}
break;
case 4:
found = line.find("dimensions");
if (found!=string::npos) {
stringExplode(line," ", &values);
if (values.size() != 4) {
state = -1;
} else {
dimx = atoi(values[1].c_str());
dimy = atoi(values[2].c_str());
scene = new SWE_VtkScenarioVisInfo(dimx,dimy);
h = scene->h.elemVector();
u = scene->u.elemVector();
v = scene->v.elemVector();
b = scene->b.elemVector();
state = 5;
}
}
break;
// Data part
case 5:
// read grid data stored in VTK file
found = line.find(" 0 ");
if (found != string::npos && scene->dx <= 0.0f) {
stringExplode(line," ", &values);
scene->dx = (float) atof(values[0].c_str());
// TODO:
// --> this will change, if VTK files can have other origins than (0,0)
scene->bndPos[BND_LEFT] = 0.0;
scene->bndPos[BND_RIGHT] = dimx*scene->dx;
}
if (line.substr(0,2) == "0 " && scene->dy <= 0.0f) {
stringExplode(line," ", &values);
scene->dy = (float) atof(values[1].c_str());
// TODO:
// --> this will change, if VTK files can have other origins than (0,0)
scene->bndPos[BND_BOTTOM] = 0.0;
scene->bndPos[BND_TOP] = dimy*scene->dy;
}
found = line.find("scalars h");
if (found != string::npos) {
state = 10;
}
break;
case 10:
found = line.find("lookup_table");
if (found!=string::npos) {
state = 11;
offsetCount = 0;
}
break;
case 11:
// Read h-values
h[offsetCount - 1] = (float) atof(line.c_str());
if (offsetCount >= (dimx - 1)*(dimy - 1)) {
state = 12;
}
break;
case 12:
found = line.find("scalars u");
if (found!=string::npos) {
state = 20;
}
break;
case 20:
found = line.find("lookup_table");
if (found!=string::npos) {
state = 21;
offsetCount = 0;
}
break;
case 21:
// Read u-values
u[offsetCount - 1] = (float) atof(line.c_str());
if (offsetCount >= (dimx - 1)*(dimy - 1)) {
state = 22;
}
break;
case 22:
found = line.find("scalars v");
if (found!=string::npos) {
state = 30;
}
break;
case 30:
found = line.find("lookup_table");
if (found!=string::npos) {
state = 31;
offsetCount = 0;
}
break;
case 31:
// Read v-values
v[offsetCount - 1] = (float) atof(line.c_str());
if (offsetCount >= (dimx - 1)*(dimy - 1)) {
state = 32;
}
break;
case 32:
found = line.find("scalars b");
if (found!=string::npos) {
state = 40;
}
break;
case 40:
found = line.find("lookup_table");
if (found!=string::npos) {
state = 41;
offsetCount = 0;
}
break;
case 41:
// Read b-values
b[offsetCount - 1] = (float) atof(line.c_str());
h[offsetCount - 1] = h[offsetCount - 1] - b[offsetCount - 1];
if (offsetCount >= (dimx - 1)*(dimy - 1)) {
state = 42;
}
break;
default:
break;
}
}
std::cout << std::endl;
// Close file
file.close();
// delete allocated scene object
if (state >= 5 && state < 42)
delete scene;
// return NULL pointer in case of error
if (state < 42) {
std::cout << "Parsing Error. Omitting input file." << std::endl;
return NULL;
}
// std::cout << "Compute scaling Info for read file\n" << flush;
scene->computeHeightAtRest();
scene->computeScalingApproximation();
// return pointer to scene, if everything went OK
return scene;
}
/**
Computes a first approximation of the scaling values needed
for visualization.
Gets called after variables have been read from VTK file;
determines the average, mininimum and maximum values of the
bathymetry and water surface data.
Uses latter values to estimate the scaling factors.
*/
void SWE_VtkScenarioVisInfo::computeScalingApproximation() {
// Averages of B and (B + H)
float avgB, avgH;
// Minimum values
float minB, minH;
// Maximum values
float maxB, maxH;
int nx = h.getRows();
int ny = h.getCols();
int maxDim = (nx > ny) ? nx : ny;
// first, compute averages:
avgH = 0.0f;
avgB = 0.0f;
int cnt = 0;
for(int i=0; i<nx; i++)
for(int j=0; j<ny; j++)
if (h[i][j]> 0) {
// Update averages
avgH += (h[i][j] + b[i][j]);
avgB += b[i][j];
cnt++;
};
bAverage = avgB/cnt;
hAverage = avgH/cnt;
// then, conpute min and max values, using average values as initial guess
minB = bAverage;
maxB = bAverage;
minH = hAverage;
maxH = hAverage;
for(int i=0; i<nx; i++)
for(int j=0; j<ny; j++)
if (h[i][j]> 0) {
float bij = b[i][j];
float hbij = h[i][j] + bij;
// Update minima
minH = (hbij < minH) ? hbij : minH;
minB = (bij < minB) ? bij : minB;
// Update maxima
maxH = (hbij > maxH) ? hbij : maxH;
maxB = (bij > maxB) ? bij : maxB;
};
std::cout << "Computed min and max values for visualisation info: \n"
<< "h: max: " << maxH << ", min: " << minH << endl
<< "b: max: " << maxB << ", min: " << minB << endl
<< flush;
if (fabs(maxB - minB) > 0.0001f) {
bScale = (maxDim/20.0f)/(maxB - minB);
} else {
bScale = (maxDim/20.0f);
}
bOffset = bScale*(bAverage - minB) + maxDim/15.0f;
// alternative values
bScale = minB;
bOffset = bAverage;
if ((maxH - minH) < 0.0001f) {
hScale = 1.0f/(maxH- minH);
} else {
hScale = 1.0f;
}
hScale = maxDim*(hScale);
hOffset = bOffset + (maxDim/5.0f);
bScale = minH;
hOffset = hAverage;
std::cout << "Computed values for visualisation info: "
<< "average h: " << hAverage << "( bOffset:" << hOffset << ", scale: " << hScale << ");"
<< "average b: " << bAverage << "( bOffset:" << bOffset << ", scale: " << bScale << ");"
<< endl << flush;
}
#ifndef __SWE_VTK_SCENARIO_VISINFO_H
#define __SWE_VTK_SCENARIO_VISINFO_H
// =====================================================================
// This file is part of SWE_CUDA (see file SWE_Block.cu for details).
//
// Copyright (C) 2010,2011 Michael Bader, Kaveh Rahnema, Tobias Schnabel
//
// SWE_CUDA is free software: you can redristribute 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_CUDA 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_CUDA. If not, see <http://www.gnu.org/licenses/>.
// =====================================================================
#include "../tools/help.hh"
#include "SWE_VtkScenario.h"
#include "SWE_VisInfo.h"
/**
* Scenario "VTK File" incl. info for visualisation:
* extends Scenario SWE_VtkScenario
*/
class SWE_VtkScenarioVisInfo : public SWE_VtkScenario, public SWE_VisInfo {
public:
// SWE_VtkScenario does not offer a public constructor
// -> use this method to create a SWE_VtkScenario object
static SWE_VtkScenarioVisInfo* readVtkFile(char const * filename);
// Scaling factors for custom visualization
virtual float waterHeightAtRest() { return hAverage; };
virtual float waterDistanceFromGround() { return hOffset; };
virtual float waterVerticalScaling() { return hScale; };
virtual float bathyVerticalCenter() { return bAverage; };
virtual float bathyDistanceFromGround() { return bOffset; };
virtual float bathyVerticalScaling() { return bScale; };
protected:
SWE_VtkScenarioVisInfo(int nx, int ny);
void computeScalingApproximation();
float bAverage;
float hAverage;
float bScale;
float hScale;
float bOffset;
float hOffset;
};
#endif
#ifndef __SWE_SIMPLE_SCENARIOS_VIS_H
#define __SWE_SIMPLE_SCENARIOS_VIS_H
// =====================================================================
// This file is part of SWE_CUDA (see file SWE_Block.cu for details).
//
// Copyright (C) 2010,2011 Michael Bader, Kaveh Rahnema, Tobias Schnabel
//
// SWE_CUDA is free software: you can redristribute 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_CUDA 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_CUDA. If not, see <http://www.gnu.org/licenses/>.
// =====================================================================
#include <math.h>
#include "SWE_simple_scenarios.h"
#include "SWE_VisInfo.h"
/**
* Scenario "Radial Dam Break":
* elevated water in the center of the domain
*/
class SWE_RadialDamBreakScenarioVisInfo
: public SWE_RadialDamBreakScenario,
public SWE_VisInfo {
virtual float waterVerticalScaling() { return 5.0f; };
/* use inherited default implementations */
};
/**
* Scenario "Splashing Pool with custom scaling":
* intial water surface has a fixed slope (diagonal to x,y)
* shows how to use custom scaling to enhance visualization
* results
*/
class SWE_SplashingPoolScenarioVisInfo
: public SWE_SplashingPoolScenario,
public SWE_VisInfo {
public:
float waterDistanceFromGround() { return 9.0f; };
float waterVerticalScaling() { return 5.0f; };
float bathyVerticalCenter() { return 0.0f; };
float bathyDistanceFromGround() { return 0.0f; };
float bathyVerticalScaling() { return 0.0f; };
virtual BoundaryType getBoundaryType(BoundaryEdge edge) { return OUTFLOW; };
};
#endif
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