8 Star 15 Fork 6

Crazyfish/Finite Element Method

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
test_eazymesh.cpp 1.23 KB
一键复制 编辑 原始数据 按行查看 历史
#include "FEMSpace.h"
#include "Surface.h"
#include <typeinfo>
#include <math.h>
#include <ctime>
#include "Error.h"
#define pi 4.0*atan(1.0)
double f(double *p)
{
return 2 * pi* pi* sin(pi * p[0]) * sin(pi * p[1]);
}
double bc(double *p)
{
return sin(pi * p[0]) * sin(pi * p[1]);
}
double f2(double *p)
{
return 2 * pi* pi* cos(pi * p[0]) * cos(pi * p[1]);
}
double bc2(double *p)
{
return cos(pi * p[0]) * cos(pi * p[1]);
}
int main()
{
//g++ -o main test_eazymesh.cpp -std=c++11 -I /usr/include/eigen3/ ./include/tinyxml2.cpp -g
RectangleDomain* r = new RectangleDomain({{0,0},{1,0},{1,1},{0,1}});
std::vector<Boundary<2> > B = r->boundary();
Mesh<2>* m = new EazyMesh("D");
Element<2>* e = new Triangular_1_Element();
Equation<2>* equ = new PossionEquation<2>();
equ ->SetRightHandsTermFunction(f);
BoundaryFunction<2> * bf = new Dirichlet<2>(bc,B);
BoundaryCondition<2> bfc;
bfc.add(bf);
Possion_2D possionproblem(m,e,equ,bfc);
possionproblem.AssembleStiffMatrix();
possionproblem.AssembleRightHandsTerm();
possionproblem.DealWithBoubdaryCondition();
possionproblem.Solve();
VectorXd u = possionproblem.solution();
Surface_EM S(m,e,u);
S.WriteVTKData("surface");
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/wang_heyu/finite-element-method.git
git@gitee.com:wang_heyu/finite-element-method.git
wang_heyu
finite-element-method
Finite Element Method
master

搜索帮助