From: wolf Date: Tue, 25 Feb 2003 00:22:03 +0000 (+0000) Subject: Add some tests. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=489fcb6af7f088a03cea9f277e2da983a24d1a65;p=dealii-svn.git Add some tests. git-svn-id: https://svn.dealii.org/trunk@7238 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/bits/Makefile b/tests/bits/Makefile index 512ff11666..337e77d660 100644 --- a/tests/bits/Makefile +++ b/tests/bits/Makefile @@ -28,6 +28,8 @@ anna_3.exe : anna_3.g.$(OBJEXT) $(libraries) anna_4.exe : anna_4.g.$(OBJEXT) $(libraries) anna_5.exe : anna_5.g.$(OBJEXT) $(libraries) anna_6.exe : anna_6.g.$(OBJEXT) $(libraries) +data_out_01.exe : data_out_01.g.$(OBJEXT) $(libraries) +data_out_faces_01.exe : data_out_faces_01.g.$(OBJEXT) $(libraries) dof_tools_01a.exe : dof_tools_01a.g.$(OBJEXT) $(libraries) dof_tools_01b.exe : dof_tools_01b.g.$(OBJEXT) $(libraries) dof_tools_01c.exe : dof_tools_01c.g.$(OBJEXT) $(libraries) @@ -81,6 +83,7 @@ unit_support_points.exe : unit_support_points.g.$(OBJEXT) $(libraries) parameter_handler_1.exe : parameter_handler_1.g.$(OBJEXT) $(libraries) tests = anna_1 anna_2 anna_3 anna_4 anna_5 anna_6 \ + data_out_01 data_out_faces_01 \ dof_tools_01a dof_tools_01b dof_tools_01c dof_tools_01d \ dof_tools_02a dof_tools_02b dof_tools_02c dof_tools_02d \ dof_tools_03 dof_tools_04 dof_tools_05 dof_tools_06 \ diff --git a/tests/bits/data_out_01.cc b/tests/bits/data_out_01.cc new file mode 100644 index 0000000000..f33ea6fd0f --- /dev/null +++ b/tests/bits/data_out_01.cc @@ -0,0 +1,49 @@ +//---------------------------- data_out_01.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2003 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. +// +//---------------------------- data_out_01.cc --------------------------- + +#include "data_out_common.cc" +#include +#include + + +std::string output_file_name = "data_out_01.output"; + + +template +void +check_this (const DoFHandler &dof_handler, + const Vector &v_node, + const Vector &v_cell) +{ + DataOut data_out; + data_out.attach_dof_handler (dof_handler); + data_out.add_data_vector (v_node, "node_data"); + data_out.add_data_vector (v_cell, "cell_data"); + data_out.build_patches (); + + data_out.write_dx (deallog.get_file_stream()); + data_out.write_ucd (deallog.get_file_stream()); + data_out.write_gmv (deallog.get_file_stream()); + data_out.write_tecplot (deallog.get_file_stream()); + data_out.write_vtk (deallog.get_file_stream()); + + // the following is only + // implemented for 2d + if (dim == 2) + { + data_out.write_povray (deallog.get_file_stream()); + data_out.write_eps (deallog.get_file_stream()); + } +} + + diff --git a/tests/bits/data_out_common.cc b/tests/bits/data_out_common.cc new file mode 100644 index 0000000000..35b2cce4d1 --- /dev/null +++ b/tests/bits/data_out_common.cc @@ -0,0 +1,144 @@ +//---------------------------- dof_tools_common.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2003 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. +// +//---------------------------- dof_tools_common.cc --------------------------- + + +// common framework for the various dof_tools_*.cc tests + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + + +// forward declaration of the function that must be provided in the +// .cc files +template +void +check_this (const DoFHandler &dof_handler, + const Vector &v_node, + const Vector &v_cell); + +// forward declaration of a variable with the name of the output file +extern std::string output_file_name; + + + + +template +void +check (const FiniteElement &fe, + const std::string &name) +{ + deallog << "Checking " << name + << " in " << dim << "d:" + << std::endl; + + // create tria and dofhandler + // objects. set different boundary + // and sub-domain ids + Triangulation tria; + GridGenerator::hyper_cube(tria, 0., 1.); + tria.refine_global (1); + tria.begin_active()->set_refine_flag(); + tria.execute_coarsening_and_refinement (); + + DoFHandler dof_handler (tria); + dof_handler.distribute_dofs (fe); + + Vector v_node (dof_handler.n_dofs()); + for (unsigned int i=0; i v_cell (dof_handler.get_tria().n_active_cells()); + for (unsigned int i=0; i EL(deg); \ + check(EL, #EL #deg); } + +#define CHECK_ALL(EL,deg)\ + { CHECK(EL,deg,1); \ + CHECK(EL,deg,2); \ + CHECK(EL,deg,3); \ + } + + +int +main() +{ + try + { + std::ofstream logfile(output_file_name.c_str()); + logfile.precision (2); + deallog.attach(logfile); + deallog.depth_console(0); + + CHECK_ALL(Q,1); + CHECK_ALL(Q,2); + CHECK_ALL(Q,3); + + CHECK_ALL(DGQ,0); + CHECK_ALL(DGQ,1); + CHECK_ALL(DGQ,2); + + CHECK(Nedelec, 1, 2); + CHECK(Nedelec, 1, 3); + + return 0; + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} + diff --git a/tests/bits/data_out_faces_01.cc b/tests/bits/data_out_faces_01.cc new file mode 100644 index 0000000000..8f4a2248c1 --- /dev/null +++ b/tests/bits/data_out_faces_01.cc @@ -0,0 +1,59 @@ +//---------------------------- data_out_faces_01.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2003 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. +// +//---------------------------- data_out_faces_01.cc --------------------------- + +#include "data_out_common.cc" +#include +#include + + +std::string output_file_name = "data_out_faces_01.output"; + + + +void +check_this (const DoFHandler<1> &dof_handler, + const Vector &v_node, + const Vector &v_cell) +{ + // nothing to check in 1d +} + + +template +void +check_this (const DoFHandler &dof_handler, + const Vector &v_node, + const Vector &v_cell) +{ + DataOutFaces data_out_faces; + data_out_faces.attach_dof_handler (dof_handler); + data_out_faces.add_data_vector (v_node, "node_data"); + data_out_faces.add_data_vector (v_cell, "cell_data"); + data_out_faces.build_patches (); + + data_out_faces.write_dx (deallog.get_file_stream()); + data_out_faces.write_ucd (deallog.get_file_stream()); + data_out_faces.write_gmv (deallog.get_file_stream()); + data_out_faces.write_tecplot (deallog.get_file_stream()); + data_out_faces.write_vtk (deallog.get_file_stream()); + + // the following is only + // implemented for 2d + if (dim == 2) + { + data_out_faces.write_povray (deallog.get_file_stream()); + data_out_faces.write_eps (deallog.get_file_stream()); + } +} + +