mirror of
https://git.gfz-potsdam.de/naaice/tug.git
synced 2025-12-16 10:58:23 +01:00
fix: remove all source file includes
This commit is contained in:
parent
b9c4474f5a
commit
ce09f0d8c8
@ -7,9 +7,12 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FTCS.cpp"
|
#include "Schemes.hpp"
|
||||||
|
#include "TugUtils.hpp"
|
||||||
|
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
#include <tug/Boundary.hpp>
|
#include <tug/Boundary.hpp>
|
||||||
|
#include <tug/Grid.hpp>
|
||||||
|
|
||||||
#define NUM_THREADS_BTCS 10
|
#define NUM_THREADS_BTCS 10
|
||||||
|
|
||||||
@ -434,7 +437,7 @@ static void BTCS_2D(Grid &grid, Boundary &bc, double timestep,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// entry point for EigenLU solver; differentiate between 1D and 2D grid
|
// entry point for EigenLU solver; differentiate between 1D and 2D grid
|
||||||
static void BTCS_LU(Grid &grid, Boundary &bc, double timestep, int numThreads) {
|
void BTCS_LU(Grid &grid, Boundary &bc, double timestep, int numThreads) {
|
||||||
if (grid.getDim() == 1) {
|
if (grid.getDim() == 1) {
|
||||||
BTCS_1D(grid, bc, timestep, EigenLUAlgorithm);
|
BTCS_1D(grid, bc, timestep, EigenLUAlgorithm);
|
||||||
} else if (grid.getDim() == 2) {
|
} else if (grid.getDim() == 2) {
|
||||||
@ -446,8 +449,7 @@ static void BTCS_LU(Grid &grid, Boundary &bc, double timestep, int numThreads) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// entry point for Thomas algorithm solver; differentiate 1D and 2D grid
|
// entry point for Thomas algorithm solver; differentiate 1D and 2D grid
|
||||||
static void BTCS_Thomas(Grid &grid, Boundary &bc, double timestep,
|
void BTCS_Thomas(Grid &grid, Boundary &bc, double timestep, int numThreads) {
|
||||||
int numThreads) {
|
|
||||||
if (grid.getDim() == 1) {
|
if (grid.getDim() == 1) {
|
||||||
BTCS_1D(grid, bc, timestep, ThomasAlgorithm);
|
BTCS_1D(grid, bc, timestep, ThomasAlgorithm);
|
||||||
} else if (grid.getDim() == 2) {
|
} else if (grid.getDim() == 2) {
|
||||||
@ -1,4 +1,5 @@
|
|||||||
#include "TugUtils.cpp"
|
#include "TugUtils.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
add_library(tug Boundary.cpp Grid.cpp Simulation.cpp FTCS.cpp BTCSv2.cpp)
|
add_library(tug Boundary.cpp Grid.cpp Simulation.cpp FTCS.cpp BTCS.cpp)
|
||||||
|
|
||||||
target_link_libraries(tug Eigen3::Eigen)
|
target_link_libraries(tug Eigen3::Eigen)
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "TugUtils.cpp"
|
#include "Schemes.hpp"
|
||||||
|
#include "TugUtils.hpp"
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
@ -377,7 +379,7 @@ static void FTCS_2D(Grid &grid, Boundary &bc, double ×tep,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// entry point; differentiate between 1D and 2D grid
|
// entry point; differentiate between 1D and 2D grid
|
||||||
static void FTCS(Grid &grid, Boundary &bc, double ×tep, int &numThreads) {
|
void FTCS(Grid &grid, Boundary &bc, double ×tep, int &numThreads) {
|
||||||
if (grid.getDim() == 1) {
|
if (grid.getDim() == 1) {
|
||||||
FTCS_1D(grid, bc, timestep);
|
FTCS_1D(grid, bc, timestep);
|
||||||
} else if (grid.getDim() == 2) {
|
} else if (grid.getDim() == 2) {
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
#include "TugUtils.cpp"
|
#include "TugUtils.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <tug/Grid.hpp>
|
#include <tug/Grid.hpp>
|
||||||
|
|
||||||
|
|||||||
28
src/Schemes.hpp
Normal file
28
src/Schemes.hpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/**
|
||||||
|
* @file BTCSv2.cpp
|
||||||
|
* @brief Implementation of heterogenous BTCS (backward time-centered space)
|
||||||
|
* solution of diffusion equation in 1D and 2D space. Internally the
|
||||||
|
* alternating-direction implicit (ADI) method is used. Version 2, because
|
||||||
|
* Version 1 was an implementation for the homogeneous BTCS solution.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SCHEMES_H_
|
||||||
|
#define SCHEMES_H_
|
||||||
|
|
||||||
|
#include "TugUtils.hpp"
|
||||||
|
|
||||||
|
#include <tug/Boundary.hpp>
|
||||||
|
#include <tug/Grid.hpp>
|
||||||
|
|
||||||
|
// entry point; differentiate between 1D and 2D grid
|
||||||
|
extern void FTCS(Grid &grid, Boundary &bc, double ×tep, int &numThreads);
|
||||||
|
|
||||||
|
// entry point for EigenLU solver; differentiate between 1D and 2D grid
|
||||||
|
extern void BTCS_LU(Grid &grid, Boundary &bc, double timestep, int numThreads);
|
||||||
|
|
||||||
|
// entry point for Thomas algorithm solver; differentiate 1D and 2D grid
|
||||||
|
extern void BTCS_Thomas(Grid &grid, Boundary &bc, double timestep,
|
||||||
|
int numThreads);
|
||||||
|
|
||||||
|
#endif // SCHEMES_H_
|
||||||
@ -1,20 +1,18 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <fstream>
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <tug/Simulation.hpp>
|
#include <tug/Simulation.hpp>
|
||||||
|
|
||||||
#include <fstream>
|
#include "TugUtils.hpp"
|
||||||
|
|
||||||
#ifndef SIMULATION_H_
|
#ifndef SIMULATION_H_
|
||||||
#define SIMULATION_H_
|
#define SIMULATION_H_
|
||||||
|
|
||||||
#include "BTCSv2.cpp"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
Simulation::Simulation(Grid &grid, Boundary &bc, APPROACH approach)
|
Simulation::Simulation(Grid &grid, Boundary &bc, APPROACH approach)
|
||||||
: grid(grid), bc(bc) {
|
: grid(grid), bc(bc) {
|
||||||
|
|
||||||
|
|||||||
@ -1,39 +0,0 @@
|
|||||||
#include <chrono>
|
|
||||||
#include <fstream>
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
// used for throwing an invalid argument message
|
|
||||||
#define throw_invalid_argument(msg) \
|
|
||||||
throw std::invalid_argument(std::string(__FILE__) + ":" + \
|
|
||||||
std::to_string(__LINE__) + ":" + \
|
|
||||||
std::string(msg))
|
|
||||||
|
|
||||||
// used for throwing an out of range message
|
|
||||||
#define throw_out_of_range(msg) \
|
|
||||||
throw std::out_of_range(std::string(__FILE__) + ":" + \
|
|
||||||
std::to_string(__LINE__) + ":" + std::string(msg))
|
|
||||||
|
|
||||||
// get current time
|
|
||||||
#define time_marker() std::chrono::high_resolution_clock::now()
|
|
||||||
|
|
||||||
// calculates difference between two time points
|
|
||||||
#define diff_time(start, end) \
|
|
||||||
({ \
|
|
||||||
std::chrono::duration<double> duration = \
|
|
||||||
std::chrono::duration_cast<std::chrono::duration<double>>(end - \
|
|
||||||
start); \
|
|
||||||
duration.count(); \
|
|
||||||
})
|
|
||||||
|
|
||||||
// calculates arithmetic or harmonic mean of alpha between two cells
|
|
||||||
static double calcAlphaIntercell(const double &alpha1, const double &alpha2,
|
|
||||||
bool useHarmonic = true) {
|
|
||||||
if (useHarmonic) {
|
|
||||||
return double(2) / ((double(1) / alpha1) + (double(1) / alpha2));
|
|
||||||
} else {
|
|
||||||
return 0.5 * (alpha1 + alpha2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,35 +1,36 @@
|
|||||||
// #ifndef BTCSUTILS_H_
|
#ifndef TUGUTILS_H_
|
||||||
// #define BTCSUTILS_H_
|
#define TUGUTILS_H_
|
||||||
|
|
||||||
// #include <chrono>
|
#include <chrono>
|
||||||
// #include <stdexcept>
|
#include <stdexcept>
|
||||||
// #include <string>
|
#include <string>
|
||||||
|
|
||||||
// #define throw_invalid_argument(msg) \
|
#define throw_invalid_argument(msg) \
|
||||||
// throw std::invalid_argument(std::string(__FILE__) + ":" + \
|
throw std::invalid_argument(std::string(__FILE__) + ":" + \
|
||||||
// std::to_string(__LINE__) + ":" + \
|
std::to_string(__LINE__) + ":" + \
|
||||||
// std::string(msg))
|
std::string(msg))
|
||||||
|
|
||||||
// #define throw_out_of_range(msg) \
|
#define throw_out_of_range(msg) \
|
||||||
// throw std::out_of_range(std::string(__FILE__) + ":" + \
|
throw std::out_of_range(std::string(__FILE__) + ":" + \
|
||||||
// std::to_string(__LINE__) + ":" + std::string(msg))
|
std::to_string(__LINE__) + ":" + std::string(msg))
|
||||||
|
|
||||||
// #define time_marker() std::chrono::high_resolution_clock::now()
|
#define time_marker() std::chrono::high_resolution_clock::now()
|
||||||
|
|
||||||
// #define diff_time(start, end) \
|
#define diff_time(start, end) \
|
||||||
// ({ \
|
({ \
|
||||||
// std::chrono::duration<double> duration = \
|
std::chrono::duration<double> duration = \
|
||||||
// std::chrono::duration_cast<std::chrono::duration<double>>(end - \
|
std::chrono::duration_cast<std::chrono::duration<double>>(end - \
|
||||||
// start); \
|
start); \
|
||||||
// duration.count(); \
|
duration.count(); \
|
||||||
// })
|
})
|
||||||
// #endif // BTCSUTILS_H_
|
|
||||||
|
|
||||||
// // calculates arithmetic or harmonic mean of alpha between two cells
|
// calculates arithmetic or harmonic mean of alpha between two cells
|
||||||
// static double calcAlphaIntercell(double &alpha1, double &alpha2, bool useHarmonic = true) {
|
constexpr double calcAlphaIntercell(double alpha1, double alpha2,
|
||||||
// if (useHarmonic) {
|
bool useHarmonic = true) {
|
||||||
// return double(2) / ((double(1)/alpha1) + (double(1)/alpha2));
|
if (useHarmonic) {
|
||||||
// } else {
|
return double(2) / ((double(1) / alpha1) + (double(1) / alpha2));
|
||||||
// return 0.5 * (alpha1 + alpha2);
|
} else {
|
||||||
// }
|
return 0.5 * (alpha1 + alpha2);
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
|
#endif // TUGUTILS_H_
|
||||||
|
|||||||
@ -19,7 +19,7 @@ get_filename_component(testSimulationCSV "FTCS_11_11_7000.csv" REALPATH CACHE)
|
|||||||
# set relative path in header file
|
# set relative path in header file
|
||||||
configure_file(testSimulation.hpp.in testSimulation.hpp)
|
configure_file(testSimulation.hpp.in testSimulation.hpp)
|
||||||
# include test directory with generated header file from above
|
# include test directory with generated header file from above
|
||||||
target_include_directories(testTug PUBLIC "${CMAKE_CURRENT_BINARY_DIR}")
|
target_include_directories(testTug PUBLIC "${CMAKE_CURRENT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/src")
|
||||||
|
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
check
|
check
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Eigen;
|
using namespace Eigen;
|
||||||
|
|
||||||
MatrixXd CSV2Eigen(string file2Convert) {
|
inline MatrixXd CSV2Eigen(string file2Convert) {
|
||||||
|
|
||||||
vector<double> matrixEntries;
|
vector<double> matrixEntries;
|
||||||
|
|
||||||
@ -37,11 +37,11 @@ MatrixXd CSV2Eigen(string file2Convert) {
|
|||||||
matrixEntries.size() / matrixRowNumber);
|
matrixEntries.size() / matrixRowNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checkSimilarity(MatrixXd a, MatrixXd b, double precision = 1e-5) {
|
inline bool checkSimilarity(MatrixXd a, MatrixXd b, double precision = 1e-5) {
|
||||||
return a.isApprox(b, precision);
|
return a.isApprox(b, precision);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checkSimilarityV2(MatrixXd a, MatrixXd b, double maxDiff) {
|
inline bool checkSimilarityV2(MatrixXd a, MatrixXd b, double maxDiff) {
|
||||||
|
|
||||||
MatrixXd diff = a - b;
|
MatrixXd diff = a - b;
|
||||||
double maxCoeff = diff.maxCoeff();
|
double maxCoeff = diff.maxCoeff();
|
||||||
@ -1,4 +1,5 @@
|
|||||||
#include <../src/FTCS.cpp>
|
#include <TugUtils.hpp>
|
||||||
|
|
||||||
#include <doctest/doctest.h>
|
#include <doctest/doctest.h>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
#include "TestUtils.cpp"
|
#include "TestUtils.hpp"
|
||||||
|
|
||||||
#include <doctest/doctest.h>
|
#include <doctest/doctest.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user