setup
This commit is contained in:
parent
db811ba902
commit
933fbf4503
|
|
@ -1,5 +1,5 @@
|
|||
cmake_minimum_required (VERSION 3.28)
|
||||
project (LinearInterpolate)
|
||||
project (Advection)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
|
@ -8,7 +8,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|||
|
||||
find_package(netCDF REQUIRED)
|
||||
|
||||
add_executable(LinearInterpolate main.cpp
|
||||
add_executable(Advection main.cpp
|
||||
readdata.cpp
|
||||
readdata.h
|
||||
interpolate.cpp
|
||||
|
|
@ -16,7 +16,8 @@ add_executable(LinearInterpolate main.cpp
|
|||
UVGrid.cpp
|
||||
UVGrid.h
|
||||
Vel.h
|
||||
Vel.cpp)
|
||||
Vel.cpp
|
||||
)
|
||||
|
||||
execute_process(
|
||||
COMMAND nc-config --includedir
|
||||
|
|
@ -30,7 +31,7 @@ execute_process(
|
|||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
target_include_directories(LinearInterpolate PUBLIC ${netCDF_INCLUDE_DIR})
|
||||
target_include_directories(Advection PUBLIC ${netCDF_INCLUDE_DIR})
|
||||
|
||||
find_library(NETCDF_LIB NAMES netcdf-cxx4 netcdf_c++4 PATHS ${NETCDFCXX_LIB_DIR} NO_DEFAULT_PATH)
|
||||
target_link_libraries(LinearInterpolate ${NETCDF_LIB})
|
||||
target_link_libraries(Advection ${NETCDF_LIB})
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef LINEARINTERPOLATE_UVGRID_H
|
||||
#define LINEARINTERPOLATE_UVGRID_H
|
||||
#ifndef ADVECTION_UVGRID_H
|
||||
#define ADVECTION_UVGRID_H
|
||||
|
||||
#include <vector>
|
||||
#include "Vel.h"
|
||||
|
|
@ -48,4 +48,4 @@ public:
|
|||
void streamSlice(std::ostream &os, size_t t);
|
||||
};
|
||||
|
||||
#endif //LINEARINTERPOLATE_UVGRID_H
|
||||
#endif //ADVECTION_UVGRID_H
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef LINEARINTERPOLATE_VEL_H
|
||||
#define LINEARINTERPOLATE_VEL_H
|
||||
#ifndef ADVECTION_VEL_H
|
||||
#define ADVECTION_VEL_H
|
||||
|
||||
#include <utility>
|
||||
#include <stdexcept>
|
||||
|
|
@ -41,4 +41,4 @@ Vel operator*(Scalar scalar, const Vel& p) {
|
|||
return Vel(p.u * scalar, p.v * scalar);
|
||||
}
|
||||
|
||||
#endif //LINEARINTERPOLATE_VEL_H
|
||||
#endif //ADVECTION_VEL_H
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
Vel bilinearInterpolate(const UVGrid &uvGrid, int time, double lat, double lon) {
|
||||
Vel biadvection(const UVGrid &uvGrid, int time, double lat, double lon) {
|
||||
double latStep = uvGrid.latStep();
|
||||
double lonStep = uvGrid.lonStep();
|
||||
int timeStep = uvGrid.timeStep();
|
||||
|
|
@ -36,11 +36,11 @@ Vel bilinearInterpolate(const UVGrid &uvGrid, int time, double lat, double lon)
|
|||
return point;
|
||||
}
|
||||
|
||||
vector<Vel> bilinearInterpolate(const UVGrid &uvGrid, vector<tuple<int, double, double>> points) {
|
||||
vector<Vel> biadvection(const UVGrid &uvGrid, vector<tuple<int, double, double>> points) {
|
||||
vector<Vel> result;
|
||||
result.reserve(points.size());
|
||||
for (auto [time, lat, lon]: points) {
|
||||
result.push_back(bilinearInterpolate(uvGrid, time, lat, lon));
|
||||
result.push_back(biadvection(uvGrid, time, lat, lon));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef LINEARINTERPOLATE_INTERPOLATE_H
|
||||
#define LINEARINTERPOLATE_INTERPOLATE_H
|
||||
#ifndef ADVECTION_INTERPOLATE_H
|
||||
#define ADVECTION_INTERPOLATE_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* @param lon longitude of point
|
||||
* @return interpolated velocity
|
||||
*/
|
||||
Vel bilinearInterpolate(const UVGrid &uvGrid, int time, double lat, double lon);
|
||||
Vel biadvection(const UVGrid &uvGrid, int time, double lat, double lon);
|
||||
|
||||
/**
|
||||
* Helper function for bilnearly interpolating a vector of points
|
||||
|
|
@ -23,6 +23,6 @@ Vel bilinearInterpolate(const UVGrid &uvGrid, int time, double lat, double lon);
|
|||
* @param points vector of points
|
||||
* @return interpolated velocities
|
||||
*/
|
||||
std::vector<Vel> bilinearInterpolate(const UVGrid &uvGrid, std::vector<std::tuple<int, double, double>> points);
|
||||
std::vector<Vel> biadvection(const UVGrid &uvGrid, std::vector<std::tuple<int, double, double>> points);
|
||||
|
||||
#endif //LINEARINTERPOLATE_INTERPOLATE_H
|
||||
#endif //ADVECTION_INTERPOLATE_H
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ int main() {
|
|||
|
||||
auto start = chrono::high_resolution_clock::now();
|
||||
|
||||
auto x = bilinearInterpolate(uvGrid, points);
|
||||
auto x = biadvection(uvGrid, points);
|
||||
|
||||
auto stop = chrono::high_resolution_clock::now();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef LINEARINTERPOLATE_READDATA_H
|
||||
#define LINEARINTERPOLATE_READDATA_H
|
||||
#ifndef ADVECTION_READDATA_H
|
||||
#define ADVECTION_READDATA_H
|
||||
|
||||
/**
|
||||
* reads the file hydrodynamic_U.h5
|
||||
|
|
@ -19,4 +19,4 @@ std::vector<double> readHydrodynamicV();
|
|||
*/
|
||||
std::tuple<std::vector<int>, std::vector<double>, std::vector<double>> readGrid();
|
||||
|
||||
#endif //LINEARINTERPOLATE_READDATA_H
|
||||
#endif //ADVECTION_READDATA_H
|
||||
|
|
|
|||
Loading…
Reference in New Issue