ElementaryDataImpl.hpp 16.1 KB
Newer Older
GILLES Sebastien's avatar
GILLES Sebastien committed
1
2
3
4
5
6
7
8
9
10
11
12
13
/*!
//
// \file
//
//
// Created by Sebastien Gilles <sebastien.gilles@inria.fr> on the Thu, 15 Sep 2016 10:56:52 +0200
// Copyright (c) Inria. All rights reserved.
//
// \ingroup OperatorsGroup
// \addtogroup OperatorsGroup
// \{
*/

14

15
16
#ifndef MOREFEM_x_OPERATORS_x_LOCAL_VARIATIONAL_OPERATOR_x_INTERNAL_x_ELEMENTARY_DATA_IMPL_HPP_
# define MOREFEM_x_OPERATORS_x_LOCAL_VARIATIONAL_OPERATOR_x_INTERNAL_x_ELEMENTARY_DATA_IMPL_HPP_
17
18
19
20
21
22

# include <memory>
# include <vector>
# include <array>
# include <cassert>

23
# include "Utilities/Pragma/Pragma.hpp"
24
# include "Utilities/Optional.hpp"
25

GILLES Sebastien's avatar
GILLES Sebastien committed
26
# include "Core/Enum.hpp"
27

28
29
30
31
32
33
# include "FiniteElement/RefFiniteElement/Internal/RefLocalFEltSpace.hpp"
# include "FiniteElement/RefFiniteElement/Advanced/RefFEltInLocalOperator.hpp"
# include "FiniteElement/FiniteElement/LocalFEltSpace.hpp"
# include "FiniteElement/QuadratureRules/QuadraturePoint.hpp"
# include "FiniteElement/Unknown/Unknown.hpp"
# include "FiniteElement/QuadratureRules/QuadratureRule.hpp"
34

35
# include "Operators/LocalVariationalOperator/Advanced/InformationsAtQuadraturePoint.hpp"
36
37


