00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef __deal2__gradient_estimator_h
00014 #define __deal2__gradient_estimator_h
00015
00016 #include <deal.II/base/config.h>
00017 #include <deal.II/base/exceptions.h>
00018 #include <deal.II/fe/fe_update_flags.h>
00019 #include <deal.II/fe/mapping.h>
00020 #include <utility>
00021
00022 DEAL_II_NAMESPACE_OPEN
00023
00024 template <int dim, int spacedim> class DoFHandler;
00025 namespace hp
00026 {
00027 template <int dim, int spacedim> class DoFHandler;
00028 }
00029
00030
00031
00179 class DerivativeApproximation
00180 {
00181 public:
00203 template <int dim, template <int, int> class DH, class InputVector, int spacedim>
00204 static void
00205 approximate_gradient (const Mapping<dim,spacedim> &mapping,
00206 const DH<dim,spacedim> &dof,
00207 const InputVector &solution,
00208 Vector<float> &derivative_norm,
00209 const unsigned int component = 0);
00210
00216 template <int dim, template <int, int> class DH, class InputVector, int spacedim>
00217 static void
00218 approximate_gradient (const DH<dim,spacedim> &dof,
00219 const InputVector &solution,
00220 Vector<float> &derivative_norm,
00221 const unsigned int component = 0);
00222
00250 template <int dim, template <int, int> class DH, class InputVector, int spacedim>
00251 static void
00252 approximate_second_derivative (const Mapping<dim,spacedim> &mapping,
00253 const DH<dim,spacedim> &dof,
00254 const InputVector &solution,
00255 Vector<float> &derivative_norm,
00256 const unsigned int component = 0);
00257
00263 template <int dim, template <int, int> class DH, class InputVector, int spacedim>
00264 static void
00265 approximate_second_derivative (const DH<dim,spacedim> &dof,
00266 const InputVector &solution,
00267 Vector<float> &derivative_norm,
00268 const unsigned int component = 0);
00269
00288 template <int dim, template <int, int> class DH, class InputVector, int order, int spacedim>
00289 static void
00290 approximate_derivative_tensor (const Mapping<dim,spacedim> &mapping,
00291 const DH<dim,spacedim> &dof,
00292 const InputVector &solution,
00293 const typename DH<dim,spacedim>::active_cell_iterator &cell,
00294 Tensor<order,dim> &derivative,
00295 const unsigned int component = 0);
00296
00302 template <int dim, template <int, int> class DH, class InputVector, int order, int spacedim>
00303 static void
00304 approximate_derivative_tensor (const DH<dim,spacedim> &dof,
00305 const InputVector &solution,
00306 const typename DH<dim,spacedim>::active_cell_iterator &cell,
00307 Tensor<order,dim> &derivative,
00308 const unsigned int component = 0);
00309
00313 template <int dim, int order>
00314 static double
00315 derivative_norm(const Tensor<order,dim> &derivative);
00316
00320 DeclException2 (ExcInvalidVectorLength,
00321 int, int,
00322 << "Vector has length " << arg1 << ", but should have "
00323 << arg2);
00327 DeclException0 (ExcInsufficientDirections);
00328
00329 private:
00330
00343 template <int dim>
00344 class Gradient
00345 {
00346 public:
00353 static const UpdateFlags update_flags;
00354
00360 typedef Tensor<1,dim> Derivative;
00361
00368 typedef double ProjectedDerivative;
00369
00381 template <class InputVector, int spacedim>
00382 static ProjectedDerivative
00383 get_projected_derivative (const FEValues<dim,spacedim> &fe_values,
00384 const InputVector &solution,
00385 const unsigned int component);
00386
00394 static double derivative_norm (const Derivative &d);
00395
00407 static void symmetrize (Derivative &derivative_tensor);
00408 };
00409
00410
00411
00424 template <int dim>
00425 class SecondDerivative
00426 {
00427 public:
00434 static const UpdateFlags update_flags;
00435
00441 typedef Tensor<2,dim> Derivative;
00442
00449 typedef Tensor<1,dim> ProjectedDerivative;
00450
00462 template <class InputVector, int spacedim>
00463 static ProjectedDerivative
00464 get_projected_derivative (const FEValues<dim,spacedim> &fe_values,
00465 const InputVector &solution,
00466 const unsigned int component);
00467
00480 static double derivative_norm (const Derivative &d);
00481
00499 static void symmetrize (Derivative &derivative_tensor);
00500 };
00501
00502 template <int dim>
00503 class ThirdDerivative
00504 {
00505 public:
00512 static const UpdateFlags update_flags;
00513
00519 typedef Tensor<3,dim> Derivative;
00520
00527 typedef Tensor<2,dim> ProjectedDerivative;
00528
00540 template <class InputVector, int spacedim>
00541 static ProjectedDerivative
00542 get_projected_derivative (const FEValues<dim,spacedim> &fe_values,
00543 const InputVector &solution,
00544 const unsigned int component);
00545
00558 static double derivative_norm (const Derivative &d);
00559
00577 static void symmetrize (Derivative &derivative_tensor);
00578 };
00579
00580 template <int order, int dim>
00581 class DerivativeSelector
00582 {
00583 public:
00593 typedef void DerivDescr;
00594
00595 };
00596
00597 template <int dim>
00598 class DerivativeSelector<1,dim>
00599 {
00600 public:
00601
00602 typedef Gradient<dim> DerivDescr;
00603 };
00604
00605 template <int dim>
00606 class DerivativeSelector<2,dim>
00607 {
00608 public:
00609
00610 typedef SecondDerivative<dim> DerivDescr;
00611 };
00612
00613 template <int dim>
00614 class DerivativeSelector<3,dim>
00615 {
00616 public:
00617
00618 typedef ThirdDerivative<dim> DerivDescr;
00619 };
00620
00621
00622
00623
00624 private:
00625
00632 typedef std::pair<unsigned int,unsigned int> IndexInterval;
00633
00653 template <class DerivativeDescription, int dim,
00654 template <int, int> class DH, class InputVector, int spacedim>
00655 static void
00656 approximate_derivative (const Mapping<dim,spacedim> &mapping,
00657 const DH<dim,spacedim> &dof,
00658 const InputVector &solution,
00659 const unsigned int component,
00660 Vector<float> &derivative_norm);
00661
00671 template <class DerivativeDescription, int dim,
00672 template <int, int> class DH, class InputVector, int spacedim>
00673 static void
00674 approximate (const Mapping<dim,spacedim> &mapping,
00675 const DH<dim,spacedim> &dof,
00676 const InputVector &solution,
00677 const unsigned int component,
00678 const IndexInterval &index_interval,
00679 Vector<float> &derivative_norm);
00680
00686 template <class DerivativeDescription, int dim,
00687 template <int, int> class DH, class InputVector, int spacedim>
00688 static void
00689 approximate_cell (const Mapping<dim,spacedim> &mapping,
00690 const DH<dim,spacedim> &dof,
00691 const InputVector &solution,
00692 const unsigned int component,
00693 const typename DH<dim,spacedim>::active_cell_iterator &cell,
00694 typename DerivativeDescription::Derivative &derivative);
00695 };
00696
00697
00698
00699
00700 template <>
00701 double
00702 DerivativeApproximation::SecondDerivative<1>::derivative_norm (const Derivative &d);
00703
00704 template <>
00705 double
00706 DerivativeApproximation::SecondDerivative<2>::derivative_norm (const Derivative &d);
00707
00708 template <>
00709 double
00710 DerivativeApproximation::SecondDerivative<3>::derivative_norm (const Derivative &d);
00711
00712
00713 DEAL_II_NAMESPACE_CLOSE
00714
00715 #endif
00716