From 6766c0f94f5e499a57217dd01d3ee388b45cd010 Mon Sep 17 00:00:00 2001 From: bangerth Date: Wed, 4 Jul 2012 10:36:06 +0000 Subject: [PATCH] New tests. git-svn-id: https://svn.dealii.org/trunk@25676 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/bits/fe_field_function_04.cc | 87 +++++++++++++++++++ tests/bits/fe_field_function_04/cmp/generic | 2 + tests/bits/fe_field_function_05.cc | 94 +++++++++++++++++++++ tests/bits/fe_field_function_05/cmp/generic | 2 + 4 files changed, 185 insertions(+) create mode 100644 tests/bits/fe_field_function_04.cc create mode 100644 tests/bits/fe_field_function_04/cmp/generic create mode 100644 tests/bits/fe_field_function_05.cc create mode 100644 tests/bits/fe_field_function_05/cmp/generic diff --git a/tests/bits/fe_field_function_04.cc b/tests/bits/fe_field_function_04.cc new file mode 100644 index 0000000000..b54a7fabf7 --- /dev/null +++ b/tests/bits/fe_field_function_04.cc @@ -0,0 +1,87 @@ +//------------------------------------------------------- +// $Id: fe_field_function_04.cc $ +// Version: $Name$ +// +// Copyright (C) 2005, 2011, 2012 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. +// +//------------------------------------------------------- + + +// FEFieldFunction ran into an assertion after +// Mapping::transform_real_to_unit_cell started throwing exceptions +// when it couldn't find the point on the reference cell that belongs +// to a given point, rather than just silently giving up + +#include "../tests.h" + +#include +#include +#include +#include +#include +#include +#include + + +template +void test() +{ + const HyperBallBoundary boundary_description; + + Triangulation triangulation; + GridGenerator::hyper_ball (triangulation); + triangulation.set_boundary (0, boundary_description); + triangulation.refine_global (1); + + FE_Q fe(2); + DoFHandler dof_handler(triangulation); + dof_handler.distribute_dofs(fe); + + Vector solution(dof_handler.n_dofs()); + + Functions::FEFieldFunction<2> fe_function (dof_handler, solution); + std::vector > points; + + // add a bunch of points. all + // points are inside the circle. + // the problem happens because we + // walk over a bunch of cells in + // the process of finding all of + // these points and then realize + // when we get to the one at the + // end that the coordinates for + // this point can't be found in the + // cell we have touched last (it's + // too far away from that cell, and + // the inverse mapping does not + // converge + for (unsigned int i=0; i<20; ++i) + for (unsigned int j=0; j<20; ++j) + points.push_back (Point(-0.7+i*0.07,-0.7+j*0.07)); + points.push_back (Point(-0.27999999999999992, -0.62999999999999989)); + + std::vector m (points.size()); + fe_function.value_list (points, m); + + triangulation.set_boundary (0); + + deallog << "OK" << std::endl; +} + + +int main () +{ + std::ofstream logfile("fe_field_function_04/output"); + deallog.attach(logfile); + deallog.depth_console(0); + + test<2>(); + + return 0; +} + diff --git a/tests/bits/fe_field_function_04/cmp/generic b/tests/bits/fe_field_function_04/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/fe_field_function_04/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/fe_field_function_05.cc b/tests/bits/fe_field_function_05.cc new file mode 100644 index 0000000000..d87f45b04a --- /dev/null +++ b/tests/bits/fe_field_function_05.cc @@ -0,0 +1,94 @@ +//------------------------------------------------------- +// $Id: fe_field_function_05.cc $ +// Version: $Name$ +// +// Copyright (C) 2005, 2011, 2012 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. +// +//------------------------------------------------------- + + +// FEFieldFunction ran into an assertion after +// Mapping::transform_real_to_unit_cell started throwing exceptions +// when it couldn't find the point on the reference cell that belongs +// to a given point, rather than just silently giving up +// +// this is a variant of _04 found by inspecting the code in +// FEFieldFunction but the (same) exception is triggered in a +// different place + +#include "../tests.h" + +#include +#include +#include +#include +#include +#include +#include + + +template +void test() +{ + const HyperBallBoundary boundary_description; + + Triangulation triangulation; + GridGenerator::hyper_ball (triangulation); + triangulation.set_boundary (0, boundary_description); + triangulation.refine_global (1); + + FE_Q fe(2); + DoFHandler dof_handler(triangulation); + dof_handler.distribute_dofs(fe); + + Vector solution(dof_handler.n_dofs()); + + Functions::FEFieldFunction<2> fe_function (dof_handler, solution); + std::vector > points; + + // add only one points but also set + // the active cell to one that + // doesn't contain the current + // point. the problem happens + // because we walk over a bunch of + // cells in the process of finding + // all of these points and then + // realize when we get to the one + // at the end that the coordinates + // for this point can't be found in + // the cell we have touched last + // (it's too far away from that + // cell, and the inverse mapping + // does not converge + points.push_back (Point(-0.27999999999999992, -0.62999999999999989)); + fe_function.set_active_cell (typename DoFHandler::active_cell_iterator + (&triangulation, + 1, + 4, + &dof_handler)); + + std::vector m (points.size()); + fe_function.value_list (points, m); + + triangulation.set_boundary (0); + + deallog << "OK" << std::endl; +} + + +int main () +{ + std::ofstream logfile("fe_field_function_05/output"); + deallog.attach(logfile); + deallog.depth_console(0); + + test<2>(); + + return 0; +} + diff --git a/tests/bits/fe_field_function_05/cmp/generic b/tests/bits/fe_field_function_05/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/fe_field_function_05/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK -- 2.39.5