38
namespace MoReFEM
39
{
40
41


42
43
    // ============================
    //! \cond IGNORE_BLOCK_IN_DOXYGEN
44
    // Forward declarations.
45
    // ============================
46

47
48

    class GeometricElt;
49
50


51
52
53
54
55
    // ============================
    // End of forward declarations.
    //! \endcond IGNORE_BLOCK_IN_DOXYGEN
    // ============================

56
57


58
59
    namespace Internal
    {
60
61


62
63
        namespace LocalVariationalOperatorNS
        {
64
65
66
67




68
69
70
71
72
73
            /*!
             * \brief Defines all of ElementaryData that does not depend upon the kind of object considered (matrix or vector).
             */
            class ElementaryDataImpl
            {

74

75
            public:
76

77
78
79
                /// \name Special members.

                ///@{
80

81
82
83
84
85
86
87
88
89
90
91
92
                /*!
                 * \brief Constructor.
                 *
                 * \param[in] ref_felt_space There is exactly one RefGeomElt associated to such an object; this and the
                 * list of unknowns involved for the operator related to this ElementaryData will provide all the data
                 * required to build RefFEltInLocalOperator objects that allow easy navigation through the
                 * elementary data (for instance methods Phi() or dPhi() use this object to extract conveniently the required
                 * data).
                 * \param[in] quadrature_rule Quadrature rule to use for the enclosing local operator.
                 * \param[in] unknown_storage List of unknowns involved in the current local operator. This must be a subset
                 * of the ones in the enclosing FEltSpace; however there is no need to follow the same ordering (ordering
                 * is specified at the LocalVariationalOperator level).
GILLES Sebastien's avatar
GILLES Sebastien committed
93
                 * \param[in] test_unknown_storage List of all the pair test_unknown/numbering subset considered by the operator.
94
                 * \param[in] felt_space_dimension Dimension considered in the finite element space.
95
                 * \param[in] mesh_dimension Dimension in the mesh.
96
97
98
99
100
101
                 *  Must be equal or higher than felt_space_dimension.
                 * \copydoc doxygen_hide_operator_do_allocate_gradient_felt_phi_arg
                 */
                explicit ElementaryDataImpl(const Internal::RefFEltNS::RefLocalFEltSpace& ref_felt_space,
                                            const QuadratureRule& quadrature_rule,
                                            const ExtendedUnknown::vector_const_shared_ptr& unknown_storage,
102
                                            const ExtendedUnknown::vector_const_shared_ptr& test_unknown_storage,
103
                                            unsigned int felt_space_dimension,
104
                                            unsigned int mesh_dimension,
105
                                            AllocateGradientFEltPhi do_allocate_gradient_felt_phi);
106

107
            protected:
108

109
110
                //! Destructor.
                ~ElementaryDataImpl() = default;
111

112
            public:
113

114
115
                //! \copydoc doxygen_hide_copy_constructor
                ElementaryDataImpl(const ElementaryDataImpl& rhs) = delete;
116

117
118
                //! \copydoc doxygen_hide_move_constructor
                ElementaryDataImpl(ElementaryDataImpl&& rhs) = default;
119

120
                //! \copydoc doxygen_hide_copy_affectation
121
                ElementaryDataImpl& operator=(const ElementaryDataImpl& rhs) = delete;
122

123
                //! \copydoc doxygen_hide_move_affectation
124
                ElementaryDataImpl& operator=(ElementaryDataImpl&& rhs) = default;
125
                ///@}
126

127
            public:
128

129
                //! Computes internal quantities related to finite element. Must absolutely be called before each finite
130
131
                //! element is used; will disappear shortly as it is way too dangerous.
                //! \param[in] local_felt_space \a LocalFEltSpace for which dinternal data are computed.
132
                void ComputeLocalFEltSpaceData(const LocalFEltSpace& local_felt_space);
133

134
135
136
137
138
139
140
141
                /*!
                 * \brief Total number of \a Node in the ElementaryData object.
                 *
                 * Might be less than the number of nodes in the RefLocalFEltSpace, as some unknowns of the latter might
                 * have been filtered out.
                 *
                 * \return Number of nodes.
                 */
142
                unsigned int NnodeRow() const noexcept;
143

144
145
146
147
148
149
150
151
                /*!
                 * \brief Total number of \a Node in the ElementaryData object.
                 *
                 * Might be less than the number of nodes in the RefLocalFEltSpace, as some unknowns of the latter might
                 * have been filtered out.
                 *
                 * \return Number of nodes.
                 */
152
                unsigned int NnodeCol() const noexcept;
153

154
155
156
157
158
159
160
161
                /*!
                 * \brief Total number of \a Dof in the ElementaryData object.
                 *
                 * Might be less than the number of dofs in the RefLocalFEltSpace, as some unknowns of the latter might
                 * have been filtered out.
                 *
                 * \return Number of dofs.
                 */
162
                unsigned int NdofRow() const noexcept;
163

164
165
166
167
168
169
170
171
                /*!
                 * \brief Total number of \a Dof in the ElementaryData object.
                 *
                 * Might be less than the number of dofs in the RefLocalFEltSpace, as some unknowns of the latter might
                 * have been filtered out.
                 *
                 * \return Number of dofs.
                 */
172
                unsigned int NdofCol() const noexcept;
173

174
175
                //! Dimension of the \a GeometricElt.
                unsigned int GetGeomEltDimension() const noexcept;
176

177
178
                //! Number of quadrature points.
                unsigned int NquadraturePoint() const noexcept;
179

180
                //! Access the properties shared by all the FElts related to the current local variational operator.
181
                //! \param[in] unknown \a Unknown sed as filter.
182
                const Advanced::RefFEltInLocalOperator& GetRefFElt(const ExtendedUnknown& unknown) const;
183

184
                //! Access the properties shared by all the FElts related to the current local variational operator.
185
                //! \param[in] unknown \a Unknown sed as filter.
186
                const Advanced::RefFEltInLocalOperator& GetTestRefFElt(const ExtendedUnknown& unknown) const;
187

188
189
                //! Number of \a Unknown.
                unsigned int Nunknown() const noexcept;
190

191
                //! Number of \a Unknown.
192
                unsigned int NtestUnknown() const noexcept;
193

194
195
                //! Get the dimension of the finite element space.
                unsigned int GetFEltSpaceDimension() const noexcept;
196

197
                //! Get the dimension of the mesh.
198
                unsigned int GetMeshDimension() const noexcept;
199

200
                //! Accessor to informations at each quadrature point (vector index stands for a quadrature point index).
201
202
                const std::vector<Advanced::LocalVariationalOperatorNS::InformationsAtQuadraturePoint>&
                    GetInformationsAtQuadraturePointList() const noexcept;
203

204
                //! Accessor to a specific element of infos_at_quad_pt_list.
205
                //! \param[in] quadrature_pt_index Position of the requested quadratuure point in the local storage.
206
                const Advanced::LocalVariationalOperatorNS::InformationsAtQuadraturePoint&
207
                    GetInformationsAtQuadraturePoint(unsigned int quadrature_pt_index) const noexcept;
208
209
210
211
212
213

                //! Access to the current \a LocalFEltSpace considered.
                const LocalFEltSpace& GetCurrentLocalFEltSpace() const noexcept;

                //! Access to the current geometric element considered.
                const GeometricElt& GetCurrentGeomElt() const noexcept;
214

215
216
                //! Returns the quadrature rule to use.
                const QuadratureRule& GetQuadratureRule() const noexcept;
217
218


219
            protected:
220
221


222
223
                //! \name Access to cached geometric data.
                ///@{
224

225
226
                //! Number of \a LocalNode in current \a RefGeomElt.
                unsigned int NnodeInRefGeomElt() const noexcept;
227

228
                ///@}
229

230
            private:
231

232
                /*!
233
                 * \brief Get the underlying \a RefGeomElt.
234
235
                 */
                const RefGeomElt& GetRefGeomElt() const  noexcept;
236

237
                /*!
238
                 * \brief Access the \a RefLocalFEltSpace.
239
240
241
                 *
                 * \internal <b><tt>[internal]</tt></b> This accessor is public but should only be used by
                 * LocalVariationalOperators.
242
243
                 *
                 * \return Underlying \a RefLocalFEltSpace.
244
245
246
                 */
                const Internal::RefFEltNS::RefLocalFEltSpace& GetRefLocalFEltSpace() const noexcept;

247

248
            private:
249

250
                //! Fill the point_ matrix with the coordinates of the points of the geometric element in the mesh.
251
                //! \param[in] geometric_element \a GeometricElt for which new coordinates are computed.
252
                void UpdateCoordinates(const GeometricElt& geometric_element);
253

254
255
                //! Set the number of components and the related sequence.
                void SetGeomEltDimension();
256

257
            private:
258
259


260
261
262
263
                //! Non constant accessor to informations at each quadrature point (vector index stands for a
                //! quadrature point index).
                std::vector<Advanced::LocalVariationalOperatorNS::InformationsAtQuadraturePoint>&
                    GetNonCstInformationsAtQuadraturePointList();
264
265


266
267
268
269
270
                /*!
                 * \brief Init the reference finite elements.
                 *
                 * Numbering subset are completely dropped in this method: they are irrelevant at a local level,
                 * which is where ElementaryData is used.
271
272
                 *
                 * \param[in] extended_unknown_list List of \a ExtendedUnknown considered in the current object.
273
                 * \param[in] test_extended_unknown_list List of \a ExtendedUnknown considered in the current object for
274
                 * test unknowns.
275
                 */
276

277
278
279
280
                void InitAllReferenceFiniteElements(const ExtendedUnknown::vector_const_shared_ptr&
                                                        extended_unknown_list,
                                                    const ExtendedUnknown::vector_const_shared_ptr&
                                                        test_extended_unknown_list);
281

282
          
283
284
                //! Access the list of reference finite elements.
                const Advanced::RefFEltInLocalOperator::vector_const_unique_ptr& GetRefFEltList() const noexcept;
285

286
287
                //! Access the list of reference finite elements.
                const Advanced::RefFEltInLocalOperator::vector_const_unique_ptr& GetTestRefFEltList() const noexcept;
288

289
                //! Set the pointer to \a LocalFEltSpace under consideration.
290
                //! \param[in] local_felt_space Pointer to the \a LocalFEltSpace to consider.
291
                void SetCurrentLocalFEltSpace(const LocalFEltSpace* local_felt_space);
292
293


294
            private:
295

296
297
                //! Finite element type for which the elementary data are produced.
                const Internal::RefFEltNS::RefLocalFEltSpace& ref_felt_space_;
298

299
300
                //! Quadrature rule to use.
                const QuadratureRule& quadrature_rule_;
301

302
303
                //! Coordinates of the points defining the element: point_(ipoint,jcoor)  (in the current FE)
                LocalMatrix point_;
304

305
306
307
308
309
                /*!
                 * \brief Stores the informations at quadrature point level.
                 *
                 * The index of the vector stands for a quadrature point.
                 */
310
                std::vector<Advanced::LocalVariationalOperatorNS::InformationsAtQuadraturePoint> infos_at_quad_pt_list_;
311

312
313
314
315
316
317
                /*!
                 * \brief Total number of \a Node in the ElementaryData object.
                 *
                 * Might be less than the number of nodes in the RefLocalFEltSpace, as some unknowns of the latter might
                 * have been filtered out.
                 */
318
                unsigned int Nnode_row_;
319

320
321
322
323
324
325
326
                /*!
                 * \brief Total number of \a Node in the ElementaryData object.
                 *
                 * Might be less than the number of nodes in the RefLocalFEltSpace, as some unknowns of the latter might
                 * have been filtered out.
                 */
                unsigned int Nnode_col_;
327
328


329
330
331
332
333
334
                /*!
                 * \brief Total number of \a Dof in the ElementaryData object.
                 *
                 * Might be less than the number of dofs in the RefLocalFEltSpace, as some unknowns of the latter might
                 * have been filtered out.
                 */
335
                unsigned int Ndof_row_;
336

337
338
339
340
341
342
343
                /*!
                 * \brief Total number of \a Dof in the ElementaryData object.
                 *
                 * Might be less than the number of dofs in the RefLocalFEltSpace, as some unknowns of the latter might
                 * have been filtered out.
                 */
                unsigned int Ndof_col_;
344

345

346
347
                //! Dimension considered in the finite element space.
                const unsigned int felt_space_dimension_;
348

349
350
                //! Dimension in the mesh. Must be equal or higher than felt_space_dimension_.
                const unsigned int mesh_dimension_;
351
352

                /*!
353
354
355
356
357
358
                 * \brief LocalFEltSpace under consideration.
                 *
                 * \warning Do not delete this pointer!
                 *
                 */
                const LocalFEltSpace* current_local_felt_space_ = nullptr;
359
360


361
            private:
362
363


364
                //! \name Cached geometric data.
365

366
                ///@{
367

368
                //! Dimension of the \a GeometricElt.
369
                unsigned int geom_elt_dimension_ = NumericNS::UninitializedIndex<unsigned int>();
370
371


372
373
374
375
376
377
                /*!
                 * \brief Number of Coords object required to describe fully a GeometricElt of this type.
                 *
                 * For instance 27 for an Hexahedron 27 or 1 for a Point.
                 */
                unsigned int Ncoords_in_geom_ref_elt_  = NumericNS::UninitializedIndex<unsigned int>();
378

379
                ///@}
380
381


382
            private:
383

384
385
                //! List of reference finite elements.
                Advanced::RefFEltInLocalOperator::vector_const_unique_ptr ref_felt_list_;
386

387
                //! List of reference finite elements for test unknowns.
388
                MOREFEM_OPTIONAL<Advanced::RefFEltInLocalOperator::vector_const_unique_ptr> test_ref_felt_list_;
389

390
            };
391
392


393
        } // namespace LocalVariationalOperatorNS
394
395


396
397
    } // namespace Internal

398

399
} // namespace MoReFEM
400
401


402
403
404
/// @} // addtogroup OperatorsGroup


405
# include "Operators/LocalVariationalOperator/Internal/ElementaryDataImpl.hxx"
406
407


408
#endif // MOREFEM_x_OPERATORS_x_LOCAL_VARIATIONAL_OPERATOR_x_INTERNAL_x_ELEMENTARY_DATA_IMPL_HPP_