⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 利用C
💻 CPP
字号:
#include <dolfin.h>#include "Poisson.h"#include "Projection.h"using namespace dolfin;int main(){  // Source term  class Source : public Function  {  public:        Source(Mesh& mesh) : Function(mesh) {}    real eval(const real* x) const    {      real dx = x[0] - 0.5;      real dy = x[1] - 0.5;      return 500.0*exp(-(dx*dx + dy*dy)/0.02);    }  };  // Create mesh  UnitCube mesh(12, 12, 12);  // Create functions  Source f(mesh);  FacetNormal n(mesh);//  InvMeshSize h(mesh);  AvgMeshSize h(mesh);  // Define PDE  PoissonBilinearForm a(n,h);  PoissonLinearForm L(f);  LinearPDE pde(a, L, mesh);  // Solve PDE  Function u;  pde.set("PDE linear solver", "direct");  pde.solve(u);  // Project solution onto piecewise linears  Function uu;  ProjectionBilinearForm aa;  ProjectionLinearForm LL(u);  LinearPDE projection(aa, LL, mesh);  projection.set("PDE linear solver", "direct");  projection.solve(uu);  // Plot solution  plot(u);  plot(uu);  // Save solution to file  File file("poisson.pvd");  file << u;  return 0;}

⌨️ 快捷键说明

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