feat: boundary conditions
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <tuple>
|
||||
|
||||
#include "Vel.h"
|
||||
#include "../Vel.h"
|
||||
|
||||
/*
|
||||
* Implement this class for every integration method.
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#include "EulerAdvectionKernel.h"
|
||||
#include "interpolate.h"
|
||||
#include "../interpolate.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define EULERADVECTIONKERNEL_H
|
||||
|
||||
#include "AdvectionKernel.h"
|
||||
#include "UVGrid.h"
|
||||
#include "../UVGrid.h"
|
||||
#include <memory>
|
||||
|
||||
/**
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "RK4AdvectionKernel.h"
|
||||
#include "interpolate.h"
|
||||
#include "../interpolate.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define RK4ADVECTIONKERNEL_H
|
||||
|
||||
#include "AdvectionKernel.h"
|
||||
#include "UVGrid.h"
|
||||
#include "../UVGrid.h"
|
||||
#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
|
||||
Reference in New Issue
Block a user