Flow123d  intersections_paper-476-gbe68821
mapping_p1.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file mapping_p1.hh
15  * @brief Class MappingP1 implements the affine transformation of
16  * the unit cell onto the actual cell.
17  * @author Jan Stebel
18  */
19 
20 #ifndef MAPPING_P1_HH_
21 #define MAPPING_P1_HH_
22 
23 #include "fem/mapping.hh"
24 #include "mesh/elements.h"
25 
26 
27 /**
28  * Auxiliary templates to resolve nonzero matrix sizes for small dimensions.
29  * ( some compilers do not accept ternary operator in template parameters.)
30  */
31 template<unsigned int dim>
32 class MatrixSizes {
33 public:
34  static const unsigned int dim_minus_one = dim-1;
35 };
36 
37 template<>
38 class MatrixSizes<0> {
39 public:
40  static const unsigned int dim_minus_one = 0;
41 };
42 
43 
44 /**
45  * @brief Affine mapping between reference and actual cell.
46  *
47  * Class MappingP1 implements the affine transformation of
48  * the reference cell onto the actual cell.
49  *
50  * @param dim Dimension of the cells.
51  * @param spacedim Dimension of the Euclidean space.
52  */
53 template<unsigned int dim, unsigned int spacedim>
54 class MappingP1 : public Mapping<dim,spacedim>
55 {
56 public:
57 
58  /**
59  * @brief Constructor.
60  */
61  MappingP1();
62 
63  /**
64  * @brief Initializes the structures and computes static data.
65  *
66  * @param q Quadrature rule.
67  * @param flags Update flags.
68  * @return The computed mapping data.
69  */
70  MappingInternalData *initialize(const Quadrature<dim> &q, UpdateFlags flags);
71 
72  /**
73  * @brief Determines which additional quantities have to be computed.
74  *
75  * @param flags Update flags for required quantities.
76  * @return All necessary flags.
77  */
78  UpdateFlags update_each(UpdateFlags flags);
79 
80  /**
81  * @brief Calculates the mapping data on the actual cell.
82  *
83  * @param cell The actual cell.
84  * @param q Quadrature rule.
85  * @param data Precomputed mapping data.
86  * @param fv_data Data to be computed.
87  */
88  void fill_fe_values(const typename DOFHandlerBase::CellIterator &cell,
89  const Quadrature<dim> &q,
90  MappingInternalData &data,
92 
93  /**
94  * @brief Calculates the mapping data on a side of a cell.
95  *
96  * @param cell The actual cell.
97  * @param sid Number of the side.
98  * @param q The quadrature rule with points on the side.
99  * @param data Precomputed mapping data.
100  * @param fv_data Data to be computed.
101  */
102  void fill_fe_side_values(const typename DOFHandlerBase::CellIterator &cell,
103  unsigned int sid,
104  const Quadrature<dim> &q,
105  MappingInternalData &data,
106  FEValuesData<dim,spacedim> &fv_data);
107 
108 
109  /**
110  * Map from reference element to global coord system.
111  * Matrix(3, dim+1), last column is the translation vector.
112  */
113  arma::mat::fixed<3, dim+1> element_map(Element &elm) const
114  {
115  ASSERT_EQ(elm.dim(), dim).error();
116 
117  arma::vec3 &v0 = elm.node[0]->point();
118  arma::mat::fixed<3, dim+1> A;
119 
120  A.col(0) = v0;
121  for(unsigned int i=1; i <= dim; i++ ) {
122  A.col(i) = elm.node[i]->point() - v0;
123  }
124 
125  return A;
126  }
127 
128  /**
129  * Project given point to the barycentic coordinates.
130  * Result vector have dimension dim()+1. Local coordinates are the first.
131  * Last is 1-...
132  */
133  arma::vec::fixed<dim+1> project_point(const arma::vec3 &point, const arma::mat::fixed<3, dim+1> &map) const;
134 
135  /**
136  * Clip a point given by barycentric cocordinates to the element.
137  * If the point is out of the element the closest point
138  * projection to the element surface is used.
139  */
140  arma::vec::fixed<dim+1> clip_to_element(arma::vec::fixed<dim+1> &barycentric);
141 
142 private:
143 
144  /**
145  * @brief Auxiliary matrix of gradients of shape functions (used for
146  * computation of the Jacobian).
147  */
148  arma::mat::fixed<dim+1,dim> grad;
149 
150 };
151 
152 
153 
154 
155 
156 
157 
158 
159 #endif /* MAPPING_P1_HH_ */
UpdateFlags
Enum type UpdateFlags indicates which quantities are to be recomputed on each finite element cell...
Definition: update_flags.hh:67
static const unsigned int dim_minus_one
Definition: mapping_p1.hh:34
Node ** node
Definition: elements.h:90
Base class for quadrature rules on simplices in arbitrary dimensions.
Definition: fe_values.hh:31
unsigned int dim() const
Abstract class for the mapping between reference and actual cell.
Definition: fe_values.hh:33
Affine mapping between reference and actual cell.
Definition: mapping_p1.hh:54
Class Mapping calculates data related to the mapping of the reference cell to the actual cell...
arma::mat::fixed< dim+1, dim > grad
Auxiliary matrix of gradients of shape functions (used for computation of the Jacobian).
Definition: mapping_p1.hh:148
arma::mat::fixed< 3, dim+1 > element_map(Element &elm) const
Definition: mapping_p1.hh:113
Class FEValuesData holds the arrays of data computed by Mapping and FiniteElement.
Definition: fe_values.hh:46
arma::vec3 & point()
Definition: nodes.hh:68
Mapping data that can be precomputed on the actual cell.
Definition: mapping.hh:99
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual)
Definition: asserts.hh:328