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);
210 velocity.zero_out_ghost_values();
214 reinit_face(IntegratorFace & integrator_m, IntegratorFace & integrator_p)
const
216 tau = 0.5 * (integrator_m.read_cell_data(array_penalty_parameter) +
217 integrator_p.read_cell_data(array_penalty_parameter));
221 reinit_boundary_face(IntegratorFace & integrator_m)
const
223 tau = integrator_m.read_cell_data(array_penalty_parameter);
227 reinit_face_cell_based(dealii::types::boundary_id
const boundary_id,
228 IntegratorFace & integrator_m,
229 IntegratorFace & integrator_p)
const
231 if(boundary_id == dealii::numbers::internal_face_boundary_id)
233 tau = 0.5 * (integrator_m.read_cell_data(array_penalty_parameter) +
234 integrator_p.read_cell_data(array_penalty_parameter));
238 tau = integrator_m.read_cell_data(array_penalty_parameter);
242 inline DEAL_II_ALWAYS_INLINE
244 calculate_flux(vector
const & u_m, vector
const & u_p, vector
const & normal_m)
const
246 vector jump_value = u_m - u_p;
250 if(data.which_components == ContinuityPenaltyComponents::All)
253 flux = tau * jump_value;
255 else if(data.which_components == ContinuityPenaltyComponents::Normal)
257 flux = tau * (jump_value * normal_m) * normal_m;
261 AssertThrow(
false, dealii::ExcMessage(
"not implemented."));
269 dealii::MatrixFree<dim, Number>
const * matrix_free;
271 unsigned int dof_index;
272 unsigned int quad_index;
276 dealii::AlignedVector<scalar> array_penalty_parameter;
300class ContinuityPenaltyOperator
303 typedef ContinuityPenaltyOperator<dim, Number> This;
305 typedef dealii::LinearAlgebra::distributed::Vector<Number> VectorType;
307 typedef dealii::Tensor<1, dim, dealii::VectorizedArray<Number>> vector;
309 typedef std::pair<unsigned int, unsigned int> Range;
311 typedef FaceIntegrator<dim, dim, Number> IntegratorFace;
316 ContinuityPenaltyOperator();
319 initialize(dealii::MatrixFree<dim, Number>
const & matrix_free,
321 std::shared_ptr<Kernel>
const kernel);
324 update(VectorType
const & velocity);
328 apply(VectorType & dst, VectorType
const & src)
const;
331 apply_add(VectorType & dst, VectorType
const & src)
const;
335 rhs(VectorType & dst, Number
const evaluation_time)
const;
338 rhs_add(VectorType & dst, Number
const evaluation_time)
const;
342 evaluate(VectorType & dst, VectorType
const & src, Number
const evaluation_time)
const;
345 evaluate_add(VectorType & dst, VectorType
const & src, Number
const evaluation_time)
const;
349 cell_loop_empty(dealii::MatrixFree<dim, Number>
const & matrix_free,
351 VectorType
const & src,
352 Range
const & range)
const;
355 face_loop(dealii::MatrixFree<dim, Number>
const & matrix_free,
357 VectorType
const & src,
358 Range
const & face_range)
const;
361 face_loop_empty(dealii::MatrixFree<dim, Number>
const & matrix_free,
363 VectorType
const & src,
364 Range
const & face_range)
const;
367 boundary_face_loop_hom(dealii::MatrixFree<dim, Number>
const & matrix_free,
369 VectorType
const & src,
370 Range
const & face_range)
const;
373 boundary_face_loop_full(dealii::MatrixFree<dim, Number>
const & matrix_free,
375 VectorType
const & src,
376 Range
const & face_range)
const;
379 boundary_face_loop_inhom(dealii::MatrixFree<dim, Number>
const & matrix_free,
381 VectorType
const & src,
382 Range
const & face_range)
const;
385 do_face_integral(IntegratorFace & integrator_m, IntegratorFace & integrator_p)
const;
388 do_boundary_integral(IntegratorFace & integrator_m,
389 OperatorType
const & operator_type,
390 dealii::types::boundary_id
const & boundary_id)
const;
392 dealii::MatrixFree<dim, Number>
const * matrix_free;
398 std::shared_ptr<Operators::ContinuityPenaltyKernel<dim, Number>> kernel;