95class ContinuityPenaltyKernel
98 typedef CellIntegrator<dim, dim, Number> IntegratorCell;
99 typedef FaceIntegrator<dim, dim, Number> IntegratorFace;
101 typedef dealii::LinearAlgebra::distributed::Vector<Number> VectorType;
103 typedef dealii::VectorizedArray<Number> scalar;
104 typedef dealii::Tensor<1, dim, dealii::VectorizedArray<Number>> vector;
107 ContinuityPenaltyKernel()
108 : matrix_free(
nullptr), dof_index(0), quad_index(0), array_penalty_parameter(0)
113 reinit(dealii::MatrixFree<dim, Number>
const & matrix_free,
114 unsigned int const dof_index,
115 unsigned int const quad_index,
118 this->matrix_free = &matrix_free;
120 this->dof_index = dof_index;
121 this->quad_index = quad_index;
125 unsigned int n_cells = matrix_free.n_cell_batches() + matrix_free.n_ghost_cell_batches();
126 array_penalty_parameter.resize(n_cells);
136 get_integrator_flags()
const
142 flags.face_evaluate = dealii::EvaluationFlags::values;
143 flags.face_integrate = dealii::EvaluationFlags::values;
155 flags.inner_faces = dealii::update_JxW_values | dealii::update_normal_vectors;
156 flags.boundary_faces =
157 dealii::update_JxW_values | dealii::update_normal_vectors | dealii::update_quadrature_points;
163 calculate_penalty_parameter(VectorType
const & velocity)
165 velocity.update_ghost_values();
167 IntegratorCell integrator(*matrix_free, dof_index, quad_index);
169 dealii::AlignedVector<scalar> JxW_values(integrator.n_q_points);
171 ElementType
const element_type =
172 get_element_type(matrix_free->get_dof_handler(dof_index).get_triangulation());
174 unsigned int n_cells = matrix_free->n_cell_batches() + matrix_free->n_ghost_cell_batches();
175 for(
unsigned int cell = 0; cell < n_cells; ++cell)
177 integrator.reinit(cell);
178 integrator.read_dof_values(velocity);
179 integrator.evaluate(dealii::EvaluationFlags::values);
180 scalar volume = dealii::make_vectorized_array<Number>(0.0);
181 scalar norm_U_mean = dealii::make_vectorized_array<Number>(0.0);
183 for(
unsigned int q = 0; q < integrator.n_q_points; ++q)
185 volume += integrator.JxW(q);
186 norm_U_mean += integrator.JxW(q) * integrator.get_value(q).norm();
189 norm_U_mean /= volume;
191 scalar tau_convective = norm_U_mean;
194 scalar tau_viscous = dealii::make_vectorized_array<Number>(data.viscosity) / h_eff;
196 if(data.type_penalty_parameter == TypePenaltyParameter::ConvectiveTerm)
198 array_penalty_parameter[cell] = data.penalty_factor * tau_convective;
200 else if(data.type_penalty_parameter == TypePenaltyParameter::ViscousTerm)
202 array_penalty_parameter[cell] = data.penalty_factor * tau_viscous;
204 else if(data.type_penalty_parameter == TypePenaltyParameter::ViscousAndConvectiveTerms)
206 array_penalty_parameter[cell] = data.penalty_factor * (tau_convective + tau_viscous);
212 reinit_face(IntegratorFace & integrator_m, IntegratorFace & integrator_p)
const
214 tau = 0.5 * (integrator_m.read_cell_data(array_penalty_parameter) +
215 integrator_p.read_cell_data(array_penalty_parameter));
219 reinit_boundary_face(IntegratorFace & integrator_m)
const
221 tau = integrator_m.read_cell_data(array_penalty_parameter);
225 reinit_face_cell_based(dealii::types::boundary_id
const boundary_id,
226 IntegratorFace & integrator_m,
227 IntegratorFace & integrator_p)
const
229 if(boundary_id == dealii::numbers::internal_face_boundary_id)
231 tau = 0.5 * (integrator_m.read_cell_data(array_penalty_parameter) +
232 integrator_p.read_cell_data(array_penalty_parameter));
236 tau = integrator_m.read_cell_data(array_penalty_parameter);
240 inline DEAL_II_ALWAYS_INLINE
242 calculate_flux(vector
const & u_m, vector
const & u_p, vector
const & normal_m)
const
244 vector jump_value = u_m - u_p;
248 if(data.which_components == ContinuityPenaltyComponents::All)
251 flux = tau * jump_value;
253 else if(data.which_components == ContinuityPenaltyComponents::Normal)
255 flux = tau * (jump_value * normal_m) * normal_m;
259 AssertThrow(
false, dealii::ExcMessage(
"not implemented."));
267 dealii::MatrixFree<dim, Number>
const * matrix_free;
269 unsigned int dof_index;
270 unsigned int quad_index;
274 dealii::AlignedVector<scalar> array_penalty_parameter;
298class ContinuityPenaltyOperator
301 typedef ContinuityPenaltyOperator<dim, Number> This;
303 typedef dealii::LinearAlgebra::distributed::Vector<Number> VectorType;
305 typedef dealii::Tensor<1, dim, dealii::VectorizedArray<Number>> vector;
307 typedef std::pair<unsigned int, unsigned int> Range;
309 typedef FaceIntegrator<dim, dim, Number> IntegratorFace;
314 ContinuityPenaltyOperator();
317 initialize(dealii::MatrixFree<dim, Number>
const & matrix_free,
319 std::shared_ptr<Kernel>
const kernel);
322 update(VectorType
const & velocity);
326 apply(VectorType & dst, VectorType
const & src)
const;
329 apply_add(VectorType & dst, VectorType
const & src)
const;
333 rhs(VectorType & dst, Number
const evaluation_time)
const;
336 rhs_add(VectorType & dst, Number
const evaluation_time)
const;
340 evaluate(VectorType & dst, VectorType
const & src, Number
const evaluation_time)
const;
343 evaluate_add(VectorType & dst, VectorType
const & src, Number
const evaluation_time)
const;
347 cell_loop_empty(dealii::MatrixFree<dim, Number>
const & matrix_free,
349 VectorType
const & src,
350 Range
const & range)
const;
353 face_loop(dealii::MatrixFree<dim, Number>
const & matrix_free,
355 VectorType
const & src,
356 Range
const & face_range)
const;
359 face_loop_empty(dealii::MatrixFree<dim, Number>
const & matrix_free,
361 VectorType
const & src,
362 Range
const & face_range)
const;
365 boundary_face_loop_hom(dealii::MatrixFree<dim, Number>
const & matrix_free,
367 VectorType
const & src,
368 Range
const & face_range)
const;
371 boundary_face_loop_full(dealii::MatrixFree<dim, Number>
const & matrix_free,
373 VectorType
const & src,
374 Range
const & face_range)
const;
377 boundary_face_loop_inhom(dealii::MatrixFree<dim, Number>
const & matrix_free,
379 VectorType
const & src,
380 Range
const & face_range)
const;
383 do_face_integral(IntegratorFace & integrator_m, IntegratorFace & integrator_p)
const;
386 do_boundary_integral(IntegratorFace & integrator_m,
387 OperatorType
const & operator_type,
388 dealii::types::boundary_id
const & boundary_id)
const;
390 dealii::MatrixFree<dim, Number>
const * matrix_free;
396 std::shared_ptr<Operators::ContinuityPenaltyKernel<dim, Number>> kernel;