From 7e089334a25693b4a203bfd1cef898658e391e79 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 28 Mar 2006 22:23:42 +0000 Subject: [PATCH] New test git-svn-id: https://svn.dealii.org/trunk@12728 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/deal.II/Makefile | 3 +- tests/deal.II/grid_in_3d.cc | 42 +++- .../deal.II/interpolate_boundary_values_01.cc | 219 ++++++++++++++++++ 3 files changed, 252 insertions(+), 12 deletions(-) create mode 100644 tests/deal.II/interpolate_boundary_values_01.cc diff --git a/tests/deal.II/Makefile b/tests/deal.II/Makefile index 9d66a1567a..43adf696a1 100644 --- a/tests/deal.II/Makefile +++ b/tests/deal.II/Makefile @@ -50,7 +50,8 @@ tests_x = block_matrices \ grid_in_3d \ face_orientations_3d \ mg_dof_handler \ - subcelldata + subcelldata \ + interpolate_boundary_values_* # from above list of regular expressions, generate the real set of # tests diff --git a/tests/deal.II/grid_in_3d.cc b/tests/deal.II/grid_in_3d.cc index e7e1660be7..6bc601a4a3 100644 --- a/tests/deal.II/grid_in_3d.cc +++ b/tests/deal.II/grid_in_3d.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2002, 2003, 2004, 2005 by the deal.II authors +// Copyright (C) 2002, 2003, 2004, 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -26,6 +26,11 @@ #include #include #include +#include +#include +#include +#include +#include #include #include @@ -47,7 +52,7 @@ void test (const char *filename) try { - gi.read_xda (in); + gi.read_ucd (in); } catch (std::exception &exc) { @@ -66,6 +71,21 @@ void test (const char *filename) for (unsigned int i=0; i::vertices_per_cell; ++i) hash += (index * i * c->vertex_index(i)) % (tria.n_active_cells()+1); deallog << " hash=" << hash << std::endl; + + FE_Q fe(1); + DoFHandler dh (tria); + dh.distribute_dofs(fe); + + Vector tmp (dh.n_dofs()); + for (unsigned int i=0; i dout; + dout.attach_dof_handler (dh); + dout.add_data_vector (tmp, "tmp"); + dout.build_patches(); + std::ofstream file("input_left.gmv"); + dout.write_gmv (file); } void test1() @@ -90,16 +110,16 @@ int main () deallog.depth_console(0); deallog.threshold_double(1.e-10); - test ("grid_in_3d_1.in"); - test ("grid_in_3d_2.in"); - test ("grid_in_3d_3.in"); - test ("grid_in_3d_4.in"); + test ("grid_in_3d_5.in"); +// test ("grid_in_3d_2.in"); +// test ("grid_in_3d_3.in"); +// test ("grid_in_3d_4.in"); - test ("grid_in_3d_evil_0.in"); - test ("grid_in_3d_evil_1.in"); - test ("grid_in_3d_evil_2.in"); - test ("grid_in_3d_evil_3.in"); - test ("grid_in_3d_evil_4.in"); +// test ("grid_in_3d_evil_0.in"); +// test ("grid_in_3d_evil_1.in"); +// test ("grid_in_3d_evil_2.in"); +// test ("grid_in_3d_evil_3.in"); +// test ("grid_in_3d_evil_4.in"); // test1 needs NetCDF // test1 (); diff --git a/tests/deal.II/interpolate_boundary_values_01.cc b/tests/deal.II/interpolate_boundary_values_01.cc new file mode 100644 index 0000000000..e4df21ecf0 --- /dev/null +++ b/tests/deal.II/interpolate_boundary_values_01.cc @@ -0,0 +1,219 @@ +//---------------------------- interpolate_boundary_values_01.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2006 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. +// +//---------------------------- interpolate_boundary_values_01.cc --------------------------- + + +// somewhat like anna_4, except that we try to get boundary values for +// the continuous component a RT x Q1 element. this presently gives an +// exception, but shouldn't + +#include "../tests.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + // We need a FESystem +#include + + // we need DG-elements + // and Q1-elements +#include +#include + +#include +#include +#include + + +template +class VectorBoundaryValues : public Function +{ + public: + VectorBoundaryValues (); + virtual void vector_value (const Point &p, + Vector &values) const; +}; + +template +VectorBoundaryValues::VectorBoundaryValues () : + Function (dim+1) +{} + +template +inline +void VectorBoundaryValues::vector_value (const Point &p, + Vector &values) const +{ + Assert (values.size() == dim+1, + ExcDimensionMismatch (values.size(), dim+1)); + + for (unsigned int i=0; i +class FindBug +{ + public: + FindBug (); + void run (); + private: + void make_grid_and_dofs (); + void dirichlet_conditions (); + + Triangulation triangulation; + FESystem fe; + DoFHandler dof_handler; + Vector solution; +}; + + + // Construct FESystem with + // first component: Q1-Element, + // second component: lowest order DG_Element +template +FindBug::FindBug () : + fe (FE_RaviartThomas(0), 1, + FE_Q(1), 1), + dof_handler (triangulation) +{} + + +template +void FindBug::make_grid_and_dofs () +{ + + GridGenerator::hyper_cube (triangulation); + triangulation.refine_global (1); + + deallog << "Number of active cells: " + << triangulation.n_active_cells() + << std::endl; + + deallog << "Total number of cells: " + << triangulation.n_cells() + << std::endl; + + + dof_handler.distribute_dofs (fe); + + + deallog << "Number of degrees of freedom: " + << dof_handler.n_dofs() + << std::endl; + + solution.reinit(dof_handler.n_dofs()); +} + + +template +void FindBug::dirichlet_conditions () +{ + std::map dirichlet_dofs; + std::vector component_mask(dim+1, false); + component_mask[dim] = true; + + // This is just for the final + // output-test + for (unsigned int i=0; i (), + dirichlet_dofs, + component_mask); + + + std::vector fixed_dofs (dof_handler.n_dofs()); + std::set boundary_indicators; + boundary_indicators.insert (0); + + // get a list of those boundary DoFs which + // we want to be fixed: + DoFTools::extract_boundary_dofs (dof_handler, + component_mask, + fixed_dofs, + boundary_indicators); + + // (Primitive) Check if the DoFs + // where adjusted correctly (note + // that we have preset all values + // to 1, and interpolate_b_v should + // have overwritten those for + // component 0 by 0) + for (unsigned int i=0; i (), + dirichlet_dofs, + component_mask); + for (unsigned int i=0; i +void FindBug::run () +{ + make_grid_and_dofs (); + dirichlet_conditions (); +} + + + +int main () +{ + std::ofstream logfile("interpolate_boundary_values_01/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + FindBug<2>().run (); + FindBug<3>().run (); + + return 0; +} + -- 2.39.5