1

我正在处理一个注释非常糟糕的代码,因为我需要扩展一些功能,我需要了解每段代码的作用,以便知道我的更改是否会影响它。

该代码正在处理 2D 网格生成(使用 Triangle 库)并在其上求解 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_ 到底是什么以及它的可能用途是什么!

它是模板类 FiniteElement 中的一个方法,假设 ORDER=1,并且 Integrator:

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));
}
4

0 回答 0