From 65cdec694f3fd382b345cd28f21b6065fe798fd9 Mon Sep 17 00:00:00 2001 From: goll Date: Thu, 16 Feb 2012 15:18:01 +0000 Subject: [PATCH] New test for FEFieldFunction git-svn-id: https://svn.dealii.org/trunk@25101 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/bits/fe_field_function_03.cc | 88 +++++++++++++++++++++ tests/bits/fe_field_function_03/cmp/generic | 19 +++++ 2 files changed, 107 insertions(+) create mode 100644 tests/bits/fe_field_function_03.cc create mode 100644 tests/bits/fe_field_function_03/cmp/generic diff --git a/tests/bits/fe_field_function_03.cc b/tests/bits/fe_field_function_03.cc new file mode 100644 index 0000000000..834205d8be --- /dev/null +++ b/tests/bits/fe_field_function_03.cc @@ -0,0 +1,88 @@ +//------------------------------------------------------- +// $Id: fe_field_function_03.cc $ +// Version: $Name$ +// +// Copyright (C) 2005, 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. +// +//------------------------------------------------------- + + +// Test the functionality of the laplacian in the FEFieldFunction class. + +#include "../tests.h" +#include + +// all include files you need here +#include +#include +#include +#include +#include +#include +#include +#include +#include + +template +void test() { + Triangulation tria; + GridGenerator::hyper_cube(tria); + tria.refine_global(9/dim); + + FE_Q fe(2); + DoFHandler dh(tria); + + dh.distribute_dofs(fe); + deallog << "Ndofs :" << dh.n_dofs() << std::endl; + + Functions::CosineFunction ff; + + Vector v1(dh.n_dofs()), v2(dh.n_dofs()); + + VectorTools::interpolate(dh, ff, v1); + deallog << "V norm: " << v1.l2_norm() << std::endl; + + Functions::FEFieldFunction, Vector > + fef(dh, v1); + + //create the origin + Point p; + //compute the error of the laplacian in this point + deallog << "Value of the laplacian in 0:" << std::endl; + deallog << "correct value: " << ff.laplacian(p) <<", approximation: "<< fef.laplacian(p) << std::endl; + + //now we want to test the list version + Point p1 = Point::unit_vector(0); + p1 = p1 * 0.5; + Point p2 = p1 * 0.5; + std::vector > vec; + vec.push_back(p1); + vec.push_back(p2); + std::vector values_c(2); + std::vector values_a(2); + + //get the laplacians at these two points + ff.laplacian_list(vec, values_c); + fef.laplacian_list(vec, values_a); + deallog << "Value of the laplacian in 0.5*e1 and 0.25 * e1:" << std::endl; + deallog << " correct values: " <(); + test<2>(); + test<3>(); + + return 0; +} + diff --git a/tests/bits/fe_field_function_03/cmp/generic b/tests/bits/fe_field_function_03/cmp/generic new file mode 100644 index 0000000000..cd95fc4b27 --- /dev/null +++ b/tests/bits/fe_field_function_03/cmp/generic @@ -0,0 +1,19 @@ + +DEAL::Ndofs :1025 +DEAL::V norm: 22.6385 +DEAL::Value of the laplacian in 0: +DEAL::correct value: -2.46740, approximation: -2.46743 +DEAL::Value of the laplacian in 0.5*e1 and 0.25 * e1: +DEAL:: correct values: -1.74472 -2.27958, approximations: -1.74739 -2.28103 +DEAL::Ndofs :1089 +DEAL::V norm: 16.5000 +DEAL::Value of the laplacian in 0: +DEAL::correct value: -4.93480, approximation: -4.92787 +DEAL::Value of the laplacian in 0.5*e1 and 0.25 * e1: +DEAL:: correct values: -3.48943 -4.55916, approximations: -3.57012 -4.59908 +DEAL::Ndofs :4913 +DEAL::V norm: 24.7815 +DEAL::Value of the laplacian in 0: +DEAL::correct value: -7.40220, approximation: -7.36064 +DEAL::Value of the laplacian in 0.5*e1 and 0.25 * e1: +DEAL:: correct values: -5.23415 -6.83874, approximations: -5.37564 -6.89283 -- 2.39.5