From ba0c33a80cb1986cd79993d4168165322bbc458f Mon Sep 17 00:00:00 2001 From: Lukas Korous Date: Wed, 12 Aug 2015 22:02:11 +0200 Subject: [PATCH] Move get_data(), get_face_data(), get_subface_data() definitions directly to places where declared. --- include/deal.II/fe/fe_face.h | 44 +++++-- include/deal.II/fe/fe_poly.h | 76 +++++++++++- include/deal.II/fe/fe_poly.templates.h | 90 --------------- include/deal.II/fe/fe_poly_face.h | 69 +++++++++-- include/deal.II/fe/fe_poly_face.templates.h | 88 -------------- include/deal.II/fe/fe_poly_tensor.h | 101 +++++++++++++++- source/fe/fe_face.cc | 57 --------- source/fe/fe_poly_tensor.cc | 121 -------------------- 8 files changed, 270 insertions(+), 376 deletions(-) diff --git a/include/deal.II/fe/fe_face.h b/include/deal.II/fe/fe_face.h index a4a54fcab4..dd51b9343f 100644 --- a/include/deal.II/fe/fe_face.h +++ b/include/deal.II/fe/fe_face.h @@ -231,17 +231,47 @@ protected: typename FiniteElement<1,spacedim>::InternalDataBase * get_data (const UpdateFlags, const Mapping<1,spacedim> &mapping, - const Quadrature<1> &quadrature) const; + const Quadrature<1> &quadrature) const + { + return new typename FiniteElement<1, spacedim>::InternalDataBase; + } typename FiniteElement<1,spacedim>::InternalDataBase * - get_face_data (const UpdateFlags, - const Mapping<1,spacedim> &mapping, - const Quadrature<0> &quadrature) const; + get_face_data(const UpdateFlags update_flags, + const Mapping<1,spacedim> &mapping, + const Quadrature<0> &quadrature) const + { + // generate a new data object and initialize some fields + typename FiniteElement<1, spacedim>::InternalDataBase *data = + new typename FiniteElement<1, spacedim>::InternalDataBase; + + // check what needs to be initialized only once and what on every + // cell/face/subface we visit + data->update_once = update_once(update_flags); + data->update_each = update_each(update_flags); + data->update_flags = data->update_once | data->update_each; + + const UpdateFlags flags(data->update_flags); + const unsigned int n_q_points = quadrature.size(); + AssertDimension(n_q_points, 1); + (void)n_q_points; + + // No derivatives of this element are implemented. + if (flags & update_gradients || flags & update_hessians) + { + Assert(false, ExcNotImplemented()); + } + + return data; + } typename FiniteElement<1,spacedim>::InternalDataBase * - get_subface_data (const UpdateFlags, - const Mapping<1,spacedim> &mapping, - const Quadrature<0> &quadrature) const; + get_subface_data(const UpdateFlags update_flags, + const Mapping<1,spacedim> &mapping, + const Quadrature<0> &quadrature) const + { + return get_face_data(update_flags, mapping, quadrature); + } virtual void diff --git a/include/deal.II/fe/fe_poly.h b/include/deal.II/fe/fe_poly.h index 41ba86416a..fb12ed105a 100644 --- a/include/deal.II/fe/fe_poly.h +++ b/include/deal.II/fe/fe_poly.h @@ -18,6 +18,7 @@ #include +#include DEAL_II_NAMESPACE_OPEN @@ -63,6 +64,7 @@ DEAL_II_NAMESPACE_OPEN * * @author Ralf Hartmann 2004, Guido Kanschat, 2009 */ + template class FE_Poly : public FiniteElement { @@ -164,9 +166,77 @@ protected: virtual typename FiniteElement::InternalDataBase * - get_data (const UpdateFlags, - const Mapping &mapping, - const Quadrature &quadrature) const; + get_data(const UpdateFlags update_flags, + const Mapping &mapping, + const Quadrature &quadrature) const + { + // generate a new data object and + // initialize some fields + InternalData *data = new InternalData; + + // check what needs to be + // initialized only once and what + // on every cell/face/subface we + // visit + data->update_once = update_once(update_flags); + data->update_each = update_each(update_flags); + data->update_flags = data->update_once | data->update_each; + + const UpdateFlags flags(data->update_flags); + const unsigned int n_q_points = quadrature.size(); + + // some scratch arrays + std::vector values(0); + std::vector > grads(0); + std::vector > grad_grads(0); + + // initialize fields only if really + // necessary. otherwise, don't + // allocate memory + if (flags & update_values) + { + values.resize(this->dofs_per_cell); + data->shape_values.resize(this->dofs_per_cell, + std::vector(n_q_points)); + } + + if (flags & update_gradients) + { + grads.resize(this->dofs_per_cell); + data->shape_gradients.resize(this->dofs_per_cell, + std::vector >(n_q_points)); + } + + // if second derivatives through + // finite differencing is required, + // then initialize some objects for + // that + if (flags & update_hessians) + data->initialize_2nd(this, mapping, quadrature); + + // next already fill those fields + // of which we have information by + // now. note that the shape + // gradients are only those on the + // unit cell, and need to be + // transformed when visiting an + // actual cell + if (flags & (update_values | update_gradients)) + for (unsigned int i = 0; idofs_per_cell; ++k) + data->shape_values[k][i] = values[k]; + + if (flags & update_gradients) + for (unsigned int k = 0; kdofs_per_cell; ++k) + data->shape_gradients[k][i] = grads[k]; + } + return data; + } virtual void diff --git a/include/deal.II/fe/fe_poly.templates.h b/include/deal.II/fe/fe_poly.templates.h index ce2a7bf4d6..63d0184474 100644 --- a/include/deal.II/fe/fe_poly.templates.h +++ b/include/deal.II/fe/fe_poly.templates.h @@ -161,96 +161,6 @@ FE_Poly::update_each (const UpdateFlags flags) const -//--------------------------------------------------------------------------- -// Data field initialization -//--------------------------------------------------------------------------- - -template -typename FiniteElement::InternalDataBase * -FE_Poly::get_data (const UpdateFlags update_flags, - const Mapping &, - const Quadrature &quadrature) const -{ - // generate a new data object and - // initialize some fields - InternalData *data = new InternalData; - - // check what needs to be - // initialized only once and what - // on every cell/face/subface we - // visit - data->update_once = update_once(update_flags); - data->update_each = update_each(update_flags); - data->update_flags = data->update_once | data->update_each; - - const UpdateFlags flags(data->update_flags); - const unsigned int n_q_points = quadrature.size(); - - // some scratch arrays - std::vector values(0); - std::vector > grads(0); - std::vector > grad_grads(0); - - // initialize fields only if really - // necessary. otherwise, don't - // allocate memory - if (flags & update_values) - { - values.resize (this->dofs_per_cell); - data->shape_values.resize (this->dofs_per_cell, - std::vector (n_q_points)); - } - - if (flags & update_gradients) - { - grads.resize (this->dofs_per_cell); - data->shape_gradients.resize (this->dofs_per_cell, - std::vector > (n_q_points)); - } - - // if second derivatives through - // finite differencing is required, - // then initialize some objects for - // that - if (flags & update_hessians) - { - grad_grads.resize (this->dofs_per_cell); - data->shape_hessians.resize (this->dofs_per_cell, - std::vector > (n_q_points)); - data->untransformed_shape_hessians.resize (n_q_points); - } - - // next already fill those fields - // of which we have information by - // now. note that the shape - // gradients are only those on the - // unit cell, and need to be - // transformed when visiting an - // actual cell - if (flags & (update_values | update_gradients | update_hessians)) - for (unsigned int i=0; idofs_per_cell; ++k) - data->shape_values[k][i] = values[k]; - - if (flags & update_gradients) - for (unsigned int k=0; kdofs_per_cell; ++k) - data->shape_gradients[k][i] = grads[k]; - - if (flags & update_hessians) - for (unsigned int k=0; kdofs_per_cell; ++k) - data->shape_hessians[k][i] = grad_grads[k]; - } - return data; -} - - - - //--------------------------------------------------------------------------- // Fill data of FEValues //--------------------------------------------------------------------------- diff --git a/include/deal.II/fe/fe_poly_face.h b/include/deal.II/fe/fe_poly_face.h index e0997eb932..628a2d4fff 100644 --- a/include/deal.II/fe/fe_poly_face.h +++ b/include/deal.II/fe/fe_poly_face.h @@ -78,17 +78,72 @@ protected: typename FiniteElement::InternalDataBase * get_data (const UpdateFlags, const Mapping &mapping, - const Quadrature &quadrature) const; + const Quadrature &quadrature) const + { + InternalData *data = new InternalData; + return data; + } typename FiniteElement::InternalDataBase * - get_face_data (const UpdateFlags, - const Mapping &mapping, - const Quadrature& quadrature) const; + get_face_data(const UpdateFlags update_flags, + const Mapping &mapping, + const Quadrature& quadrature) const + { + // generate a new data object and + // initialize some fields + InternalData *data = new InternalData; + + // check what needs to be + // initialized only once and what + // on every cell/face/subface we + // visit + data->update_once = update_once(update_flags); + data->update_each = update_each(update_flags); + data->update_flags = data->update_once | data->update_each; + + const UpdateFlags flags(data->update_flags); + const unsigned int n_q_points = quadrature.size(); + + // some scratch arrays + std::vector values(0); + std::vector > grads(0); + std::vector > grad_grads(0); + + // initialize fields only if really + // necessary. otherwise, don't + // allocate memory + if (flags & update_values) + { + values.resize(poly_space.n()); + data->shape_values.resize(poly_space.n(), + std::vector(n_q_points)); + for (unsigned int i = 0; ishape_values[k][i] = values[k]; + } + } + // No derivatives of this element + // are implemented. + if (flags & update_gradients || flags & update_hessians) + { + Assert(false, ExcNotImplemented()); + } + + return data; + } typename FiniteElement::InternalDataBase * - get_subface_data (const UpdateFlags, - const Mapping &mapping, - const Quadrature& quadrature) const; + get_subface_data(const UpdateFlags update_flags, + const Mapping &mapping, + const Quadrature& quadrature) const + { + return get_face_data(update_flags, mapping, + QProjector::project_to_all_children(quadrature)); + } virtual void diff --git a/include/deal.II/fe/fe_poly_face.templates.h b/include/deal.II/fe/fe_poly_face.templates.h index ca0a4037b7..786f0bd3e9 100644 --- a/include/deal.II/fe/fe_poly_face.templates.h +++ b/include/deal.II/fe/fe_poly_face.templates.h @@ -78,94 +78,6 @@ FE_PolyFace::update_each (const UpdateFlags flags) const } - -//--------------------------------------------------------------------------- -// Data field initialization -//--------------------------------------------------------------------------- - -template -typename FiniteElement::InternalDataBase * -FE_PolyFace::get_data ( - const UpdateFlags, - const Mapping &, - const Quadrature &) const -{ - InternalData *data = new InternalData; - return data; -} - - -template -typename FiniteElement::InternalDataBase * -FE_PolyFace::get_face_data ( - const UpdateFlags update_flags, - const Mapping &, - const Quadrature& quadrature) const -{ - // generate a new data object and - // initialize some fields - InternalData *data = new InternalData; - - // check what needs to be - // initialized only once and what - // on every cell/face/subface we - // visit - data->update_once = update_once(update_flags); - data->update_each = update_each(update_flags); - data->update_flags = data->update_once | data->update_each; - - const UpdateFlags flags(data->update_flags); - const unsigned int n_q_points = quadrature.size(); - - // some scratch arrays - std::vector values(0); - std::vector > grads(0); - std::vector > grad_grads(0); - - // initialize fields only if really - // necessary. otherwise, don't - // allocate memory - if (flags & update_values) - { - values.resize (poly_space.n()); - data->shape_values.resize (poly_space.n(), - std::vector (n_q_points)); - for (unsigned int i=0; ishape_values[k][i] = values[k]; - } - } - // No derivatives of this element - // are implemented. - if (flags & update_gradients || flags & update_hessians) - { - Assert(false, ExcNotImplemented()); - } - - return data; -} - - - -template -typename FiniteElement::InternalDataBase * -FE_PolyFace::get_subface_data ( - const UpdateFlags flags, - const Mapping &mapping, - const Quadrature& quadrature) const -{ - return get_face_data (flags, mapping, - QProjector::project_to_all_children(quadrature)); -} - - - - - //--------------------------------------------------------------------------- // Fill data of FEValues //--------------------------------------------------------------------------- diff --git a/include/deal.II/fe/fe_poly_tensor.h b/include/deal.II/fe/fe_poly_tensor.h index 0c9c5ed9b3..63b2e4b6e5 100644 --- a/include/deal.II/fe/fe_poly_tensor.h +++ b/include/deal.II/fe/fe_poly_tensor.h @@ -177,9 +177,104 @@ protected: virtual typename FiniteElement::InternalDataBase * - get_data (const UpdateFlags, - const Mapping &mapping, - const Quadrature &quadrature) const; + get_data(const UpdateFlags update_flags, + const Mapping &mapping, + const Quadrature &quadrature) const + { + // generate a new data object and + // initialize some fields + InternalData *data = new InternalData; + + // check what needs to be + // initialized only once and what + // on every cell/face/subface we + // visit + data->update_once = update_once(update_flags); + data->update_each = update_each(update_flags); + data->update_flags = data->update_once | data->update_each; + + const UpdateFlags flags(data->update_flags); + const unsigned int n_q_points = quadrature.size(); + + // some scratch arrays + std::vector > values(0); + std::vector > grads(0); + std::vector > grad_grads(0); + + // initialize fields only if really + // necessary. otherwise, don't + // allocate memory + if (flags & update_values) + { + values.resize(this->dofs_per_cell); + data->shape_values.resize(this->dofs_per_cell); + for (unsigned int i = 0; idofs_per_cell; ++i) + data->shape_values[i].resize(n_q_points); + } + + if (flags & update_gradients) + { + grads.resize(this->dofs_per_cell); + data->shape_grads.resize(this->dofs_per_cell); + for (unsigned int i = 0; idofs_per_cell; ++i) + data->shape_grads[i].resize(n_q_points); + } + + // if second derivatives through + // finite differencing is required, + // then initialize some objects for + // that + if (flags & update_hessians) + { + // grad_grads.resize (this->dofs_per_cell); + data->initialize_2nd(this, mapping, quadrature); + } + + // Compute shape function values + // and derivatives on the reference + // cell. Make sure, that for the + // node values N_i holds + // N_i(v_j)=\delta_ij for all basis + // functions v_j + if (flags & (update_values | update_gradients)) + for (unsigned int k = 0; kdofs_per_cell; ++i) + data->shape_values[i][k] = values[i]; + else + for (unsigned int i = 0; idofs_per_cell; ++i) + { + Tensor<1, dim> add_values; + for (unsigned int j = 0; jdofs_per_cell; ++j) + add_values += inverse_node_matrix(j, i) * values[j]; + data->shape_values[i][k] = add_values; + } + } + + if (flags & update_gradients) + { + if (inverse_node_matrix.n_cols() == 0) + for (unsigned int i = 0; idofs_per_cell; ++i) + data->shape_grads[i][k] = grads[i]; + else + for (unsigned int i = 0; idofs_per_cell; ++i) + { + Tensor<2, dim> add_grads; + for (unsigned int j = 0; jdofs_per_cell; ++j) + add_grads += inverse_node_matrix(j, i) * grads[j]; + data->shape_grads[i][k] = add_grads; + } + } + + } + return data; + } virtual void diff --git a/source/fe/fe_face.cc b/source/fe/fe_face.cc index 68418bfc68..b3d9e2db48 100644 --- a/source/fe/fe_face.cc +++ b/source/fe/fe_face.cc @@ -458,63 +458,6 @@ FE_FaceQ<1,spacedim>::update_each (const UpdateFlags flags) const } - -template -typename FiniteElement<1,spacedim>::InternalDataBase * -FE_FaceQ<1,spacedim>::get_data ( - const UpdateFlags, - const Mapping<1,spacedim> &, - const Quadrature<1> &) const -{ - return new typename FiniteElement<1,spacedim>::InternalDataBase; -} - - -template -typename FiniteElement<1,spacedim>::InternalDataBase * -FE_FaceQ<1,spacedim>::get_face_data ( - const UpdateFlags update_flags, - const Mapping<1,spacedim> &, - const Quadrature<0> &quadrature) const -{ - // generate a new data object and initialize some fields - typename FiniteElement<1,spacedim>::InternalDataBase *data = - new typename FiniteElement<1,spacedim>::InternalDataBase; - - // check what needs to be initialized only once and what on every - // cell/face/subface we visit - data->update_once = update_once(update_flags); - data->update_each = update_each(update_flags); - data->update_flags = data->update_once | data->update_each; - - const UpdateFlags flags(data->update_flags); - const unsigned int n_q_points = quadrature.size(); - AssertDimension(n_q_points, 1); - (void)n_q_points; - - // No derivatives of this element are implemented. - if (flags & update_gradients || flags & update_hessians) - { - Assert(false, ExcNotImplemented()); - } - - return data; -} - - - -template -typename FiniteElement<1,spacedim>::InternalDataBase * -FE_FaceQ<1,spacedim>::get_subface_data ( - const UpdateFlags flags, - const Mapping<1,spacedim> &mapping, - const Quadrature<0> &quadrature) const -{ - return get_face_data (flags, mapping, quadrature); -} - - - template void FE_FaceQ<1,spacedim>:: diff --git a/source/fe/fe_poly_tensor.cc b/source/fe/fe_poly_tensor.cc index 57bdd8b80b..fc9e1e752a 100644 --- a/source/fe/fe_poly_tensor.cc +++ b/source/fe/fe_poly_tensor.cc @@ -273,127 +273,6 @@ FE_PolyTensor::shape_grad_grad_component (const unsigned int } - -//--------------------------------------------------------------------------- -// Data field initialization -//--------------------------------------------------------------------------- - -template -typename FiniteElement::InternalDataBase * -FE_PolyTensor::get_data ( - const UpdateFlags update_flags, - const Mapping &mapping, - const Quadrature &quadrature) const -{ - // generate a new data object and - // initialize some fields - InternalData *data = new InternalData; - - // check what needs to be - // initialized only once and what - // on every cell/face/subface we - // visit - data->update_once = update_once(update_flags); - data->update_each = update_each(update_flags); - data->update_flags = data->update_once | data->update_each; - - const UpdateFlags flags(data->update_flags); - const unsigned int n_q_points = quadrature.size(); - - // some scratch arrays - std::vector > values(0); - std::vector > grads(0); - std::vector > grad_grads(0); - - data->sign_change.resize (this->dofs_per_cell); - - // initialize fields only if really - // necessary. otherwise, don't - // allocate memory - if (flags & update_values) - { - values.resize (this->dofs_per_cell); - data->shape_values.resize (this->dofs_per_cell); - for (unsigned int i=0; idofs_per_cell; ++i) - data->shape_values[i].resize (n_q_points); - if (mapping_type != mapping_none) - data->transformed_shape_values.resize (n_q_points); - } - - if (flags & update_gradients) - { - grads.resize (this->dofs_per_cell); - data->shape_grads.resize (this->dofs_per_cell); - for (unsigned int i=0; idofs_per_cell; ++i) - data->shape_grads[i].resize (n_q_points); - data->transformed_shape_grads.resize (n_q_points); - if ( (mapping_type == mapping_raviart_thomas) - || - (mapping_type == mapping_piola) - || - (mapping_type == mapping_nedelec)) - data->untransformed_shape_grads.resize(n_q_points); - } - - // if second derivatives through - // finite differencing is required, - // then initialize some objects for - // that - if (flags & update_hessians) - { -// grad_grads.resize (this->dofs_per_cell); - data->initialize_2nd (this, mapping, quadrature); - } - - // Compute shape function values - // and derivatives on the reference - // cell. Make sure, that for the - // node values N_i holds - // N_i(v_j)=\delta_ij for all basis - // functions v_j - if (flags & (update_values | update_gradients)) - for (unsigned int k=0; kdofs_per_cell; ++i) - data->shape_values[i][k] = values[i]; - else - for (unsigned int i=0; idofs_per_cell; ++i) - { - Tensor<1,dim> add_values; - for (unsigned int j=0; jdofs_per_cell; ++j) - add_values += inverse_node_matrix(j,i) * values[j]; - data->shape_values[i][k] = add_values; - } - } - - if (flags & update_gradients) - { - if (inverse_node_matrix.n_cols() == 0) - for (unsigned int i=0; idofs_per_cell; ++i) - data->shape_grads[i][k] = grads[i]; - else - for (unsigned int i=0; idofs_per_cell; ++i) - { - Tensor<2,dim> add_grads; - for (unsigned int j=0; jdofs_per_cell; ++j) - add_grads += inverse_node_matrix(j,i) * grads[j]; - data->shape_grads[i][k] = add_grads; - } - } - - } - return data; -} - - - - //--------------------------------------------------------------------------- // Fill data of FEValues //--------------------------------------------------------------------------- -- 2.39.5