deal.II version 9.8.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
fe_bernardi_raugel.cc
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2018 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13
17
19
20#include <deal.II/fe/fe.h>
22#include <deal.II/fe/fe_tools.h>
24#include <deal.II/fe/mapping.h>
25
26#include <deal.II/grid/tria.h>
28
29#include <iostream>
30#include <memory>
31#include <sstream>
32
33
35
36// TODO: implement the adjust_quad_dof_index_for_face_orientation_table and
37// adjust_line_dof_index_for_line_orientation_table fields, and write tests
38// similar to bits/face_orientation_and_fe_q_*
39
40template <int dim>
42 : FE_PolyTensor<dim>(
45 dim,
46 2,
48 std::vector<bool>(PolynomialsBernardiRaugel<dim>::n_polynomials(p), true),
49 std::vector<ComponentMask>(PolynomialsBernardiRaugel<dim>::n_polynomials(
50 p),
51 ComponentMask(std::vector<bool>(dim, true))))
52{
53 Assert(dim == 2 || dim == 3, ExcImpossibleInDim(dim));
54 Assert(p == 1, ExcMessage("Only BR1 elements are available"));
55
56 // const unsigned int n_dofs = this->n_dofs_per_cell();
57
58 this->mapping_kind = {mapping_none};
59 // These must be done first, since
60 // they change the evaluation of
61 // basis functions
62
63 // Set up the generalized support
64 // points
66
67 // We need to initialize the dof permutation table and the one for the sign
68 // change.
70}
71
72
73
74template <int dim>
75std::string
77{
78 std::ostringstream namebuf;
79 namebuf << "FE_BR<" << dim << ">(" << 1 << ")";
80
81 return namebuf.str();
82}
83
84
85template <int dim>
86void
88{
89 // for 1d and 2d, do nothing
90 if (dim < 3)
91 return;
92
93 // TODO: Implement this for this class
94 return;
95}
96
97
98template <int dim>
99std::unique_ptr<FiniteElement<dim, dim>>
101{
102 return std::make_unique<FE_BernardiRaugel<dim>>(*this);
103}
104
105
106
107template <int dim>
108void
110 const std::vector<Vector<double>> &support_point_values,
111 std::vector<double> &nodal_values) const
112{
113 Assert(support_point_values.size() == this->generalized_support_points.size(),
114 ExcDimensionMismatch(support_point_values.size(),
115 this->generalized_support_points.size()));
116 AssertDimension(support_point_values[0].size(), dim);
117 Assert(nodal_values.size() == this->n_dofs_per_cell(),
118 ExcDimensionMismatch(nodal_values.size(), this->n_dofs_per_cell()));
119
120 std::vector<Tensor<1, dim>> normals;
121 for (const unsigned int i : GeometryInfo<dim>::face_indices())
122 {
123 Tensor<1, dim> normal;
124 normal[i / 2] = 1;
125 normals.push_back(normal);
126 }
127
128 for (unsigned int i = 0; i < dim * GeometryInfo<dim>::vertices_per_cell; ++i)
129 nodal_values[i] = support_point_values[i][i % dim];
130
131 // Compute the support points values for the bubble functions
132 for (unsigned int i = dim * GeometryInfo<dim>::vertices_per_cell;
133 i < dim * GeometryInfo<dim>::vertices_per_cell +
135 ++i)
136 {
137 nodal_values[i] = 0;
138 for (unsigned int j = 0; j < dim; ++j)
139 nodal_values[i] +=
140 support_point_values[i][j] *
141 normals[i - dim * GeometryInfo<dim>::vertices_per_cell][j];
142 }
143}
144
145
146
147template <int dim>
148std::vector<unsigned int>
150{
151 // compute the number of unknowns per cell interior/face/edge
152 //
153 // there are <tt>dim</tt> degrees of freedom per vertex and there
154 // is 1 degree of freedom per edge in 2d (face in 3d)
155 std::vector<unsigned int> dpo(dim + 1, 0u);
156 dpo[0] = dim;
157 dpo[dim - 1] = 1u;
158
159 return dpo;
160}
161
162
163
164template <int dim>
165void
167{
168 // The support points for our shape functions are the vertices and
169 // the face midpoints, for a total of #vertices + #faces points
170 this->generalized_support_points.resize(this->n_dofs_per_cell());
171
172 // We need dim copies of each vertex for the first dim*vertices_per_cell
173 // generalized support points
174 for (unsigned int i = 0; i < dim * GeometryInfo<dim>::vertices_per_cell; ++i)
177
178 // The remaining 2*dim points are the edge midpoints
179 for (unsigned int i = 0; i < dim; ++i)
180 {
181 for (unsigned int j = 0; j < 2; ++j)
182 {
183 Point<dim> p;
184 p[0] = 0.5;
185 p[1] = 0.5;
186 if (dim == 3)
187 p[2] = 0.5;
188 p[i] = j;
189
190 const unsigned int k =
191 dim * GeometryInfo<dim>::vertices_per_cell + i * 2 + j;
192 this->generalized_support_points[k] = p;
193 }
194 }
195}
196
197template class FE_BernardiRaugel<2>;
198template class FE_BernardiRaugel<3>;
199
static std::vector< unsigned int > get_dpo_vector()
virtual void convert_generalized_support_point_values_to_dof_values(const std::vector< Vector< double > > &support_point_values, std::vector< double > &nodal_values) const override
void initialize_quad_dof_index_permutation_and_sign_change()
FE_BernardiRaugel(const unsigned int p=1)
virtual std::unique_ptr< FiniteElement< dim, dim > > clone() const override
virtual std::string get_name() const override
std::vector< MappingKind > mapping_kind
FE_PolyTensor(const TensorPolynomialsBase< dim > &polynomials, const FiniteElementData< dim > &fe_data, const std::vector< bool > &restriction_is_additive_flags, const std::vector< ComponentMask > &nonzero_components)
unsigned int n_dofs_per_cell() const
FiniteElementData(const std::vector< unsigned int > &dofs_per_object, const unsigned int n_components, const unsigned int degree, const Conformity conformity=unknown, const BlockIndices &block_indices=BlockIndices())
Definition fe_data.cc:112
std::vector< Point< dim > > generalized_support_points
Definition fe.h:2598
Definition point.h:111
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
#define Assert(cond, exc)
static ::ExceptionBase & ExcImpossibleInDim(int arg1)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcMessage(std::string arg1)
@ mapping_none
Definition mapping.h:84
STL namespace.
static constexpr unsigned int vertices_per_cell
static constexpr unsigned int faces_per_cell
static std_cxx20::ranges::iota_view< unsigned int, unsigned int > face_indices()
static Point< dim > unit_cell_vertex(const unsigned int vertex)