From 6ac981b47b7ac37cb12bc998d89a461cbed192fb Mon Sep 17 00:00:00 2001 From: wolf Date: Tue, 4 May 1999 11:59:50 +0000 Subject: [PATCH] Add functions which tell us how often a given line/quad/hex is refined. git-svn-id: https://svn.dealii.org/trunk@1263 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/grid/tria_accessor.h | 33 ++++++++++ .../include/grid/tria_accessor.templates.h | 65 +++++++++++++++++++ deal.II/deal.II/source/fe/fe_values.cc | 4 +- deal.II/deal.II/source/grid/tria_accessor.cc | 8 --- 4 files changed, 100 insertions(+), 10 deletions(-) diff --git a/deal.II/deal.II/include/grid/tria_accessor.h b/deal.II/deal.II/include/grid/tria_accessor.h index 12bdd7fecd..ee28d62fae 100644 --- a/deal.II/deal.II/include/grid/tria_accessor.h +++ b/deal.II/deal.II/include/grid/tria_accessor.h @@ -385,6 +385,17 @@ class LineAccessor : public TriaAccessor { */ bool has_children () const; + /** + * Return the number of times that this + * cell is refined. Note that not all + * its children are refined that often + * (which is why we prepend #max_#), + * the returned number is rather the + * maximum number of refinement in + * any branch of children of this object. + */ + unsigned int max_refinement_depth () const; + /** * Return the boundary indicator of this * line. Since boundary data is only useful @@ -715,6 +726,17 @@ class QuadAccessor : public TriaAccessor { */ bool has_children () const; + /** + * Return the number of times that this + * cell is refined. Note that not all + * its children are refined that often + * (which is why we prepend #max_#), + * the returned number is rather the + * maximum number of refinement in + * any branch of children of this object. + */ + unsigned int max_refinement_depth () const; + /** * Return the boundary indicator of this * quad. Since boundary data is only useful @@ -1074,6 +1096,17 @@ class HexAccessor : public TriaAccessor { */ bool has_children () const; + /** + * Return the number of times that this + * cell is refined. Note that not all + * its children are refined that often + * (which is why we prepend #max_#), + * the returned number is rather the + * maximum number of refinement in + * any branch of children of this object. + */ + unsigned int max_refinement_depth () const; + /** * Return the boundary indicator of this * hex. Since boundary data is only useful diff --git a/deal.II/deal.II/include/grid/tria_accessor.templates.h b/deal.II/deal.II/include/grid/tria_accessor.templates.h index c1addddbd2..c49912ff2a 100644 --- a/deal.II/deal.II/include/grid/tria_accessor.templates.h +++ b/deal.II/deal.II/include/grid/tria_accessor.templates.h @@ -169,6 +169,22 @@ LineAccessor::has_children () const { +template +inline +unsigned int +LineAccessor::max_refinement_depth () const +{ + if (!has_children()) + return 0; + + const unsigned int depths[2] = { child(0)->max_refinement_depth() + 1, + child(1)->max_refinement_depth() + 1 }; + return max (depths[0], depths[1]); +}; + + + + template inline void @@ -331,6 +347,24 @@ QuadAccessor::has_children () const { +template +inline +unsigned int +QuadAccessor::max_refinement_depth () const +{ + if (!has_children()) + return 0; + + const unsigned int depths[4] = { child(0)->max_refinement_depth() + 1, + child(1)->max_refinement_depth() + 1, + child(2)->max_refinement_depth() + 1, + child(3)->max_refinement_depth() + 1 }; + return max (max (depths[0], depths[1]), + max (depths[2], depths[3])); +}; + + + template inline void @@ -539,6 +573,37 @@ int HexAccessor::child_index (unsigned int i) const { +template +bool HexAccessor::has_children () const { + Assert (state() == valid, ExcDereferenceInvalidObject()); + return (tria->levels[present_level]->hexes.children[present_index] != -1); +}; + + + +template +inline +unsigned int +HexAccessor::max_refinement_depth () const +{ + if (!has_children()) + return 0; + + const unsigned int depths[8] = { child(0)->max_refinement_depth() + 1, + child(1)->max_refinement_depth() + 1, + child(2)->max_refinement_depth() + 1, + child(3)->max_refinement_depth() + 1, + child(4)->max_refinement_depth() + 1, + child(5)->max_refinement_depth() + 1, + child(6)->max_refinement_depth() + 1, + child(7)->max_refinement_depth() + 1 }; + return max (max (max (depths[0], depths[1]), + max (depths[2], depths[3])), + max (max (depths[4], depths[5]), + max (depths[6], depths[7]))); +}; + + template inline diff --git a/deal.II/deal.II/source/fe/fe_values.cc b/deal.II/deal.II/source/fe/fe_values.cc index 048ebe4ade..3745fb14f4 100644 --- a/deal.II/deal.II/source/fe/fe_values.cc +++ b/deal.II/deal.II/source/fe/fe_values.cc @@ -142,8 +142,8 @@ template void FEValuesBase::get_function_grads (const Vector &fe_function, vector > &gradients) const { - Assert (fe->n_components == 1, - ExcWrongNoOfComponents()); +// Assert (fe->n_components == 1, +// ExcWrongNoOfComponents()); Assert (gradients.size() == n_quadrature_points, ExcWrongVectorSize(gradients.size(), n_quadrature_points)); diff --git a/deal.II/deal.II/source/grid/tria_accessor.cc b/deal.II/deal.II/source/grid/tria_accessor.cc index 1551fbc68c..770f021f50 100644 --- a/deal.II/deal.II/source/grid/tria_accessor.cc +++ b/deal.II/deal.II/source/grid/tria_accessor.cc @@ -680,14 +680,6 @@ void HexAccessor::clear_children () const { -template -bool HexAccessor::has_children () const { - Assert (state() == valid, ExcDereferenceInvalidObject()); - return (tria->levels[present_level]->hexes.children[present_index] != -1); -}; - - - template unsigned char HexAccessor::boundary_indicator () const { Assert (dim<4, ExcNotUsefulForThisDimension()); -- 2.39.5