37 #include "Grid/grid_dist_id.hpp" 38 #include "Matrix/SparseMatrix.hpp" 39 #include "Vector/Vector.hpp" 40 #include "FiniteDifference/FDScheme.hpp" 41 #include "FiniteDifference/util/common.hpp" 42 #include "FiniteDifference/eq.hpp" 43 #include "Solvers/petsc_solver.hpp" 44 #include "Solvers/petsc_solver.hpp" 49 static const unsigned int dims = 2;
52 static const unsigned int nvar = 3;
55 static const bool boundary[];
74 static const int grid_type = STAGGERED_GRID;
77 const bool lid_nn::boundary[] = {NON_PERIODIC,NON_PERIODIC};
117 typedef void const_field;
119 static float val() {
return 1.0;}
123 constexpr
unsigned int v[] = {0,1};
124 constexpr
unsigned int P = 2;
125 constexpr
unsigned int ic = 2;
206 #include "Vector/vector_dist.hpp" 207 #include "data_type/aggregate.hpp" 209 int main(
int argc,
char* argv[])
233 openfpm_init(&argc,&argv);
236 constexpr
int velocity = 0;
237 constexpr
int pressure = 1;
246 long int sz[] = {96,32};
248 szu[0] = (size_t)sz[0];
249 szu[1] = (size_t)sz[1];
327 fd.impose(
ic_eq(),0.0, EQ_3, {0,0},{sz[0]-2,sz[1]-2},
true);
328 fd.impose(
Prs(), 0.0, EQ_3, {0,0},{0,0});
331 fd.impose(
vx_eq(),0.0, EQ_1, {1,0},{sz[0]-2,sz[1]-2});
332 fd.impose(
vy_eq(),0.0, EQ_2, {0,1},{sz[0]-2,sz[1]-2});
336 fd.impose(
v_x(),0.0, EQ_1, {0,0},{0,sz[1]-2});
337 fd.impose(
avg_vy_f(),0.0, EQ_2 , {-1,0},{-1,sz[1]-1});
339 fd.impose(
v_x(),0.0, EQ_1, {sz[0]-1,0},{sz[0]-1,sz[1]-2});
340 fd.impose(
avg_vy(),1.0, EQ_2, {sz[0]-1,0},{sz[0]-1,sz[1]-1});
343 fd.impose(
avg_vx_f(),0.0, EQ_1, {0,-1},{sz[0]-1,-1});
344 fd.impose(
v_y(), 0.0, EQ_2, {0,0},{sz[0]-2,0});
346 fd.impose(
avg_vx(),0.0, EQ_1, {0,sz[1]-1},{sz[0]-1,sz[1]-1});
347 fd.impose(
v_y(), 0.0, EQ_2, {0,sz[1]-1},{sz[0]-2,sz[1]-1});
356 fd.impose(
Prs(), 0.0, EQ_3, {-1,-1},{sz[0]-1,-1});
357 fd.impose(
Prs(), 0.0, EQ_3, {-1,sz[1]-1},{sz[0]-1,sz[1]-1});
358 fd.impose(
Prs(), 0.0, EQ_3, {-1,0},{-1,sz[1]-2});
359 fd.impose(
Prs(), 0.0, EQ_3, {sz[0]-1,0},{sz[0]-1,sz[1]-2});
362 fd.impose(
v_x(), 0.0, EQ_1, {-1,-1},{-1,sz[1]-1});
363 fd.impose(
v_y(), 0.0, EQ_2, {-1,-1},{sz[0]-1,-1});
396 auto x = solver.
try_solve(fd.getA(),fd.getB());
413 fd.template copy<velocity,pressure>(x,{0,0},{sz[0]-1,sz[1]-1},g_dist);
415 g_dist.write(
"lid_driven_cavity_p_petsc");
451 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.
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.