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

📄 main.cpp

📁 利用C
💻 CPP
字号:
// Copyright (C) 2006-2007 Anders Logg and Kristian Oelgaard.// Licensed under the GNU LGPL Version 2.1.//// First added:  2006-12-05// Last changed: 2007-08-20//// This demo program solves Poisson's equation////     - div grad u(x, y) = f(x, y)//// on the unit square with source f given by////     f(x, y) = 500*exp(-((x-0.5)^2 + (y-0.5)^2)/0.02)//// and boundary conditions given by////     u(x, y)     = 0//     du/dn(x, y) = 0//// using a discontinuous Galerkin formulation (interior penalty method).#include <dolfin.h>#include "Poisson.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  UnitSquare mesh(64, 64);  // Create functions  Source f(mesh);  FacetNormal n(mesh);  AvgMeshSize h(mesh);  // Define PDE  PoissonBilinearForm a(n, h);  PoissonLinearForm L(f);  LinearPDE pde(a, L, mesh);  // Solve PDE  Function u;  pde.solve(u);  // Plot solution  plot(u);  // Save solution to file  File file("poisson.pvd");  file << u;  return 0;}

⌨️ 快捷键说明

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