From 1addbf9b29a439837a563f6a546877bb3a2908cd Mon Sep 17 00:00:00 2001 From: Daniel Garcia-Sanchez Date: Fri, 1 Nov 2019 14:59:41 +0100 Subject: [PATCH] Write complex periodicity_factor test --- tests/bits/periodicity_09.cc | 94 ++++++++++++++++++++++++++++++++ tests/bits/periodicity_09.output | 25 +++++++++ 2 files changed, 119 insertions(+) create mode 100644 tests/bits/periodicity_09.cc create mode 100644 tests/bits/periodicity_09.output diff --git a/tests/bits/periodicity_09.cc b/tests/bits/periodicity_09.cc new file mode 100644 index 0000000000..82baa4c9b1 --- /dev/null +++ b/tests/bits/periodicity_09.cc @@ -0,0 +1,94 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2002 - 2018 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.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + + +// check periodic boundary conditions with a complex periodicity_factor for a +// simple enough case where we know the exact set of constraints +// +// this test simply uses two hypercubes, refines one of them and matches the +// faces at the far ends +// +// This test is based on bits/periodicity_02 + +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include "../tests.h" + + + +template +void +test() +{ + deallog << dim << "D" << std::endl; + + // create a 2x1 (or 2x1x1) mesh and refine the leftmost cell + Triangulation triangulation; + std::vector repetitions(dim, 1); + repetitions[0] = 2; + GridGenerator::subdivided_hyper_rectangle(triangulation, + repetitions, + Point(), + (dim == 2 ? Point(2, 1) : + Point(2, 1, 1))); + triangulation.begin_active()->set_refine_flag(); + triangulation.execute_coarsening_and_refinement(); + + FE_Q fe(1); + DoFHandler dof_handler(triangulation); + dof_handler.distribute_dofs(fe); + + + AffineConstraints> cm; + const std::complex periodicity_factor = + std::exp(-std::complex(0, 1) * 0.4); + + deallog << dim << " 1/periodicity_factor: " << 1. / periodicity_factor + << std::endl; + + DoFTools::make_periodicity_constraints(dof_handler.begin(0)->face(0), + (++dof_handler.begin(0))->face(1), + cm, + ComponentMask(), + true, + false, + false, + FullMatrix(), + std::vector(), + periodicity_factor); + cm.print(deallog.get_file_stream()); +} + + + +int +main() +{ + initlog(); + + test<2>(); + test<3>(); + return 0; +} diff --git a/tests/bits/periodicity_09.output b/tests/bits/periodicity_09.output new file mode 100644 index 0000000000..249e451de3 --- /dev/null +++ b/tests/bits/periodicity_09.output @@ -0,0 +1,25 @@ + +DEAL::2D +DEAL::2 1/periodicity_factor: (0.921061,0.389418) + 4 1: (0.921061,0.389418) + 6 1: (0.500000,0.00000) + 6 3: (0.500000,0.00000) + 9 3: (0.921061,0.389418) +DEAL::3D +DEAL::3 1/periodicity_factor: (0.921061,0.389418) + 8 1: (0.921061,0.389418) + 10 1: (0.500000,0.00000) + 10 3: (0.500000,0.00000) + 12 1: (0.500000,0.00000) + 12 5: (0.500000,0.00000) + 14 1: (0.250000,0.00000) + 14 3: (0.250000,0.00000) + 14 5: (0.250000,0.00000) + 14 7: (0.250000,0.00000) + 19 3: (0.921061,0.389418) + 21 3: (0.500000,0.00000) + 21 7: (0.500000,0.00000) + 24 5: (0.921061,0.389418) + 26 5: (0.500000,0.00000) + 26 7: (0.500000,0.00000) + 29 7: (0.921061,0.389418) -- 2.39.5