8 #ifndef OPENFPM_NUMERICS_SRC_FINITEDIFFERENCE_EQ_UNIT_TEST_HPP_
9 #define OPENFPM_NUMERICS_SRC_FINITEDIFFERENCE_EQ_UNIT_TEST_HPP_
11 #include "Laplacian.hpp"
12 #include "FiniteDifference/eq.hpp"
13 #include "FiniteDifference/sum.hpp"
14 #include "FiniteDifference/mul.hpp"
15 #include "Grid/grid_dist_id.hpp"
16 #include "Decomposition/CartDecomposition.hpp"
17 #include "Vector/Vector.hpp"
18 #include "Solvers/umfpack_solver.hpp"
19 #include "data_type/aggregate.hpp"
20 #include "FiniteDifference/FDScheme.hpp"
22 BOOST_AUTO_TEST_SUITE( eq_test_suite )
29 static const unsigned int dims = 2;
32 static const unsigned int nvar = 3;
35 static const bool boundary[];
53 static const int grid_type = STAGGERED_GRID;
56 const bool lid_nn::boundary[] = {NON_PERIODIC,NON_PERIODIC};
65 typedef void const_field;
67 static float val() {
return 1.0;}
71 constexpr
unsigned int v[] = {0,1};
72 constexpr
unsigned int P = 2;
73 constexpr
unsigned int ic = 2;
138 template<
typename solver_type,
typename l
id_nn>
void lid_driven_cavity_2d()
140 Vcluster & v_cl = create_vcluster();
148 constexpr
int velocity = 0;
149 constexpr
int pressure = 1;
158 long int sz[] = {256,64};
160 szu[0] = (size_t)sz[0];
161 szu[1] = (size_t)sz[1];
183 fd.impose(
ic_eq(),0.0, EQ_3, {0,0},{sz[0]-2,sz[1]-2},
true);
184 fd.impose(
Prs(), 0.0, EQ_3, {0,0},{0,0});
187 fd.impose(
vx_eq(),0.0, EQ_1, {1,0},{sz[0]-2,sz[1]-2});
188 fd.impose(
vy_eq(),0.0, EQ_2, {0,1},{sz[0]-2,sz[1]-2});
192 fd.impose(
v_x(),0.0, EQ_1, {0,0},{0,sz[1]-2});
193 fd.impose(
avg_vy_f(),0.0, EQ_2 , {-1,0},{-1,sz[1]-1});
195 fd.impose(
v_x(),0.0, EQ_1, {sz[0]-1,0},{sz[0]-1,sz[1]-2});
196 fd.impose(
avg_vy(),1.0, EQ_2, {sz[0]-1,0},{sz[0]-1,sz[1]-1});
199 fd.impose(
avg_vx_f(),0.0, EQ_1, {0,-1},{sz[0]-1,-1});
200 fd.impose(
v_y(), 0.0, EQ_2, {0,0},{sz[0]-2,0});
202 fd.impose(
avg_vx(),0.0, EQ_1, {0,sz[1]-1},{sz[0]-1,sz[1]-1});
203 fd.impose(
v_y(), 0.0, EQ_2, {0,sz[1]-1},{sz[0]-2,sz[1]-1});
212 fd.impose(
Prs(), 0.0, EQ_3, {-1,-1},{sz[0]-1,-1});
213 fd.impose(
Prs(), 0.0, EQ_3, {-1,sz[1]-1},{sz[0]-1,sz[1]-1});
214 fd.impose(
Prs(), 0.0, EQ_3, {-1,0},{-1,sz[1]-2});
215 fd.impose(
Prs(), 0.0, EQ_3, {sz[0]-1,0},{sz[0]-1,sz[1]-2});
218 fd.impose(
v_x(), 0.0, EQ_1, {-1,-1},{-1,sz[1]-1});
219 fd.impose(
v_y(), 0.0, EQ_2, {-1,-1},{sz[0]-1,-1});
222 auto x = solver.solve(fd.getA(),fd.getB());
228 fd.template copy<velocity,pressure>(x,{0,0},{sz[0]-1,sz[1]-1},g_dist);
230 std::string s = std::string(demangle(
typeid(solver_type).name()));
235 g_dist.write(s +
"lid_driven_cavity_p" + std::to_string(v_cl.
getProcessingUnits()) +
"_grid");
239 std::string file1 = std::string(
"test/") + s +
"lid_driven_cavity_p" + std::to_string(v_cl.
getProcessingUnits()) +
"_grid_" + std::to_string(v_cl.
getProcessUnitID()) +
"_test_osx.vtk";
246 std::string file1 = std::string(
"test/") + s +
"lid_driven_cavity_p" + std::to_string(v_cl.
getProcessingUnits()) +
"_grid_" + std::to_string(v_cl.
getProcessUnitID()) +
"_test_GCC6.vtk";
251 std::string file1 = std::string(
"test/") + s +
"lid_driven_cavity_p" + std::to_string(v_cl.
getProcessingUnits()) +
"_grid_" + std::to_string(v_cl.
getProcessUnitID()) +
"_test_GCC5.vtk";
256 std::string file1 = std::string(
"test/") + s +
"lid_driven_cavity_p" + std::to_string(v_cl.
getProcessingUnits()) +
"_grid_" + std::to_string(v_cl.
getProcessUnitID()) +
"_test_GCC4.vtk";
264 std::cout <<
"File1: " << file1 << std::endl;
265 std::cout <<
"File2: " << file2 << std::endl;
270 bool test = compare(file1,file2);
271 BOOST_REQUIRE_EQUAL(test,
true);
279 BOOST_AUTO_TEST_CASE(lid_driven_cavity)
281 lid_driven_cavity_2d<umfpack_solver<double>,
lid_nn>();
284 BOOST_AUTO_TEST_SUITE_END()
Derivative second order on h (spacing)
[Definition of the system]
It ancapsulate the minus operation.
size_t getProcessUnitID()
Get the process unit id.
Sparse Matrix implementation stub object when OpenFPM is compiled with no linear algebra support...
Class that contain Padding information on each direction positive and Negative direction.
Implementation of VCluster class.
It model an expression expr1 * expr2.
This class decompose a space into sub-sub-domains and distribute them across processors.
Sparse Matrix implementation.
This is a distributed grid.
[Definition of the system]
This class represent an N-dimensional box.
It model an expression expr1 + ... exprn.
Test structure used for several test.
size_t getProcessingUnits()
Get the total number of processors.