1 /** @file gsMaterialMatrixBase.h
2 
3     @brief Provides a base class for material matrices
4 
5     This file is part of the G+Smo library.
6 
7     This Source Code Form is subject to the terms of the Mozilla Public
8     License, v. 2.0. If a copy of the MPL was not distributed with this
9     file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11     Author(s):
12         H.M. Verhelst   (2019-..., TU Delft)
13         A. Mantzaflaris (2019-..., Inria)
14 */
15 
16 #pragma once
17 
18 #include <gsCore/gsFuncData.h>
19 #include <gsUtils/gsThreaded.h>
20 
21 namespace gismo
22 {
23 
24 /**
25  * @brief      This class defines the base class for material matrices
26  *
27  * @tparam     T     Real type
28  *
29  * @ingroup    KLShell
30  */
31 template <short_t dim, class T>
32 class gsMaterialMatrixBaseDim : public gsMaterialMatrixBase<T>
33 {
34     using Base = gsMaterialMatrixBase<T>;
35 
36 public:
37 
gsMaterialMatrixBaseDim()38     gsMaterialMatrixBaseDim() : m_patches(nullptr)
39     {
40         membersSetZero();
41     }
42 
43 
gsMaterialMatrixBaseDim(const gsFunctionSet<T> & mp)44     gsMaterialMatrixBaseDim(const gsFunctionSet<T> & mp)
45     :
46     m_patches(&mp)
47     {
48         membersSetZero();
49     }
50 
gsMaterialMatrixBaseDim(const gsFunctionSet<T> & mp,const gsFunctionSet<T> & mp_def)51     gsMaterialMatrixBaseDim(const gsFunctionSet<T> & mp,
52                             const gsFunctionSet<T> & mp_def)
53     :
54     m_patches(&mp)
55     {
56         membersSetZero();
57         this->setDeformed(&mp_def);
58     }
59 
60 
61     /// Destructor
~gsMaterialMatrixBaseDim()62     virtual ~gsMaterialMatrixBaseDim() {}
63 
64 public:
65 
66     /// Computes metric quantities on the deformed geometry
67     void _computeMetricDeformed(const index_t patch, const gsMatrix<T> & u, bool basis = true) const;
68 
69     /// Computes metric quantities on the undeformed geometry
70     void _computeMetricUndeformed(const index_t patch, const gsMatrix<T> & u, bool basis = true) const;
71 
72     /// Gets metric quantities on the deformed and undeformed geometries
73     void _getMetric(index_t k, T z, bool basis = true) const;
74 
75     /// Gets metric quantities on the deformed geometry
76     void _getMetricDeformed(index_t k, T z, bool basis = true) const;
77 
78     /// Gets metric quantities on the undeformed geometry
79     void _getMetricUndeformed(index_t k, T z, bool basis = true) const;
80 
81     /// Computes the stretch given deformation tensor C, into a pair
82     std::pair<gsVector<T>,gsMatrix<T>> _evalStretch(const gsMatrix<T> & C ) const;
83 
84     /// Computes the stretch given deformation tensor C, into class members m_stretches and m_stretchDirs
85     void _computeStretch(const gsMatrix<T> & C ) const;
86 
87     /// Computes the stretch given deformation tensor C, into class members m_stretches and m_stretchDirs
88     gsMatrix<T> _transformation(const gsMatrix<T> & basis1, const gsMatrix<T> & basis2 ) const;
89 
90 private:
91     /// Implementation of \ref _computeMetricUndeformed for planar geometries
92     template<short_t _dim>
93     typename std::enable_if<_dim==2, void>::type _computeMetricDeformed_impl(const index_t patch, const gsMatrix<T> & u, bool basis) const;
94 
95     /// Implementation of \ref _computeMetricUndeformed for surface geometries
96     template<short_t _dim>
97     typename std::enable_if<_dim==3, void>::type _computeMetricDeformed_impl(const index_t patch, const gsMatrix<T> & u, bool basis) const;
98 
99     /// Implementation of \ref _getMetric for planar geometries
100     template<short_t _dim>
101     typename std::enable_if<_dim==2, void>::type _computeMetricUndeformed_impl(const index_t patch, const gsMatrix<T> & u, bool basis) const;
102 
103     /// Implementation of \ref _getMetric for surface geometries
104     template<short_t _dim>
105     typename std::enable_if<_dim==3, void>::type _computeMetricUndeformed_impl(const index_t patch, const gsMatrix<T> & u, bool basis) const;
106 
107     /// Implementation of \ref _getMetricDeformed for planar geometries
108     template<short_t _dim>
109     typename std::enable_if<_dim==2, void>::type _getMetric_impl(index_t k, T z, bool basis) const;
110 
111     template<short_t _dim>
112     typename std::enable_if<_dim==3, void>::type _getMetric_impl(index_t k, T z, bool basis) const;
113 
114     /// Implementation of \ref _getMetricDeformed for surface geometries
115     template<short_t _dim>
116     typename std::enable_if<_dim==2, void>::type _getMetricDeformed_impl(index_t k, T z, bool basis) const;
117 
118     /// Implementation of \ref _getMetricDeformed for surface geometries
119     template<short_t _dim>
120     typename std::enable_if<_dim==3, void>::type _getMetricDeformed_impl(index_t k, T z, bool basis) const;
121 
122     /// Implementation of \ref _getMetricUndeformed for planar geometries
123     template<short_t _dim>
124     typename std::enable_if<_dim==2, void>::type _getMetricUndeformed_impl(index_t k, T z, bool basis) const;
125 
126     /// Implementation of \ref _getMetricUndeformed for surface geometries
127     template<short_t _dim>
128     typename std::enable_if<_dim==3, void>::type _getMetricUndeformed_impl(index_t k, T z, bool basis) const;
129 
130 protected:
131 
membersSetZero()132     void membersSetZero()
133     {
134         m_Acov_ori.setZero(); m_Acon_ori.setZero(); m_Acov_def.setZero(); m_Acon_def.setZero(); m_Bcov_ori.setZero(); m_Bcon_ori.setZero(); m_Bcov_def.setZero(); m_Bcon_def.setZero();
135         m_acov_ori.setZero(); m_acon_ori.setZero(); m_acov_def.setZero(); m_acon_def.setZero();
136         m_ncov_ori.setZero(); m_ncov_def.setZero();
137         m_Gcov_ori.setZero(); m_Gcon_ori.setZero(); m_Gcov_def.setZero(); m_Gcon_def.setZero(); m_Gcov_ori_L.setZero(); m_Gcov_def_L.setZero();
138         m_gcov_ori.setZero(); m_gcov_def.setZero();m_gcon_ori.setZero(); m_gcon_def.setZero();
139         m_Acov_ori_mat.setZero(); m_Acon_ori_mat.setZero(); m_Acov_def_mat.setZero(); m_Acon_def_mat.setZero(); m_Bcov_ori_mat.setZero(); m_Bcov_def_mat.setZero();
140         m_acov_ori_mat.setZero(); m_acon_ori_mat.setZero(); m_acov_def_mat.setZero(); m_acon_def_mat.setZero(); m_ncov_ori_mat.setZero(); m_ncov_def_mat.setZero();
141 
142     }
143 
144     const gsFunctionSet<T> * m_patches;
145     using Base::m_defpatches;
146     // const gsFunctionSet<T> * m_defpatches;
147 
148     // Geometric data point
149     mutable util::gsThreaded<gsMapData<T> > m_map, m_map_def;
150 
151     mutable gsMatrix<T,2,2> m_Acov_ori, m_Acon_ori, m_Acov_def, m_Acon_def, m_Bcov_ori, m_Bcon_ori, m_Bcov_def, m_Bcon_def;
152     mutable gsMatrix<T,dim,2> m_acov_ori, m_acon_ori, m_acov_def, m_acon_def;
153     mutable gsMatrix<T,3,2> m_ncov_ori, m_ncov_def;
154     mutable gsMatrix<T,3,3> m_Gcov_ori, m_Gcon_ori, m_Gcov_def, m_Gcon_def, m_Gcov_ori_L, m_Gcov_def_L;
155     mutable gsMatrix<T,3,3> m_gcov_ori, m_gcov_def,m_gcon_ori, m_gcon_def;
156     mutable gsMatrix<T> m_Acov_ori_mat, m_Acon_ori_mat, m_Acov_def_mat, m_Acon_def_mat, m_Bcov_ori_mat, m_Bcov_def_mat;
157     mutable gsMatrix<T> m_acov_ori_mat, m_acon_ori_mat, m_acov_def_mat, m_acon_def_mat, m_ncov_ori_mat, m_ncov_def_mat;
158 
159     mutable gsMatrix<T> m_stretches, m_stretchvec;
160 
161     mutable T           m_J0_sq, m_J_sq;
162 
163 public:
164     EIGEN_MAKE_ALIGNED_OPERATOR_NEW //must be present whenever the class contains fixed size matrices
165 
166 };
167 
168 } // namespace
169 
170 #ifndef GISMO_BUILD_LIB
171 #include GISMO_HPP_HEADER(gsMaterialMatrixBaseDim.hpp)
172 #endif
173