From f0e7b3c651593835a2684f1c2aa7cb058bae609f Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Thu, 10 Aug 2017 16:18:50 -0600 Subject: [PATCH] Add check that mesh_loop and workstream are the SAME. --- tests/meshworker/mesh_loop_03.cc | 95 ++++++++++++++++++++++++++++ tests/meshworker/mesh_loop_03.output | 33 ++++++++++ 2 files changed, 128 insertions(+) create mode 100644 tests/meshworker/mesh_loop_03.cc create mode 100644 tests/meshworker/mesh_loop_03.output diff --git a/tests/meshworker/mesh_loop_03.cc b/tests/meshworker/mesh_loop_03.cc new file mode 100644 index 0000000000..5b388de4ef --- /dev/null +++ b/tests/meshworker/mesh_loop_03.cc @@ -0,0 +1,95 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2007 - 2016 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 assemble_flags.h + +#include "../tests.h" +#include +#include +#include +#include +#include +#include + +#include + +struct ScratchData {}; +struct CopyData {}; + +using namespace MeshWorker; + +template +void test() { + Triangulation tria; + GridGenerator::hyper_cube(tria); + tria.refine_global(1); + tria.begin_active()->set_refine_flag(); + tria.execute_coarsening_and_refinement(); + + ScratchData scratch; + CopyData copy; + + auto cell=tria.begin_active(); + auto endc=tria.end(); + + typedef decltype(cell) Iterator; + + + + auto cell_worker = [] (const Iterator &cell, ScratchData &s, CopyData &c) { + deallog << "Cell worker on : " << cell << std::endl; + }; + + auto boundary_worker = [] (const Iterator &cell, const unsigned int &f, ScratchData &, CopyData &) { + deallog << "Boundary worker on : " << cell << ", Face : "<< f << std::endl; + }; + + auto face_worker = [] + (const Iterator &cell, const unsigned int & f, const unsigned int &sf, + const Iterator &ncell, const unsigned int &nf, const unsigned int & nsf, + ScratchData &s, CopyData &c) { + deallog << "Face worker on : " << cell << ", Neighbor cell : " << ncell + << ", Face : "<< f << ", Neighbor Face : " << nf + << ", Subface: " << sf + << ", Neighbor Subface: " << nsf << std::endl; + }; + + auto copyer = [](const CopyData &) { + deallog << "Copyer" << std::endl; + }; + + deallog << "CELLS ONLY" << std::endl << std::endl; + + mesh_loop(cell, endc, cell_worker, copyer, scratch, copy, + assemble_own_cells, + boundary_worker, face_worker); + + + deallog << "CELLS ONLY WORKSTREAM" << std::endl << std::endl; + + WorkStream::run(cell, endc, cell_worker, copyer, scratch, copy); + + +} + + +int main() +{ + initlog(); + + test<2,2>(); +} diff --git a/tests/meshworker/mesh_loop_03.output b/tests/meshworker/mesh_loop_03.output new file mode 100644 index 0000000000..7060a52ee6 --- /dev/null +++ b/tests/meshworker/mesh_loop_03.output @@ -0,0 +1,33 @@ + +DEAL::CELLS ONLY +DEAL:: +DEAL::Cell worker on : 1.1 +DEAL::Cell worker on : 1.2 +DEAL::Cell worker on : 1.3 +DEAL::Cell worker on : 2.0 +DEAL::Cell worker on : 2.1 +DEAL::Cell worker on : 2.2 +DEAL::Cell worker on : 2.3 +DEAL::Copyer +DEAL::Copyer +DEAL::Copyer +DEAL::Copyer +DEAL::Copyer +DEAL::Copyer +DEAL::Copyer +DEAL::CELLS ONLY WORKSTREAM +DEAL:: +DEAL::Cell worker on : 1.1 +DEAL::Cell worker on : 1.2 +DEAL::Cell worker on : 1.3 +DEAL::Cell worker on : 2.0 +DEAL::Cell worker on : 2.1 +DEAL::Cell worker on : 2.2 +DEAL::Cell worker on : 2.3 +DEAL::Copyer +DEAL::Copyer +DEAL::Copyer +DEAL::Copyer +DEAL::Copyer +DEAL::Copyer +DEAL::Copyer -- 2.39.5