From: Daniel Garcia-Sanchez Date: Fri, 2 Aug 2019 16:56:54 +0000 (+0200) Subject: Add tests for std::complex make_periodicity_constraints() X-Git-Tag: v9.2.0-rc1~1300^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1402a2b1cfe5cf8ebc600338221cc39db24f41a2;p=dealii.git Add tests for std::complex make_periodicity_constraints() --- diff --git a/tests/bits/periodicity_08.cc b/tests/bits/periodicity_08.cc new file mode 100644 index 0000000000..0101fed219 --- /dev/null +++ b/tests/bits/periodicity_08.cc @@ -0,0 +1,74 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2019 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 for a simple enough case where we know +// the exact set of constraints +// +// this test simply uses two hypercubes and matches the faces at the far ends +// and the AffineConstraints is std::complex + +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include "../tests.h" + + + +template +void +test() +{ + // create a 2x1 (or 2x1x1) mesh + 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))); + + FE_Q fe(1); + DoFHandler dof_handler(triangulation); + dof_handler.distribute_dofs(fe); + + AffineConstraints> cm; + DoFTools::make_periodicity_constraints(dof_handler.begin(0)->face(0), + (++dof_handler.begin(0))->face(1), + cm); + cm.print(deallog.get_file_stream()); +} + + + +int +main() +{ + initlog(); + + test<2>(); + test<3>(); + return 0; +} diff --git a/tests/bits/periodicity_08.output b/tests/bits/periodicity_08.output new file mode 100644 index 0000000000..f4ef592fa7 --- /dev/null +++ b/tests/bits/periodicity_08.output @@ -0,0 +1,7 @@ + + 4 0: (1.00000,0.00000) + 5 2: (1.00000,0.00000) + 8 0: (1.00000,0.00000) + 9 2: (1.00000,0.00000) + 10 4: (1.00000,0.00000) + 11 6: (1.00000,0.00000) diff --git a/tests/dofs/dof_tools_23.cc b/tests/dofs/dof_tools_23.cc new file mode 100644 index 0000000000..767b62ebc2 --- /dev/null +++ b/tests/dofs/dof_tools_23.cc @@ -0,0 +1,95 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2001 - 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. +// +// --------------------------------------------------------------------- + + +#include +#include + +#include + +#include +#include + +#include +#include + +#include + +#include "../tests.h" +#include "dof_tools_periodic.h" + +// A simple test for +// DoFTools:: +// make_periodicity_constraints (const FaceIterator &, +// const FaceIterator &, +// dealii::AffineConstraints &, +// const std::vector &) +// +// We project an already periodic function onto the FE space of +// periodic functions and store the resulting L2 difference +// between the projected and unprojected function. +// This should reveal any errors in the constraint_matrix. +// AffineConstraints is std::complex. + + + +template +void +check_this(const DoFHandlerType &dof_handler) +{ + Functions::CosineFunction test_func( + dof_handler.get_fe().n_components()); + + AffineConstraints> cm; + + // Apply periodic boundary conditions only in the one direction where + // we can match the (locally refined) faces: + DoFTools::make_periodicity_constraints(dof_handler.begin(0)->face(0), + dof_handler.begin(0)->face(1), + cm); + cm.close(); + + deallog << cm.n_constraints() << std::endl; + deallog << cm.max_constraint_indirections() << std::endl; + + QGauss quadrature(6); + + Vector unconstrained(dof_handler.n_dofs()); + Vector> unconstrained_complex(dof_handler.n_dofs()); + Vector> constrained(dof_handler.n_dofs()); + + // Ensure that we can interpolate: + if (dof_handler.get_fe().get_unit_support_points().size() == 0) + return; + + VectorTools::interpolate(dof_handler, test_func, unconstrained); + + constrained = unconstrained; + cm.distribute(constrained); + + // Cast Vector to Vector> + for (unsigned int index = 0; index < unconstrained.size(); index++) + { + unconstrained_complex[index] = unconstrained[index]; + } + + constrained -= unconstrained_complex; + + const double p_l2_error = constrained.l2_norm(); + + Assert(p_l2_error < 1e-11, ExcInternalError()); + + deallog << "L2_Error : " << p_l2_error << std::endl; +} diff --git a/tests/dofs/dof_tools_23.output b/tests/dofs/dof_tools_23.output new file mode 100644 index 0000000000..7ac94c50bf --- /dev/null +++ b/tests/dofs/dof_tools_23.output @@ -0,0 +1,159 @@ + +DEAL::Checking Q1 in 2d: +DEAL::7 +DEAL::1 +DEAL::L2_Error : 0 +DEAL::Checking Q1 in 3d: +DEAL::41 +DEAL::1 +DEAL::L2_Error : 0 +DEAL::Checking Q2 in 2d: +DEAL::13 +DEAL::1 +DEAL::L2_Error : 0 +DEAL::Checking Q2 in 3d: +DEAL::141 +DEAL::1 +DEAL::L2_Error : 0 +DEAL::Checking Q3 in 2d: +DEAL::19 +DEAL::1 +DEAL::L2_Error : 0 +DEAL::Checking Q3 in 3d: +DEAL::297 +DEAL::1 +DEAL::L2_Error : 0 +DEAL::Checking DGQ0 in 2d: +DEAL::0 +DEAL::0 +DEAL::L2_Error : 0 +DEAL::Checking DGQ0 in 3d: +DEAL::0 +DEAL::0 +DEAL::L2_Error : 0 +DEAL::Checking DGQ1 in 2d: +DEAL::0 +DEAL::0 +DEAL::L2_Error : 0 +DEAL::Checking DGQ1 in 3d: +DEAL::0 +DEAL::0 +DEAL::L2_Error : 0 +DEAL::Checking DGQ3 in 2d: +DEAL::0 +DEAL::0 +DEAL::L2_Error : 0 +DEAL::Checking DGQ3 in 3d: +DEAL::0 +DEAL::0 +DEAL::L2_Error : 0 +DEAL::Checking DGP0 in 2d: +DEAL::0 +DEAL::0 +DEAL::Checking DGP0 in 3d: +DEAL::0 +DEAL::0 +DEAL::Checking DGP1 in 2d: +DEAL::0 +DEAL::0 +DEAL::Checking DGP1 in 3d: +DEAL::0 +DEAL::0 +DEAL::Checking DGP3 in 2d: +DEAL::0 +DEAL::0 +DEAL::Checking DGP3 in 3d: +DEAL::0 +DEAL::0 +DEAL::Checking Nedelec0 in 2d: +DEAL::6 +DEAL::1 +DEAL::Checking Nedelec0 in 3d: +DEAL::72 +DEAL::1 +DEAL::Checking RaviartThomas0 in 2d: +DEAL::6 +DEAL::1 +DEAL::Checking RaviartThomas1 in 2d: +DEAL::12 +DEAL::1 +DEAL::Checking RaviartThomas2 in 2d: +DEAL::18 +DEAL::1 +DEAL::Checking RaviartThomasNodal0 in 2d: +DEAL::6 +DEAL::1 +DEAL::Checking RaviartThomasNodal1 in 2d: +DEAL::12 +DEAL::1 +DEAL::Checking RaviartThomasNodal2 in 2d: +DEAL::18 +DEAL::1 +DEAL::Checking RaviartThomasNodal0 in 3d: +DEAL::28 +DEAL::1 +DEAL::Checking RaviartThomasNodal1 in 3d: +DEAL::112 +DEAL::1 +DEAL::Checking RaviartThomasNodal2 in 3d: +DEAL::252 +DEAL::1 +DEAL::Checking FE_Q<2>(1)3 in 2d: +DEAL::21 +DEAL::1 +DEAL::L2_Error : 0 +DEAL::Checking FE_DGQ<2>(2)2 in 2d: +DEAL::0 +DEAL::0 +DEAL::L2_Error : 0 +DEAL::Checking FE_DGP<2>(3)1 in 2d: +DEAL::0 +DEAL::0 +DEAL::Checking FE_Q<3>(1)3 in 3d: +DEAL::123 +DEAL::1 +DEAL::L2_Error : 0 +DEAL::Checking FE_DGQ<3>(2)2 in 3d: +DEAL::0 +DEAL::0 +DEAL::L2_Error : 0 +DEAL::Checking FE_DGP<3>(3)1 in 3d: +DEAL::0 +DEAL::0 +DEAL::Checking FE_Q<2>(1)3FE_DGQ<2>(2)2 in 2d: +DEAL::21 +DEAL::1 +DEAL::L2_Error : 0 +DEAL::Checking FE_DGQ<2>(2)2FE_DGP<2>(3)1 in 2d: +DEAL::0 +DEAL::0 +DEAL::Checking FE_DGP<2>(3)1FE_DGQ<2>(2)2 in 2d: +DEAL::0 +DEAL::0 +DEAL::Checking FE_Q<2>(1)3FE_DGP<2>(3)1FE_Q<2>(1)3 in 2d: +DEAL::42 +DEAL::1 +DEAL::Checking FE_DGQ<2>(2)2FE_DGQ<2>(2)2FE_Q<2>(3)3 in 2d: +DEAL::57 +DEAL::1 +DEAL::L2_Error : 0 +DEAL::Checking FE_DGP<2>(3)1FE_DGP<2>(3)1FE_Q<2>(2)3 in 2d: +DEAL::39 +DEAL::1 +DEAL::Checking FE_DGQ<3>(1)3FE_DGP<3>(3)1FE_Q<3>(1)3 in 3d: +DEAL::123 +DEAL::1 +DEAL::Checking (FESystem<2>(FE_Q<2>(1),3))3FE_DGQ<2>(0)1FE_Q<2>(1)3 in 2d: +DEAL::84 +DEAL::1 +DEAL::L2_Error : 0 +DEAL::Checking FE_DGQ<2>(3)1FESystem<2>(FE_DGQ<2>(0),3)1FESystem<2>(FE_Q<2>(2),1, FE_DGQ<2>(0),1)2 in 2d: +DEAL::26 +DEAL::1 +DEAL::L2_Error : 0 +DEAL::Checking FE_DGQ<2>(3)1FE_Nedelec<2>(0)2 in 2d: +DEAL::12 +DEAL::1 +DEAL::Checking FE_Nedelec<2>(0)1FESystem<2>(FE_DGQ<2>(1),2)1FESystem<2>(FE_Q<2>(2),1, FE_Nedelec<2>(0),2)2 in 2d: +DEAL::56 +DEAL::1