feat: boundary conditions
This commit is contained in:
parent
83ec8d7d9b
commit
1b4c92cadf
|
|
@ -54,19 +54,21 @@ add_executable(ParticleTrackTrace MACOSX_BUNDLE main.cpp
|
||||||
commands/CameraMoveCallback.cpp
|
commands/CameraMoveCallback.cpp
|
||||||
commands/CameraMoveCallback.h
|
commands/CameraMoveCallback.h
|
||||||
CartographicTransformation.cpp
|
CartographicTransformation.cpp
|
||||||
advection/AdvectionKernel.h
|
advection/kernel/AdvectionKernel.h
|
||||||
advection/EulerAdvectionKernel.cpp
|
advection/kernel/EulerAdvectionKernel.cpp
|
||||||
advection/EulerAdvectionKernel.h
|
advection/kernel/EulerAdvectionKernel.h
|
||||||
advection/interpolate.cpp
|
advection/interpolate.cpp
|
||||||
advection/interpolate.h
|
advection/interpolate.h
|
||||||
advection/readdata.cpp
|
advection/readdata.cpp
|
||||||
advection/readdata.h
|
advection/readdata.h
|
||||||
advection/RK4AdvectionKernel.cpp
|
advection/kernel/RK4AdvectionKernel.cpp
|
||||||
advection/RK4AdvectionKernel.h
|
advection/kernel/RK4AdvectionKernel.h
|
||||||
advection/UVGrid.cpp
|
advection/UVGrid.cpp
|
||||||
advection/UVGrid.h
|
advection/UVGrid.h
|
||||||
advection/Vel.cpp
|
advection/Vel.cpp
|
||||||
advection/Vel.h
|
advection/Vel.h
|
||||||
|
advection/kernel/SnapBoundaryConditionKernel.h
|
||||||
|
advection/kernel/SnapBoundaryConditionKernel.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
execute_process(
|
execute_process(
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
#include "Vel.h"
|
#include "../Vel.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Implement this class for every integration method.
|
* Implement this class for every integration method.
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
#include "EulerAdvectionKernel.h"
|
#include "EulerAdvectionKernel.h"
|
||||||
#include "interpolate.h"
|
#include "../interpolate.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#define EULERADVECTIONKERNEL_H
|
#define EULERADVECTIONKERNEL_H
|
||||||
|
|
||||||
#include "AdvectionKernel.h"
|
#include "AdvectionKernel.h"
|
||||||
#include "UVGrid.h"
|
#include "../UVGrid.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#include "RK4AdvectionKernel.h"
|
#include "RK4AdvectionKernel.h"
|
||||||
#include "interpolate.h"
|
#include "../interpolate.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#define RK4ADVECTIONKERNEL_H
|
#define RK4ADVECTIONKERNEL_H
|
||||||
|
|
||||||
#include "AdvectionKernel.h"
|
#include "AdvectionKernel.h"
|
||||||
#include "UVGrid.h"
|
#include "../UVGrid.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
#include "SnapBoundaryConditionKernel.h"
|
||||||
|
|
||||||
|
SnapBoundaryConditionKernel::SnapBoundaryConditionKernel(std::unique_ptr<AdvectionKernel> kernel,
|
||||||
|
std::shared_ptr<UVGrid> uvGrid) :
|
||||||
|
kernel(std::move(kernel)),
|
||||||
|
uvGrid(uvGrid) { }
|
||||||
|
std::pair<double, double> SnapBoundaryConditionKernel::advect(int time, double latitude, double longitude, int dt) const {
|
||||||
|
auto [newLat, newLon] = kernel->advect(time, latitude, longitude, dt);
|
||||||
|
double minLat = uvGrid->lats.front();
|
||||||
|
double maxLat = uvGrid->lats.back();
|
||||||
|
double minLon = uvGrid->lons.front();
|
||||||
|
double maxLon = uvGrid->lons.back();
|
||||||
|
if (newLat < minLat) {
|
||||||
|
newLat = minLat;
|
||||||
|
}
|
||||||
|
if (newLat > maxLat) {
|
||||||
|
newLat = maxLat;
|
||||||
|
}
|
||||||
|
if (newLon < minLon) {
|
||||||
|
newLon = minLon;
|
||||||
|
}
|
||||||
|
if (newLon > maxLon) {
|
||||||
|
newLon = maxLon;
|
||||||
|
}
|
||||||
|
return {newLat, newLon};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
#ifndef SNAPBOUNDARYCONDITIONKERNEL_H
|
||||||
|
#define SNAPBOUNDARYCONDITIONKERNEL_H
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include "AdvectionKernel.h"
|
||||||
|
#include "../UVGrid.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When
|
||||||
|
*/
|
||||||
|
class SnapBoundaryConditionKernel: public AdvectionKernel {
|
||||||
|
std::unique_ptr<AdvectionKernel> kernel;
|
||||||
|
std::shared_ptr<UVGrid> uvGrid;
|
||||||
|
public:
|
||||||
|
SnapBoundaryConditionKernel(std::unique_ptr<AdvectionKernel> kernel, std::shared_ptr<UVGrid> uvGrid);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::pair<double, double> advect(int time, double latitude, double longitude, int dt) const override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif //SNAPBOUNDARYCONDITIONKERNEL_H
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#define LGLYPHLAYER_H
|
#define LGLYPHLAYER_H
|
||||||
|
|
||||||
#include "Layer.h"
|
#include "Layer.h"
|
||||||
#include "../advection/AdvectionKernel.h"
|
#include "../advection/kernel/AdvectionKernel.h"
|
||||||
#include "../commands/SpawnPointCallback.h"
|
#include "../commands/SpawnPointCallback.h"
|
||||||
#include <vtkPolyData.h>
|
#include <vtkPolyData.h>
|
||||||
#include <vtkInteractorStyle.h>
|
#include <vtkInteractorStyle.h>
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,8 @@
|
||||||
#include "layers/LGlyphLayer.h"
|
#include "layers/LGlyphLayer.h"
|
||||||
#include "Program.h"
|
#include "Program.h"
|
||||||
#include "advection/UVGrid.h"
|
#include "advection/UVGrid.h"
|
||||||
#include "advection/RK4AdvectionKernel.h"
|
#include "advection/kernel/RK4AdvectionKernel.h"
|
||||||
|
#include "advection/kernel/SnapBoundaryConditionKernel.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
@ -22,13 +23,14 @@ using namespace std;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
cout << "reading data..." << endl;
|
cout << "reading data..." << endl;
|
||||||
shared_ptr<UVGrid> uvGrid = std::make_shared<UVGrid>();
|
shared_ptr<UVGrid> uvGrid = make_shared<UVGrid>();
|
||||||
auto kernelRK4 = make_unique<RK4AdvectionKernel>(uvGrid);
|
auto kernelRK4 = make_unique<RK4AdvectionKernel>(uvGrid);
|
||||||
|
auto kernelRK4BoundaryChecked = make_unique<SnapBoundaryConditionKernel>(std::move(kernelRK4), uvGrid);
|
||||||
cout << "Starting vtk..." << endl;
|
cout << "Starting vtk..." << endl;
|
||||||
|
|
||||||
auto l = new LGlyphLayer(uvGrid, std::move(kernelRK4));
|
auto l = new LGlyphLayer(uvGrid, std::move(kernelRK4BoundaryChecked));
|
||||||
|
|
||||||
Program *program = new Program(DT);
|
unique_ptr<Program> program = make_unique<Program>(DT);
|
||||||
program->addLayer(new BackgroundImage("../../../../data/map_661-661.png"));
|
program->addLayer(new BackgroundImage("../../../../data/map_661-661.png"));
|
||||||
program->addLayer(new EGlyphLayer(uvGrid));
|
program->addLayer(new EGlyphLayer(uvGrid));
|
||||||
program->addLayer(l);
|
program->addLayer(l);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue