有限元c ++实现

时间:2016-10-05 12:48:30

标签: c++ finite-element-analysis

我正在处理一个评论很少的代码,因为我需要扩展一些功能,我需要了解每一段代码的作用,以便知道我的更改是否会影响它。

代码正在处理2D网格生成(使用库三角形)并在其上解决PDE。

以下是我不理解的代码:

void FiniteElement<Integrator, ORDER>::setPhiMaster()
{
    Eigen::Matrix<Real,3*ORDER,1> coefficients;
    for (auto i=0; i < 3*ORDER; i++)
    {
        coefficients = MatrixXr::Zero(3*ORDER,1);
        coefficients(i) = 1;
        for (auto iq=0; iq < Integrator::NNODES; iq++)
        {
            Real phi = evaluate_point<ORDER>(reference_,Integrator::NODES[iq],coefficients);
            phiMapMaster_(i,iq) = phi;
        }
    }
}

最后我想知道phiMapMaster_究竟是什么,以及它可能的用途!

这是模板类的有限元内部的一个方法,假设ORDER = 1,并且积分器:

class IntegratorTriangleP2{
    public:
    static const UInt ORDER = 1;
//Number of nodes
    static const UInt NNODES = 3;
//Point locations
    static const std::vector<Point> NODES;
    static const std::vector<Real> WEIGHTS;
};


const std::vector<Real> IntegratorTriangleP2::WEIGHTS = std::vector<Real>{ {1./3, 1./3, 1./3} };
const std::vector<Point> IntegratorTriangleP2::NODES = std::vector<Point> { {Point(1./6,1./6),Point(2./3,1./6),Point(1./6,2./3)} };

(Point与std :: complex相同),这里是evaluate_point方法,它将一个三角形(简称为逆时针3个点),点(三角形内部)和系数作为输入在三角形上定义的傅里叶基础

template <>
inline Real evaluate_point<1>(const Triangle<3>& t, const Point& point,      const Eigen::Matrix<Real,3,1>& coefficients)
{
    Eigen::Matrix<Real,3,1> bary_coeff = t.getBaryCoordinates(point);
      //getBaryCoordinates retunrs the barycentric coordinates of the point wrt the triangle t
    return(coefficients.dot(bary_coeff));
}

0 个答案:

没有答案
相关问题