From: bangerth Date: Sun, 3 Jun 2012 17:44:51 +0000 (+0000) Subject: Implement W1infty norm and seminorm in VectorTools::integrate_difference. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c8a6630be5f82da8fd4b71c125b57970ff8b772c;p=dealii-svn.git Implement W1infty norm and seminorm in VectorTools::integrate_difference. git-svn-id: https://svn.dealii.org/trunk@25597 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 8a4f303a51..f52970946e 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -47,6 +47,13 @@ used for boundary indicators.
    +
  1. +New: step-15 has been replaced by a program that demonstrates the +solution of nonlinear problem (the minimal surface equation) using +Newton's method. +
    +(Sven Wetterauer, 2012/06/03) +
  2. New: step-48 demonstrates the solution of a nonlinear wave equation @@ -201,6 +208,12 @@ enabled due to a missing include file in file

    Specific improvements

      +
    1. Fixed: Computing the $W^{1,\infty}$ norm and seminorm in +VectorTools::integrate_difference was not implemented. This is now +fixed. +
      +(Wolfgang Bangerth 2012/06/02) +
    2. Fixed: A problem in MappingQ::transform_real_to_unit_cell that sometimes led the algorithm in this function to abort.
      diff --git a/deal.II/include/deal.II/numerics/vectors.templates.h b/deal.II/include/deal.II/numerics/vectors.templates.h index 72b02f2b7b..941af268f5 100644 --- a/deal.II/include/deal.II/numerics/vectors.templates.h +++ b/deal.II/include/deal.II/numerics/vectors.templates.h @@ -5192,9 +5192,9 @@ namespace VectorTools 0.0); diff = std::sqrt(diff); break; + case W1infty_seminorm: case W1infty_norm: - Assert(false, ExcNotImplemented()); std::fill_n (psi_scalar.begin(), n_q_points, 0.0); for (unsigned int k=0; k +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + + +template +void test () +{ + deallog << "dim=" << dim << std::endl; + + Triangulation tria; + GridGenerator::hyper_cube(tria); + tria.refine_global (2); + tria.begin_active()->set_refine_flag (); + tria.execute_coarsening_and_refinement (); + tria.refine_global (4-dim); + + hp::FECollection fe_collection; + hp::QCollection q_collection; + for (unsigned int i=1; i<=4; ++i) + { + fe_collection.push_back(FE_Q (i)); + q_collection.push_back (QGauss (i+2)); + } + + + hp::DoFHandler dof_handler(tria); + + for (typename hp::DoFHandler::active_cell_iterator + cell = dof_handler.begin_active(); + cell != dof_handler.end(); ++cell) + cell->set_active_fe_index (rand() % fe_collection.size()); + + dof_handler.distribute_dofs(fe_collection); + + // interpolate a linear function + Vector vec (dof_handler.n_dofs()); + VectorTools::interpolate (dof_handler, + Functions::Monomial + (dim == 1 ? + Point(1.) : + (dim == 2 ? + Point(1.,0.) : + Point(1.,0.,0.))), + vec); + + Vector diff (tria.n_active_cells()); + + // L1 norm. the function is u(x)=x, so its + // L1 norm should be equal to 1/2 + { + VectorTools::integrate_difference (dof_handler, + vec, + ZeroFunction(), + diff, + q_collection, + VectorTools::L1_norm); + deallog << "L1, diff=" << diff.l1_norm() << std::endl; + } + + // H1 seminorm. the function is u(x)=x, so + // its H1 seminorm should be equal to 1/2 + { + VectorTools::integrate_difference (dof_handler, + vec, + ZeroFunction(), + diff, + q_collection, + VectorTools::H1_seminorm); + deallog << "H1 seminorm, diff=" << diff.l2_norm() << std::endl; + } + + // W1infty seminorm. the function is + // u(x)=x, so the norm must be equal to 1 + // on every cell + { + VectorTools::integrate_difference (dof_handler, + vec, + ZeroFunction(), + diff, + q_collection, + VectorTools::W1infty_seminorm); + deallog << "W1infty semi, diff=" << diff.linfty_norm() << std::endl; + // also ensure that we indeed get the + // same value on every cell + diff. add(-1); + Assert (diff.l2_norm() == 0, ExcInternalError()); + } + + // W1infty norm. the Linfty norm is one, so + // the W1infty norm must be two. but not on + // every cell + { + VectorTools::integrate_difference (dof_handler, + vec, + ZeroFunction(), + diff, + q_collection, + VectorTools::W1infty_norm); + deallog << "W1infty, diff=" << diff.linfty_norm() << std::endl; + diff.add(-2); + Assert (diff.l1_norm() > 0.5, ExcInternalError()); + } +} + + +int main () +{ + std::ofstream logfile("integrate_difference_02/output"); + logfile.precision(2); + deallog << std::setprecision(2); + + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test<1> (); + test<2> (); + test<3> (); + + deallog << "OK" << std::endl; +} diff --git a/tests/hp/integrate_difference_02/cmp/generic b/tests/hp/integrate_difference_02/cmp/generic new file mode 100644 index 0000000000..b5969a89a3 --- /dev/null +++ b/tests/hp/integrate_difference_02/cmp/generic @@ -0,0 +1,17 @@ + +DEAL::dim=1 +DEAL::L1, diff=0.50 +DEAL::H1 seminorm, diff=1.0 +DEAL::W1infty semi, diff=1.0 +DEAL::W1infty, diff=2.0 +DEAL::dim=2 +DEAL::L1, diff=0.50 +DEAL::H1 seminorm, diff=1.0 +DEAL::W1infty semi, diff=1.0 +DEAL::W1infty, diff=2.0 +DEAL::dim=3 +DEAL::L1, diff=0.50 +DEAL::H1 seminorm, diff=1.0 +DEAL::W1infty semi, diff=1.0 +DEAL::W1infty, diff=2.0 +DEAL::OK