38 #include "Grid/grid_dist_id.hpp" 39 #include "Matrix/SparseMatrix.hpp" 40 #include "Vector/Vector.hpp" 41 #include "FiniteDifference/FDScheme.hpp" 42 #include "FiniteDifference/util/common.hpp" 43 #include "FiniteDifference/eq.hpp" 44 #include "Solvers/umfpack_solver.hpp" 45 #include "Solvers/petsc_solver.hpp" 50 static const unsigned int dims = 3;
53 static const unsigned int nvar = 4;
56 static const bool boundary[];
76 static const int grid_type = STAGGERED_GRID;
79 const bool lid_nn::boundary[] = {NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
125 static float val() {
return 1.0;}
130 constexpr
unsigned int v[] = {0,1,2};
131 constexpr
unsigned int P = 3;
132 constexpr
unsigned int ic = 3;
234 #include "Vector/vector_dist.hpp" 235 #include "data_type/aggregate.hpp" 237 int main(
int argc,
char* argv[])
261 openfpm_init(&argc,&argv);
264 constexpr
int velocity = 0;
265 constexpr
int pressure = 1;
274 long int sz[] = {36,12,12};
276 szu[0] = (size_t)sz[0];
277 szu[1] = (size_t)sz[1];
278 szu[2] = (size_t)sz[2];
359 fd.impose(
ic_eq(),0.0, EQ_4, {0,0,0},{sz[0]-2,sz[1]-2,sz[2]-2},
true);
360 fd.impose(
Prs(), 0.0, EQ_4, {0,0,0},{0,0,0});
361 fd.impose(
vx_eq(),0.0, EQ_1, {1,0},{sz[0]-2,sz[1]-2,sz[2]-2});
362 fd.impose(
vy_eq(),0.0, EQ_2, {0,1},{sz[0]-2,sz[1]-2,sz[2]-2});
363 fd.impose(
vz_eq(),0.0, EQ_3, {0,0,1},{sz[0]-2,sz[1]-2,sz[2]-2});
367 fd.impose(
v_x(),0.0, EQ_1, {0,0,0}, {0,sz[1]-2,sz[2]-2});
368 fd.impose(
v_x(),0.0, EQ_1, {sz[0]-1,0,0},{sz[0]-1,sz[1]-2,sz[2]-2});
371 fd.impose(
avg_y_vx_f(),0.0, EQ_1, {0,-1,0}, {sz[0]-1,-1,sz[2]-2});
372 fd.impose(
avg_y_vx(),0.0, EQ_1, {0,sz[1]-1,0},{sz[0]-1,sz[1]-1,sz[2]-2});
375 fd.impose(
avg_z_vx_f(),0.0, EQ_1, {0,-1,-1}, {sz[0]-1,sz[1]-1,-1});
376 fd.impose(
avg_z_vx(),0.0, EQ_1, {0,-1,sz[2]-1},{sz[0]-1,sz[1]-1,sz[2]-1});
380 fd.impose(
avg_x_vy_f(),0.0, EQ_2, {-1,0,0}, {-1,sz[1]-1,sz[2]-2});
381 fd.impose(
avg_x_vy(),1.0, EQ_2, {sz[0]-1,0,0},{sz[0]-1,sz[1]-1,sz[2]-2});
384 fd.impose(
v_y(), 0.0, EQ_2, {0,0,0}, {sz[0]-2,0,sz[2]-2});
385 fd.impose(
v_y(), 0.0, EQ_2, {0,sz[1]-1,0},{sz[0]-2,sz[1]-1,sz[2]-2});
388 fd.impose(
avg_z_vy(),0.0, EQ_2, {-1,0,sz[2]-1}, {sz[0]-1,sz[1]-1,sz[2]-1});
389 fd.impose(
avg_z_vy_f(),0.0, EQ_2, {-1,0,-1}, {sz[0]-1,sz[1]-1,-1});
393 fd.impose(
avg_x_vz_f(),0.0, EQ_3, {-1,0,0}, {-1,sz[1]-2,sz[2]-1});
394 fd.impose(
avg_x_vz(),1.0, EQ_3, {sz[0]-1,0,0},{sz[0]-1,sz[1]-2,sz[2]-1});
397 fd.impose(
avg_y_vz(),0.0, EQ_3, {-1,sz[1]-1,0},{sz[0]-1,sz[1]-1,sz[2]-1});
398 fd.impose(
avg_y_vz_f(),0.0, EQ_3, {-1,-1,0}, {sz[0]-1,-1,sz[2]-1});
401 fd.impose(
v_z(),0.0, EQ_3, {0,0,0}, {sz[0]-2,sz[1]-2,0});
402 fd.impose(
v_z(),0.0, EQ_3, {0,0,sz[2]-1},{sz[0]-2,sz[1]-2,sz[2]-1});
411 fd.impose(
Prs(), 0.0, EQ_4, {-1,-1,-1},{-1,sz[1]-1,sz[2]-1});
412 fd.impose(
Prs(), 0.0, EQ_4, {sz[0]-1,-1,-1},{sz[0]-1,sz[1]-1,sz[2]-1});
415 fd.impose(
Prs(), 0.0, EQ_4, {0,sz[1]-1,-1}, {sz[0]-2,sz[1]-1,sz[2]-1});
416 fd.impose(
Prs(), 0.0, EQ_4, {0,-1 ,-1}, {sz[0]-2,-1, sz[2]-1});
419 fd.impose(
Prs(), 0.0, EQ_4, {0,0,sz[2]-1}, {sz[0]-2,sz[1]-2,sz[2]-1});
420 fd.impose(
Prs(), 0.0, EQ_4, {0,0,-1}, {sz[0]-2,sz[1]-2,-1});
423 fd.impose(
v_x(), 0.0, EQ_1, {-1,-1,-1},{-1,sz[1]-1,sz[2]-1});
424 fd.impose(
v_y(), 0.0, EQ_2, {-1,-1,-1},{sz[0]-1,-1,sz[2]-1});
425 fd.impose(
v_z(), 0.0, EQ_3, {-1,-1,-1},{sz[0]-1,sz[1]-1,-1});
457 auto x = solver.
solve(fd.getA(),fd.getB());
475 fd.template copy<velocity,pressure>(x,{0,0},{sz[0]-1,sz[1]-1,sz[2]-1},g_dist);
477 g_dist.write(
"lid_driven_cavity_p_petsc");
512 int main(
int argc,
char* argv[])
Derivative second order on h (spacing)
[Definition of the system]
It ancapsulate the minus operation.
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.
Vector< double, PETSC_BASE > solve(SparseMatrix< double, int, PETSC_BASE > &A, const Vector< double, PETSC_BASE > &b, bool initial_guess=false)
Here we invert the matrix and solve the system.
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.
This class is able to do Matrix inversion in parallel with PETSC solvers.
[Definition of the system]
void const_field
indicate it is a constant field
It model an expression expr1 + ... exprn.
Test structure used for several test.
static float val()
Eta is constant one.