Reference documentation for deal.II version 9.0.0
mapping_data_on_the_fly.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2014 - 2018 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 
17 #ifndef dealii_matrix_free_mapping_data_on_the_fly_h
18 #define dealii_matrix_free_mapping_data_on_the_fly_h
19 
20 
21 #include <deal.II/base/config.h>
22 #include <deal.II/base/exceptions.h>
23 #include <deal.II/base/subscriptor.h>
24 #include <deal.II/base/vectorization.h>
25 #include <deal.II/base/aligned_vector.h>
26 #include <deal.II/matrix_free/shape_info.h>
27 #include <deal.II/matrix_free/mapping_info.h>
28 #include <deal.II/fe/fe_values.h>
29 #include <deal.II/fe/fe_nothing.h>
30 #include <deal.II/fe/mapping_q1.h>
31 
32 
33 DEAL_II_NAMESPACE_OPEN
34 
35 
36 namespace internal
37 {
38  namespace MatrixFreeFunctions
39  {
58  template <int dim, typename Number=double>
60  {
61  public:
68  MappingDataOnTheFly (const Mapping<dim> &mapping,
69  const Quadrature<1> &quadrature,
70  const UpdateFlags update_flags);
71 
77  MappingDataOnTheFly (const Quadrature<1> &quadrature,
78  const UpdateFlags update_flags);
79 
83  void reinit(typename ::Triangulation<dim>::cell_iterator cell);
84 
89  bool is_initialized() const;
90 
94  typename ::Triangulation<dim>::cell_iterator get_cell () const;
95 
102  const ::FEValues<dim> &get_fe_values () const;
103 
111  get_data_storage() const;
112 
116  const Quadrature<1> &
117  get_quadrature () const;
118 
119  private:
124  typename ::Triangulation<dim>::cell_iterator present_cell;
125 
131 
136 
141 
147  };
148 
149 
150  /*----------------------- Inline functions ----------------------------------*/
151 
152  template <int dim, typename Number>
153  inline
155  const Quadrature<1> &quadrature,
156  const UpdateFlags update_flags)
157  :
158  fe_values(mapping, fe_dummy, Quadrature<dim>(quadrature),
159  MappingInfo<dim,Number>::compute_update_flags(update_flags)),
160  quadrature_1d(quadrature)
161  {
163  mapping_info_storage.descriptor[0].initialize(quadrature);
167  if (update_flags & update_quadrature_points)
168  {
171  }
173  {
176  }
179  }
180 
181 
182 
183  template <int dim, typename Number>
184  inline
186  const UpdateFlags update_flags)
187  :
188  MappingDataOnTheFly(::StaticMappingQ1<dim,dim>::mapping,
189  quadrature, update_flags)
190  {}
191 
192 
193 
194  template <int dim, typename Number>
195  inline
196  void
197  MappingDataOnTheFly<dim,Number>::reinit(typename ::Triangulation<dim>::cell_iterator cell)
198  {
199  if (present_cell == cell)
200  return;
201  present_cell = cell;
202  fe_values.reinit(present_cell);
203  for (unsigned int q=0; q<fe_values.get_quadrature().size(); ++q)
204  {
205  if (fe_values.get_update_flags() & update_JxW_values)
206  mapping_info_storage.JxW_values[q] = fe_values.JxW(q);
207  if (fe_values.get_update_flags() & update_jacobians)
208  {
209  Tensor<2,dim> jac = fe_values.jacobian(q);
210  jac = invert(transpose(jac));
211  for (unsigned int d=0; d<dim; ++d)
212  for (unsigned int e=0; e<dim; ++e)
213  mapping_info_storage.jacobians[0][q][d][e] = jac[d][e];
214  }
215  if (fe_values.get_update_flags() & update_quadrature_points)
216  for (unsigned int d=0; d<dim; ++d)
217  mapping_info_storage.quadrature_points[q][d] = fe_values.quadrature_point(q)[d];
218  if (fe_values.get_update_flags() & update_normal_vectors)
219  {
220  for (unsigned int d=0; d<dim; ++d)
221  mapping_info_storage.normal_vectors[q][d] = fe_values.normal_vector(q)[d];
222  mapping_info_storage.normals_times_jacobians[0][q] =
223  mapping_info_storage.normal_vectors[q] *
224  mapping_info_storage.jacobians[0][q];
225  }
226  }
227  }
228 
229 
230 
231  template <int dim, typename Number>
232  inline
233  bool
235  {
236  return present_cell != typename ::Triangulation<dim>::cell_iterator();
237  }
238 
239 
240 
241  template <int dim, typename Number>
242  inline
243  typename ::Triangulation<dim>::cell_iterator
245  {
246  return fe_values.get_cell();
247  }
248 
249 
250 
251  template <int dim, typename Number>
252  inline
253  const ::FEValues<dim> &
255  {
256  return fe_values;
257  }
258 
259 
260 
261  template <int dim, typename Number>
262  inline
265  {
266  return mapping_info_storage;
267  }
268 
269 
270 
271  template <int dim, typename Number>
272  inline
273  const Quadrature<1> &
275  {
276  return quadrature_1d;
277  }
278 
279 
280  } // end of namespace MatrixFreeFunctions
281 } // end of namespace internal
282 
283 
284 DEAL_II_NAMESPACE_CLOSE
285 
286 #endif
Transformed quadrature weights.
typename ::Triangulation< dim >::cell_iterator present_cell
AlignedVector< unsigned int > data_index_offsets
Definition: mapping_info.h:173
MappingInfoStorage< dim, dim, Number > mapping_info_storage
AlignedVector< unsigned int > quadrature_point_offsets
Definition: mapping_info.h:237
Volume element.
const MappingInfoStorage< dim, dim, Number > & get_data_storage() const
UpdateFlags get_update_flags() const
Transformed quadrature points.
AlignedVector< Tensor< 1, spacedim, VectorizedArray< Number > > > normals_times_jacobians[2]
Definition: mapping_info.h:229
void resize(const size_type size_in)
std::vector< QuadratureDescriptor > descriptor
Definition: mapping_info.h:165
AlignedVector< Tensor< 2, spacedim, VectorizedArray< Number > > > jacobians[2]
Definition: mapping_info.h:202
SymmetricTensor< 2, dim, Number > invert(const SymmetricTensor< 2, dim, Number > &)
typename ::Triangulation< dim >::cell_iterator get_cell() const
AlignedVector< Tensor< 1, spacedim, VectorizedArray< Number > > > normal_vectors
Definition: mapping_info.h:189
#define Assert(cond, exc)
Definition: exceptions.h:1142
UpdateFlags
SymmetricTensor< rank_, dim, Number > transpose(const SymmetricTensor< rank_, dim, Number > &t)
Gradient of volume element.
const unsigned int n_quadrature_points
Definition: fe_values.h:1840
AlignedVector< Point< spacedim, VectorizedArray< Number > > > quadrature_points
Definition: mapping_info.h:246
Normal vectors.
static ::ExceptionBase & ExcNotImplemented()
AlignedVector< VectorizedArray< Number > > JxW_values
Definition: mapping_info.h:182
void reinit(typename ::Triangulation< dim >::cell_iterator cell)
MappingDataOnTheFly(const Mapping< dim > &mapping, const Quadrature< 1 > &quadrature, const UpdateFlags update_flags)