From 1c92feb848e8238924db5fe09d51f0a557f9c2d7 Mon Sep 17 00:00:00 2001 From: hartmann Date: Tue, 8 May 2001 10:02:13 +0000 Subject: [PATCH] Implementation of all FE::shape_value, shape_grad and shape_grad_grad functions. git-svn-id: https://svn.dealii.org/trunk@4560 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/fe/fe_base.h | 63 ++++++++++++++++++++++++++ deal.II/deal.II/include/fe/fe_dgq.h | 34 ++++++++++++++ deal.II/deal.II/include/fe/fe_q.h | 53 +++++++++++++++++++++- deal.II/deal.II/include/fe/fe_system.h | 60 ++++++++++++++++++++++++ deal.II/deal.II/source/fe/fe.cc | 31 +++++++++++++ deal.II/deal.II/source/fe/fe_dgq.cc | 28 ++++++++++++ deal.II/deal.II/source/fe/fe_q.cc | 35 ++++++++++++++ deal.II/deal.II/source/fe/fe_system.cc | 46 +++++++++++++++++++ 8 files changed, 349 insertions(+), 1 deletion(-) diff --git a/deal.II/deal.II/include/fe/fe_base.h b/deal.II/deal.II/include/fe/fe_base.h index 9bad222e31..3b1361b432 100644 --- a/deal.II/deal.II/include/fe/fe_base.h +++ b/deal.II/deal.II/include/fe/fe_base.h @@ -379,6 +379,64 @@ class FiniteElementBase : public Subscriptor, FiniteElementBase (const FiniteElementData &fe_data, const std::vector &restriction_is_additive_flags); + /** + * Return the value of the + * @p{i}th shape function at the + * point @p{p}. @p{p} is a point + * on the reference element. + * + * An + * @p{ExcUnitShapeValuesDoNotExist} + * is thrown if the shape values + * of the @p{FiniteElement} under + * consideration depend on the + * shape of the cell in real + * space. + */ + virtual double shape_value (const unsigned int i, + const Point &p) const; + + /** + * Return the gradient of the + * @p{i}th shape function at the + * point @p{p}. @p{p} is a point + * on the reference element, and + * likewise the gradient is the + * gradient on the unit cell with + * respect to unit cell + * coordinates. + * + * An + * @p{ExcUnitShapeValuesDoNotExist} + * is thrown if the shape values + * of the @p{FiniteElement} under + * consideration depend on the + * shape of the cell in real + * space. + */ + virtual Tensor<1,dim> shape_grad (const unsigned int i, + const Point &p) const; + + /** + * Return the tensor of second + * derivatives of the @p{i}th + * shape function at point @p{p} + * on the unit cell. The + * derivatives are derivatives on + * the unit cell with respect to + * unit cell coordinates. + * + * An + * @p{ExcUnitShapeValuesDoNotExist} + * is thrown if the shape values + * of the @p{FiniteElement} under + * consideration depend on the + * shape of the cell in real + * space. + */ + virtual Tensor<2,dim> shape_grad_grad (const unsigned int i, + const Point &p) const; + /** * Projection from a fine grid * space onto a coarse grid @@ -663,6 +721,11 @@ class FiniteElementBase : public Subscriptor, */ unsigned int memory_consumption () const; + /** + * Exception + */ + DeclException0 (ExcUnitShapeValuesDoNotExist); + /** * Exception */ diff --git a/deal.II/deal.II/include/fe/fe_dgq.h b/deal.II/deal.II/include/fe/fe_dgq.h index ac2b3307da..86e8a5425f 100644 --- a/deal.II/deal.II/include/fe/fe_dgq.h +++ b/deal.II/deal.II/include/fe/fe_dgq.h @@ -43,7 +43,41 @@ class FE_DGQ : public FiniteElement * Destructor. */ ~FE_DGQ (); + + /** + * Return the value of the + * @p{i}th shape function at the + * point @p{p}. @p{p} is a point + * on the reference element. + */ + virtual double shape_value (const unsigned int i, + const Point &p) const; + + /** + * Return the gradient of the + * @p{i}th shape function at the + * point @p{p}. @p{p} is a point + * on the reference element, and + * likewise the gradient is the + * gradient on the unit cell with + * respect to unit cell + * coordinates. + */ + virtual Tensor<1,dim> shape_grad (const unsigned int i, + const Point &p) const; + /** + * Return the tensor of second + * derivatives of the @p{i}th + * shape function at point @p{p} + * on the unit cell. The + * derivatives are derivatives on + * the unit cell with respect to + * unit cell coordinates. + */ + virtual Tensor<2,dim> shape_grad_grad (const unsigned int i, + const Point &p) const; + /** * Return the polynomial degree * of this finite element, diff --git a/deal.II/deal.II/include/fe/fe_q.h b/deal.II/deal.II/include/fe/fe_q.h index 3b7bb883c4..67b096c783 100644 --- a/deal.II/deal.II/include/fe/fe_q.h +++ b/deal.II/deal.II/include/fe/fe_q.h @@ -248,11 +248,54 @@ class FE_Q : public FiniteElement * Destructor. */ ~FE_Q (); + + /** + * Return the value of the + * @p{i}th shape function at the + * point @p{p}. @p{p} is a point + * on the reference element. + */ + virtual double shape_value (const unsigned int i, + const Point &p) const; + + /** + * Return the gradient of the + * @p{i}th shape function at the + * point @p{p}. @p{p} is a point + * on the reference element, and + * likewise the gradient is the + * gradient on the unit cell with + * respect to unit cell + * coordinates. + */ + virtual Tensor<1,dim> shape_grad (const unsigned int i, + const Point &p) const; + + /** + * Return the tensor of second + * derivatives of the @p{i}th + * shape function at point @p{p} + * on the unit cell. The + * derivatives are derivatives on + * the unit cell with respect to + * unit cell coordinates. + */ + virtual Tensor<2,dim> shape_grad_grad (const unsigned int i, + const Point &p) const; //TODO:[RH] make get_renumber private or move it some other place /** * Read-only access to the * renumber vector. + * + * This function shouldn't be + * used, i.e. the users code + * shouldn't rely on the actual + * numbering of the degrees of + * dreedom on each cell. This, + * because this internal + * numbering might change in + * future. */ const std::vector & get_renumber() const; @@ -514,7 +557,15 @@ class FE_Q : public FiniteElement * shape function numbering. */ std::vector renumber; - + + /** + * Inverse renumber + * vector. i.e. mapping from + * shape function numbering to + * lexicographic numbering. + */ + std::vector renumber_inverse; + /** * Mapping from lexicographic to * shape function numbering on first face. diff --git a/deal.II/deal.II/include/fe/fe_system.h b/deal.II/deal.II/include/fe/fe_system.h index dbeb5bca16..2252f56991 100644 --- a/deal.II/deal.II/include/fe/fe_system.h +++ b/deal.II/deal.II/include/fe/fe_system.h @@ -122,6 +122,66 @@ class FESystem : public FiniteElement */ virtual ~FESystem (); + /** + * Return the value of the + * @p{i}th shape function at the + * point @p{p}. @p{p} is a point + * on the reference element. + * + * An + * @p{ExcUnitShapeValuesDoNotExist} + * is thrown if the shape values + * of the @p{FiniteElement} + * (corresponding to the @p{i}th + * shape function) depend on the + * shape of the cell in real + * space. + */ + virtual double shape_value (const unsigned int i, + const Point &p) const; + + /** + * Return the gradient of the + * @p{i}th shape function at the + * point @p{p}. @p{p} is a point + * on the reference element, and + * likewise the gradient is the + * gradient on the unit cell with + * respect to unit cell + * coordinates. + * + * An + * @p{ExcUnitShapeValuesDoNotExist} + * is thrown if the shape values + * of the @p{FiniteElement} + * (corresponding to the @p{i}th + * shape function) depend on the + * shape of the cell in real + * space. + */ + virtual Tensor<1,dim> shape_grad (const unsigned int i, + const Point &p) const; + + /** + * Return the tensor of second + * derivatives of the @p{i}th + * shape function at point @p{p} + * on the unit cell. The + * derivatives are derivatives on + * the unit cell with respect to + * unit cell coordinates. + * + * An + * @p{ExcUnitShapeValuesDoNotExist} + * is thrown if the shape values + * of the @p{FiniteElement} + * (corresponding to the @p{i}th + * shape function) depend on the + * shape of the cell in real + * space. + */ + virtual Tensor<2,dim> shape_grad_grad (const unsigned int i, + const Point &p) const; /** * Number of different base diff --git a/deal.II/deal.II/source/fe/fe.cc b/deal.II/deal.II/source/fe/fe.cc index 5a2378127c..c3877ab1f2 100644 --- a/deal.II/deal.II/source/fe/fe.cc +++ b/deal.II/deal.II/source/fe/fe.cc @@ -167,6 +167,37 @@ FiniteElementBase::FiniteElementBase (const FiniteElementData &fe_data }; +template +double +FiniteElementBase::shape_value (const unsigned int, + const Point &) const +{ + AssertThrow(false, ExcUnitShapeValuesDoNotExist()); + return 0.; +} + + + +template +Tensor<1,dim> +FiniteElementBase::shape_grad (const unsigned int, + const Point &) const +{ + AssertThrow(false, ExcUnitShapeValuesDoNotExist()); + return Tensor<1,dim> (); +} + + + +template +Tensor<2,dim> +FiniteElementBase::shape_grad_grad (const unsigned int, + const Point &) const +{ + AssertThrow(false, ExcUnitShapeValuesDoNotExist()); + return Tensor<2,dim> (); +} + template const FullMatrix & diff --git a/deal.II/deal.II/source/fe/fe_dgq.cc b/deal.II/deal.II/source/fe/fe_dgq.cc index e4fe8910e7..87a428ec69 100644 --- a/deal.II/deal.II/source/fe/fe_dgq.cc +++ b/deal.II/deal.II/source/fe/fe_dgq.cc @@ -214,6 +214,34 @@ FE_DGQ::clone() const +template +double +FE_DGQ::shape_value (const unsigned int i, + const Point &p) const +{ + return poly->compute_value(i, p); +} + + + +template +Tensor<1,dim> +FE_DGQ::shape_grad (const unsigned int i, + const Point &p) const +{ + return poly->compute_grad(i, p); +} + + + +template +Tensor<2,dim> +FE_DGQ::shape_grad_grad (const unsigned int i, + const Point &p) const +{ + return poly->compute_grad_grad(i, p); +} + //---------------------------------------------------------------------- // Auxiliary functions diff --git a/deal.II/deal.II/source/fe/fe_q.cc b/deal.II/deal.II/source/fe/fe_q.cc index 4b0828fa2e..f21d11d117 100644 --- a/deal.II/deal.II/source/fe/fe_q.cc +++ b/deal.II/deal.II/source/fe/fe_q.cc @@ -34,6 +34,7 @@ FE_Q::FE_Q (const unsigned int degree) std::vector (1,false)), degree(degree), renumber(dofs_per_cell, 0), + renumber_inverse(dofs_per_cell, 0), face_renumber(dofs_per_face, 0), poly(0) { @@ -52,6 +53,11 @@ FE_Q::FE_Q (const unsigned int degree) // face function is empty build_renumbering (*this, degree, renumber); build_face_renumbering (degree, face_renumber); + + // build inverse of renumbering + // vector + for (unsigned int i=0; i::clone() const +template +double +FE_Q::shape_value (const unsigned int i, + const Point &p) const +{ + return poly->compute_value(renumber_inverse[i], p); +} + + + +template +Tensor<1,dim> +FE_Q::shape_grad (const unsigned int i, + const Point &p) const +{ + return poly->compute_grad(renumber_inverse[i], p); +} + + + +template +Tensor<2,dim> +FE_Q::shape_grad_grad (const unsigned int i, + const Point &p) const +{ + return poly->compute_grad_grad(renumber_inverse[i], p); +} + + //---------------------------------------------------------------------- // Auxiliary functions //---------------------------------------------------------------------- diff --git a/deal.II/deal.II/source/fe/fe_system.cc b/deal.II/deal.II/source/fe/fe_system.cc index 58b134bd04..d9323270a3 100644 --- a/deal.II/deal.II/source/fe/fe_system.cc +++ b/deal.II/deal.II/source/fe/fe_system.cc @@ -232,6 +232,52 @@ FESystem::clone() const +template +double +FESystem::shape_value (const unsigned int i, + const Point &p) const +{ + Assert((i comp = system_to_component_index(i); + + return base_element(component_to_base_table[comp.first]) + .shape_value(comp.second, p); +} + + + +template +Tensor<1,dim> +FESystem::shape_grad (const unsigned int i, + const Point &p) const +{ + Assert((i comp = system_to_component_index(i); + + return base_element(component_to_base_table[comp.first]) + .shape_grad(comp.second, p); +} + + + +template +Tensor<2,dim> +FESystem::shape_grad_grad (const unsigned int i, + const Point &p) const +{ + Assert((i comp = system_to_component_index(i); + + return base_element(component_to_base_table[comp.first]) + .shape_grad_grad(comp.second, p); +} + + + template UpdateFlags FESystem::update_once (const UpdateFlags flags) const -- 2.39.5