This commit is contained in:
robin 2024-05-06 17:52:26 +02:00
parent 1b4c92cadf
commit 5a2e9a8a7a
2 changed files with 8 additions and 3 deletions

View File

@ -6,15 +6,20 @@
#include "../UVGrid.h" #include "../UVGrid.h"
/** /**
* When * When a point goes outside of the grid, this Kernel will snap it to the closest edge.
* This kernel wraps around another kernel, and implements only the boundary conditions.
*/ */
class SnapBoundaryConditionKernel: public AdvectionKernel { class SnapBoundaryConditionKernel: public AdvectionKernel {
std::unique_ptr<AdvectionKernel> kernel; std::unique_ptr<AdvectionKernel> kernel;
std::shared_ptr<UVGrid> uvGrid; std::shared_ptr<UVGrid> uvGrid;
public: public:
/**
* Construct the kernel.
* @param kernel The kernel to be called first before boundary conditions are applied
* @param uvGrid The grid that is used to check boundary conditions against
*/
SnapBoundaryConditionKernel(std::unique_ptr<AdvectionKernel> kernel, std::shared_ptr<UVGrid> uvGrid); 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; std::pair<double, double> advect(int time, double latitude, double longitude, int dt) const override;
}; };

View File

@ -22,7 +22,7 @@ using namespace std;
#define DT 60 * 60 // 60 sec/min * 60 mins #define DT 60 * 60 // 60 sec/min * 60 mins
int main() { int main() {
cout << "reading data..." << endl; cout << "Reading data..." << endl;
shared_ptr<UVGrid> uvGrid = 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); auto kernelRK4BoundaryChecked = make_unique<SnapBoundaryConditionKernel>(std::move(kernelRK4), uvGrid);