Fluid structure interaction suite
create_nitsche_rhs_with_exact_intersections.cc
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2022 by Luca Heltai
4 //
5 // This file is part of the FSI-suite platform, based on the deal.II library.
6 //
7 // The FSI-suite platform is free software; you can use it, redistribute it,
8 // and/or modify it under the terms of the GNU Lesser General Public License as
9 // published by the Free Software Foundation; either version 3.0 of the License,
10 // or (at your option) any later version. The full text of the license can be
11 // found in the file LICENSE at the top level of the FSI-suite platform
12 // distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 
17 
19 
20 using namespace dealii;
21 
22 namespace dealii
23 {
24  namespace NonMatching
25  {
26  template <int dim0, int dim1, int spacedim, typename VectorType>
27  void
29  const DoFHandler<dim0, spacedim> &space_dh,
30  const std::vector<std::tuple<
31  typename dealii::Triangulation<dim0, spacedim>::cell_iterator,
32  typename dealii::Triangulation<dim1, spacedim>::cell_iterator,
33  dealii::Quadrature<spacedim>>> &cells_and_quads,
34  VectorType &rhs,
36  &space_constraints,
37  const Mapping<dim0, spacedim> &space_mapping,
40  const double penalty)
41  {
42  AssertDimension(rhs.size(), space_dh.n_dofs());
43  Assert(dim1 <= dim0,
44  ExcMessage("This function can only work if dim1<=dim0"));
45 
46 
47  const auto &space_fe = space_dh.get_fe();
48 
49  const unsigned int n_dofs_per_space_cell = space_fe.n_dofs_per_cell();
50 
51 
52 
53  Vector<double> local_rhs(n_dofs_per_space_cell);
54  // DoF indices
55  std::vector<types::global_dof_index> local_space_dof_indices(
56  n_dofs_per_space_cell);
57 
58 
59 
60  // Loop over vector of tuples, and gather everything together
61 
62  double h;
63  for (const auto &infos : cells_and_quads)
64  {
65  const auto &[first_cell, second_cell, quad_formula] = infos;
66 
67  if (first_cell->is_active())
68  {
69  h = first_cell->diameter();
70  local_rhs = typename VectorType::value_type();
71 
72 
73  const unsigned int n_quad_pts = quad_formula.size();
74  const auto &real_qpts = quad_formula.get_points();
75  std::vector<Point<std::min(dim0, spacedim)>> ref_pts_space(
76  n_quad_pts);
77  std::vector<double> rhs_function_values(n_quad_pts);
78  rhs_function.value_list(real_qpts, rhs_function_values);
79 
80 
81  std::vector<double> coefficient_values(n_quad_pts);
82  coefficient.value_list(real_qpts, coefficient_values);
83 
84  space_mapping.transform_points_real_to_unit_cell(first_cell,
85  real_qpts,
86  ref_pts_space);
87 
88  const auto &JxW = quad_formula.get_weights();
89  for (unsigned int q = 0; q < n_quad_pts; ++q)
90  {
91  const auto &q_ref_point = ref_pts_space[q];
92  for (unsigned int i = 0; i < n_dofs_per_space_cell; ++i)
93  {
94  local_rhs(i) += coefficient_values[q] * (penalty / h) *
95  space_fe.shape_value(i, q_ref_point) *
96  rhs_function_values[q] * JxW[q];
97  }
98  }
99  typename DoFHandler<dim0, spacedim>::cell_iterator space_cell_dh(
100  *first_cell, &space_dh);
101 
102  space_cell_dh->get_dof_indices(local_space_dof_indices);
103  space_constraints.distribute_local_to_global(
104  local_rhs, local_space_dof_indices, rhs);
105  }
106  }
107  }
108 
109 
110 
111  template void
113  const DoFHandler<2, 2> &,
114  const std::vector<
115  std::tuple<typename dealii::Triangulation<2, 2>::cell_iterator,
116  typename dealii::Triangulation<2, 2>::cell_iterator,
117  dealii::Quadrature<2>>> &,
118  Vector<double> &vector,
120  const Mapping<2, 2> &,
121  const Function<2, double> &,
122  const Function<2, double> &,
123  const double);
124 
125 
126 
127  template void
129  const DoFHandler<2, 2> &,
130  const std::vector<
131  std::tuple<typename dealii::Triangulation<2, 2>::cell_iterator,
132  typename dealii::Triangulation<1, 2>::cell_iterator,
133  dealii::Quadrature<2>>> &,
134  Vector<double> &vector,
136  const Mapping<2, 2> &,
137  const Function<2, double> &,
138  const Function<2, double> &,
139  const double);
140 
141 
142 
143  template void
145  const DoFHandler<3, 3> &,
146  const std::vector<
147  std::tuple<typename dealii::Triangulation<3, 3>::cell_iterator,
148  typename dealii::Triangulation<3, 3>::cell_iterator,
149  dealii::Quadrature<3>>> &,
150  Vector<double> &vector,
152  const Mapping<3, 3> &,
153  const Function<3, double> &,
154  const Function<3, double> &,
155  const double);
156 
157  template void
159  const DoFHandler<3, 3> &,
160  const std::vector<
161  std::tuple<typename dealii::Triangulation<3, 3>::cell_iterator,
162  typename dealii::Triangulation<2, 3>::cell_iterator,
163  dealii::Quadrature<3>>> &,
164  Vector<double> &vector,
166  const Mapping<3, 3> &,
167  const Function<3, double> &,
168  const Function<3, double> &,
169  const double);
170 
171 
172  } // namespace NonMatching
173 } // namespace dealii
void distribute_local_to_global(const InVector &local_vector, const std::vector< size_type > &local_dof_indices, OutVector &global_vector) const
const FiniteElement< dim, spacedim > & get_fe(const types::fe_index index=0) const
types::global_dof_index n_dofs() const
unsigned int n_dofs_per_cell() const
virtual void value_list(const std::vector< Point< dim > > &points, std::vector< RangeNumberType > &values, const unsigned int component=0) const
virtual void transform_points_real_to_unit_cell(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const ArrayView< const Point< spacedim > > &real_points, const ArrayView< Point< dim > > &unit_points) const
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcMessage(std::string arg1)
typename ActiveSelector::cell_iterator cell_iterator
void create_nitsche_rhs_with_exact_intersections(const DoFHandler< dim0, spacedim > &, const std::vector< std::tuple< typename Triangulation< dim0, spacedim >::cell_iterator, typename Triangulation< dim1, spacedim >::cell_iterator, Quadrature< spacedim >>> &, VectorType &vector, const AffineConstraints< typename VectorType::value_type > &, const Mapping< dim0, spacedim > &, const Function< spacedim, typename VectorType::value_type > &, const Function< spacedim, typename VectorType::value_type > &, const double penalty=1.)
Create the r.h.s.
template void create_nitsche_rhs_with_exact_intersections< 3, 2, 3 >(const DoFHandler< 3, 3 > &, const std::vector< std::tuple< typename Triangulation< 3, 3 >::cell_iterator, typename Triangulation< 2, 3 >::cell_iterator, Quadrature< 3 >>> &, Vector< double > &vector, const AffineConstraints< double > &, const Mapping< 3, 3 > &, const Function< 3, double > &, const Function< 3, double > &, const double)
template void create_nitsche_rhs_with_exact_intersections< 2, 1, 2 >(const DoFHandler< 2, 2 > &, const std::vector< std::tuple< typename Triangulation< 2, 2 >::cell_iterator, typename Triangulation< 1, 2 >::cell_iterator, Quadrature< 2 >>> &, Vector< double > &vector, const AffineConstraints< double > &, const Mapping< 2, 2 > &, const Function< 2, double > &, const Function< 2, double > &, const double)
template void create_nitsche_rhs_with_exact_intersections< 3, 3, 3 >(const DoFHandler< 3, 3 > &, const std::vector< std::tuple< typename Triangulation< 3, 3 >::cell_iterator, typename Triangulation< 3, 3 >::cell_iterator, Quadrature< 3 >>> &, Vector< double > &vector, const AffineConstraints< double > &, const Mapping< 3, 3 > &, const Function< 3, double > &, const Function< 3, double > &, const double)
template void create_nitsche_rhs_with_exact_intersections< 2, 2, 2 >(const DoFHandler< 2, 2 > &, const std::vector< std::tuple< typename Triangulation< 2, 2 >::cell_iterator, typename Triangulation< 2, 2 >::cell_iterator, Quadrature< 2 >>> &, Vector< double > &vector, const AffineConstraints< double > &, const Mapping< 2, 2 > &, const Function< 2, double > &, const Function< 2, double > &, const double)
::VectorizedArray< Number, width > min(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)