navier_stokes_test.cc

来自「Flens库-一个在C++的矩阵运算库」· CC 代码 · 共 66 行

CC
66
字号
#include <poisson_solver/flens_impl.h>#include <poisson_solver/examples/navier_stokes.h>#include <dirichlet_poisson.h>using namespace flens;using namespace std;typedef StaggeredGridVector2D<false, true>  GridTypeU;typedef StaggeredGridVector2D<true, false>  GridTypeV;typedef StaggeredGridVector2D<true, true>   GridTypeP;typedef GaussSeidelRedBlack<NeumannPoisson2D, GridTypeP>  Smoother;typedef StationaryIterativeSolver<Smoother>               DS;intmain(){    int l = 2;    int rh = (1<<l);    GridTypeU u(rh), fx(rh);    GridTypeV v(rh), fy(rh);    GridTypeP p(rh), rhs(rh);    setBoundaryCondition(rh, u.grid, v.grid);    cout << "u = " << u << endl;    cout << "v = " << v << endl;    double re = 1000;    double pr = 7;    double delta = 0.5;    double dt = computeTimeStep(rh, u.grid, v.grid, re, pr, delta);    cout << "dt = " << dt << endl;    double gamma = 0.9;    double gx = 0;    double gy = -9.81;    computeForce(rh, u.grid, v.grid, dt, gamma, re, gx, gy, fx.grid, fy.grid);    cout << "fx = " << fx << endl;    cout << "fy = " << fy << endl;    computePoissonRhs(rh, fx.grid, fy.grid, dt, rhs.grid);    cout << "rhs = " << rhs << endl;    NeumannPoisson2D NP(rh);    DS ds(NP, rhs, p);    ds.solve();    cout << "p = " << p << endl;    computeVelocity(rh, fx.grid, fy.grid, p.grid, dt, u.grid, v.grid);    cout << "u = " << u << endl;    cout << "v = " << v << endl;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?