16 #ifndef dealii_integrators_advection_h 17 #define dealii_integrators_advection_h 20 #include <deal.II/base/config.h> 22 #include <deal.II/base/exceptions.h> 23 #include <deal.II/base/quadrature.h> 25 #include <deal.II/fe/fe_values.h> 26 #include <deal.II/fe/mapping.h> 28 #include <deal.II/lac/full_matrix.h> 30 #include <deal.II/meshworker/dof_info.h> 32 DEAL_II_NAMESPACE_OPEN
84 const VectorSlice<
const std::vector<std::vector<double>>> &velocity,
85 const double factor = 1.)
89 const unsigned int n_components = fe.
get_fe().n_components();
96 const unsigned int v_increment = (velocity[0].size() == 1) ? 0 : 1;
108 const double dx = factor * fe.
JxW(k);
109 const unsigned int vindex = k * v_increment;
111 for (
unsigned j = 0; j < n_dofs; ++j)
112 for (
unsigned i = 0; i < t_dofs; ++i)
113 for (
unsigned int c = 0; c < n_components; ++c)
117 for (
unsigned int d = 1; d < dim; ++d)
141 const VectorSlice<
const std::vector<std::vector<double>>> &velocity,
151 const unsigned int v_increment = (velocity[0].size() == 1) ? 0 : 1;
152 if (v_increment == 1)
157 for (
unsigned k = 0; k < nq; ++k)
159 const double dx = factor * fe.
JxW(k);
160 for (
unsigned i = 0; i < n_dofs; ++i)
161 for (
unsigned int d = 0; d < dim; ++d)
162 result(i) += dx * input[k][d] * fe.
shape_value(i, k) *
163 velocity[d][k * v_increment];
185 const VectorSlice<
const std::vector<std::vector<double>>> &velocity,
190 const unsigned int n_comp = fe.
get_fe().n_components();
197 const unsigned int v_increment = (velocity[0].size() == 1) ? 0 : 1;
198 if (v_increment == 1)
203 for (
unsigned k = 0; k < nq; ++k)
205 const double dx = factor * fe.
JxW(k);
206 for (
unsigned i = 0; i < n_dofs; ++i)
207 for (
unsigned int c = 0; c < n_comp; ++c)
208 for (
unsigned int d = 0; d < dim; ++d)
209 result(i) += dx * input[c][k][d] *
211 velocity[d][k * v_increment];
227 const std::vector<double> & input,
228 const VectorSlice<
const std::vector<std::vector<double>>> &velocity,
238 const unsigned int v_increment = (velocity[0].size() == 1) ? 0 : 1;
239 if (v_increment == 1)
244 for (
unsigned k = 0; k < nq; ++k)
246 const double dx = factor * fe.
JxW(k);
247 for (
unsigned i = 0; i < n_dofs; ++i)
248 for (
unsigned int d = 0; d < dim; ++d)
249 result(i) -= dx * input[k] * fe.
shape_grad(i, k)[d] *
250 velocity[d][k * v_increment];
268 const VectorSlice<
const std::vector<std::vector<double>>> &input,
269 const VectorSlice<
const std::vector<std::vector<double>>> &velocity,
274 const unsigned int n_comp = fe.
get_fe().n_components();
281 const unsigned int v_increment = (velocity[0].size() == 1) ? 0 : 1;
282 if (v_increment == 1)
287 for (
unsigned k = 0; k < nq; ++k)
289 const double dx = factor * fe.
JxW(k);
290 for (
unsigned i = 0; i < n_dofs; ++i)
291 for (
unsigned int c = 0; c < n_comp; ++c)
292 for (
unsigned int d = 0; d < dim; ++d)
293 result(i) -= dx * input[c][k] *
295 velocity[d][k * v_increment];
324 const VectorSlice<
const std::vector<std::vector<double>>> &velocity,
329 unsigned int n_components = fe.
get_fe().n_components();
334 const unsigned int v_increment = (velocity[0].size() == 1) ? 0 : 1;
335 if (v_increment == 1)
342 const double dx = factor * fe.
JxW(k);
345 for (
unsigned int d = 0; d < dim; ++d)
350 for (
unsigned i = 0; i < t_dofs; ++i)
351 for (
unsigned j = 0; j < n_dofs; ++j)
353 if (fe.
get_fe().is_primitive())
357 for (
unsigned int c = 0; c < n_components; ++c)
397 const std::vector<double> & input,
398 const std::vector<double> & data,
399 const VectorSlice<
const std::vector<std::vector<double>>> &velocity,
408 const unsigned int v_increment = (velocity[0].size() == 1) ? 0 : 1;
409 if (v_increment == 1)
417 const double dx = factor * fe.
JxW(k);
420 for (
unsigned int d = 0; d < dim; ++d)
424 const double val = (nv > 0.) ? input[k] : -data[k];
426 for (
unsigned i = 0; i < n_dofs; ++i)
429 result(i) += dx * nv * val * v;
465 const VectorSlice<
const std::vector<std::vector<double>>> &input,
466 const VectorSlice<
const std::vector<std::vector<double>>> &data,
467 const VectorSlice<
const std::vector<std::vector<double>>> &velocity,
471 const unsigned int n_comp = fe.
get_fe().n_components();
477 const unsigned int v_increment = (velocity[0].size() == 1) ? 0 : 1;
478 if (v_increment == 1)
486 const double dx = factor * fe.
JxW(k);
489 for (
unsigned int d = 0; d < dim; ++d)
492 std::vector<double> val(n_comp);
494 for (
unsigned int d = 0; d < n_comp; ++d)
496 val[d] = (nv > 0.) ? input[d][k] : -data[d][k];
497 for (
unsigned i = 0; i < n_dofs; ++i)
500 result(i) += dx * nv * val[d] * v;
539 const VectorSlice<
const std::vector<std::vector<double>>> &velocity,
540 const double factor = 1.)
548 const unsigned int v_increment = (velocity[0].size() == 1) ? 0 : 1;
549 if (v_increment == 1)
556 double nbeta = fe1.
normal_vector(k)[0] * velocity[0][k * v_increment];
557 for (
unsigned int d = 1; d < dim; ++d)
558 nbeta += fe1.
normal_vector(k)[d] * velocity[d][k * v_increment];
559 const double dx_nbeta = factor * std::abs(nbeta) * fe1.
JxW(k);
565 for (
unsigned i = 0; i < n1; ++i)
566 for (
unsigned j = 0; j < n1; ++j)
568 if (fe1.
get_fe().is_primitive())
577 for (
unsigned int d = 0; d < fe1.
get_fe().n_components();
580 M1(i, j) += dx_nbeta *
583 M2(i, j) -= dx_nbeta *
621 const std::vector<double> & input1,
622 const std::vector<double> & input2,
623 const VectorSlice<
const std::vector<std::vector<double>>> &velocity,
624 const double factor = 1.)
637 const unsigned int v_increment = (velocity[0].size() == 1) ? 0 : 1;
638 if (v_increment == 1)
645 double nbeta = fe1.
normal_vector(k)[0] * velocity[0][k * v_increment];
646 for (
unsigned int d = 1; d < dim; ++d)
647 nbeta += fe1.
normal_vector(k)[d] * velocity[d][k * v_increment];
648 const double dx_nbeta = factor * nbeta * fe1.
JxW(k);
650 for (
unsigned i = 0; i < n1; ++i)
654 const double u1 = input1[k];
655 const double u2 = input2[k];
658 result1(i) += dx_nbeta * u1 * v1;
659 result2(i) -= dx_nbeta * u1 * v2;
663 result1(i) += dx_nbeta * u2 * v1;
664 result2(i) -= dx_nbeta * u2 * v2;
699 const VectorSlice<
const std::vector<std::vector<double>>> &input1,
700 const VectorSlice<
const std::vector<std::vector<double>>> &input2,
701 const VectorSlice<
const std::vector<std::vector<double>>> &velocity,
702 const double factor = 1.)
704 const unsigned int n_comp = fe1.
get_fe().n_components();
714 const unsigned int v_increment = (velocity[0].size() == 1) ? 0 : 1;
715 if (v_increment == 1)
722 double nbeta = fe1.
normal_vector(k)[0] * velocity[0][k * v_increment];
723 for (
unsigned int d = 1; d < dim; ++d)
724 nbeta += fe1.
normal_vector(k)[d] * velocity[d][k * v_increment];
725 const double dx_nbeta = factor * nbeta * fe1.
JxW(k);
727 for (
unsigned i = 0; i < n1; ++i)
728 for (
unsigned int d = 0; d < n_comp; ++d)
732 const double u1 = input1[d][k];
733 const double u2 = input2[d][k];
736 result1(i) += dx_nbeta * u1 * v1;
737 result2(i) -= dx_nbeta * u1 * v2;
741 result1(i) += dx_nbeta * u2 * v1;
742 result2(i) -= dx_nbeta * u2 * v2;
752 DEAL_II_NAMESPACE_CLOSE
double shape_value_component(const unsigned int function_no, const unsigned int point_no, const unsigned int component) const
const Tensor< 1, spacedim > & shape_grad(const unsigned int function_no, const unsigned int quadrature_point) const
#define AssertDimension(dim1, dim2)
const unsigned int dofs_per_cell
const Tensor< 1, spacedim > & normal_vector(const unsigned int i) const
#define AssertVectorVectorDimension(vec, dim1, dim2)
void cell_residual(Vector< double > &result, const FEValuesBase< dim > &fe, const std::vector< Tensor< 1, dim >> &input, const VectorSlice< const std::vector< std::vector< double >>> &velocity, double factor=1.)
Library of integrals over cells and faces.
void cell_matrix(FullMatrix< double > &M, const FEValuesBase< dim > &fe, const FEValuesBase< dim > &fetest, const VectorSlice< const std::vector< std::vector< double >>> &velocity, const double factor=1.)
void upwind_value_residual(Vector< double > &result, const FEValuesBase< dim > &fe, const std::vector< double > &input, const std::vector< double > &data, const VectorSlice< const std::vector< std::vector< double >>> &velocity, double factor=1.)
#define Assert(cond, exc)
void upwind_value_matrix(FullMatrix< double > &M, const FEValuesBase< dim > &fe, const FEValuesBase< dim > &fetest, const VectorSlice< const std::vector< std::vector< double >>> &velocity, double factor=1.)
static::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
const FiniteElement< dim, spacedim > & get_fe() const
const unsigned int n_quadrature_points
const double & shape_value(const unsigned int function_no, const unsigned int point_no) const
void upwind_face_residual(Vector< double > &result1, Vector< double > &result2, const FEValuesBase< dim > &fe1, const FEValuesBase< dim > &fe2, const std::vector< double > &input1, const std::vector< double > &input2, const VectorSlice< const std::vector< std::vector< double >>> &velocity, const double factor=1.)
Tensor< 1, spacedim > shape_grad_component(const unsigned int function_no, const unsigned int point_no, const unsigned int component) const
double JxW(const unsigned int quadrature_point) const