28 const Eigen::Vector2d &xh) {
30 return (Eigen::Matrix<double, 4, 2>(4, 2) <<
47 LF_ASSERT_MSG(geo_ptr !=
nullptr,
"Invalid geometry!");
49 "Only 2D implementation available!");
51 auto vertices = geo_ptr->
Global(ref_el.NodeCoords());
53 SPDLOG_LOGGER_TRACE(
Logger(),
"{}, shape={}", ref_el, vertices);
56 ElemMat elem_mat = ElemMat::Zero(4, 4);
65 LF_ASSERT_MSG((vertices.cols() == 3) && (vertices.rows() == 2),
66 "Wrong size of vertex matrix!");
69 Eigen::Matrix<double, 3, 3> X;
70 X.block<3, 1>(0, 0) = Eigen::Vector3d::Ones();
71 X.block<3, 2>(0, 1) = vertices.transpose();
73 const double area = 0.5 * std::abs(X.determinant());
74 SPDLOG_LOGGER_TRACE(
Logger(),
"Area: {} <-> {}", area,
79 Eigen::Matrix<double, 2, 3> grad_bary_coords{
80 X.inverse().block<2, 3>(1, 0)};
82 elem_mat.block<3, 3>(0, 0) =
83 area * grad_bary_coords.transpose() * grad_bary_coords;
87 LF_ASSERT_MSG((vertices.cols() == 4) && (vertices.rows() == 2),
88 "Wrong size of vertex matrix!");
91 Eigen::Matrix<double, 2, 4> G(vertices *
92 (Eigen::Matrix<double, 4, 4>() <<
102 Eigen::Vector3d detc{
103 (Eigen::Vector3d() <<
104 G(0, 1) * G(1, 2) - G(1, 1) * G(0, 2),
105 G(0, 1) * G(1, 3) - G(1, 1) * G(0, 3),
106 G(1, 2) * G(0, 3) - G(0, 2) * G(1, 3))
110 auto detDPhi = [&detc](
const Eigen::Vector2d &xh) ->
double {
111 return std::abs(detc[0] + detc[1] * xh[0] + detc[2] * xh[1]);
113 SPDLOG_LOGGER_DEBUG(
Logger(),
"Determinant: {} <-> {}", detDPhi(
kQuadpt),
118 [&G](
const Eigen::Vector2d &xh) -> Eigen::Matrix<double, 2, 2> {
120 return ((Eigen::Matrix<double, 2, 2>() <<
121 G(1, 2) + G(1, 3) * xh[0] , -G(1, 1) - G(1, 3) * xh[1],
122 -G(0, 2) - G(0, 3) * xh[0], G(0, 1) + G(0, 3) * xh[1])
127 SPDLOG_LOGGER_TRACE(
Logger(),
"InverseTransposedJacobian:\n{} <-> {}",
134 for (
int q = 0; q < 4; ++q) {
139 Eigen::Matrix<double, 2, 4> gradmat(DPhiadj(qp) *
143 elem_mat += gradmat.transpose() * gradmat / detDPhi(qp);
150 LF_ASSERT_MSG(
false,
"Illegal cell type");
154 auto nv = vertices.cols();
155 SPDLOG_LOGGER_TRACE(
Logger(),
"Element matrix\n{}",
156 elem_mat.block(0, 0, nv, nv));
157 SPDLOG_LOGGER_TRACE(
Logger(),
"Row sums = {},\ncol sums = {}",
158 elem_mat.block(0, 0, nv, nv).colwise().sum(),
159 elem_mat.block(0, 0, nv, nv).rowwise().sum().transpose());
Represents a reference element with all its properties.
static constexpr RefEl kTria()
Returns the reference triangle.
static constexpr RefEl kQuad()
Returns the reference quadrilateral.
Interface class for shape information on a mesh cell in the spirit of parametric finite element metho...
virtual Eigen::MatrixXd Global(const Eigen::MatrixXd &local) const =0
Map a number of points in local coordinates into the global coordinate system.
virtual dim_t DimLocal() const =0
Dimension of the domain of this mapping.
virtual dim_t DimGlobal() const =0
Dimension of the image of this mapping.
virtual Eigen::MatrixXd JacobianInverseGramian(const Eigen::MatrixXd &local) const =0
Evaluate the Jacobian * Inverse Gramian ( ) simultaneously at numPoints.
virtual Eigen::VectorXd IntegrationElement(const Eigen::MatrixXd &local) const =0
The integration element (factor appearing in integral transformation formula, see below) at number of...
Interface class representing a topological entity in a cellular complex
virtual const geometry::Geometry * Geometry() const =0
Describes the geometry of this entity.
virtual base::RefEl RefEl() const =0
Describes the reference element type of this entity.
Eigen::Matrix< double, 4, 4 > ElemMat
const Eigen::Matrix< double, 2, 1 > kTriabc
const Eigen::Matrix< double, 2, 1 > kQuadpt
ElemMat Eval(const lf::mesh::Entity &cell) const
main routine for the computation of element matrices
static std::shared_ptr< spdlog::logger > & Logger()
Used by LinearFELaplaceElementMatrix to log additional (debug) info.
static Eigen::Matrix< double, 4, 2 > DervRefShapFncts(const Eigen::Vector2d &xh)
const std::array< Eigen::Vector2d, 4 > kQuadPoints
std::shared_ptr< spdlog::logger > InitLogger(const std::string &name)
Create a spdlog logger, register it in the spdlog registry and initialize it with LehrFEM++ specific ...
Collects data structures and algorithms designed for scalar finite element methods primarily meant fo...
std::shared_ptr< spdlog::logger > & LinearFeLocalLoadVectorLogger()
Used by LinearFELocalLoadVector to log additional (debug) information during vector assembly.