16 #ifndef dealii_integrators_advection_h 17 #define dealii_integrators_advection_h 20 #include <deal.II/base/config.h> 21 #include <deal.II/base/exceptions.h> 22 #include <deal.II/base/quadrature.h> 23 #include <deal.II/lac/full_matrix.h> 24 #include <deal.II/fe/mapping.h> 25 #include <deal.II/fe/fe_values.h> 26 #include <deal.II/meshworker/dof_info.h> 28 DEAL_II_NAMESPACE_OPEN
79 const VectorSlice<
const std::vector<std::vector<double> > > &velocity,
80 const double factor = 1.)
84 const unsigned int n_components = fe.
get_fe().n_components();
91 const unsigned int v_increment = (velocity[0].size() == 1) ? 0 : 1;
103 const double dx = factor * fe.
JxW(k);
104 const unsigned int vindex = k * v_increment;
106 for (
unsigned j=0; j<n_dofs; ++j)
107 for (
unsigned i=0; i<t_dofs; ++i)
108 for (
unsigned int c=0; c<n_components; ++c)
110 double wgradv = velocity[0][vindex]
112 for (
unsigned int d=1; d<dim; ++d)
113 wgradv += velocity[d][vindex]
136 const VectorSlice<
const std::vector<std::vector<double> > > &velocity,
145 const unsigned int v_increment = (velocity[0].size() == 1) ? 0 : 1;
146 if (v_increment == 1)
151 for (
unsigned k=0; k<nq; ++k)
153 const double dx = factor * fe.
JxW(k);
154 for (
unsigned i=0; i<n_dofs; ++i)
155 for (
unsigned int d=0; d<dim; ++d)
156 result(i) += dx * input[k][d]
157 * fe.
shape_value(i,k) * velocity[d][k * v_increment];
179 const VectorSlice<
const std::vector<std::vector<double> > > &velocity,
184 const unsigned int n_comp = fe.
get_fe().n_components();
190 const unsigned int v_increment = (velocity[0].size() == 1) ? 0 : 1;
191 if (v_increment == 1)
196 for (
unsigned k=0; k<nq; ++k)
198 const double dx = factor * fe.
JxW(k);
199 for (
unsigned i=0; i<n_dofs; ++i)
200 for (
unsigned int c=0; c<n_comp; ++c)
201 for (
unsigned int d=0; d<dim; ++d)
202 result(i) += dx * input[c][k][d]
219 const std::vector<double> &input,
220 const VectorSlice<
const std::vector<std::vector<double> > > &velocity,
229 const unsigned int v_increment = (velocity[0].size() == 1) ? 0 : 1;
230 if (v_increment == 1)
235 for (
unsigned k=0; k<nq; ++k)
237 const double dx = factor * fe.
JxW(k);
238 for (
unsigned i=0; i<n_dofs; ++i)
239 for (
unsigned int d=0; d<dim; ++d)
240 result(i) -= dx * input[k]
241 * fe.
shape_grad(i,k)[d] * velocity[d][k * v_increment];
259 const VectorSlice<
const std::vector<std::vector<double> > > &input,
260 const VectorSlice<
const std::vector<std::vector<double> > > &velocity,
265 const unsigned int n_comp = fe.
get_fe().n_components();
271 const unsigned int v_increment = (velocity[0].size() == 1) ? 0 : 1;
272 if (v_increment == 1)
277 for (
unsigned k=0; k<nq; ++k)
279 const double dx = factor * fe.
JxW(k);
280 for (
unsigned i=0; i<n_dofs; ++i)
281 for (
unsigned int c=0; c<n_comp; ++c)
282 for (
unsigned int d=0; d<dim; ++d)
283 result(i) -= dx * input[c][k]
312 const VectorSlice<
const std::vector<std::vector<double> > > &velocity,
317 unsigned int n_components = fe.
get_fe().n_components();
322 const unsigned int v_increment = (velocity[0].size() == 1) ? 0 : 1;
323 if (v_increment == 1)
330 const double dx = factor * fe.
JxW(k);
333 for (
unsigned int d=0; d<dim; ++d)
338 for (
unsigned i=0; i<t_dofs; ++i)
339 for (
unsigned j=0; j<n_dofs; ++j)
341 if (fe.
get_fe().is_primitive())
344 for (
unsigned int c=0; c<n_components; ++c)
383 const std::vector<double> &input,
384 const std::vector<double> &data,
385 const VectorSlice<
const std::vector<std::vector<double> > > &velocity,
394 const unsigned int v_increment = (velocity[0].size() == 1) ? 0 : 1;
395 if (v_increment == 1)
403 const double dx = factor * fe.
JxW(k);
406 for (
unsigned int d=0; d<dim; ++d)
410 const double val = (nv > 0.) ? input[k] : -data[k];
412 for (
unsigned i=0; i<n_dofs; ++i)
415 result(i) += dx * nv * val *v;
451 const VectorSlice<
const std::vector<std::vector<double> > > &input,
452 const VectorSlice<
const std::vector<std::vector<double> > > &data,
453 const VectorSlice<
const std::vector<std::vector<double> > > &velocity,
457 const unsigned int n_comp = fe.
get_fe().n_components();
463 const unsigned int v_increment = (velocity[0].size() == 1) ? 0 : 1;
464 if (v_increment == 1)
472 const double dx = factor * fe.
JxW(k);
475 for (
unsigned int d=0; d<dim; ++d)
478 std::vector<double> val(n_comp);
480 for (
unsigned int d=0; d<n_comp; ++d)
482 val[d] = (nv > 0.) ? input[d][k] : -data[d][k];
483 for (
unsigned i=0; i<n_dofs; ++i)
486 result(i) += dx * nv * val[d] *v;
524 const VectorSlice<
const std::vector<std::vector<double> > > &velocity,
525 const double factor = 1.)
533 const unsigned int v_increment = (velocity[0].size() == 1) ? 0 : 1;
534 if (v_increment == 1)
541 double nbeta = fe1.
normal_vector(k)[0] * velocity[0][k * v_increment];
542 for (
unsigned int d=1; d<dim; ++d)
543 nbeta += fe1.
normal_vector(k)[d] * velocity[d][k * v_increment];
544 const double dx_nbeta = factor * std::abs(nbeta) * fe1.
JxW(k);
550 for (
unsigned i=0; i<n1; ++i)
551 for (
unsigned j=0; j<n1; ++j)
553 if (fe1.
get_fe().is_primitive())
560 for (
unsigned int d=0; d<fe1.
get_fe().n_components(); ++d)
598 const std::vector<double> &input1,
599 const std::vector<double> &input2,
600 const VectorSlice<
const std::vector<std::vector<double> > > &velocity,
601 const double factor = 1.)
614 const unsigned int v_increment = (velocity[0].size() == 1) ? 0 : 1;
615 if (v_increment == 1)
622 double nbeta = fe1.
normal_vector(k)[0] * velocity[0][k * v_increment];
623 for (
unsigned int d=1; d<dim; ++d)
624 nbeta += fe1.
normal_vector(k)[d] * velocity[d][k * v_increment];
625 const double dx_nbeta = factor * nbeta * fe1.
JxW(k);
627 for (
unsigned i=0; i<n1; ++i)
631 const double u1 = input1[k];
632 const double u2 = input2[k];
635 result1(i) += dx_nbeta*u1*v1;
636 result2(i) -= dx_nbeta*u1*v2;
641 result1(i) += dx_nbeta*u2*v1;
642 result2(i) -= dx_nbeta*u2*v2;
676 const VectorSlice<
const std::vector<std::vector<double> > > &input1,
677 const VectorSlice<
const std::vector<std::vector<double> > > &input2,
678 const VectorSlice<
const std::vector<std::vector<double> > > &velocity,
679 const double factor = 1.)
681 const unsigned int n_comp = fe1.
get_fe().n_components();
691 const unsigned int v_increment = (velocity[0].size() == 1) ? 0 : 1;
692 if (v_increment == 1)
699 double nbeta = fe1.
normal_vector(k)[0] * velocity[0][k * v_increment];
700 for (
unsigned int d=1; d<dim; ++d)
701 nbeta += fe1.
normal_vector(k)[d] * velocity[d][k * v_increment];
702 const double dx_nbeta = factor * nbeta * fe1.
JxW(k);
704 for (
unsigned i=0; i<n1; ++i)
705 for (
unsigned int d=0; d<n_comp; ++d)
709 const double u1 = input1[d][k];
710 const double u2 = input2[d][k];
713 result1(i) += dx_nbeta*u1*v1;
714 result2(i) -= dx_nbeta*u1*v2;
719 result1(i) += dx_nbeta*u2*v1;
720 result2(i) -= dx_nbeta*u2*v2;
730 DEAL_II_NAMESPACE_CLOSE
#define AssertDimension(dim1, dim2)
const unsigned int dofs_per_cell
#define AssertVectorVectorDimension(vec, dim1, dim2)
const FiniteElement< dim, spacedim > & get_fe() const
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.)
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.)
double shape_value_component(const unsigned int function_no, const unsigned int point_no, const unsigned int component) const
Library of integrals over cells and faces.
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.)
const double & shape_value(const unsigned int function_no, const unsigned int point_no) const
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
const unsigned int n_quadrature_points
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.)
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.)
double JxW(const unsigned int quadrature_point) const
const Tensor< 1, spacedim > & shape_grad(const unsigned int function_no, const unsigned int quadrature_point) const
const Tensor< 1, spacedim > & normal_vector(const unsigned int i) const
Tensor< 1, spacedim > shape_grad_component(const unsigned int function_no, const unsigned int point_no, const unsigned int component) const