fix: add namespaces to executables
This commit is contained in:
parent
2096ee5cc3
commit
8af03777b8
@ -6,24 +6,21 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
using namespace std;
|
inline Eigen::MatrixXd CSV2Eigen(std::string file2Convert) {
|
||||||
using namespace Eigen;
|
|
||||||
|
|
||||||
inline MatrixXd CSV2Eigen(string file2Convert) {
|
std::vector<double> matrixEntries;
|
||||||
|
|
||||||
vector<double> matrixEntries;
|
std::ifstream matrixDataFile(file2Convert);
|
||||||
|
|
||||||
ifstream matrixDataFile(file2Convert);
|
|
||||||
if (matrixDataFile.fail()) {
|
if (matrixDataFile.fail()) {
|
||||||
throw invalid_argument("File probably non-existent!");
|
throw std::invalid_argument("File probably non-existent!");
|
||||||
}
|
}
|
||||||
|
|
||||||
string matrixRowString;
|
std::string matrixRowString;
|
||||||
string matrixEntry;
|
std::string matrixEntry;
|
||||||
int matrixRowNumber = 0;
|
int matrixRowNumber = 0;
|
||||||
|
|
||||||
while (getline(matrixDataFile, matrixRowString)) {
|
while (getline(matrixDataFile, matrixRowString)) {
|
||||||
stringstream matrixRowStringStream(matrixRowString);
|
std::stringstream matrixRowStringStream(matrixRowString);
|
||||||
while (getline(matrixRowStringStream, matrixEntry, ' ')) {
|
while (getline(matrixRowStringStream, matrixEntry, ' ')) {
|
||||||
matrixEntries.push_back(stod(matrixEntry));
|
matrixEntries.push_back(stod(matrixEntry));
|
||||||
}
|
}
|
||||||
@ -32,18 +29,21 @@ inline MatrixXd CSV2Eigen(string file2Convert) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Map<Matrix<double, Dynamic, Dynamic, RowMajor>>(
|
return Eigen::Map<
|
||||||
|
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>(
|
||||||
matrixEntries.data(), matrixRowNumber,
|
matrixEntries.data(), matrixRowNumber,
|
||||||
matrixEntries.size() / matrixRowNumber);
|
matrixEntries.size() / matrixRowNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool checkSimilarity(MatrixXd a, MatrixXd b, double precision = 1e-5) {
|
inline bool checkSimilarity(Eigen::MatrixXd a, Eigen::MatrixXd b,
|
||||||
|
double precision = 1e-5) {
|
||||||
return a.isApprox(b, precision);
|
return a.isApprox(b, precision);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool checkSimilarityV2(MatrixXd a, MatrixXd b, double maxDiff) {
|
inline bool checkSimilarityV2(Eigen::MatrixXd a, Eigen::MatrixXd b,
|
||||||
|
double maxDiff) {
|
||||||
|
|
||||||
MatrixXd diff = a - b;
|
Eigen::MatrixXd diff = a - b;
|
||||||
double maxCoeff = diff.maxCoeff();
|
double maxCoeff = diff.maxCoeff();
|
||||||
return abs(maxCoeff) < maxDiff;
|
return abs(maxCoeff) < maxDiff;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,8 @@
|
|||||||
#include <tug/Boundary.hpp>
|
#include <tug/Boundary.hpp>
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
TEST_CASE("BoundaryElement") {
|
TEST_CASE("BoundaryElement") {
|
||||||
|
|
||||||
SUBCASE("Closed case") {
|
SUBCASE("Closed case") {
|
||||||
@ -71,4 +73,4 @@ TEST_CASE("Boundary Class") {
|
|||||||
CHECK_EQ(boundary2D.getBoundaryElement(BC_SIDE_LEFT, 0).getType(),
|
CHECK_EQ(boundary2D.getBoundaryElement(BC_SIDE_LEFT, 0).getType(),
|
||||||
boundary1DVector[0].getType());
|
boundary1DVector[0].getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,10 @@
|
|||||||
#include <doctest/doctest.h>
|
#include <doctest/doctest.h>
|
||||||
#include <tug/Grid.hpp>
|
#include <tug/Grid.hpp>
|
||||||
|
|
||||||
|
using namespace Eigen;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("1D Grid, too small length") {
|
TEST_CASE("1D Grid, too small length") {
|
||||||
int l = 2;
|
int l = 2;
|
||||||
CHECK_THROWS(Grid(l));
|
CHECK_THROWS(Grid(l));
|
||||||
@ -246,4 +250,4 @@ TEST_CASE("2D Grid non-quadratic") {
|
|||||||
dr = -2;
|
dr = -2;
|
||||||
CHECK_THROWS(grid.setDomain(dr, dc));
|
CHECK_THROWS(grid.setDomain(dr, dc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,9 @@
|
|||||||
// include the configured header file
|
// include the configured header file
|
||||||
#include <testSimulation.hpp>
|
#include <testSimulation.hpp>
|
||||||
|
|
||||||
|
using namespace Eigen;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
static Grid setupSimulation(APPROACH approach, double timestep,
|
static Grid setupSimulation(APPROACH approach, double timestep,
|
||||||
int iterations) {
|
int iterations) {
|
||||||
int row = 11;
|
int row = 11;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user