From 6f2cf75e3c31bba430b2662f4117318128e2c73a Mon Sep 17 00:00:00 2001 From: heister Date: Fri, 3 Jan 2014 12:02:03 +0000 Subject: [PATCH] add new test git-svn-id: https://svn.dealii.org/trunk@32146 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/mpi/mesh_worker_03.cc | 205 +++++++++++++++++++++++ tests/mpi/mesh_worker_03.mpirun=2.output | 35 ++++ 2 files changed, 240 insertions(+) create mode 100644 tests/mpi/mesh_worker_03.cc create mode 100644 tests/mpi/mesh_worker_03.mpirun=2.output diff --git a/tests/mpi/mesh_worker_03.cc b/tests/mpi/mesh_worker_03.cc new file mode 100644 index 0000000000..b1a1311f46 --- /dev/null +++ b/tests/mpi/mesh_worker_03.cc @@ -0,0 +1,205 @@ +// --------------------------------------------------------------------- +// $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 + +#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) + { + typename parallel::distributed::Triangulation::active_cell_iterator + it = tr.begin_active(); + it->set_refine_flag(); + ++it;++it;++it; + it->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); + + lctrl.own_faces = MeshWorker::LoopControl::never; + lctrl.faces_to_ghost = MeshWorker::LoopControl::one; + test_loop(dofs, lctrl); + + lctrl.own_faces = MeshWorker::LoopControl::never; + lctrl.faces_to_ghost = MeshWorker::LoopControl::both; + 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_03.mpirun=2.output b/tests/mpi/mesh_worker_03.mpirun=2.output new file mode 100644 index 0000000000..7ece9d388c --- /dev/null +++ b/tests/mpi/mesh_worker_03.mpirun=2.output @@ -0,0 +1,35 @@ + +DEAL:0::DoFHandler ndofs=10 +DEAL:0::* own_cells=0 ghost_cells=0 own_faces=1 faces_to_ghost=0 +DEAL:0::F cell1 = 0_2:00 face = 1 cell2 = 0_2:01 face2 = 0 +DEAL:0::F cell1 = 0_2:00 face = 3 cell2 = 0_2:02 face2 = 2 +DEAL:0::F cell1 = 0_2:01 face = 1 cell2 = 0_1:1 face2 = 0 +DEAL:0::F cell1 = 0_2:01 face = 3 cell2 = 0_2:03 face2 = 2 +DEAL:0::F cell1 = 0_2:02 face = 1 cell2 = 0_2:03 face2 = 0 +DEAL:0::F cell1 = 0_2:03 face = 1 cell2 = 0_1:1 face2 = 0 +DEAL:0::* own_cells=0 ghost_cells=0 own_faces=0 faces_to_ghost=1 +DEAL:0::F cell1 = 0_2:02 face = 3 cell2 = 0_1:2 face2 = 2 +DEAL:0::F cell1 = 0_2:03 face = 3 cell2 = 0_1:2 face2 = 2 +DEAL:0::* own_cells=0 ghost_cells=0 own_faces=0 faces_to_ghost=2 +DEAL:0::F cell1 = 0_2:02 face = 3 cell2 = 0_1:2 face2 = 2 +DEAL:0::F cell1 = 0_2:03 face = 3 cell2 = 0_1:2 face2 = 2 +DEAL:0::F cell1 = 0_2:30 face = 2 cell2 = 0_1:1 face2 = 3 +DEAL:0::F cell1 = 0_2:31 face = 2 cell2 = 0_1:1 face2 = 3 + +DEAL:1::DoFHandler ndofs=10 +DEAL:1::* own_cells=0 ghost_cells=0 own_faces=1 faces_to_ghost=0 +DEAL:1::F cell1 = 0_2:30 face = 0 cell2 = 0_1:2 face2 = 1 +DEAL:1::F cell1 = 0_2:30 face = 1 cell2 = 0_2:31 face2 = 0 +DEAL:1::F cell1 = 0_2:30 face = 3 cell2 = 0_2:32 face2 = 2 +DEAL:1::F cell1 = 0_2:31 face = 3 cell2 = 0_2:33 face2 = 2 +DEAL:1::F cell1 = 0_2:32 face = 0 cell2 = 0_1:2 face2 = 1 +DEAL:1::F cell1 = 0_2:32 face = 1 cell2 = 0_2:33 face2 = 0 +DEAL:1::* own_cells=0 ghost_cells=0 own_faces=0 faces_to_ghost=1 +DEAL:1::F cell1 = 0_2:30 face = 2 cell2 = 0_1:1 face2 = 3 +DEAL:1::F cell1 = 0_2:31 face = 2 cell2 = 0_1:1 face2 = 3 +DEAL:1::* own_cells=0 ghost_cells=0 own_faces=0 faces_to_ghost=2 +DEAL:1::F cell1 = 0_2:02 face = 3 cell2 = 0_1:2 face2 = 2 +DEAL:1::F cell1 = 0_2:03 face = 3 cell2 = 0_1:2 face2 = 2 +DEAL:1::F cell1 = 0_2:30 face = 2 cell2 = 0_1:1 face2 = 3 +DEAL:1::F cell1 = 0_2:31 face = 2 cell2 = 0_1:1 face2 = 3 + -- 2.39.5