From: Wolfgang Bangerth Date: Thu, 12 May 2011 03:10:56 +0000 (+0000) Subject: Implement VectorTools::compute_mean_value for dim!=spacedim. X-Git-Tag: v8.0.0~4074 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64590b8c9c1ebefd8295e9d5266f3a3385f314f1;p=dealii.git Implement VectorTools::compute_mean_value for dim!=spacedim. git-svn-id: https://svn.dealii.org/trunk@23691 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/numerics/vectors.templates.h b/deal.II/include/deal.II/numerics/vectors.templates.h index 6e9293591d..ad435b58eb 100644 --- a/deal.II/include/deal.II/numerics/vectors.templates.h +++ b/deal.II/include/deal.II/numerics/vectors.templates.h @@ -5243,9 +5243,9 @@ VectorTools::compute_mean_value (const Mapping &mapping, Assert (component < dof.get_fe().n_components(), ExcIndexRange(component, 0, dof.get_fe().n_components())); - FEValues fe(mapping, dof.get_fe(), quadrature, - UpdateFlags(update_JxW_values - | update_values)); + FEValues fe(mapping, dof.get_fe(), quadrature, + UpdateFlags(update_JxW_values + | update_values)); typename DoFHandler::active_cell_iterator cell; std::vector > values(quadrature.size(), @@ -5298,7 +5298,7 @@ VectorTools::compute_mean_value (const DoFHandler &dof, const unsigned int component) { Assert (DEAL_II_COMPAT_MAPPING, ExcCompatibility("mapping")); - return compute_mean_value(StaticMappingQ1::mapping, dof, quadrature, v, component); + return compute_mean_value(StaticMappingQ1::mapping, dof, quadrature, v, component); } DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/numerics/vectors.inst.in b/deal.II/source/numerics/vectors.inst.in index b921e567d9..2d3b5e8b95 100644 --- a/deal.II/source/numerics/vectors.inst.in +++ b/deal.II/source/numerics/vectors.inst.in @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -24,7 +24,7 @@ for (VEC : SERIAL_VECTORS ; deal_II_dimension : DIMENSIONS) (const DoFHandler&, const Function&, VEC&); - + template void VectorTools::interpolate (const Mapping&, @@ -252,6 +252,22 @@ for (VEC : SERIAL_VECTORS ; deal_II_dimension : DIMENSIONS) const VEC&, const unsigned int); +#if deal_II_dimension < 3 + template + double VectorTools::compute_mean_value + (const Mapping&, + const DoFHandler&, + const Quadrature&, + const VEC&, + const unsigned int); + template + double VectorTools::compute_mean_value + (const DoFHandler&, + const Quadrature&, + const VEC&, + const unsigned int); +#endif + template void VectorTools::project (const Mapping &, diff --git a/tests/codim_one/mean_value.cc b/tests/codim_one/mean_value.cc new file mode 100644 index 0000000000..233d3285f1 --- /dev/null +++ b/tests/codim_one/mean_value.cc @@ -0,0 +1,76 @@ +//---------------------------- template.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2005, 2008, 2011 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//---------------------------- template.cc --------------------------- + + +// continous projection of a function on the surface of a hypersphere + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + + +std::ofstream logfile("mean_value/output"); + + +template +void test() +{ + Triangulation triangulation; + GridGenerator::hyper_cube (triangulation, -1, 1); + + FE_Q fe (1); + DoFHandler dof_handler (triangulation); + + dof_handler.distribute_dofs (fe); + Functions::CosineFunction cosine; + Vector x(dof_handler.n_dofs()); + VectorTools::interpolate(dof_handler, cosine, x); + + const double mean = VectorTools::compute_mean_value (dof_handler, + QGauss(2), + x, 0); + // we have a symmetric domain and a symmetric function. the result + // should be close to zero + Assert (std::fabs(mean) < 1e-15, ExcInternalError()); + deallog << "OK" << std::endl; +} + + + +int main () +{ + deallog.attach(logfile); + deallog.depth_console(0); + + test<1,2>(); + test<2,3>(); +} diff --git a/tests/codim_one/mean_value/cmp/generic b/tests/codim_one/mean_value/cmp/generic new file mode 100644 index 0000000000..8b3b075900 --- /dev/null +++ b/tests/codim_one/mean_value/cmp/generic @@ -0,0 +1,3 @@ + +DEAL::OK +DEAL::OK