From: heister Date: Fri, 3 Jan 2014 13:48:18 +0000 (+0000) Subject: add test to check meshworker boundary terms X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46e53b01b7644d20de5f3c0430cd41832129c42f;p=dealii-svn.git add test to check meshworker boundary terms git-svn-id: https://svn.dealii.org/trunk@32153 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/mpi/mesh_worker_04.cc b/tests/mpi/mesh_worker_04.cc new file mode 100644 index 0000000000..e19250e939 --- /dev/null +++ b/tests/mpi/mesh_worker_04.cc @@ -0,0 +1,190 @@ +// --------------------------------------------------------------------- +// $Id: mesh_worker_matrix_01.cc 31349 2013-10-20 19:07:06Z maier $ +// +// Copyright (C) 2000 - 2013 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + +// test meshworker LoopControl +// make sure boundary faces are only assembled for own cells + +#include "../tests.h" +#include +#include + +#include +#include +#include +#include + +#include +#include + +using namespace dealii; + + +template +class myIntegrator: public dealii::MeshWorker::LocalIntegrator +{ +public: + typedef MeshWorker::IntegrationInfo CellInfo; + + void cell(MeshWorker::DoFInfo &dinfo, CellInfo &info) const; + void boundary(MeshWorker::DoFInfo &dinfo, CellInfo &info) const; + void face(MeshWorker::DoFInfo &dinfo1, MeshWorker::DoFInfo &dinfo2, + CellInfo &info1, CellInfo &info2) const; + + +}; + +template +void +myIntegrator::cell(MeshWorker::DoFInfo &info, CellInfo &) const +{ + //deallog << "C " << info.cell->id() << std::endl; +} + + +template +void +myIntegrator::boundary(MeshWorker::DoFInfo &info, CellInfo &) const +{ + deallog << "B cell = " << info.cell->id() << " face = " << info.face_number << std::endl; +} + + +template +void +myIntegrator::face(MeshWorker::DoFInfo &info1, MeshWorker::DoFInfo &info2, + CellInfo &, CellInfo &) const +{ +// deallog << "F cell1 = " << info1.cell->id() +// << " face = " << info1.face_number +// << " cell2 = " << info2.cell->id() +// << " face2 = " << info2.face_number +// << std::endl; +} + + +class DoNothingAssembler +{ + public: + template + void initialize_info(DOFINFO &info, bool face) const {} + template + void assemble(const DOFINFO &info){} + template + void assemble(const DOFINFO &info1, + const DOFINFO &info2) {} + +}; + +template +void +test_simple(DoFHandler &dofs, MeshWorker::LoopControl &lctrl) +{ + myIntegrator local; + DoNothingAssembler assembler; + MeshWorker::IntegrationInfoBox info_box; + + MeshWorker::DoFInfo dof_info(dofs.block_info()); + +// integration_loop(ITERATOR begin, +// typename identity::type end, +// DOFINFO &dinfo, +// INFOBOX &info, +// const std_cxx1x::function &cell_worker, +// const std_cxx1x::function &boundary_worker, +// const std_cxx1x::function &face_worker, +// ASSEMBLER &assembler, +// const LoopControl &lctrl) +// + + + MeshWorker::integration_loop::active_cell_iterator, DoNothingAssembler> + (dofs.begin_active(), dofs.end(), + dof_info, info_box, + local, + assembler, + lctrl); + +// MeshWorker::loop, MeshWorker::IntegrationInfoBox > +// (dofs.begin_active(), dofs.end(), +// dof_info, info_box, +// std_cxx1x::bind (&Integrator::cell, local, std_cxx1x::_1, std_cxx1x::_2), +// std_cxx1x::bind (&Integrator::bdry, local, std_cxx1x::_1, std_cxx1x::_2), +// std_cxx1x::bind (&Integrator::face, local, std_cxx1x::_1, std_cxx1x::_2, std_cxx1x::_3, std_cxx1x::_4), +// local, +// lctrl); +} + +std::string id_to_string(const CellId &id) +{ + std::ostringstream ss; + ss << id; + return ss.str(); +} + +template +void test_loop(DoFHandler &dofs, MeshWorker::LoopControl &lctrl) +{ + deallog << "* own_cells=" << lctrl.own_cells + << " ghost_cells=" << lctrl.ghost_cells + << " own_faces=" << lctrl.own_faces + << " faces_to_ghost=" << lctrl.faces_to_ghost + << std::endl; + test_simple(dofs, lctrl); +} + +template +void +test() +{ + parallel::distributed::Triangulation tr(MPI_COMM_WORLD, + Triangulation::none/*, + parallel::distributed::Triangulation::construct_multigrid_hierarchy*/); + GridGenerator::hyper_cube(tr); + tr.refine_global(1); + unsigned int myid=Utilities::MPI::this_mpi_process(MPI_COMM_WORLD); + if (myid==0) + tr.begin_active()->set_refine_flag(); + tr.execute_coarsening_and_refinement(); + + FE_DGP fe(0); + + DoFHandler dofs(tr); + dofs.distribute_dofs(fe); + + dofs.initialize_local_block_info(); + deallog << "DoFHandler ndofs=" << dofs.n_dofs() << std::endl; + + MeshWorker::LoopControl lctrl; + + lctrl.own_cells = false; + lctrl.ghost_cells = false; + + lctrl.own_faces = MeshWorker::LoopControl::one; + lctrl.faces_to_ghost = MeshWorker::LoopControl::never; + test_loop(dofs, lctrl); +} + + +int main (int argc, char **argv) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv); + MPILogInitAll log; + + test<2>(); +} diff --git a/tests/mpi/mesh_worker_04.mpirun=2.output b/tests/mpi/mesh_worker_04.mpirun=2.output new file mode 100644 index 0000000000..fcad5a031a --- /dev/null +++ b/tests/mpi/mesh_worker_04.mpirun=2.output @@ -0,0 +1,17 @@ + +DEAL:0::DoFHandler ndofs=7 +DEAL:0::* own_cells=0 ghost_cells=0 own_faces=1 faces_to_ghost=0 +DEAL:0::B cell = 0_2:00 face = 0 +DEAL:0::B cell = 0_2:00 face = 2 +DEAL:0::B cell = 0_2:01 face = 2 +DEAL:0::B cell = 0_2:02 face = 0 + +DEAL:1::DoFHandler ndofs=7 +DEAL:1::* own_cells=0 ghost_cells=0 own_faces=1 faces_to_ghost=0 +DEAL:1::B cell = 0_1:1 face = 1 +DEAL:1::B cell = 0_1:1 face = 2 +DEAL:1::B cell = 0_1:2 face = 0 +DEAL:1::B cell = 0_1:2 face = 3 +DEAL:1::B cell = 0_1:3 face = 1 +DEAL:1::B cell = 0_1:3 face = 3 +