6#include <deal.II/lac/full_matrix.h>
7#include <deal.II/lac/vector.h>
12 const unsigned int degree)
16 unsigned int nb_points = degree;
29 AssertThrow(degree > 0,
30 ExcMessage(
"IB stencil degree must be greater than 0."));
35 for (
unsigned int i = 0; i < degree + 1; ++i)
44 const double length_ratio)
48 std::vector<double> coef(degree + 1);
50 FullMatrix<double> vandermonde(degree + 1, degree + 1);
51 FullMatrix<double> stencil(degree + 1, degree + 1);
52 FullMatrix<double> inv_vandermonde(degree + 1, degree + 1);
54 Vector<double> rhs(degree + 1);
56 for (
unsigned int i = 0; i < degree + 1; ++i)
58 for (
unsigned int j = 0; j < degree + 1; ++j)
62 rhs[i] = std::pow(1 + length_ratio, i);
65 inv_vandermonde.invert(vandermonde);
68 for (
unsigned int i = 0; i < degree + 1; ++i)
70 for (
unsigned int j = 0; j < degree + 1; ++j)
72 stencil[i][j] = inv_vandermonde[i][j] * rhs[i];
76 for (
unsigned int i = 0; i < degree + 1; ++i)
78 for (
unsigned int j = 0; j < degree + 1; ++j)
80 coef[degree - i] += stencil[j][i];
98std::tuple<Point<dim>, std::vector<Point<dim>>>
100 const unsigned int degree,
101 const double length_ratio,
103 const Point<dim> &dof_point,
104 const typename DoFHandler<dim>::active_cell_iterator &cell_guess)
111 Point<dim> surface_point;
113 std::vector<Point<dim>> interpolation_points;
120 Tensor<1, dim, double> vect_ib = dof_point - surface_point;
121 point = surface_point;
123 Point<dim, double> interpolation_point_1(dof_point +
124 vect_ib * 1. / length_ratio);
126 interpolation_points.resize(1);
127 interpolation_points[0] = interpolation_point_1;
131 interpolation_points.resize(degree);
132 Tensor<1, dim, double> vect_ib = dof_point - surface_point;
134 for (
unsigned int i = 1; i < degree + 1; ++i)
136 interpolation_points[i - 1] =
141 return {point, interpolation_points};
145std::tuple<Point<dim>, std::vector<Point<dim>>>
147 const double length_ratio,
149 const Point<dim> &dof_point)
156 Point<dim> surface_point;
158 std::vector<Point<dim>> interpolation_points;
165 Tensor<1, dim, double> vect_ib = dof_point - surface_point;
166 point = surface_point;
168 Point<dim, double> interpolation_point_1(dof_point +
169 vect_ib * 1. / length_ratio);
171 interpolation_points.resize(1);
172 interpolation_points[0] = interpolation_point_1;
176 interpolation_points.resize(degree);
177 Tensor<1, dim, double> vect_ib = dof_point - surface_point;
179 for (
unsigned int i = 1; i < degree + 1; ++i)
181 interpolation_points[i - 1] =
186 return {point, interpolation_points};
193 const Point<dim> &dof_point,
194 const typename DoFHandler<dim>::active_cell_iterator &cell_guess)
199 Point<dim> surface_point;
201 Tensor<1, dim, double> vect_ib = dof_point - surface_point;
202 Point<dim> point = dof_point + vect_ib / 16.;
210 const Point<dim> &dof_point)
216 Point<dim> surface_point;
218 Tensor<1, dim, double> vect_ib = dof_point - surface_point;
219 Point<dim> point = dof_point + vect_ib / 16.;
228 const Point<dim> &dof_point,
229 unsigned int component,
230 const typename DoFHandler<dim>::active_cell_iterator &cell_guess)
232 double immersed_boundary_velocity = 0;
235 Tensor<1, 3, double> radial_vector;
236 Point<dim> closest_point;
238 Point<dim> position_to_surface;
239 position_to_surface = closest_point - p.
position;
240 radial_vector[0] = position_to_surface[0];
241 radial_vector[1] = position_to_surface[1];
244 if constexpr (dim == 3)
245 radial_vector[2] = position_to_surface[2];
247 if constexpr (dim == 2)
249 Tensor<1, 3> relative_tangential_velocity =
250 cross_product_3d(p.
omega, radial_vector);
254 immersed_boundary_velocity =
255 relative_tangential_velocity[0] + p.
velocity[0];
260 immersed_boundary_velocity =
261 relative_tangential_velocity[1] + p.
velocity[1];
264 if constexpr (dim == 3)
266 Tensor<1, 3> relative_tangential_velocity =
267 cross_product_3d(p.
omega, radial_vector);
271 immersed_boundary_velocity =
272 relative_tangential_velocity[0] + p.
velocity[0];
277 immersed_boundary_velocity =
278 relative_tangential_velocity[1] + p.
velocity[1];
283 immersed_boundary_velocity =
284 relative_tangential_velocity[2] + p.
velocity[2];
288 return immersed_boundary_velocity;
294 const Point<dim> &dof_point,
295 unsigned int component)
297 double immersed_boundary_velocity = 0;
300 Tensor<1, 3, double> radial_vector;
301 Point<dim> closest_point;
303 Point<dim> position_to_surface;
304 position_to_surface = closest_point - p.
position;
305 radial_vector[0] = position_to_surface[0];
306 radial_vector[1] = position_to_surface[1];
309 if constexpr (dim == 3)
310 radial_vector[2] = position_to_surface[2];
312 if constexpr (dim == 2)
314 Tensor<1, 3> relative_tangential_velocity =
315 cross_product_3d(p.
omega, radial_vector);
319 immersed_boundary_velocity =
320 relative_tangential_velocity[0] + p.
velocity[0];
325 immersed_boundary_velocity =
326 relative_tangential_velocity[1] + p.
velocity[1];
329 if constexpr (dim == 3)
331 Tensor<1, 3> relative_tangential_velocity =
332 cross_product_3d(p.
omega, radial_vector);
336 immersed_boundary_velocity =
337 relative_tangential_velocity[0] + p.
velocity[0];
342 immersed_boundary_velocity =
343 relative_tangential_velocity[1] + p.
velocity[1];
348 immersed_boundary_velocity =
349 relative_tangential_velocity[2] + p.
velocity[2];
353 return immersed_boundary_velocity;
Define the behavior of a specific particle for the sharp interface IB solver.
Tensor< 1, 3 > omega
Angular velocity.
Tensor< 1, 3 > velocity
Translational velocity.
void closest_surface_point(const Point< dim > &p, Point< dim > &closest_point, const typename DoFHandler< dim >::active_cell_iterator &cell_guess)
Find the closest surface point on the shape.
Point< dim > position
Position, which corresponds to the centroid for most implemented shapes.
Define where the sharp immersed-boundaries are imposed on Eulerian grid.
void p_base(const unsigned int degree)
Return the points on the reference 1D element for the polynomial base.
virtual std::tuple< Point< dim >, std::vector< Point< dim > > > support_points_for_interpolation(const unsigned int degree, const double length_ratio, IBParticle< dim > &p, const Point< dim > &dof_point, const typename DoFHandler< dim >::active_cell_iterator &cell_guess)
Find the DOF at which we try to apply the IB by interpolation and the location of the support points ...
virtual double ib_velocity(IBParticle< dim > &p, const Point< dim > &dof_point, const unsigned int component, const typename DoFHandler< dim >::active_cell_iterator &cell_guess)
Return the velocity of the IB used in the RHS of the equation.
virtual std::vector< double > coefficients(const unsigned int degree, const double length_ratio)
Return the coefficients (weights) of the stencil.
virtual Point< dim > point_for_cell_detection(IBParticle< dim > &p, const Point< dim > &dof_point, const typename DoFHandler< dim >::active_cell_iterator &cell_guess)
Define the point used to define the cell used for the stencil calculation.
virtual unsigned int number_of_interpolation_support_points(const unsigned int degree)
Return the number of points used by the interpolation stencil (excluding the dof itself) for a stenci...
std::vector< double > reference_points
Points of the reference 1D stencil.