OGS
ComputeNaturalCoordsRootFindingProblem.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
8#include "MeshLib/Node.h"
11
12namespace ApplicationUtils
13{
21template <typename ShapeFunction>
23{
24 static constexpr int Dim = ShapeFunction::DIM;
26
27public:
29 Eigen::Matrix<double, Dim, Dim, Eigen::RowMajor>;
32 using LocalResidualVector = Eigen::Matrix<double, Dim, 1>;
33
35 MeshLib::Element const& e, LocalResidualVector const& x_expected)
36 : e_{e},
38 x_expected_{x_expected},
39 // TODO 2D elements with 3D coordinates etc.
40 // TODO check all dims
41 sm_{ShapeFunction::DIM, e.getDimension(), ShapeFunction::NPOINTS}
42 {
43 updateShp();
44 }
45
47 {
48 auto const& dNdr = sm_.dNdr;
49
50 for (int comp = 0; comp < Dim; ++comp)
51 {
52 J.row(comp) = node_coords_.row(comp) * dNdr.transpose();
53 }
54 }
55
57 {
58 res = node_coords_ * sm_.N.transpose() - x_expected_;
59 }
60
65 {
66 r_ += delta_r;
67 updateShp();
68 }
69
70 LocalResidualVector const& getNaturalCoordinates() const { return r_; }
71
72private:
74 Eigen::Matrix<double, Dim, ShapeFunction::NPOINTS, Eigen::RowMajor>;
75
76 void updateShp()
77 {
78 auto const fe =
81
82 constexpr auto GlobalDim = Dim;
83 fe.template computeShapeFunctions<NumLib::ShapeMatrixType::N_J>(
84 r_.data(), sm_, GlobalDim, false);
85 }
86
88 {
89 NodeCoordsMatrix node_coords;
90
91 for (std::size_t n = 0; n < ShapeFunction::NPOINTS; ++n)
92 {
93 node_coords.col(n) = Eigen::Map<const Eigen::Vector<double, Dim>>(
94 e.getNode(n)->data());
95 }
96
97 return node_coords;
98 }
99
101 {
102 return LocalResidualVector::Constant(0.5);
103 }
104
108
111};
112} // namespace ApplicationUtils
EigenFixedShapeMatrixPolicy< ShapeFunction, GlobalDim > ShapeMatrixPolicyType
Eigen::Matrix< double, Dim, Dim, Eigen::RowMajor > LocalJacobianMatrix
Eigen::Matrix< double, Dim, ShapeFunction::NPOINTS, Eigen::RowMajor > NodeCoordsMatrix
ComputeNaturalCoordsRootFindingProblem(MeshLib::Element const &e, LocalResidualVector const &x_expected)
virtual const Node * getNode(unsigned idx) const =0
NumLib::TemplateIsoparametric< ShapeFunction, ShapeMatricesType > createIsoparametricFiniteElement(MeshLib::Element const &e)
NumLib::ShapeMatrices< NodalRowVectorType, DimNodalMatrixType, DimMatrixType, GlobalDimNodalMatrixType > ShapeMatrices