From: Wolfgang Bangerth Date: Mon, 4 Dec 2017 18:00:01 +0000 (-0700) Subject: Add a test. X-Git-Tag: v9.0.0-rc1~692^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14d64bdc5616e17ad052b08b353c31a6111cee4d;p=dealii.git Add a test. --- diff --git a/tests/vector_tools/boundaries_complex.cc b/tests/vector_tools/boundaries_complex.cc new file mode 100644 index 0000000000..86fd083267 --- /dev/null +++ b/tests/vector_tools/boundaries_complex.cc @@ -0,0 +1,183 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2000 - 2015 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. +// +// --------------------------------------------------------------------- + + + +/* Author: Wolfgang Bangerth, University of Heidelberg, 2001 */ +/* Purpose: check interpolation and projection of boundary values. + Like the boundaries.cc test, but for complex-valued objects + */ + + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +template +class MySquareFunction : public Function> +{ +public: + MySquareFunction () : Function>(2) {} + + virtual std::complex value (const Point &p, + const unsigned int component) const + { + return std::complex(100*(component+1)*p.square()*std::sin(p.square()), 0); + } + + virtual void vector_value (const Point &p, + Vector> &values) const + { + for (unsigned int d=0; dn_components; ++d) + values(d) = value(p,d); + } +}; + + +template +const Quadrature & +boundary_q (const DoFHandler &) +{ + static const QGauss q(4); + return q; +} + + +void write_map (const std::map> &bv) +{ + for (std::map>::const_iterator + i=bv.begin(); i!=bv.end(); ++i) + deallog << i->first << ' ' << i->second < +void +check () +{ + Triangulation tr; + if (dim==2) + { + GridGenerator::hyper_ball(tr, Point(), 1); + } + else + GridGenerator::hyper_cube(tr, -1./std::sqrt(static_cast(dim)),1./std::sqrt(static_cast(dim))); + static const HyperBallBoundary boundary; + if (dim != 1) + { + tr.set_boundary (0, boundary); + } + tr.refine_global (1); + tr.begin_active()->set_refine_flag (); + tr.execute_coarsening_and_refinement (); + if (dim==1) + tr.refine_global(2); + + // use a cubic mapping to make + // things a little more complicated + MappingQ mapping(3); + + + // list of finite elements for + // which we want check, and + // associated list of boundary + // value functions + std::vector*> fe_list; + std::vector>*> function_list; + + // FE1: a system of a quadratic and + // a linear element + fe_list.push_back (new FESystem (FE_Q(2), 1, FE_Q(1), 1)); + function_list.push_back (new MySquareFunction()); + + // FE2: a linear element, to make + // things simple + fe_list.push_back (new FE_Q (1)); + function_list.push_back (new Functions::ConstantFunction>(std::complex(1,0))); + + // check all of them + for (unsigned int i=0; i &fe = *fe_list[i]; + + DoFHandler dof(tr); + dof.distribute_dofs(fe); + + typename FunctionMap>::type function_map; + function_map[0] = function_list[i]; + + // interpolate boundary values + deallog << "Interpolated boundary values" << std::endl; + std::map> interpolated_bv; + VectorTools::interpolate_boundary_values (mapping, dof, function_map, + interpolated_bv, std::vector()); + write_map (interpolated_bv); + + // // project boundary values + // // presently this is not + // // implemented for 3d + // if (dim != 3) + // { + // deallog << "Projected boundary values" << std::endl; + // std::map projected_bv; + // VectorTools::project_boundary_values (mapping, dof, function_map, + // boundary_q(dof), projected_bv); + // write_map (projected_bv); + // }; + }; + + + // delete objects now no more needed + for (unsigned int i=0; i (); + deallog.pop (); + deallog.push ("2d"); + check<2> (); + deallog.pop (); + deallog.push ("3d"); + check<3> (); + deallog.pop (); +} diff --git a/tests/vector_tools/boundaries_complex.output b/tests/vector_tools/boundaries_complex.output new file mode 100644 index 0000000000..73086f2c76 --- /dev/null +++ b/tests/vector_tools/boundaries_complex.output @@ -0,0 +1,268 @@ + +DEAL:1d::Interpolated boundary values +DEAL:1d::14 (84.15,0.00) +DEAL:1d::15 (168.29,0.00) +DEAL:1d::Interpolated boundary values +DEAL:1d::5 (1.00,0.00) +DEAL:2d::Interpolated boundary values +DEAL:2d::0 (84.15,0.00) +DEAL:2d::1 (168.29,0.00) +DEAL:2d::2 (84.15,0.00) +DEAL:2d::3 (168.29,0.00) +DEAL:2d::10 (84.09,0.00) +DEAL:2d::29 (84.15,0.00) +DEAL:2d::30 (168.29,0.00) +DEAL:2d::31 (84.15,0.00) +DEAL:2d::32 (168.29,0.00) +DEAL:2d::35 (84.09,0.00) +DEAL:2d::45 (84.15,0.00) +DEAL:2d::46 (168.29,0.00) +DEAL:2d::49 (84.09,0.00) +DEAL:2d::78 (84.15,0.00) +DEAL:2d::79 (168.29,0.00) +DEAL:2d::83 (84.09,0.00) +DEAL:2d::86 (84.15,0.00) +DEAL:2d::87 (168.29,0.00) +DEAL:2d::91 (84.09,0.00) +DEAL:2d::98 (84.15,0.00) +DEAL:2d::99 (168.29,0.00) +DEAL:2d::102 (84.09,0.00) +DEAL:2d::108 (84.09,0.00) +DEAL:2d::112 (84.15,0.00) +DEAL:2d::113 (168.29,0.00) +DEAL:2d::120 (84.14,0.00) +DEAL:2d::126 (84.14,0.00) +DEAL:2d::Interpolated boundary values +DEAL:2d::0 (1.00,0.00) +DEAL:2d::1 (1.00,0.00) +DEAL:2d::8 (1.00,0.00) +DEAL:2d::9 (1.00,0.00) +DEAL:2d::12 (1.00,0.00) +DEAL:2d::19 (1.00,0.00) +DEAL:2d::21 (1.00,0.00) +DEAL:2d::23 (1.00,0.00) +DEAL:2d::25 (1.00,0.00) +DEAL:3d::Interpolated boundary values +DEAL:3d::0 (84.15,0.00) +DEAL:3d::1 (168.29,0.00) +DEAL:3d::2 (84.15,0.00) +DEAL:3d::3 (168.29,0.00) +DEAL:3d::4 (84.15,0.00) +DEAL:3d::5 (168.29,0.00) +DEAL:3d::6 (84.15,0.00) +DEAL:3d::7 (168.29,0.00) +DEAL:3d::8 (84.15,0.00) +DEAL:3d::9 (168.29,0.00) +DEAL:3d::10 (84.15,0.00) +DEAL:3d::11 (168.29,0.00) +DEAL:3d::14 (84.15,0.00) +DEAL:3d::15 (168.29,0.00) +DEAL:3d::16 (84.09,0.00) +DEAL:3d::17 (84.13,0.00) +DEAL:3d::18 (84.13,0.00) +DEAL:3d::19 (84.09,0.00) +DEAL:3d::21 (84.09,0.00) +DEAL:3d::22 (84.09,0.00) +DEAL:3d::24 (84.09,0.00) +DEAL:3d::25 (84.13,0.00) +DEAL:3d::27 (84.09,0.00) +DEAL:3d::29 (84.03,0.00) +DEAL:3d::30 (84.03,0.00) +DEAL:3d::32 (84.03,0.00) +DEAL:3d::35 (84.15,0.00) +DEAL:3d::36 (168.29,0.00) +DEAL:3d::37 (84.15,0.00) +DEAL:3d::38 (168.29,0.00) +DEAL:3d::39 (84.15,0.00) +DEAL:3d::40 (168.29,0.00) +DEAL:3d::41 (84.15,0.00) +DEAL:3d::42 (168.29,0.00) +DEAL:3d::43 (84.15,0.00) +DEAL:3d::44 (168.29,0.00) +DEAL:3d::45 (84.15,0.00) +DEAL:3d::46 (168.29,0.00) +DEAL:3d::47 (84.13,0.00) +DEAL:3d::48 (84.09,0.00) +DEAL:3d::49 (84.09,0.00) +DEAL:3d::50 (84.13,0.00) +DEAL:3d::51 (84.09,0.00) +DEAL:3d::54 (84.09,0.00) +DEAL:3d::55 (84.09,0.00) +DEAL:3d::56 (84.13,0.00) +DEAL:3d::57 (84.09,0.00) +DEAL:3d::58 (84.03,0.00) +DEAL:3d::61 (84.03,0.00) +DEAL:3d::62 (84.03,0.00) +DEAL:3d::65 (84.15,0.00) +DEAL:3d::66 (168.29,0.00) +DEAL:3d::67 (84.15,0.00) +DEAL:3d::68 (168.29,0.00) +DEAL:3d::69 (84.13,0.00) +DEAL:3d::70 (84.13,0.00) +DEAL:3d::71 (84.09,0.00) +DEAL:3d::72 (84.09,0.00) +DEAL:3d::73 (84.13,0.00) +DEAL:3d::74 (84.03,0.00) +DEAL:3d::75 (84.03,0.00) +DEAL:3d::76 (84.03,0.00) +DEAL:3d::79 (84.15,0.00) +DEAL:3d::80 (168.29,0.00) +DEAL:3d::81 (84.15,0.00) +DEAL:3d::82 (168.29,0.00) +DEAL:3d::83 (84.15,0.00) +DEAL:3d::84 (168.29,0.00) +DEAL:3d::85 (84.15,0.00) +DEAL:3d::86 (168.29,0.00) +DEAL:3d::87 (84.15,0.00) +DEAL:3d::88 (168.29,0.00) +DEAL:3d::89 (84.09,0.00) +DEAL:3d::90 (84.09,0.00) +DEAL:3d::91 (84.13,0.00) +DEAL:3d::92 (84.09,0.00) +DEAL:3d::93 (84.13,0.00) +DEAL:3d::94 (84.09,0.00) +DEAL:3d::95 (84.13,0.00) +DEAL:3d::96 (84.09,0.00) +DEAL:3d::97 (84.09,0.00) +DEAL:3d::99 (84.03,0.00) +DEAL:3d::101 (84.03,0.00) +DEAL:3d::104 (84.03,0.00) +DEAL:3d::106 (84.15,0.00) +DEAL:3d::107 (168.29,0.00) +DEAL:3d::108 (84.15,0.00) +DEAL:3d::109 (168.29,0.00) +DEAL:3d::110 (84.13,0.00) +DEAL:3d::111 (84.13,0.00) +DEAL:3d::112 (84.09,0.00) +DEAL:3d::113 (84.13,0.00) +DEAL:3d::114 (84.09,0.00) +DEAL:3d::115 (84.03,0.00) +DEAL:3d::116 (84.03,0.00) +DEAL:3d::118 (84.03,0.00) +DEAL:3d::120 (84.15,0.00) +DEAL:3d::121 (168.29,0.00) +DEAL:3d::122 (84.15,0.00) +DEAL:3d::123 (168.29,0.00) +DEAL:3d::124 (84.13,0.00) +DEAL:3d::125 (84.09,0.00) +DEAL:3d::126 (84.13,0.00) +DEAL:3d::127 (84.13,0.00) +DEAL:3d::128 (84.09,0.00) +DEAL:3d::129 (84.03,0.00) +DEAL:3d::131 (84.03,0.00) +DEAL:3d::132 (84.03,0.00) +DEAL:3d::134 (84.15,0.00) +DEAL:3d::135 (168.29,0.00) +DEAL:3d::136 (84.13,0.00) +DEAL:3d::137 (84.13,0.00) +DEAL:3d::138 (84.13,0.00) +DEAL:3d::139 (84.03,0.00) +DEAL:3d::140 (84.03,0.00) +DEAL:3d::141 (84.03,0.00) +DEAL:3d::143 (84.15,0.00) +DEAL:3d::144 (168.29,0.00) +DEAL:3d::145 (84.15,0.00) +DEAL:3d::146 (168.29,0.00) +DEAL:3d::147 (84.15,0.00) +DEAL:3d::148 (168.29,0.00) +DEAL:3d::149 (84.15,0.00) +DEAL:3d::150 (168.29,0.00) +DEAL:3d::151 (84.15,0.00) +DEAL:3d::152 (168.29,0.00) +DEAL:3d::153 (84.15,0.00) +DEAL:3d::154 (168.29,0.00) +DEAL:3d::155 (84.15,0.00) +DEAL:3d::156 (168.29,0.00) +DEAL:3d::159 (84.15,0.00) +DEAL:3d::160 (84.14,0.00) +DEAL:3d::161 (84.15,0.00) +DEAL:3d::162 (84.14,0.00) +DEAL:3d::163 (84.14,0.00) +DEAL:3d::165 (84.14,0.00) +DEAL:3d::167 (84.15,0.00) +DEAL:3d::168 (84.14,0.00) +DEAL:3d::169 (84.14,0.00) +DEAL:3d::171 (84.14,0.00) +DEAL:3d::173 (84.14,0.00) +DEAL:3d::175 (84.14,0.00) +DEAL:3d::178 (84.15,0.00) +DEAL:3d::179 (168.29,0.00) +DEAL:3d::180 (84.15,0.00) +DEAL:3d::181 (168.29,0.00) +DEAL:3d::184 (84.14,0.00) +DEAL:3d::185 (84.15,0.00) +DEAL:3d::186 (84.14,0.00) +DEAL:3d::188 (84.14,0.00) +DEAL:3d::190 (84.14,0.00) +DEAL:3d::193 (84.14,0.00) +DEAL:3d::195 (84.14,0.00) +DEAL:3d::198 (84.15,0.00) +DEAL:3d::199 (168.29,0.00) +DEAL:3d::200 (84.15,0.00) +DEAL:3d::201 (168.29,0.00) +DEAL:3d::204 (84.15,0.00) +DEAL:3d::205 (84.14,0.00) +DEAL:3d::206 (84.14,0.00) +DEAL:3d::207 (84.14,0.00) +DEAL:3d::210 (84.14,0.00) +DEAL:3d::212 (84.14,0.00) +DEAL:3d::215 (84.14,0.00) +DEAL:3d::220 (84.14,0.00) +DEAL:3d::221 (84.14,0.00) +DEAL:3d::227 (84.14,0.00) +DEAL:3d::230 (84.15,0.00) +DEAL:3d::231 (168.29,0.00) +DEAL:3d::232 (84.15,0.00) +DEAL:3d::233 (168.29,0.00) +DEAL:3d::236 (84.14,0.00) +DEAL:3d::238 (84.14,0.00) +DEAL:3d::240 (84.15,0.00) +DEAL:3d::241 (84.14,0.00) +DEAL:3d::242 (84.14,0.00) +DEAL:3d::244 (84.14,0.00) +DEAL:3d::246 (84.14,0.00) +DEAL:3d::253 (84.14,0.00) +DEAL:3d::255 (84.14,0.00) +DEAL:3d::258 (84.14,0.00) +DEAL:3d::264 (84.14,0.00) +DEAL:3d::267 (84.14,0.00) +DEAL:3d::269 (84.14,0.00) +DEAL:3d::Interpolated boundary values +DEAL:3d::0 (1.00,0.00) +DEAL:3d::1 (1.00,0.00) +DEAL:3d::2 (1.00,0.00) +DEAL:3d::3 (1.00,0.00) +DEAL:3d::4 (1.00,0.00) +DEAL:3d::5 (1.00,0.00) +DEAL:3d::7 (1.00,0.00) +DEAL:3d::8 (1.00,0.00) +DEAL:3d::9 (1.00,0.00) +DEAL:3d::10 (1.00,0.00) +DEAL:3d::11 (1.00,0.00) +DEAL:3d::12 (1.00,0.00) +DEAL:3d::13 (1.00,0.00) +DEAL:3d::14 (1.00,0.00) +DEAL:3d::15 (1.00,0.00) +DEAL:3d::16 (1.00,0.00) +DEAL:3d::17 (1.00,0.00) +DEAL:3d::18 (1.00,0.00) +DEAL:3d::19 (1.00,0.00) +DEAL:3d::20 (1.00,0.00) +DEAL:3d::21 (1.00,0.00) +DEAL:3d::22 (1.00,0.00) +DEAL:3d::23 (1.00,0.00) +DEAL:3d::24 (1.00,0.00) +DEAL:3d::25 (1.00,0.00) +DEAL:3d::26 (1.00,0.00) +DEAL:3d::27 (1.00,0.00) +DEAL:3d::28 (1.00,0.00) +DEAL:3d::29 (1.00,0.00) +DEAL:3d::30 (1.00,0.00) +DEAL:3d::31 (1.00,0.00) +DEAL:3d::32 (1.00,0.00) +DEAL:3d::34 (1.00,0.00) +DEAL:3d::35 (1.00,0.00) +DEAL:3d::37 (1.00,0.00) +DEAL:3d::38 (1.00,0.00) +DEAL:3d::41 (1.00,0.00) +DEAL:3d::42 (1.00,0.00)