1 /*=========================================================================
2  *
3  *  Copyright Insight Software Consortium
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *         http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  *=========================================================================*/
18 
19 #ifndef itkFEMElement3DStrain_h
20 #define itkFEMElement3DStrain_h
21 
22 #include "itkFEMElementBase.h"
23 #include "itkFEMMaterialLinearElasticity.h"
24 
25 namespace itk
26 {
27 namespace fem
28 {
29 /**
30  * \class Element3DStrain
31  * \brief Class that is used to define linear elasticity problem in 3D space.
32  *
33  * This class only defines the physics of the problem. Use his class together
34  * with element classes that specify the geometry to fully define the element.
35  *
36  * This class defines the physics to define element strain.
37  *
38  * You can specify one template parameter:
39  *
40  *   TBaseClass - Class from which Element3DStrain is derived. TBaseClass must
41  *                be derived from the Element base class. This enables you
42  *                to use this class at any level of element definition.
43  *                If not specified, it defaults to the Element base class.
44  * \ingroup ITKFEM
45  */
46 template <typename TBaseClass = Element>
47 class ITK_TEMPLATE_EXPORT Element3DStrain : public TBaseClass
48 {
49 public:
50   /** Standard class type aliases. */
51   using Self = Element3DStrain;
52   using Superclass = TBaseClass;
53   using Pointer = SmartPointer<Self>;
54   using ConstPointer = SmartPointer<const Self>;
55 
56   /** Run-time type information (and related methods). */
57   itkTypeMacro(Element3DStrain, TBaseClass);
58 
59   // Repeat the required type alias and enums from parent class
60   using Float = typename Superclass::Float;
61   using MatrixType = typename Superclass::MatrixType;
62   using VectorType = typename Superclass::VectorType;
63 
64   /**
65    * Default constructor only clears the internal storage
66    */
67   Element3DStrain();
68 
69   // ////////////////////////////////////////////////////////////////////////
70   /**
71    * Methods related to the physics of the problem.
72    */
73 
74   /**
75    * Compute the B matrix.
76    */
77   void GetStrainDisplacementMatrix(MatrixType & B, const MatrixType & shapeDgl) const override;
78 
79   /**
80    * Compute the D matrix.
81    */
82   void GetMaterialMatrix(MatrixType & D) const override;
83 
84   /**
85    * 3D strain elements have 3 DOFs per node.
86    */
GetNumberOfDegreesOfFreedomPerNode()87   unsigned int GetNumberOfDegreesOfFreedomPerNode() const override
88   {
89     return 3;
90   }
91 
92   /**
93    * Get/Set the material properties for the element
94    */
GetMaterial()95   Material::ConstPointer GetMaterial() const override
96   {
97     return m_mat;
98   }
99 
SetMaterial(Material::ConstPointer mat_)100   void SetMaterial(Material::ConstPointer mat_) override
101   {
102     m_mat =
103       dynamic_cast<const MaterialLinearElasticity *>( mat_.GetPointer() );
104   }
105 
106 protected:
107 
108   void PrintSelf(std::ostream& os, Indent indent) const override;
109 
110   /**
111    * Pointer to material properties of the element
112    */
113   const MaterialLinearElasticity *m_mat;
114 
115 };  // class Element3DStrain
116 } // end namespace fem
117 } // end namespace itk
118 
119 #ifndef ITK_MANUAL_INSTANTIATION
120 #include "itkFEMElement3DStrain.hxx"
121 #endif
122 
123 #endif  // itkFEMElement3DStrain_h
124