94class ContinuityPenaltyKernel
97 typedef CellIntegrator<dim, dim, Number> IntegratorCell;
98 typedef FaceIntegrator<dim, dim, Number> IntegratorFace;
100 typedef dealii::LinearAlgebra::distributed::Vector<Number> VectorType;
102 typedef dealii::VectorizedArray<Number> scalar;
103 typedef dealii::Tensor<1, dim, dealii::VectorizedArray<Number>> vector;
106 ContinuityPenaltyKernel()
107 : matrix_free(
nullptr), dof_index(0), quad_index(0), array_penalty_parameter(0)
112 reinit(dealii::MatrixFree<dim, Number>
const & matrix_free,
113 unsigned int const dof_index,
114 unsigned int const quad_index,
117 this->matrix_free = &matrix_free;
119 this->dof_index = dof_index;
120 this->quad_index = quad_index;
124 unsigned int n_cells = matrix_free.n_cell_batches() + matrix_free.n_ghost_cell_batches();
125 array_penalty_parameter.resize(n_cells);
135 get_integrator_flags()
const
141 flags.face_evaluate = dealii::EvaluationFlags::values;
142 flags.face_integrate = dealii::EvaluationFlags::values;
154 flags.inner_faces = dealii::update_JxW_values | dealii::update_normal_vectors;
155 flags.boundary_faces =
156 dealii::update_JxW_values | dealii::update_normal_vectors | dealii::update_quadrature_points;
162 calculate_penalty_parameter(VectorType
const & velocity)
164 velocity.update_ghost_values();
166 IntegratorCell integrator(*matrix_free, dof_index, quad_index);
168 dealii::AlignedVector<scalar> JxW_values(integrator.n_q_points);
170 ElementType
const element_type =
171 get_element_type(matrix_free->get_dof_handler(dof_index).get_triangulation());
173 unsigned int n_cells = matrix_free->n_cell_batches() + matrix_free->n_ghost_cell_batches();
174 for(
unsigned int cell = 0; cell < n_cells; ++cell)
176 integrator.reinit(cell);
177 integrator.read_dof_values(velocity);
178 integrator.evaluate(dealii::EvaluationFlags::values);
179 scalar volume = dealii::make_vectorized_array<Number>(0.0);
180 scalar norm_U_mean = dealii::make_vectorized_array<Number>(0.0);
182 for(
unsigned int q = 0; q < integrator.n_q_points; ++q)
184 volume += integrator.JxW(q);
185 norm_U_mean += integrator.JxW(q) * integrator.get_value(q).norm();
188 norm_U_mean /= volume;
190 scalar tau_convective = norm_U_mean;
193 scalar tau_viscous = dealii::make_vectorized_array<Number>(data.viscosity) / h_eff;
195 if(data.type_penalty_parameter == TypePenaltyParameter::ConvectiveTerm)
197 array_penalty_parameter[cell] = data.penalty_factor * tau_convective;
199 else if(data.type_penalty_parameter == TypePenaltyParameter::ViscousTerm)
201 array_penalty_parameter[cell] = data.penalty_factor * tau_viscous;
203 else if(data.type_penalty_parameter == TypePenaltyParameter::ViscousAndConvectiveTerms)
205 array_penalty_parameter[cell] = data.penalty_factor * (tau_convective + tau_viscous);
211 reinit_face(IntegratorFace & integrator_m, IntegratorFace & integrator_p)
const
213 tau = 0.5 * (integrator_m.read_cell_data(array_penalty_parameter) +
214 integrator_p.read_cell_data(array_penalty_parameter));
218 reinit_boundary_face(IntegratorFace & integrator_m)
const
220 tau = integrator_m.read_cell_data(array_penalty_parameter);
224 reinit_face_cell_based(dealii::types::boundary_id
const boundary_id,
225 IntegratorFace & integrator_m,
226 IntegratorFace & integrator_p)
const
228 if(boundary_id == dealii::numbers::internal_face_boundary_id)
230 tau = 0.5 * (integrator_m.read_cell_data(array_penalty_parameter) +
231 integrator_p.read_cell_data(array_penalty_parameter));
235 tau = integrator_m.read_cell_data(array_penalty_parameter);
239 inline DEAL_II_ALWAYS_INLINE
241 calculate_flux(vector
const & u_m, vector
const & u_p, vector
const & normal_m)
const
243 vector jump_value = u_m - u_p;
247 if(data.which_components == ContinuityPenaltyComponents::All)
250 flux = tau * jump_value;
252 else if(data.which_components == ContinuityPenaltyComponents::Normal)
254 flux = tau * (jump_value * normal_m) * normal_m;
258 AssertThrow(
false, dealii::ExcMessage(
"not implemented."));
266 dealii::MatrixFree<dim, Number>
const * matrix_free;
268 unsigned int dof_index;
269 unsigned int quad_index;
273 dealii::AlignedVector<scalar> array_penalty_parameter;
297class ContinuityPenaltyOperator
300 typedef ContinuityPenaltyOperator<dim, Number> This;
302 typedef dealii::LinearAlgebra::distributed::Vector<Number> VectorType;
304 typedef dealii::Tensor<1, dim, dealii::VectorizedArray<Number>> vector;
306 typedef std::pair<unsigned int, unsigned int> Range;
308 typedef FaceIntegrator<dim, dim, Number> IntegratorFace;
313 ContinuityPenaltyOperator();
316 initialize(dealii::MatrixFree<dim, Number>
const & matrix_free,
318 std::shared_ptr<Kernel>
const kernel);
321 update(VectorType
const & velocity);
325 apply(VectorType & dst, VectorType
const & src)
const;
328 apply_add(VectorType & dst, VectorType
const & src)
const;
332 rhs(VectorType & dst, Number
const evaluation_time)
const;
335 rhs_add(VectorType & dst, Number
const evaluation_time)
const;
339 evaluate(VectorType & dst, VectorType
const & src, Number
const evaluation_time)
const;
342 evaluate_add(VectorType & dst, VectorType
const & src, Number
const evaluation_time)
const;
346 cell_loop_empty(dealii::MatrixFree<dim, Number>
const & matrix_free,
348 VectorType
const & src,
349 Range
const & range)
const;
352 face_loop(dealii::MatrixFree<dim, Number>
const & matrix_free,
354 VectorType
const & src,
355 Range
const & face_range)
const;
358 face_loop_empty(dealii::MatrixFree<dim, Number>
const & matrix_free,
360 VectorType
const & src,
361 Range
const & face_range)
const;
364 boundary_face_loop_hom(dealii::MatrixFree<dim, Number>
const & matrix_free,
366 VectorType
const & src,
367 Range
const & face_range)
const;
370 boundary_face_loop_full(dealii::MatrixFree<dim, Number>
const & matrix_free,
372 VectorType
const & src,
373 Range
const & face_range)
const;
376 boundary_face_loop_inhom(dealii::MatrixFree<dim, Number>
const & matrix_free,
378 VectorType
const & src,
379 Range
const & face_range)
const;
382 do_face_integral(IntegratorFace & integrator_m, IntegratorFace & integrator_p)
const;
385 do_boundary_integral(IntegratorFace & integrator_m,
386 OperatorType
const & operator_type,
387 dealii::types::boundary_id
const & boundary_id)
const;
389 dealii::MatrixFree<dim, Number>
const * matrix_free;
395 std::shared_ptr<Operators::ContinuityPenaltyKernel<dim, Number>> kernel;