From: bangerth Date: Tue, 16 Nov 2010 19:55:27 +0000 (+0000) Subject: Split _01 test into two pieces: one that works for a sphere surface and one that... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b91fcbdf58033e4006e61641b3def7dead0bc50;p=dealii-svn.git Split _01 test into two pieces: one that works for a sphere surface and one that doesn't. git-svn-id: https://svn.dealii.org/trunk@22768 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/codim_one/extract_boundary_mesh_01.cc b/tests/codim_one/extract_boundary_mesh_01.cc index 87a1b69ec0..e7183458ce 100644 --- a/tests/codim_one/extract_boundary_mesh_01.cc +++ b/tests/codim_one/extract_boundary_mesh_01.cc @@ -17,8 +17,10 @@ We test that the order of cells and the orientation of the vertices is consistent between the two meshes. - It's faling when boundary object is attached and refinement - for a ball in 3D + Compared to the _00 test, we here test things with the surface of a + 3d sphere. There is no surface object attached, so the surface is + topologically a sphere but not geometrically. The _02 test checks the + same with a boundary object attached. */ #include "../tests.h" @@ -78,7 +80,7 @@ template void save_mesh(const Triangulation& tria) { GridOut grid_out; - grid_out.write_ucd (tria, deallog.get_file_stream()); + grid_out.write_gnuplot (tria, deallog.get_file_stream()); } @@ -98,26 +100,18 @@ int main () map< Triangulation::cell_iterator, Triangulation::face_iterator> surface_to_volume_mapping; - const HyperBallBoundary boundary_description; Triangulation volume_mesh; GridGenerator::hyper_ball(volume_mesh); - volume_mesh.set_boundary (0, boundary_description); volume_mesh.refine_global (1); - // save_mesh(volume_mesh); - Triangulation boundary_mesh; GridTools::extract_boundary_mesh (volume_mesh, boundary_mesh, surface_to_volume_mapping); - if (test_vertices_orientation(boundary_mesh, surface_to_volume_mapping,2)) - deallog << "Passed."; - else - deallog << "Failed."; - deallog << endl; - + Assert (test_vertices_orientation(boundary_mesh, surface_to_volume_mapping,2), + ExcInternalError()); save_mesh(boundary_mesh); } diff --git a/tests/codim_one/extract_boundary_mesh_02.cc b/tests/codim_one/extract_boundary_mesh_02.cc new file mode 100644 index 0000000000..adb298b3eb --- /dev/null +++ b/tests/codim_one/extract_boundary_mesh_02.cc @@ -0,0 +1,122 @@ +//---------------------------- extract_boundary_mesh_01.cc --------------------------- +// $Id: bem.cc 22693 2010-11-11 20:11:47Z kanschat $ +// Version: $Name$ +// +// Copyright (C) 2010 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. +// +//---------------------------- extract_boundary_mesh_01.cc --------------------------- + +/* + Code for testing the function + GridTools::extract_boundary_mesh (...). + We test that the order of cells and the orientation + of the vertices is consistent between the two meshes. + + It's faling when boundary object is attached and refinement + for a ball in 3D +*/ + +#include "../tests.h" + +#include +#include +#include +#include +#include + +using namespace std; + + +template +bool test_vertices_orientation(const Triangulation &boundary_mesh, + map< typename Triangulation::cell_iterator, + typename Triangulation::face_iterator > + &surface_to_volume_mapping, + const int verbosity = 1) +{ + typename Triangulation::active_cell_iterator + cell = boundary_mesh.begin_active(), + endc = boundary_mesh.end(); + typename Triangulation::face_iterator face; + + bool success = true; + + if (verbosity>1){ + deallog << "The last column should be 0" <::vertices_per_cell; ++k) + { + Point diff(face->vertex(k)); + diff -= cell->vertex(k); + if (verbosity>1){ + deallog << face->vertex(k) << "\t\t"; + deallog << cell->vertex(k) << "\t\t\t" << diff.square() << endl; + } + if (diff.square()>0){ + success = false; + break; + } + } + if (verbosity>1) deallog << endl; + } + return success; +} + +template +void save_mesh(const Triangulation& tria) +{ + GridOut grid_out; + grid_out.write_ucd (tria, deallog.get_file_stream()); +} + + +int main () +{ + + ofstream logfile("extract_boundary_mesh_01/output"); + deallog.attach(logfile); + deallog.depth_console(0); + + + { // Extract the boundary of a hyper-sphere + + const int dim = 3; + deallog << "Testing hyper_cube in dim: " << dim << "..."<< endl; + + map< Triangulation::cell_iterator, + Triangulation::face_iterator> + surface_to_volume_mapping; + const HyperBallBoundary boundary_description; + Triangulation volume_mesh; + GridGenerator::hyper_ball(volume_mesh); + volume_mesh.set_boundary (0, boundary_description); + + volume_mesh.refine_global (1); + + // save_mesh(volume_mesh); + + Triangulation boundary_mesh; + + GridTools::extract_boundary_mesh (volume_mesh, boundary_mesh, + surface_to_volume_mapping); + + Assert (test_vertices_orientation(boundary_mesh, surface_to_volume_mapping,2), + ExcInternalError()); + save_mesh(boundary_mesh); + } + + + return 0; + }