10#include <deal.II/fe/fe_interface_values.h>
21 const auto &JxW_vec = scratch_data.
JxW;
22 const unsigned int n_q_points = scratch_data.
n_q_points;
23 const unsigned int n_dofs = scratch_data.
n_dofs;
27 std::vector<double> time_steps_vector =
29 const double dt = time_steps_vector[0];
30 const double sdt = 1. / dt;
40 for (
unsigned int q = 0; q < n_q_points; ++q)
47 const double JxW = JxW_vec[q];
50 const double tolerance = 1e-12;
54 const double u_mag = std::max(
velocity.norm(), tolerance);
65 Utilities::fixed_power<2>(2. * u_mag / h) +
66 9 * Utilities::fixed_power<2>(4 * diffusivity / (h * h))) :
68 std::sqrt(Utilities::fixed_power<2>(sdt) +
69 Utilities::fixed_power<2>(2. * u_mag / h) +
70 9 * Utilities::fixed_power<2>(4 * diffusivity / (h * h)));
72 for (
unsigned int j = 0; j < n_dofs; ++j)
74 const auto phi_phase_j = scratch_data.
phi[q][j];
75 const auto grad_phi_phase_j = scratch_data.
grad_phi[q][j];
76 const auto laplacian_phi_phase_j = scratch_data.
laplacian_phi[q][j];
79 strong_jacobian_vec[q][j] +=
80 velocity * grad_phi_phase_j - diffusivity * laplacian_phi_phase_j;
83 strong_jacobian_vec[q][j] += phi_phase_j * velocity_divergence;
86 for (
unsigned int i = 0; i < n_dofs; ++i)
88 const auto phi_phase_i = scratch_data.
phi[q][i];
89 const auto grad_phi_phase_i = scratch_data.
grad_phi[q][i];
92 for (
unsigned int j = 0; j < n_dofs; ++j)
94 const auto phi_phase_j = scratch_data.
phi[q][j];
95 const auto grad_phi_phase_j = scratch_data.
grad_phi[q][j];
100 local_matrix(i, j) +=
101 (phi_phase_i *
velocity * grad_phi_phase_j +
102 diffusivity * grad_phi_phase_i * grad_phi_phase_j) *
107 local_matrix(i, j) +=
108 phi_phase_i * phi_phase_j * velocity_divergence * JxW;
111 local_matrix(i, j) += tau * strong_jacobian_vec[q][j] *
112 (grad_phi_phase_i *
velocity) * JxW;
131 const auto &JxW_vec = scratch_data.
JxW;
132 const unsigned int n_q_points = scratch_data.
n_q_points;
133 const unsigned int n_dofs = scratch_data.
n_dofs;
137 std::vector<double> time_steps_vector =
139 const double dt = time_steps_vector[0];
140 const double sdt = 1. / dt;
147 for (
unsigned int q = 0; q < n_q_points; ++q)
157 const double JxW = JxW_vec[q];
160 const double tolerance = 1e-12;
163 const double u_mag = std::max(
velocity.norm(), tolerance);
174 Utilities::fixed_power<2>(2. * u_mag / h) +
175 9 * Utilities::fixed_power<2>(4 * diffusivity / (h * h))) :
177 std::sqrt(Utilities::fixed_power<2>(sdt) +
178 Utilities::fixed_power<2>(2. * u_mag / h) +
179 9 * Utilities::fixed_power<2>(4 * diffusivity / (h * h)));
182 strong_residual_vec[q] +=
183 velocity * phase_gradient - diffusivity * phase_laplacians;
186 strong_residual_vec[q] +=
phase * velocity_divergence;
188 for (
unsigned int i = 0; i < n_dofs; ++i)
190 const auto phi_phase_i = scratch_data.
phi[q][i];
191 const auto grad_phi_phase_i = scratch_data.
grad_phi[q][i];
195 local_rhs(i) -= (phi_phase_i *
velocity * phase_gradient +
196 diffusivity * grad_phi_phase_i * phase_gradient) *
200 local_rhs(i) -= phi_phase_i *
phase * velocity_divergence * JxW;
203 tau * (strong_residual_vec[q] * (grad_phi_phase_i *
velocity)) *
219 const auto &JxW = scratch_data.
JxW;
220 const unsigned int n_q_points = scratch_data.
n_q_points;
221 const unsigned int n_dofs = scratch_data.
n_dofs;
231 const Vector<double> &bdf_coefs =
236 for (
unsigned int q = 0; q < n_q_points; ++q)
247 strong_residual[q] += (bdf_coefs[p] * phase_value[p]);
250 for (
unsigned int j = 0; j < n_dofs; ++j)
252 strong_jacobian[q][j] += bdf_coefs[0] * scratch_data.
phi[q][j];
256 for (
unsigned int i = 0; i < n_dofs; ++i)
258 const auto phi_phase_i = scratch_data.
phi[q][i];
259 for (
unsigned int j = 0; j < n_dofs; ++j)
261 const auto phi_phase_j = scratch_data.
phi[q][j];
263 local_matrix(i, j) +=
264 phi_phase_j * phi_phase_i * bdf_coefs[0] * JxW[q];
276 const auto &JxW = scratch_data.
JxW;
277 const unsigned int n_q_points = scratch_data.
n_q_points;
278 const unsigned int n_dofs = scratch_data.
n_dofs;
287 const Vector<double> &bdf_coefs =
292 for (
unsigned int q = 0; q < n_q_points; ++q)
302 strong_residual[q] += (bdf_coefs[p] * phase_value[p]);
305 for (
unsigned int i = 0; i < n_dofs; ++i)
307 const double phi_phase_i = scratch_data.
phi[q][i];
308 double local_rhs_i = 0;
312 local_rhs_i -= bdf_coefs[p] * (phase_value[p] * phi_phase_i);
314 local_rhs(i) += local_rhs_i * JxW[q];
330 const auto &JxW_vec = scratch_data.
JxW;
331 const unsigned int n_q_points = scratch_data.
n_q_points;
332 const unsigned int n_dofs = scratch_data.
n_dofs;
339 for (
unsigned int q = 0; q < n_q_points; ++q)
343 const double JxW = JxW_vec[q];
346 const Tensor<1, dim> previous_phase_gradient =
350 const double tolerance = 1e-12;
354 const double velocity_norm =
velocity.norm();
355 const double phase_gradient_norm = previous_phase_gradient.norm();
358 Tensor<1, dim> gradient_unit_vector =
359 previous_phase_gradient / (phase_gradient_norm + tolerance);
363 Tensor<1, dim> velocity_unit_vector =
364 velocity / (velocity_norm + tolerance);
367 const Tensor<2, dim> dir_tensor =
368 outer_product(gradient_unit_vector, gradient_unit_vector) -
369 ((gradient_unit_vector * velocity_unit_vector) *
370 outer_product(velocity_unit_vector, velocity_unit_vector));
373 const double nu_dcdd =
377 for (
unsigned int i = 0; i < n_dofs; ++i)
379 const auto grad_phi_phase_i = scratch_data.
grad_phi[q][i];
381 for (
unsigned int j = 0; j < n_dofs; ++j)
383 const auto grad_phi_phase_j = scratch_data.
grad_phi[q][j];
384 local_matrix(i, j) +=
385 (nu_dcdd * scalar_product(grad_phi_phase_i,
386 dir_tensor * grad_phi_phase_j)) *
400 const auto &JxW_vec = scratch_data.
JxW;
401 const unsigned int n_q_points = scratch_data.
n_q_points;
402 const unsigned int n_dofs = scratch_data.
n_dofs;
409 for (
unsigned int q = 0; q < n_q_points; ++q)
414 const double JxW = JxW_vec[q];
417 const Tensor<1, dim> previous_phase_gradient =
421 const double tolerance = 1e-12;
425 const double velocity_norm =
velocity.norm();
426 const double phase_gradient_norm = previous_phase_gradient.norm();
429 Tensor<1, dim> gradient_unit_vector =
430 previous_phase_gradient / (phase_gradient_norm + tolerance);
434 Tensor<1, dim> velocity_unit_vector =
435 velocity / (velocity_norm + tolerance);
438 const Tensor<2, dim> dir_tensor =
439 outer_product(gradient_unit_vector, gradient_unit_vector) -
440 ((gradient_unit_vector * velocity_unit_vector) *
441 outer_product(velocity_unit_vector, velocity_unit_vector));
444 const double nu_dcdd =
448 for (
unsigned int i = 0; i < n_dofs; ++i)
450 const auto grad_phi_phase_i = scratch_data.
grad_phi[q][i];
453 scalar_product(grad_phi_phase_i, dir_tensor * phase_gradient) * JxW;
469 const auto &JxW_vec = scratch_data.
JxW;
470 const unsigned int n_q_points = scratch_data.
n_q_points;
471 const unsigned int n_dofs = scratch_data.
n_dofs;
477 for (
unsigned int q = 0; q < n_q_points; ++q)
483 const double JxW = JxW_vec[q];
485 for (
unsigned int i = 0; i < n_dofs; ++i)
487 const auto grad_phi_phase_i = scratch_data.
grad_phi[q][i];
489 for (
unsigned int j = 0; j < n_dofs; ++j)
491 const auto phi_phase_j = scratch_data.
phi[q][j];
496 local_matrix(i, j) +=
497 (-grad_phi_phase_i *
velocity * phi_phase_j) * JxW;
510 const auto &JxW_vec = scratch_data.
JxW;
511 const unsigned int n_q_points = scratch_data.
n_q_points;
512 const unsigned int n_dofs = scratch_data.
n_dofs;
518 for (
unsigned int q = 0; q < n_q_points; ++q)
525 const double JxW = JxW_vec[q];
527 for (
unsigned int i = 0; i < n_dofs; ++i)
529 const auto grad_phi_phase_i = scratch_data.
grad_phi[q][i];
534 local_rhs(i) -= (-grad_phi_phase_i *
velocity * phase_value) * JxW;
550 const auto &q_points = fe_iv.get_quadrature_points();
551 auto ©_data_face = copy_data.
face_data.back();
552 const unsigned int n_dofs = fe_iv.n_current_interface_dofs();
555 const std::vector<double> &JxW = fe_iv.get_JxW_values();
556 const std::vector<Tensor<1, dim>> &normals = fe_iv.get_normal_vectors();
558 for (
unsigned int q = 0; q < q_points.size(); ++q)
560 const double velocity_dot_n =
562 for (
unsigned int i = 0; i < n_dofs; ++i)
563 for (
unsigned int j = 0; j < n_dofs; ++j)
570 copy_data_face.face_matrix(i, j) +=
571 fe_iv.jump_in_shape_values(i, q) *
572 fe_iv.shape_value((velocity_dot_n > 0.), j, q) * velocity_dot_n *
584 const auto &q_points = fe_iv.get_quadrature_points();
585 const unsigned int n_dofs = fe_iv.n_current_interface_dofs();
587 auto ©_data_face = copy_data.
face_data.back();
589 const std::vector<double> &JxW = fe_iv.get_JxW_values();
590 const std::vector<Tensor<1, dim>> &normals = fe_iv.get_normal_vectors();
592 for (
unsigned int q = 0; q < q_points.size(); ++q)
594 const double velocity_dot_n =
596 for (
unsigned int i = 0; i < n_dofs; ++i)
601 if (velocity_dot_n > 0)
603 copy_data_face.face_rhs(i) -=
604 fe_iv.jump_in_shape_values(i, q)
611 copy_data_face.face_rhs(i) -=
612 fe_iv.jump_in_shape_values(i, q)
unsigned int number_of_previous_solutions(const Parameters::SimulationControl::TimeSteppingMethod method)
Get the number of previous time steps for a specific BDF scheme.
Class that assembles the transient time arising from BDF time integration for the CLS equation....
virtual void assemble_rhs(const CLSScratchData< dim > &scratch_data, StabilizedMethodsCopyData ©_data) override
assemble_rhs Assembles the rhs
const std::shared_ptr< SimulationControl > simulation_control
virtual void assemble_matrix(const CLSScratchData< dim > &scratch_data, StabilizedMethodsCopyData ©_data) override
assemble_matrix Assembles the matrix
Class that assembles the core of the CLS solver. According to the following weak form: with an SUPG ...
const Parameters::CLS cls_parameters
const std::shared_ptr< SimulationControl > simulation_control
virtual void assemble_matrix(const CLSScratchData< dim > &scratch_data, StabilizedMethodsCopyData ©_data) override
assemble_matrix Assembles the matrix
virtual void assemble_rhs(const CLSScratchData< dim > &scratch_data, StabilizedMethodsCopyData ©_data) override
assemble_rhs Assembles the rhs
Assemble the Discontinuity-Capturing Directional Dissipation (DCDD) stabilization term for the CLS ph...
const double diffusion_constant
Diffusion coefficient.
virtual void assemble_matrix(const CLSScratchData< dim > &scratch_data, StabilizedMethodsCopyData ©_data) override
Assemble the matrix.
virtual void assemble_rhs(const CLSScratchData< dim > &scratch_data, StabilizedMethodsCopyData ©_data) override
Assemble the right-hand side (rhs).
Class that assembles the core (cells) of the CLS equation for DG elements. This class assembles the w...
virtual void assemble_rhs(const CLSScratchData< dim > &scratch_data, StabilizedMethodsCopyData ©_data) override
Assemble the rhs.
virtual void assemble_matrix(const CLSScratchData< dim > &scratch_data, StabilizedMethodsCopyData ©_data) override
Assemble the matrix.
Assembles the symmetric interior penalty Galerkin (SIPG) method (or Nitsche's method) for internal fa...
virtual void assemble_matrix(const CLSScratchData< dim > &scratch_data, StabilizedDGMethodsCopyData ©_data) override
Interface to call the matrix assembly.
virtual void assemble_rhs(const CLSScratchData< dim > &scratch_data, StabilizedDGMethodsCopyData ©_data) override
Interface for the call to rhs.
Store the information required by the assembly procedure for a CLS free surface equation....
std::vector< Tensor< 1, dim > > face_velocity_values
std::vector< double > values_there
std::vector< double > velocity_divergences
Table< 2, Tensor< 1, dim > > grad_phi
Table< 2, double > laplacian_phi
FEInterfaceValues< dim > fe_interface_values_cls
std::vector< double > values_here
std::vector< double > phase_laplacians
std::vector< std::vector< double > > previous_phase_values
std::vector< double > present_phase_values
std::vector< Tensor< 1, dim > > previous_phase_gradients
std::vector< Tensor< 1, dim > > velocity_values
std::vector< Tensor< 1, dim > > phase_gradients
Responsible for storing the information calculated using the discontinuous galerkin (DG) assembly of ...
std::vector< CopyDataFace > face_data
Class responsible for storing the information calculated using the assembly of stabilized scalar equa...
Vector< double > local_rhs
Vector< double > strong_residual
FullMatrix< double > local_matrix
std::vector< Vector< double > > strong_jacobian
@ phase
Phase indicator scalar field from CLS.
@ velocity
Velocity vector field from fluid dynamics.
bool is_steady(const Parameters::SimulationControl::TimeSteppingMethod method)
Determines if the time integration method is a steady-state method.