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());