From: Guido Kanschat Date: Tue, 15 Feb 2011 18:38:43 +0000 (+0000) Subject: test CellsAndFaces X-Git-Tag: v8.0.0~4331 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=40550eb9d051419ee9c5007415b62bb44851b4e4;p=dealii.git test CellsAndFaces git-svn-id: https://svn.dealii.org/trunk@23371 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/integrators/cells_and_faces_01.cc b/tests/integrators/cells_and_faces_01.cc new file mode 100644 index 0000000000..d78d3b4b34 --- /dev/null +++ b/tests/integrators/cells_and_faces_01.cc @@ -0,0 +1,198 @@ +//---------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2000, 2001, 2003, 2004, 2007, 2008, 2009, 2010, 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 whether Assember::CellsAndFaces adds up correctly. + +#include "../tests.h" +#include "empty_info.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace dealii; + + +// Define a class that fills all available entries in the info objects +// with recognizable numbers. + +// Fills the following functionals: +// 0: number of cells +// 1: number of interior faces +// 2: number of boundary faces + +const unsigned int n_functionals = 3; + +template +class Local : public Subscriptor +{ + public: + typedef EmptyInfo CellInfo; + + void cell(MeshWorker::DoFInfo& dinfo, CellInfo& info) const; + void bdry(MeshWorker::DoFInfo& dinfo, CellInfo& info) const; + void face(MeshWorker::DoFInfo& dinfo1, MeshWorker::DoFInfo& dinfo2, + CellInfo& info1, CellInfo& info2) const; +}; + + +template +void +Local::cell(MeshWorker::DoFInfo& info, CellInfo&) const +{ + info.value(0) = 1.; +} + + +template +void +Local::bdry(MeshWorker::DoFInfo& info, CellInfo&) const +{ + info.value(2) = 1.; +} + + +template +void +Local::face(MeshWorker::DoFInfo& info1, MeshWorker::DoFInfo& info2, + CellInfo&, CellInfo&) const +{ + info1.value(1) = 1./2.; + info2.value(1) = 1./2.; +} + + +template +void +test_mesh(MGDoFHandler& mgdofs) +{ + const DoFHandler& dofs = mgdofs; + + BlockVector cells(n_functionals); + BlockVector faces(n_functionals); + for (unsigned int i=0;i* > out_data; + BlockVector* p = &cells; + out_data.add(p, "cells"); + p = &faces; + out_data.add(p, "faces"); + + Local local; + EmptyInfoBox info_box; + MeshWorker::DoFInfo dof_info(dofs); + + MeshWorker::Assembler::CellsAndFaces assembler; + assembler.initialize(out_data, true); + + MeshWorker::loop, EmptyInfoBox> + (dofs.begin_active(), dofs.end(), + dof_info, info_box, + std_cxx1x::bind (&Local::cell, local, _1, _2), + std_cxx1x::bind (&Local::bdry, local, _1, _2), + std_cxx1x::bind (&Local::face, local, _1, _2, _3, _4), + assembler, true); + + deallog << " Results cells"; + for (unsigned int i=0;i mg_dof_info(mgdofs); + MeshWorker::loop, EmptyInfoBox> + (mgdofs.begin(), mgdofs.end(), + mg_dof_info, info_box, + std_cxx1x::bind (&Local::cell, local, _1, _2), + std_cxx1x::bind (&Local::bdry, local, _1, _2), + std_cxx1x::bind (&Local::face, local, _1, _2, _3, _4), + assembler, true); + + deallog << "MGResults cells"; + for (unsigned int i=0;i +void +test(const FiniteElement& fe) +{ + Triangulation tr; + MGDoFHandler dofs(tr); + GridGenerator::hyper_cube(tr); + tr.refine_global(1); + deallog.push("1"); + dofs.distribute_dofs(fe); + test_mesh(dofs); + deallog.pop(); + tr.begin(1)->set_refine_flag(); + tr.execute_coarsening_and_refinement(); + deallog.push("2"); + dofs.distribute_dofs(fe); + test_mesh(dofs); + deallog.pop(); + tr.begin(2)->set_refine_flag(); + tr.execute_coarsening_and_refinement(); + deallog.push("3"); + dofs.distribute_dofs(fe); + test_mesh(dofs); + deallog.pop(); +} + + +int main () +{ + const std::string logname = JobIdentifier::base_name(__FILE__) + std::string("/output"); + std::ofstream logfile(logname.c_str()); + deallog.attach(logfile); + deallog.depth_console (0); + + FE_DGP<2> el2(0); + FE_DGP<3> el3(0); + + deallog.push("2D"); + test(el2); + deallog.pop(); + deallog.push("3D"); + test(el3); + deallog.pop(); +} diff --git a/tests/integrators/cells_and_faces_01/cmp/generic b/tests/integrators/cells_and_faces_01/cmp/generic new file mode 100644 index 0000000000..15ce5acf02 --- /dev/null +++ b/tests/integrators/cells_and_faces_01/cmp/generic @@ -0,0 +1,25 @@ + +DEAL:2D:1:: Results cells 4.00000 0 0 +DEAL:2D:1:: Results faces 0 4.00000 8.00000 +DEAL:2D:1::MGResults cells 5.00000 0 0 +DEAL:2D:1::MGResults faces 0 4.00000 12.0000 +DEAL:2D:2:: Results cells 7.00000 0 0 +DEAL:2D:2:: Results faces 0 14.0000 10.0000 +DEAL:2D:2::MGResults cells 9.00000 0 0 +DEAL:2D:2::MGResults faces 0 16.0000 16.0000 +DEAL:2D:3:: Results cells 10.0000 0 0 +DEAL:2D:3:: Results faces 0 24.0000 12.0000 +DEAL:2D:3::MGResults cells 13.0000 0 0 +DEAL:2D:3::MGResults faces 0 28.0000 20.0000 +DEAL:3D:1:: Results cells 8.00000 0 0 +DEAL:3D:1:: Results faces 0 12.0000 24.0000 +DEAL:3D:1::MGResults cells 9.00000 0 0 +DEAL:3D:1::MGResults faces 0 12.0000 30.0000 +DEAL:3D:2:: Results cells 15.0000 0 0 +DEAL:3D:2:: Results faces 0 45.0000 33.0000 +DEAL:3D:2::MGResults cells 17.0000 0 0 +DEAL:3D:2::MGResults faces 0 48.0000 42.0000 +DEAL:3D:3:: Results cells 22.0000 0 0 +DEAL:3D:3:: Results faces 0 78.0000 42.0000 +DEAL:3D:3::MGResults cells 25.0000 0 0 +DEAL:3D:3::MGResults faces 0 84.0000 54.0000