17 #ifndef dealii__matrix_free_operators_h 18 #define dealii__matrix_free_operators_h 21 #include <deal.II/base/exceptions.h> 22 #include <deal.II/base/vectorization.h> 24 #include <deal.II/matrix_free/fe_evaluation.h> 27 DEAL_II_NAMESPACE_OPEN
51 template <
int dim,
int fe_degree,
int n_components = 1,
typename Number =
double>
70 const unsigned int n_actual_components,
97 template <
int dim,
int fe_degree,
int n_components,
typename Number>
105 for (
unsigned int i=0, c=0; i<shapes_1d.
m(); ++i)
106 for (
unsigned int j=0; j<shapes_1d.
n(); ++j, ++c)
109 const unsigned int stride = (fe_degree+2)/2;
111 for (
unsigned int i=0; i<stride; ++i)
112 for (
unsigned int q=0; q<(fe_degree+2)/2; ++q)
115 0.5 * (shapes_1d(i,q) + shapes_1d(i,fe_degree-q));
117 0.5 * (shapes_1d(i,q) - shapes_1d(i,fe_degree-q));
119 if (fe_degree % 2 == 0)
120 for (
unsigned int q=0; q<(fe_degree+2)/2; ++q)
121 inverse_shape[fe_degree/2*stride+q] = shapes_1d(fe_degree/2,q);
126 template <
int dim,
int fe_degree,
int n_components,
typename Number>
133 Assert(inverse_jxw.size() > 0 &&
134 inverse_jxw.size() % dofs_per_cell == 0,
135 ExcMessage(
"Expected diagonal to be a multiple of scalar dof per cells"));
139 const unsigned int previous_size = inverse_jxw.size();
140 inverse_jxw.resize(dofs_per_cell);
144 inverse_jxw.resize_fast(previous_size);
145 for (
unsigned int q=0; q<dofs_per_cell; ++q)
146 inverse_jxw[q] = 1./inverse_jxw[q];
148 for (
unsigned int q=dofs_per_cell; q<previous_size; )
149 for (
unsigned int i=0; i<dofs_per_cell; ++i, ++q)
150 inverse_jxw[q] = inverse_jxw[i];
155 template <
int dim,
int fe_degree,
int n_components,
typename Number>
160 const unsigned int n_actual_components,
165 Assert(inverse_coefficients.size() > 0 &&
166 inverse_coefficients.size() % dofs_per_cell == 0,
167 ExcMessage(
"Expected diagonal to be a multiple of scalar dof per cells"));
168 if (inverse_coefficients.size() != dofs_per_cell)
169 AssertDimension(n_actual_components * dofs_per_cell, inverse_coefficients.size());
171 Assert(dim == 2 || dim == 3, ExcNotImplemented());
173 internal::EvaluatorTensorProduct<internal::evaluate_evenodd,dim,fe_degree,
177 const unsigned int shift_coefficient =
178 inverse_coefficients.size() > dofs_per_cell ? dofs_per_cell : 0;
181 for (
unsigned int d=0; d<n_actual_components; ++d)
187 evaluator.template hessians<0,false,false> (in, temp_data_field);
188 evaluator.template hessians<1,false,false> (temp_data_field, out);
192 evaluator.template hessians<2,false,false> (out, temp_data_field);
193 for (
unsigned int q=0; q<dofs_per_cell; ++q)
194 temp_data_field[q] *= inv_coefficient[q];
195 evaluator.template hessians<2,true,false> (temp_data_field, out);
198 for (
unsigned int q=0; q<dofs_per_cell; ++q)
199 out[q] *= inv_coefficient[q];
201 evaluator.template hessians<1,true,false>(out, temp_data_field);
202 evaluator.template hessians<0,true,false>(temp_data_field, out);
204 inv_coefficient += shift_coefficient;
211 DEAL_II_NAMESPACE_CLOSE
#define AssertDimension(dim1, dim2)
void apply(const AlignedVector< VectorizedArray< Number > > &inverse_coefficient, const unsigned int n_actual_components, const VectorizedArray< Number > *in_array, VectorizedArray< Number > *out_array) const
::ExceptionBase & ExcMessage(std::string arg1)
const FEEvaluationBase< dim, n_components, Number > & fe_eval
void fill_JxW_values(AlignedVector< VectorizedArray< Number > > &JxW_values) const
#define Assert(cond, exc)
void resize(const size_type size_in, const T &init=T())
AlignedVector< VectorizedArray< Number > > inverse_shape
CellwiseInverseMassMatrix(const FEEvaluationBase< dim, n_components, Number > &fe_eval)
void fill_inverse_JxW_values(AlignedVector< VectorizedArray< Number > > &inverse_jxw) const
const internal::MatrixFreeFunctions::ShapeInfo< Number > & get_shape_info() const