17 #include <deal.II/base/utilities.h> 18 #include <deal.II/base/quadrature.h> 19 #include <deal.II/base/quadrature_lib.h> 20 #include <deal.II/base/qprojector.h> 21 #include <deal.II/base/table.h> 22 #include <deal.II/grid/tria.h> 23 #include <deal.II/grid/tria_iterator.h> 24 #include <deal.II/dofs/dof_accessor.h> 25 #include <deal.II/fe/fe.h> 26 #include <deal.II/fe/mapping.h> 27 #include <deal.II/fe/fe_abf.h> 28 #include <deal.II/fe/fe_values.h> 29 #include <deal.II/fe/fe_tools.h> 33 #include <deal.II/base/std_cxx14/memory.h> 41 DEAL_II_NAMESPACE_OPEN
55 std::vector<bool>(dim,true))),
90 std::vector<FullMatrix<double> >
98 unsigned int target_row=0;
99 for (
unsigned int d=0; d<face_embeddings.size(); ++d)
100 for (
unsigned int i=0; i<face_embeddings[d].m(); ++i)
102 for (
unsigned int j=0; j<face_embeddings[d].n(); ++j)
121 std::ostringstream namebuf;
123 namebuf <<
"FE_ABF<" << dim <<
">(" << rt_order <<
")";
125 return namebuf.str();
131 std::unique_ptr<FiniteElement<dim,dim> >
134 return std_cxx14::make_unique<FE_ABF<dim>>(rt_order);
150 const unsigned int n_interior_points = cell_quadrature.
size();
152 unsigned int n_face_points = (dim>1) ? 1 : 0;
154 for (
unsigned int d=1; d<dim; ++d)
155 n_face_points *= deg+1;
158 + n_interior_points);
159 this->generalized_face_support_points.resize (n_face_points);
164 std::vector<AnisotropicPolynomials<dim>* > polynomials_abf(dim);
167 for (
unsigned int dd=0; dd<dim; ++dd)
169 std::vector<std::vector<Polynomials::Polynomial<double> > > poly(dim);
170 for (
unsigned int d=0; d<dim; ++d)
178 unsigned int current = 0;
182 QGauss<dim-1> face_points (deg+1);
186 boundary_weights.reinit(n_face_points, legendre.n());
191 for (
unsigned int k=0; k<n_face_points; ++k)
193 this->generalized_face_support_points[k] = face_points.point(k);
197 for (
unsigned int i=0; i<legendre.n(); ++i)
199 boundary_weights(k, i)
200 = face_points.weight(k)
201 * legendre.compute_value(i, face_points.point(k));
206 for (; current<GeometryInfo<dim>::faces_per_cell*n_face_points;
211 this->generalized_support_points[current] = faces.
point(current);
220 boundary_weights_abf.reinit(faces.
size(), polynomials_abf[0]->n() * dim);
221 for (
unsigned int k=0; k < faces.
size(); ++k)
223 for (
unsigned int i=0; i<polynomials_abf[0]->n() * dim; ++i)
225 boundary_weights_abf(k,i) = polynomials_abf[i%dim]->
226 compute_value(i / dim, faces.
point(k)) * faces.
weight(k);
235 std::vector<AnisotropicPolynomials<dim>* > polynomials(dim);
237 for (
unsigned int dd=0; dd<dim; ++dd)
239 std::vector<std::vector<Polynomials::Polynomial<double> > > poly(dim);
240 for (
unsigned int d=0; d<dim; ++d)
247 interior_weights.reinit(
TableIndices<3>(n_interior_points, polynomials[0]->n(), dim));
249 for (
unsigned int k=0; k<cell_quadrature.
size(); ++k)
251 for (
unsigned int i=0; i<polynomials[0]->n(); ++i)
252 for (
unsigned int d=0; d<dim; ++d)
253 interior_weights(k,i,d) = cell_quadrature.
weight(k)
254 * polynomials[d]->compute_value(i,cell_quadrature.
point(k));
257 for (
unsigned int d=0; d<dim; ++d)
258 delete polynomials[d];
264 for (
unsigned int k=0; k<cell_quadrature.
size(); ++k)
265 this->generalized_support_points[current++] = cell_quadrature.
point(k);
272 polynomials_abf[0]->n() * dim, dim));
275 for (
unsigned int k=0; k<cell_quadrature.
size(); ++k)
277 for (
unsigned int i=0; i<polynomials_abf[0]->n() * dim; ++i)
279 poly_grad = polynomials_abf[i%dim]->compute_grad(i / dim,cell_quadrature.
point(k))
280 * cell_quadrature.
weight(k);
282 for (
unsigned int d=0; d<dim; ++d)
283 interior_weights_abf(k,i,d) = -poly_grad[d];
287 for (
unsigned int d=0; d<dim; ++d)
288 delete polynomials_abf[d];
290 Assert (current == this->generalized_support_points.size(),
313 for (
unsigned int i=0; i<GeometryInfo<dim>::max_children_per_cell; ++i)
314 this->restriction[iso][i].reinit(0,0);
318 QGauss<dim-1> q_base (rt_order+1);
319 const unsigned int n_face_points = q_base.size();
322 for (
unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
334 for (
unsigned int k=0; k<q_face.
size(); ++k)
335 for (
unsigned int i = 0; i < this->dofs_per_cell; ++i)
336 cached_values_face(i,k)
337 = this->shape_value_component(i, q_face.
point(k),
340 for (
unsigned int sub=0; sub<GeometryInfo<dim>::max_children_per_face; ++sub)
348 const unsigned int child
364 for (
unsigned int k=0; k<n_face_points; ++k)
365 for (
unsigned int i_child = 0; i_child < this->dofs_per_cell; ++i_child)
366 for (
unsigned int i_face = 0; i_face < this->dofs_per_face; ++i_face)
373 this->restriction[iso][child](face*this->dofs_per_face+i_face,
375 += Utilities::fixed_power<dim-1>(.5) * q_sub.
weight(k)
376 * cached_values_face(i_child, k)
377 * this->shape_value_component(face*this->dofs_per_face+i_face,
384 if (rt_order==0)
return;
389 std::vector<AnisotropicPolynomials<dim>* > polynomials(dim);
390 for (
unsigned int dd=0; dd<dim; ++dd)
392 std::vector<std::vector<Polynomials::Polynomial<double> > > poly(dim);
393 for (
unsigned int d=0; d<dim; ++d)
401 const unsigned int start_cell_dofs
408 for (
unsigned int k=0; k<q_cell.
size(); ++k)
409 for (
unsigned int i = 0; i < this->dofs_per_cell; ++i)
410 for (
unsigned int d=0; d<dim; ++d)
411 cached_values_cell(i,k,d) = this->shape_value_component(i, q_cell.
point(k), d);
413 for (
unsigned int child=0; child<GeometryInfo<dim>::max_children_per_cell; ++child)
417 for (
unsigned int k=0; k<q_sub.
size(); ++k)
418 for (
unsigned int i_child = 0; i_child < this->dofs_per_cell; ++i_child)
419 for (
unsigned int d=0; d<dim; ++d)
420 for (
unsigned int i_weight=0; i_weight<polynomials[d]->n(); ++i_weight)
422 this->restriction[iso][child](start_cell_dofs+i_weight*dim+d,
425 * cached_values_cell(i_child, k, d)
426 * polynomials[d]->compute_value(i_weight, q_sub.
point(k));
430 for (
unsigned int d=0; d<dim; ++d)
431 delete polynomials[d];
437 std::vector<unsigned int>
443 return std::vector<unsigned int>();
451 unsigned int dofs_per_face = 1;
452 for (
int d=0; d<dim-1; ++d)
453 dofs_per_face *= rt_order+1;
457 interior_dofs = dim*(rt_order+1)*dofs_per_face;
459 std::vector<unsigned int> dpo(dim+1);
460 dpo[dim-1] = dofs_per_face;
461 dpo[dim] = interior_dofs;
473 const unsigned int face_index)
const 475 Assert (shape_index < this->dofs_per_cell,
517 std::vector<double> &nodal_values)
const 519 Assert (support_point_values.size() == this->generalized_support_points.size(),
523 Assert (nodal_values.size() == this->dofs_per_cell,
526 std::fill(nodal_values.begin(), nodal_values.end(), 0.);
528 const unsigned int n_face_points = boundary_weights.size(0);
529 for (
unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
530 for (
unsigned int k=0; k<n_face_points; ++k)
531 for (
unsigned int i=0; i<boundary_weights.size(1); ++i)
533 nodal_values[i+face*this->dofs_per_face] += boundary_weights(k,i)
540 for (
unsigned int k=0; k<interior_weights.size(0); ++k)
541 for (
unsigned int i=0; i<interior_weights.size(1); ++i)
542 for (
unsigned int d=0; d<dim; ++d)
543 nodal_values[start_cell_dofs+i*dim+d] += interior_weights(k,i,d) * support_point_values[k+start_cell_points][d];
545 const unsigned int start_abf_dofs = start_cell_dofs + interior_weights.size(1) * dim;
548 for (
unsigned int k=0; k<interior_weights_abf.size(0); ++k)
549 for (
unsigned int i=0; i<interior_weights_abf.size(1); ++i)
550 for (
unsigned int d=0; d<dim; ++d)
551 nodal_values[start_abf_dofs+i] += interior_weights_abf(k,i,d) * support_point_values[k+start_cell_points][d];
554 for (
unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
557 for (
unsigned int fp=0; fp < n_face_points; ++fp)
561 for (
unsigned int i=0; i<boundary_weights_abf.size(1); ++i)
562 nodal_values[start_abf_dofs+i] += n_orient * boundary_weights_abf(k + fp, i)
568 for (
unsigned int i=0; i<boundary_weights_abf.size(1); ++i)
569 if (std::fabs (nodal_values[start_abf_dofs+i]) < 1.0e-16)
570 nodal_values[start_abf_dofs+i] = 0.0;
586 #include "fe_abf.inst" 588 DEAL_II_NAMESPACE_CLOSE
void initialize_restriction()
static Quadrature< dim > project_to_child(const Quadrature< dim > &quadrature, const unsigned int child_no)
FullMatrix< double > interface_constraints
static std::vector< Polynomial< double > > generate_complete_basis(const unsigned int degree)
virtual std::string get_name() const
const Point< dim > & point(const unsigned int i) const
virtual std::size_t memory_consumption() const
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
virtual void convert_generalized_support_point_values_to_dof_values(const std::vector< Vector< double > > &support_point_values, std::vector< double > &nodal_values) const
virtual bool has_support_on_face(const unsigned int shape_index, const unsigned int face_index) const
static ::ExceptionBase & ExcImpossibleInDim(int arg1)
std::vector< std::vector< FullMatrix< double > > > prolongation
void invert(const FullMatrix< number2 > &M)
static unsigned int child_cell_on_face(const RefinementCase< dim > &ref_case, const unsigned int face, const unsigned int subface, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false, const RefinementCase< dim-1 > &face_refinement_case=RefinementCase< dim-1 >::isotropic_refinement)
void reinit(const TableIndices< N > &new_size, const bool omit_default_initialization=false)
#define Assert(cond, exc)
static void project_to_subface(const SubQuadrature &quadrature, const unsigned int face_no, const unsigned int subface_no, std::vector< Point< dim > > &q_points, const RefinementCase< dim-1 > &ref_case=RefinementCase< dim-1 >::isotropic_refinement)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static std::vector< Polynomial< number > > generate_complete_basis(const unsigned int degree)
unsigned int size() const
const unsigned int dofs_per_cell
static Quadrature< dim > project_to_all_faces(const SubQuadrature &quadrature)
static void project_to_face(const SubQuadrature &quadrature, const unsigned int face_no, std::vector< Point< dim > > &q_points)
const unsigned int dofs_per_face
static std::vector< unsigned int > get_dpo_vector(const unsigned int degree)
void reinit_restriction_and_prolongation_matrices(const bool isotropic_restriction_only=false, const bool isotropic_prolongation_only=false)
static ::ExceptionBase & ExcNotImplemented()
unsigned int n_components(const DoFHandler< dim, spacedim > &dh)
void initialize_support_points(const unsigned int rt_degree)
FullMatrix< double > inverse_node_matrix
virtual std::unique_ptr< FiniteElement< dim, dim > > clone() const
double weight(const unsigned int i) const
static ::ExceptionBase & ExcInternalError()
static DataSetDescriptor face(const unsigned int face_no, const bool face_orientation, const bool face_flip, const bool face_rotation, const unsigned int n_quadrature_points)