33 #include "Grid/grid_dist_id.hpp"
34 #include "Matrix/SparseMatrix.hpp"
35 #include "Vector/Vector.hpp"
36 #include "FiniteDifference/FDScheme.hpp"
37 #include "FiniteDifference/util/common.hpp"
38 #include "FiniteDifference/eq.hpp"
39 #include "Solvers/petsc_solver.hpp"
40 #include "Solvers/petsc_solver.hpp"
45 static const unsigned int dims = 2;
48 static const unsigned int nvar = 3;
51 static const bool boundary[];
70 static const int grid_type = STAGGERED_GRID;
73 const bool lid_nn::boundary[] = {NON_PERIODIC,NON_PERIODIC};
113 typedef void const_field;
115 static float val() {
return 1.0;}
119 constexpr
unsigned int v[] = {0,1};
120 constexpr
unsigned int P = 2;
121 constexpr
unsigned int ic = 2;
202 #include "Vector/vector_dist.hpp"
203 #include "data_type/aggregate.hpp"
205 int main(
int argc,
char* argv[])
229 openfpm_init(&argc,&argv);
232 constexpr
int velocity = 0;
233 constexpr
int pressure = 1;
242 long int sz[] = {96,32};
244 szu[0] = (size_t)sz[0];
245 szu[1] = (size_t)sz[1];
323 fd.impose(
ic_eq(),0.0, EQ_3, {0,0},{sz[0]-2,sz[1]-2},
true);
324 fd.impose(
Prs(), 0.0, EQ_3, {0,0},{0,0});
327 fd.impose(
vx_eq(),0.0, EQ_1, {1,0},{sz[0]-2,sz[1]-2});
328 fd.impose(
vy_eq(),0.0, EQ_2, {0,1},{sz[0]-2,sz[1]-2});
332 fd.impose(
v_x(),0.0, EQ_1, {0,0},{0,sz[1]-2});
333 fd.impose(
avg_vy_f(),0.0, EQ_2 , {-1,0},{-1,sz[1]-1});
335 fd.impose(
v_x(),0.0, EQ_1, {sz[0]-1,0},{sz[0]-1,sz[1]-2});
336 fd.impose(
avg_vy(),1.0, EQ_2, {sz[0]-1,0},{sz[0]-1,sz[1]-1});
339 fd.impose(
avg_vx_f(),0.0, EQ_1, {0,-1},{sz[0]-1,-1});
340 fd.impose(
v_y(), 0.0, EQ_2, {0,0},{sz[0]-2,0});
342 fd.impose(
avg_vx(),0.0, EQ_1, {0,sz[1]-1},{sz[0]-1,sz[1]-1});
343 fd.impose(
v_y(), 0.0, EQ_2, {0,sz[1]-1},{sz[0]-2,sz[1]-1});
352 fd.impose(
Prs(), 0.0, EQ_3, {-1,-1},{sz[0]-1,-1});
353 fd.impose(
Prs(), 0.0, EQ_3, {-1,sz[1]-1},{sz[0]-1,sz[1]-1});
354 fd.impose(
Prs(), 0.0, EQ_3, {-1,0},{-1,sz[1]-2});
355 fd.impose(
Prs(), 0.0, EQ_3, {sz[0]-1,0},{sz[0]-1,sz[1]-2});
358 fd.impose(
v_x(), 0.0, EQ_1, {-1,-1},{-1,sz[1]-1});
359 fd.impose(
v_y(), 0.0, EQ_2, {-1,-1},{sz[0]-1,-1});
392 auto x = solver.
try_solve(fd.getA(),fd.getB());
409 fd.template copy<velocity,pressure>(x,{0,0},{sz[0]-1,sz[1]-1},g_dist);
411 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...
void setMaxIter(PetscInt n)
Set the maximum number of iteration for Krylov solvers.
Class that contain Padding information on each direction positive and Negative direction.
Vector< double, PETSC_BASE > try_solve(SparseMatrix< double, int, PETSC_BASE > &A, const Vector< double, PETSC_BASE > &b)
Try to solve the system using all the solvers and generate a report.
void setRestart(PetscInt n)
For GMRES based method, the number of Krylov directions to orthogonalize against. ...
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]
This class represent an N-dimensional box.
It model an expression expr1 + ... exprn.
Test structure used for several test.