34 #include "Grid/grid_dist_id.hpp"
35 #include "Matrix/SparseMatrix.hpp"
36 #include "Vector/Vector.hpp"
37 #include "FiniteDifference/FDScheme.hpp"
38 #include "FiniteDifference/util/common.hpp"
39 #include "FiniteDifference/eq.hpp"
40 #include "Solvers/umfpack_solver.hpp"
41 #include "Solvers/petsc_solver.hpp"
46 static const unsigned int dims = 3;
49 static const unsigned int nvar = 4;
52 static const bool boundary[];
72 static const int grid_type = STAGGERED_GRID;
75 const bool lid_nn::boundary[] = {NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
121 static float val() {
return 1.0;}
126 constexpr
unsigned int v[] = {0,1,2};
127 constexpr
unsigned int P = 3;
128 constexpr
unsigned int ic = 3;
230 #include "Vector/vector_dist.hpp"
231 #include "data_type/aggregate.hpp"
233 int main(
int argc,
char* argv[])
257 openfpm_init(&argc,&argv);
260 constexpr
int velocity = 0;
261 constexpr
int pressure = 1;
270 long int sz[] = {36,12,12};
272 szu[0] = (size_t)sz[0];
273 szu[1] = (size_t)sz[1];
274 szu[2] = (size_t)sz[2];
355 fd.impose(
ic_eq(),0.0, EQ_4, {0,0,0},{sz[0]-2,sz[1]-2,sz[2]-2},
true);
356 fd.impose(
Prs(), 0.0, EQ_4, {0,0,0},{0,0,0});
357 fd.impose(
vx_eq(),0.0, EQ_1, {1,0},{sz[0]-2,sz[1]-2,sz[2]-2});
358 fd.impose(
vy_eq(),0.0, EQ_2, {0,1},{sz[0]-2,sz[1]-2,sz[2]-2});
359 fd.impose(
vz_eq(),0.0, EQ_3, {0,0,1},{sz[0]-2,sz[1]-2,sz[2]-2});
363 fd.impose(
v_x(),0.0, EQ_1, {0,0,0}, {0,sz[1]-2,sz[2]-2});
364 fd.impose(
v_x(),0.0, EQ_1, {sz[0]-1,0,0},{sz[0]-1,sz[1]-2,sz[2]-2});
367 fd.impose(
avg_y_vx_f(),0.0, EQ_1, {0,-1,0}, {sz[0]-1,-1,sz[2]-2});
368 fd.impose(
avg_y_vx(),0.0, EQ_1, {0,sz[1]-1,0},{sz[0]-1,sz[1]-1,sz[2]-2});
371 fd.impose(
avg_z_vx_f(),0.0, EQ_1, {0,-1,-1}, {sz[0]-1,sz[1]-1,-1});
372 fd.impose(
avg_z_vx(),0.0, EQ_1, {0,-1,sz[2]-1},{sz[0]-1,sz[1]-1,sz[2]-1});
376 fd.impose(
avg_x_vy_f(),0.0, EQ_2, {-1,0,0}, {-1,sz[1]-1,sz[2]-2});
377 fd.impose(
avg_x_vy(),1.0, EQ_2, {sz[0]-1,0,0},{sz[0]-1,sz[1]-1,sz[2]-2});
380 fd.impose(
v_y(), 0.0, EQ_2, {0,0,0}, {sz[0]-2,0,sz[2]-2});
381 fd.impose(
v_y(), 0.0, EQ_2, {0,sz[1]-1,0},{sz[0]-2,sz[1]-1,sz[2]-2});
384 fd.impose(
avg_z_vy(),0.0, EQ_2, {-1,0,sz[2]-1}, {sz[0]-1,sz[1]-1,sz[2]-1});
385 fd.impose(
avg_z_vy_f(),0.0, EQ_2, {-1,0,-1}, {sz[0]-1,sz[1]-1,-1});
389 fd.impose(
avg_x_vz_f(),0.0, EQ_3, {-1,0,0}, {-1,sz[1]-2,sz[2]-1});
390 fd.impose(
avg_x_vz(),1.0, EQ_3, {sz[0]-1,0,0},{sz[0]-1,sz[1]-2,sz[2]-1});
393 fd.impose(
avg_y_vz(),0.0, EQ_3, {-1,sz[1]-1,0},{sz[0]-1,sz[1]-1,sz[2]-1});
394 fd.impose(
avg_y_vz_f(),0.0, EQ_3, {-1,-1,0}, {sz[0]-1,-1,sz[2]-1});
397 fd.impose(
v_z(),0.0, EQ_3, {0,0,0}, {sz[0]-2,sz[1]-2,0});
398 fd.impose(
v_z(),0.0, EQ_3, {0,0,sz[2]-1},{sz[0]-2,sz[1]-2,sz[2]-1});
407 fd.impose(
Prs(), 0.0, EQ_4, {-1,-1,-1},{-1,sz[1]-1,sz[2]-1});
408 fd.impose(
Prs(), 0.0, EQ_4, {sz[0]-1,-1,-1},{sz[0]-1,sz[1]-1,sz[2]-1});
411 fd.impose(
Prs(), 0.0, EQ_4, {0,sz[1]-1,-1}, {sz[0]-2,sz[1]-1,sz[2]-1});
412 fd.impose(
Prs(), 0.0, EQ_4, {0,-1 ,-1}, {sz[0]-2,-1, sz[2]-1});
415 fd.impose(
Prs(), 0.0, EQ_4, {0,0,sz[2]-1}, {sz[0]-2,sz[1]-2,sz[2]-1});
416 fd.impose(
Prs(), 0.0, EQ_4, {0,0,-1}, {sz[0]-2,sz[1]-2,-1});
419 fd.impose(
v_x(), 0.0, EQ_1, {-1,-1,-1},{-1,sz[1]-1,sz[2]-1});
420 fd.impose(
v_y(), 0.0, EQ_2, {-1,-1,-1},{sz[0]-1,-1,sz[2]-1});
421 fd.impose(
v_z(), 0.0, EQ_3, {-1,-1,-1},{sz[0]-1,sz[1]-1,-1});
453 auto x = solver.
solve(fd.getA(),fd.getB());
471 fd.template copy<velocity,pressure>(x,{0,0},{sz[0]-1,sz[1]-1,sz[2]-1},g_dist);
473 g_dist.write(
"lid_driven_cavity_p_petsc");
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.