LifeV
ETFESpace.hpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4 
5  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory UNiversity
7 
8  This file is part of the LifeV library
9 
10  LifeV is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation; either version 3 of the License, or
13  (at your option) any later version.
14 
15  LifeV is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public
21  License along with this library; if not, see <http://www.gnu.org/licenses/>
22 
23 
24 *******************************************************************************
25 */
26 //@HEADER
27 
28 /*!
29  * @file
30  @brief This file contains the definition of the ETFESpace.
31 
32  @date 06/2011
33  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
34  */
35 
36 #ifndef ETFESPACE_HPP
37 #define ETFESPACE_HPP
38 
39 #include <boost/shared_ptr.hpp>
40 
41 #include <lifev/core/LifeV.hpp>
42 
43 #include <lifev/core/fem/GeometricMap.hpp>
44 #include <lifev/core/fem/ReferenceFEScalar.hpp>
45 #include <lifev/core/fem/ReferenceFEHdiv.hpp>
46 #include <lifev/core/fem/ReferenceFEHybrid.hpp>
47 #include <lifev/core/fem/QuadratureRule.hpp>
48 #include <lifev/core/fem/DOF.hpp>
49 
50 #include <lifev/eta/fem/MeshGeometricMap.hpp>
51 #include <lifev/core/mesh/MeshPartitioner.hpp>
52 
53 namespace LifeV
54 {
55 
56 
57 
58 //! class ETFESpace A light, templated version of the FESpace
59 /*!
60  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
61 
62  This class represents a data structure for everything a finite element space
63  requires to be defined:
64 
65  <ul>
66  <li> The mesh
67  <li> The reference element
68  <li> The geometric map (between the reference element and mesh elements)
69  <li> The degree of freedom numbering
70  <li> The repartition of the degrees of freedom across the processors (algebraic map)
71  </ul>
72 
73  It does not contain any information about the quadrature (unlike LifeV::FESpace), as this is not strictly needed for the definition of the space.
74 
75  This class is supposed to be constant during a simulation, so that it can
76  be shared across the different structures using it.
77 
78  <b>Template parameters</b>
79 
80  <i> MeshType </i> The type of the mesh used.
81  <i> MapType </i> The type of the algebraic map (for distributed computations, e.g. MapEpetra).
82  <i> SpaceDim </i> The space of the domain definition
83  <i> FieldDim </i> The dimension of the field (1 for a scalar FE, more for a vectorial one)
84 
85  <b>Template requirements</b>
86 
87  <i> MeshType </i> Same as for std::shared_ptr
88  <i> MapType </i> empty constructor; copy constructor; constructor using the reference FE, the mesh and a communicator;
89  concatenation operator +=
90 
91 */
92 template<typename MeshType, typename MapType, UInt SpaceDim, UInt FieldDim>
93 class ETFESpace
94 {
95 public:
96 
97  //! @name Public Types
98  //@{
99 
100  //! Typedef for the mesh
101  typedef MeshType mesh_Type;
102 
103  //! Typedef for the map (algebraic)
104  typedef MapType map_Type;
105 
106  //! Typedef for a pointer on the mesh
107  typedef std::shared_ptr<mesh_Type> meshPtr_Type;
108 
109  //! Typedef for a pointer on the communicator
110  typedef typename map_Type::commPtr_Type commPtr_Type;
111 
112  //@}
113 
114 
115  //! @name Static constants
116  //@{
117 
118  //! Dimension of the space
119  enum {space_dim = SpaceDim};
120 
121  //! Dimension of the field of the FE space
122  enum {field_dim = FieldDim};
123 
124  //@}
125 
126 
127  //! @name Constructors, destructor
128  //@{
129 
130  //! Full constructor using the mesh, the referenceFE, the mapping and the communicator
131  /*!
132  @param mesh Pointer on the mesh
133  @param refFE The reference element for the finite element
134  @param geoMap The geometric mapping
135  @param commptr Pointer on the communicator to be used
136  */
137  ETFESpace (const meshPtr_Type& mesh,
138  const ReferenceFE* refFE,
139  const GeometricMap* geoMap,
140  commPtr_Type& commptr);
141 
142  //! Constructor where the geometric mapping is guessed
143  /*!
144  In this constructor, the geometric map is guessed using the shape of the
145  elements of the mesh.
146 
147  @param mesh Pointer on the mesh
148  @param refFE The reference element for the finite element
149  @param commptr Pointer on the communicator to be used
150  */
151  ETFESpace (const meshPtr_Type& mesh,
152  const ReferenceFE* refFE,
153  commPtr_Type& commptr);
154 
155  //! Full constructor using the partitioner of the mesh
156  /*!
157  @param meshPartitioner The partition of the mesh
158  @param refFE The reference element for the finite element
159  @param geoMap The geometric mapping
160  @param commptr Pointer on the communicator to be used
161  */
162  ETFESpace (const MeshPartitioner<MeshType>& meshPartitioner,
163  const ReferenceFE* refFE,
164  const GeometricMap* geoMap,
165  commPtr_Type& commptr);
166 
167  //! Full constructor using the partitioner of the mesh and a guessed geometric map
168  /*!
169  In this constructor, the geometric map is guessed using the shape of the
170  elements of the mesh.
171 
172  @param meshPartitioner The partition of the mesh
173  @param refFE The reference element for the finite element
174  @param commptr Pointer on the communicator to be used
175  */
176  ETFESpace (const MeshPartitioner<MeshType>& meshPartitioner,
177  const ReferenceFE* refFE,
178  commPtr_Type& commptr);
179 
180 
181  //! Copy constructor
182  /*!
183  @param otherSpace The finite element space to be copied
184  */
185  ETFESpace (const ETFESpace<MeshType, MapType, SpaceDim, FieldDim>& otherSpace);
186 
187  //! Destructor
188  virtual ~ETFESpace()
189  {}
190 
191  //@}
192 
193 
194  //! @name Get Methods
195  //@{
196 
197  //! Getter for the mesh pointer
198  /*!
199  @return The pointer (shared) on the mesh
200  */
201  meshPtr_Type mesh() const
202  {
203  return M_mesh;
204  }
205 
206  //! Getter for the reference FE
207  /*!
208  @return The reference FE of this space
209  */
210  const ReferenceFE& refFE() const
211  {
212  return *M_referenceFE;
213  }
214 
215  //! Getter for the geometric mapping
216  /*!
217  @return The geometric mapping used for this space
218  */
219  const GeometricMap& geoMap() const
220  {
221  return *M_geometricMap;
222  }
223 
224  //! Getter for the dof manager
225  /*!
226  @return The structure retaining the dof numbering
227  */
228  const DOF& dof() const
229  {
230  return *M_dof;
231  }
232 
233  //! Getter for the algebraic map
234  /*!
235  @return The algebraic map
236  */
237  const MapType& map() const
238  {
239  return *M_map;
240  }
241 
242  //! Getter for the algebraic map
243  /*!
244  @return The algebraic map
245  */
246  MapType& map()
247  {
248  return *M_map;
249  }
250 
251  //! Getter for the dimension of the space (geometric, ambiant space)
252  /*!
253  @return The dimension of the space in which this FE space is defined
254  */
255  const UInt spaceDim() const
256  {
257  return space_dim;
258  }
259 
260  //! Getter for the dimension of the field (scalar vs vectorial FE)
261  /*!
262  @return The dimension of the field represented.
263  */
264  const UInt fieldDim() const
265  {
266  return field_dim;
267  }
268  //@}
269 
270 private:
271 
272  //! @name Private Methods
273  //@{
274 
275  //! No empty constructor
276  ETFESpace();
277 
278  //! Creates the map from the input
279  void createMap (const commPtr_Type& commptr);
280 
281  //@}
282 
283 
284  // Mesh member
285  meshPtr_Type M_mesh;
286 
287  // Reference FE
288  const ReferenceFE* M_referenceFE;
289 
290  // Geometric mapping
291  const GeometricMap* M_geometricMap;
292 
293  // DoF manager
294  DOF* M_dof;
295 
296  // Algebraic map
297  MapType* M_map;
298 };
299 
300 
301 // ===================================================
302 // IMPLEMENTATION
303 // ===================================================
304 
305 // ===================================================
306 // Constructors & Destructor
307 // ===================================================
308 
309 template<typename MeshType, typename MapType, UInt SpaceDim, UInt FieldDim>
310 ETFESpace<MeshType, MapType, SpaceDim, FieldDim>::
311 ETFESpace (const meshPtr_Type& mesh, const ReferenceFE* refFE, const GeometricMap* geoMap, commPtr_Type& commptr)
312 
313  : M_mesh (mesh),
314  M_referenceFE (refFE),
315  M_geometricMap (geoMap),
316  M_dof ( new DOF ( *M_mesh, *M_referenceFE ) ),
317  M_map (new MapType() )
318 {
319  createMap (commptr);
320 }
321 
322 template<typename MeshType, typename MapType, UInt SpaceDim, UInt FieldDim>
323 ETFESpace<MeshType, MapType, SpaceDim, FieldDim>::
324 ETFESpace (const meshPtr_Type& mesh, const ReferenceFE* refFE, commPtr_Type& commptr)
325 
326  : M_mesh (mesh),
327  M_referenceFE (refFE),
328  M_geometricMap (&geometricMapFromMesh<MeshType>() ),
329  M_dof ( new DOF ( *M_mesh, *M_referenceFE ) ),
330  M_map (new MapType() )
331 {
332 
333  createMap (commptr);
334 }
335 
336 template<typename MeshType, typename MapType, UInt SpaceDim, UInt FieldDim>
337 ETFESpace<MeshType, MapType, SpaceDim, FieldDim>::
338 ETFESpace (const MeshPartitioner<MeshType>& meshPartitioner,
339  const ReferenceFE* refFE,
340  const GeometricMap* geoMap,
341  commPtr_Type& commptr)
342  : M_mesh (meshPartitioner.meshPartition() ),
343  M_referenceFE (refFE),
344  M_geometricMap (geoMap),
345  M_dof ( new DOF ( *M_mesh, *M_referenceFE ) ),
346  M_map (new MapType() )
347 {
348  createMap (commptr);
349 }
350 
351 template<typename MeshType, typename MapType, UInt SpaceDim, UInt FieldDim>
352 ETFESpace<MeshType, MapType, SpaceDim, FieldDim>::
353 ETFESpace (const MeshPartitioner<MeshType>& meshPartitioner,
354  const ReferenceFE* refFE,
355  commPtr_Type& commptr)
356  : M_mesh (meshPartitioner.meshPartition() ),
357  M_referenceFE (refFE),
358  M_geometricMap ( &geometricMapFromMesh<MeshType>() ),
359  M_dof ( new DOF ( *M_mesh, *M_referenceFE ) ),
360  M_map (new MapType() )
361 {
362  createMap (commptr);
363 }
364 
365 template<typename MeshType, typename MapType, UInt SpaceDim, UInt FieldDim>
366 ETFESpace<MeshType, MapType, SpaceDim, FieldDim>::
367 ETFESpace (const ETFESpace<MeshType, MapType, SpaceDim, FieldDim>& otherSpace)
368 
369  : M_mesh (otherSpace.M_mesh),
370  M_referenceFE (otherSpace.M_referenceFE),
371  M_geometricMap (otherSpace.M_geometricMap),
372  M_dof (otherSpace.M_dof),
373  M_map (otherSpace.M_map)
374 {}
375 
376 template<typename MeshType, typename MapType, UInt SpaceDim, UInt FieldDim>
377 void
378 ETFESpace<MeshType, MapType, SpaceDim, FieldDim>::
379 createMap (const commPtr_Type& commptr)
380 {
381  // get globalElements list from DOF
382  typename MapType::mapData_Type mapData = this->M_dof->createMapData ( *this->M_mesh );
383  // Create the map
384  MapType map ( mapData, commptr );
385 
386  for ( UInt ii (0); ii < FieldDim; ++ii )
387  {
388  *M_map += map;
389  }
390 }
391 
392 
393 } //Namespace LifeV
394 
395 #endif //ETFESPACE_HPP
GeometricMap - Structure for the geometrical mapping.
void updateInverseJacobian(const UInt &iQuadPt)
The class for a reference Lagrangian finite element.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191