1

I'm dealing with a code that is really poorly commented, since I need to expand a few functionalities I need to understand what every piece of code does in order to know if my changes will affect it.

The code is dealing with 2D mesh generation (using library Triangle for it) and solving PDEs on it.

Here is the code I don't understand:

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

In the end I would like to know what exactly is phiMapMaster_ and whats the possible use of it!

It is a method inside the template class FiniteElement, suppose ORDER=1, and 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 is the same as std::complex), and here is the method evaluate_point that takes as imput a triangle (simply 3 points counter-clockwise ordered), the point (which is internal to the triangle) and the coefficients of the Fourier basis defined on the triangle

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));
}
mariob6
  • 469
  • 1
  • 6
  • 16
  • In the context of FEM the variable phi typically is used to denote [shape functions](http://kratos-wiki.cimne.upc.edu/index.php/One-dimensional_Shape_Functions). This would make sense here because it depends on the `ORDER`, as shape functions are many times some order of special polynomials (lagrangian, etc). It looks like this function is trying to determine the coefficients for that particular shape function polynomial. – Cory Kramer Oct 05 '16 at 12:55
  • The code is not complete enough to fill in the gaps, but I guess Integrator is a numerical spatial integrator (result = sum ( weight_i * evaluatedPoint_i). phiMapMaster_ seems to contain those evaluated points. Just a guess though... You haven't posted code where phiMapMaster_ is actually being used. – mfnx Mar 14 '18 at 16:41

0 Answers0