LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
solution_to_mesh_data_set.cc
1
2#include "solution_to_mesh_data_set.h"
3
4#include <lf/uscalfe/lagr_fe.h>
5
7
9 const std::shared_ptr<const lf::mesh::Mesh> &mesh,
10 const lf::assemble::DofHandler &dofh, const Eigen::VectorXd &solution) {
12 for (const auto *const node : mesh->Entities(2)) {
13 coefficients(*node) = solution[dofh.GlobalDofIndices(*node)[0]];
14 }
15 return coefficients;
16}
17
19 const std::shared_ptr<const lf::mesh::Mesh> &mesh,
20 const lf::assemble::DofHandler &dofh, const Eigen::VectorXd &solution) {
22 for (const auto *const cell : mesh->Entities(0)) {
23 const auto *geom = cell->Geometry();
24 // Construct the basis functions from the curl of the standard hat functions
26 const Eigen::MatrixXd ref_grads =
27 hat_func.GradientsReferenceShapeFunctions(Eigen::VectorXd::Zero(2))
28 .transpose();
29 const Eigen::MatrixXd J_inv_trans =
30 geom->JacobianInverseGramian(Eigen::VectorXd::Zero(2));
31 const Eigen::MatrixXd grads = J_inv_trans * ref_grads;
32 Eigen::MatrixXd basis_funct(2, 3);
33 basis_funct << grads.row(1), -grads.row(0);
34 const auto idx = dofh.GlobalDofIndices(*cell);
35 velocity(*cell) = solution[idx[0]] * basis_funct.col(0) +
36 solution[idx[1]] * basis_funct.col(1) +
37 solution[idx[2]] * basis_funct.col(2);
38 }
39 return velocity;
40}
41
42} // end namespace projects::ipdg_stokes::post_processing
A general (interface) class for DOF handling, see Lecture Document Paragraph 2.7.4....
Definition: dofhandler.h:109
virtual nonstd::span< const gdof_idx_t > GlobalDofIndices(const lf::mesh::Entity &entity) const =0
access to indices of global dof's belonging to an entity
A MeshDataSet that attaches data of type T to every entity of a mesh that has a specified codimension...
Linear Lagrange finite element on triangular reference element.
Definition: lagr_fe.h:58
Eigen::Matrix< SCALAR, Eigen::Dynamic, Eigen::Dynamic > GradientsReferenceShapeFunctions(const Eigen::MatrixXd &refcoords) const override
Computation of the gradients of all reference shape functions in a number of points.
Definition: lagr_fe.h:117
lf::mesh::utils::CodimMeshDataSet< Eigen::Vector2d > extractVelocity(const std::shared_ptr< const lf::mesh::Mesh > &mesh, const lf::assemble::DofHandler &dofh, const Eigen::VectorXd &solution)
Extract the flow velocity on cells from the solution vector.
lf::mesh::utils::CodimMeshDataSet< double > extractBasisFunctionCoefficients(const std::shared_ptr< const lf::mesh::Mesh > &mesh, const lf::assemble::DofHandler &dofh, const Eigen::VectorXd &solution)
Extract the basis function coefficients from the solution vector.