--- /dev/null
+// ---------------------------------------------------------------------
+//
+// 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 <deal.II/base/function_lib.h>
+#include <deal.II/base/quadrature_lib.h>
+#include <deal.II/lac/vector.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/tria_boundary_lib.h>
+#include <deal.II/dofs/dof_accessor.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_tools.h>
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/fe/fe_system.h>
+#include <deal.II/fe/mapping_q.h>
+#include <deal.II/numerics/vector_tools.h>
+
+
+
+template <int dim>
+class MySquareFunction : public Function<dim,std::complex<double>>
+{
+public:
+ MySquareFunction () : Function<dim,std::complex<double>>(2) {}
+
+ virtual std::complex<double> value (const Point<dim> &p,
+ const unsigned int component) const
+ {
+ return std::complex<double>(100*(component+1)*p.square()*std::sin(p.square()), 0);
+ }
+
+ virtual void vector_value (const Point<dim> &p,
+ Vector<std::complex<double>> &values) const
+ {
+ for (unsigned int d=0; d<this->n_components; ++d)
+ values(d) = value(p,d);
+ }
+};
+
+
+template <int dim>
+const Quadrature<dim-1> &
+boundary_q (const DoFHandler<dim> &)
+{
+ static const QGauss<dim-1> q(4);
+ return q;
+}
+
+
+void write_map (const std::map<types::global_dof_index,std::complex<double>> &bv)
+{
+ for (std::map<types::global_dof_index,std::complex<double>>::const_iterator
+ i=bv.begin(); i!=bv.end(); ++i)
+ deallog << i->first << ' ' << i->second <<std::endl;
+}
+
+
+
+
+template <int dim>
+void
+check ()
+{
+ Triangulation<dim> tr;
+ if (dim==2)
+ {
+ GridGenerator::hyper_ball(tr, Point<dim>(), 1);
+ }
+ else
+ GridGenerator::hyper_cube(tr, -1./std::sqrt(static_cast<double>(dim)),1./std::sqrt(static_cast<double>(dim)));
+ static const HyperBallBoundary<dim> 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<dim> mapping(3);
+
+
+ // list of finite elements for
+ // which we want check, and
+ // associated list of boundary
+ // value functions
+ std::vector<const FiniteElement<dim>*> fe_list;
+ std::vector<const Function<dim,std::complex<double>>*> function_list;
+
+ // FE1: a system of a quadratic and
+ // a linear element
+ fe_list.push_back (new FESystem<dim> (FE_Q<dim>(2), 1, FE_Q<dim>(1), 1));
+ function_list.push_back (new MySquareFunction<dim>());
+
+ // FE2: a linear element, to make
+ // things simple
+ fe_list.push_back (new FE_Q<dim> (1));
+ function_list.push_back (new Functions::ConstantFunction<dim,std::complex<double>>(std::complex<double>(1,0)));
+
+ // check all of them
+ for (unsigned int i=0; i<fe_list.size(); ++i)
+ {
+ const FiniteElement<dim> &fe = *fe_list[i];
+
+ DoFHandler<dim> dof(tr);
+ dof.distribute_dofs(fe);
+
+ typename FunctionMap<dim,std::complex<double>>::type function_map;
+ function_map[0] = function_list[i];
+
+ // interpolate boundary values
+ deallog << "Interpolated boundary values" << std::endl;
+ std::map<types::global_dof_index,std::complex<double>> interpolated_bv;
+ VectorTools::interpolate_boundary_values (mapping, dof, function_map,
+ interpolated_bv, std::vector<bool>());
+ 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<types::global_dof_index,double> 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<fe_list.size(); ++i)
+ {
+ delete fe_list[i];
+ delete function_list[i];
+ };
+}
+
+
+int main ()
+{
+ initlog();
+ deallog << std::setprecision (2);
+ deallog << std::fixed;
+
+ deallog.push ("1d");
+ check<1> ();
+ deallog.pop ();
+ deallog.push ("2d");
+ check<2> ();
+ deallog.pop ();
+ deallog.push ("3d");
+ check<3> ();
+ deallog.pop ();
+}
--- /dev/null
+
+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)