--- /dev/null
+//---------------------------- rt_projection_01.cc ---------------------------
+// rt_projection_01.cc,v 1.3 2003/06/09 16:00:38 wolf Exp
+// Version:
+//
+// Copyright (C) 2003, 2005, 2006 by the deal.II authors
+//
+// This file is subject to QPL and may not be distributed
+// without copyright and license information. Please refer
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- rt_projection_01.cc ---------------------------
+
+/*
+ * Little snippet, which tests, to what degree the RT/ABF elements
+ * can approximate a polynomial exactly on deformed geometries.
+ */
+
+
+
+#include "../tests.h"
+#include <base/logstream.h>
+
+#define PRECISION 2
+
+#include <fstream>
+
+std::ofstream logfile ("rt_projection_01/output");
+
+char buf[1000];
+#include <fstream>
+
+#include <grid/grid_generator.h>
+#include <grid/grid_in.h>
+#include <grid/grid_out.h>
+#include <grid/tria_boundary_lib.h>
+
+#include <fe/mapping_q.h>
+#include <fe/mapping_q1_eulerian.h>
+
+#include <numerics/vectors.h>
+#include <numerics/matrices.h>
+#include <numerics/data_out.h>
+#include <lac/vector.h>
+#include <lac/solver_cg.h>
+#include <lac/precondition.h>
+#include <lac/vector_memory.h>
+#include <lac/sparsity_pattern.h>
+#include <lac/sparse_matrix.h>
+
+#include <base/function.h>
+#include <base/quadrature_lib.h>
+#include <dofs/dof_constraints.h>
+#include <dofs/dof_tools.h>
+
+#include <fe/fe_system.h>
+#include <fe/fe.h>
+#include <fe/fe_q.h>
+#include <fe/fe_values.h>
+#include <fe/fe_raviart_thomas.h>
+#include <fe/fe_abf.h>
+#include <fe/fe_dgq.h>
+
+
+template <int dim>
+class TestMap1 : public Function<dim>
+{
+ public:
+ TestMap1 (const unsigned int n_components) :
+ Function<dim> (n_components)
+ {};
+
+ virtual ~TestMap1 () {};
+
+ virtual double value (const Point<dim> &p,
+ const unsigned int component = 0) const;
+
+ void vector_value (const Point<dim> &p,
+ Vector<double> &return_value) const;
+};
+
+
+
+template <int dim>
+double
+TestMap1<dim>::value (const Point<dim> &,
+ const unsigned int ) const
+{
+ return (1.0);
+}
+
+
+template <int dim>
+void TestMap1<dim>::vector_value (const Point<dim> &p,
+ Vector<double> &return_value) const
+{
+ Assert (return_value.size() == this->n_components,
+ ExcDimensionMismatch (return_value.size(), this->n_components));
+
+ // Parabolic inflow profile
+ for (unsigned int iCount = 0; iCount < this->n_components; iCount++)
+ return_value (iCount) = value (p, iCount);
+}
+
+
+/*
+ * Check the value of the derivative field.
+ */
+
+void EvaluateDerivative (DoFHandler<2> *dof_handler,
+ Vector<double> &solution)
+{
+ // This quadrature rule determines the points, where the
+ // derivative will be evaluated.
+ QGauss<2> quad (3);
+ FEValues<2> fe_values (dof_handler->get_fe (), quad,
+ UpdateFlags(update_values |
+ update_q_points |
+ update_gradients |
+ update_JxW_values));
+
+ const unsigned int n_q_points = quad.n_quadrature_points;
+ const unsigned int n_components = dof_handler->get_fe().n_components();
+ const unsigned int dofs_per_cell = dof_handler->get_fe().dofs_per_cell;
+
+ // Cell iterators
+ DoFHandler<2>::active_cell_iterator cell = dof_handler->begin_active(),
+ endc = dof_handler->end();
+
+ double err_l2 = 0,
+ err_hdiv = 0;
+
+ std::vector<unsigned int> local_dof_indices (dofs_per_cell);
+
+ for (; cell!=endc; ++cell)
+ {
+ cell->get_dof_indices (local_dof_indices);
+
+ fe_values.reinit (cell);
+
+ // Get function values
+ std::vector<Vector<double> > this_value(n_q_points,
+ Vector<double>(n_components));
+ fe_values.get_function_values (solution, this_value);
+
+ // Get values from solution vector (For Trap.Rule)
+ std::vector<std::vector<Tensor<1,2> > >
+ grads_here (n_q_points, std::vector<Tensor<1,2> > (n_components));
+ fe_values.get_function_grads (solution, grads_here);
+
+ for (unsigned int q_point=0; q_point<n_q_points; ++q_point)
+ {
+ // double u0 = this_value[q_point](0);
+ //double v0 = this_value[q_point](1);
+
+ double u0 = 0;
+ double v0 = 0;
+ for (unsigned int i = 0; i < dofs_per_cell; ++i)
+ {
+ u0 += (solution (local_dof_indices[i]) *
+ fe_values.shape_value_component(i, q_point, 0));
+ v0 += (solution (local_dof_indices[i]) *
+ fe_values.shape_value_component(i, q_point, 1));
+ }
+ u0 -= 1.0;
+ v0 -= 1.0;
+
+ double dudx = grads_here[q_point][0][0];
+ double dvdy = grads_here[q_point][1][1];
+
+ /*
+ sprintf (buf, "QP %i %e %e %e %e %e %e Div %e\n", q_point, u0, v0,
+ dudx, dudy, dvdx, dvdy, dudx + dvdy);
+ */
+
+ err_l2 += (u0 * u0 + v0 * v0) * fe_values.JxW (q_point);
+ err_hdiv += (dudx + dvdy) * (dudx + dvdy) * fe_values.JxW (q_point);
+ }
+ }
+
+ sprintf (buf, "L2-Err %e Hdiv-Err %e\n", pow (err_l2, 0.5),
+ pow (err_hdiv, 0.5));
+ deallog << buf;
+}
+
+
+template <int dim>
+void create_mass_matrix (const Mapping<dim> &mapping,
+ const DoFHandler<dim> &dof,
+ const Quadrature<dim> &q,
+ SparseMatrix<double> &matrix,
+ const Function<dim> &rhs_function,
+ Vector<double> &rhs_vector,
+ const Function<dim> * const coefficient = 0)
+{
+ UpdateFlags update_flags = UpdateFlags(update_values | update_JxW_values | update_q_points);
+ if (coefficient != 0)
+ update_flags = UpdateFlags (update_flags | update_q_points);
+
+ FEValues<dim> fe_values (mapping, dof.get_fe(), q, update_flags);
+
+ const unsigned int dofs_per_cell = fe_values.dofs_per_cell,
+ n_q_points = fe_values.n_quadrature_points;
+ const FiniteElement<dim> &fe = fe_values.get_fe();
+ const unsigned int n_components = fe.n_components();
+
+ Assert(coefficient == 0 ||
+ coefficient->n_components==1 ||
+ coefficient->n_components==n_components, ExcInternalError());
+
+ FullMatrix<double> cell_matrix (dofs_per_cell, dofs_per_cell);
+ Vector<double> cell_vector (dofs_per_cell);
+ std::vector<double> coefficient_values (n_q_points);
+ std::vector<Vector<double> > coefficient_vector_values (n_q_points,
+ Vector<double> (n_components));
+
+ std::vector<unsigned int> dof_indices (dofs_per_cell);
+
+ std::vector<Vector<double> > rhs_values(n_q_points, Vector<double>(n_components));
+
+ typename DoFHandler<dim>::active_cell_iterator cell = dof.begin_active (),
+ endc = dof.end ();
+ for (; cell!=endc; ++cell)
+ {
+ fe_values.reinit (cell);
+
+ cell_matrix = 0;
+ cell->get_dof_indices (dof_indices);
+
+ const std::vector<double> &weights = fe_values.get_JxW_values ();
+ rhs_function.vector_value_list (fe_values.get_quadrature_points(), rhs_values);
+ cell_vector = 0;
+
+ if (coefficient != 0)
+ {
+ if (coefficient->n_components==1)
+ {
+ coefficient->value_list (fe_values.get_quadrature_points(),
+ coefficient_values);
+ for (unsigned int point=0; point<n_q_points; ++point)
+ {
+ const double weight = fe_values.JxW(point);
+ for (unsigned int i=0; i<dofs_per_cell; ++i)
+ {
+ const double v = fe_values.shape_value(i,point);
+ for (unsigned int j=0; j<dofs_per_cell; ++j)
+ {
+ const double u = fe_values.shape_value(j,point);
+
+ if ((n_components==1) ||
+ (fe.system_to_component_index(i).first ==
+ fe.system_to_component_index(j).first))
+ cell_matrix(i,j) +=
+ (u * v * weight * coefficient_values[point]);
+ }
+ }
+ }
+ }
+ else
+ {
+ coefficient->vector_value_list (fe_values.get_quadrature_points(),
+ coefficient_vector_values);
+ for (unsigned int point=0; point<n_q_points; ++point)
+ {
+ const double weight = fe_values.JxW(point);
+ for (unsigned int i=0; i<dofs_per_cell; ++i)
+ {
+ const double v = fe_values.shape_value(i,point);
+ const unsigned int component_i=
+ fe.system_to_component_index(i).first;
+ for (unsigned int j=0; j<dofs_per_cell; ++j)
+ {
+ const double u = fe_values.shape_value(j,point);
+ if ((n_components==1) ||
+ (fe.system_to_component_index(j).first == component_i))
+ cell_matrix(i,j) +=
+ (u * v * weight *
+ coefficient_vector_values[point](component_i));
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ // Compute eventual sign changes depending on the neighborhood
+ // between two faces.
+ std::vector<double> sign_change (dofs_per_cell, 1.0);
+ const unsigned int dofs_per_face = fe.dofs_per_face;
+ std::vector<unsigned int> face_dof_indices (dofs_per_face);
+
+ for (unsigned int f = 0; f < 2; ++f)
+ {
+ typename DoFHandler<dim>::active_face_iterator face = cell->face (f);
+ if (!face->at_boundary ())
+ {
+ unsigned int nn = cell->neighbor_of_neighbor (f);
+ sprintf (buf, "Face %i NeigNeig %i\n", f, nn);
+ deallog << buf;
+ if (nn > 1)
+ {
+ face->get_dof_indices (face_dof_indices);
+ for (unsigned int j = 0; j < dofs_per_face; ++j)
+ {
+ sign_change[face_dof_indices[j]] = -1.0;
+ sprintf (buf, "DoF %i\n", face_dof_indices[j]);
+ deallog << buf;
+ }
+ }
+ }
+ }
+
+ for (unsigned int point=0; point<n_q_points; ++point)
+ {
+ const double weight = fe_values.JxW(point);
+ // const double weight = q.weight(point);
+
+ std::vector<Vector<double> > val_vector (dofs_per_cell,
+ Vector<double> (n_components));
+
+ // Precompute the component values
+ for (unsigned int i=0; i < dofs_per_cell; ++i)
+ for (unsigned int comp_i = 0; comp_i < fe.n_components ();
+ ++comp_i)
+ {
+ val_vector[i](comp_i) = sign_change[i] *
+ fe_values.shape_value_component(i,point,comp_i);
+ }
+ // Now eventually switch the sign of some of the ansatzfunctions.
+ // TODO
+
+ for (unsigned int i=0; i<dofs_per_cell; ++i)
+ for (unsigned int comp_i = 0; comp_i < fe.n_components ();
+ ++comp_i)
+ if (fe.get_nonzero_components(i)[comp_i] == true)
+ {
+ const double v = val_vector[i](comp_i);
+ for (unsigned int j=0; j<dofs_per_cell; ++j)
+ for (unsigned int comp_j = 0;
+ comp_j < fe.n_components (); ++comp_j)
+ if (fe.get_nonzero_components(j)[comp_j] == true)
+ {
+ const double u = val_vector[j](comp_j);
+ if ((n_components==1) ||
+ (comp_i == comp_j))
+ cell_matrix(i,j) += (u * v * weight);
+ }
+ }
+
+
+ for (unsigned int i=0; i<dofs_per_cell; ++i)
+ for (unsigned int comp_i = 0; comp_i < fe.n_components ();
+ ++comp_i)
+ if (fe.get_nonzero_components(i)[comp_i] == true)
+ {
+ cell_vector(i) += rhs_values[point](comp_i) *
+ val_vector[i](comp_i) * weights[point];
+ }
+ }
+ }
+ // transfer everything into the
+ // global object. lock the
+ // matrix meanwhile
+ for (unsigned int i=0; i<dofs_per_cell; ++i)
+ for (unsigned int j=0; j<dofs_per_cell; ++j)
+ if ((n_components==1) ||
+ (cell_matrix (i,j) != 0.0))
+/*
+ (fe.system_to_component_index(i).first ==
+ fe.system_to_component_index(j).first))
+*/
+ matrix.add (dof_indices[i], dof_indices[j],
+ cell_matrix(i,j));
+
+ for (unsigned int i=0; i<dofs_per_cell; ++i)
+ rhs_vector(dof_indices[i]) += cell_vector(i);
+ }
+}
+
+
+template <int dim>
+void create_right_hand_side (const Mapping<dim> &mapping,
+ const DoFHandler<dim> &dof_handler,
+ const Quadrature<dim> &quadrature,
+ const Function<dim> &rhs_function,
+ Vector<double> &rhs_vector)
+{
+ const FiniteElement<dim> &fe = dof_handler.get_fe();
+ Assert (fe.n_components() == rhs_function.n_components,
+ ExcInternalError());
+ Assert (rhs_vector.size() == dof_handler.n_dofs(),
+ ExcDimensionMismatch(rhs_vector.size(), dof_handler.n_dofs()));
+ rhs_vector = 0;
+
+ UpdateFlags update_flags = UpdateFlags(update_values |
+ update_q_points |
+ update_JxW_values);
+ FEValues<dim> fe_values (mapping, fe, quadrature, update_flags);
+
+ const unsigned int dofs_per_cell = fe_values.dofs_per_cell,
+ n_q_points = fe_values.n_quadrature_points,
+ n_components = fe.n_components();
+
+ std::vector<unsigned int> dofs (dofs_per_cell);
+ Vector<double> cell_vector (dofs_per_cell);
+
+ typename DoFHandler<dim>::active_cell_iterator cell = dof_handler.begin_active(),
+ endc = dof_handler.end();
+
+ if (n_components==1)
+ {
+ std::vector<double> rhs_values(n_q_points);
+
+ for (; cell!=endc; ++cell)
+ {
+ fe_values.reinit(cell);
+
+ const std::vector<double> &weights = fe_values.get_JxW_values ();
+ rhs_function.value_list (fe_values.get_quadrature_points(), rhs_values);
+
+ cell_vector = 0;
+ for (unsigned int point=0; point<n_q_points; ++point)
+ for (unsigned int i=0; i<dofs_per_cell; ++i)
+ cell_vector(i) += rhs_values[point] *
+ fe_values.shape_value(i,point) *
+ weights[point];
+
+ cell->get_dof_indices (dofs);
+
+ for (unsigned int i=0; i<dofs_per_cell; ++i)
+ rhs_vector(dofs[i]) += cell_vector(i);
+ }
+ }
+ else
+ {
+ std::vector<Vector<double> > rhs_values(n_q_points, Vector<double>(n_components));
+
+ for (; cell!=endc; ++cell)
+ {
+ fe_values.reinit(cell);
+
+ const std::vector<double> &weights = fe_values.get_JxW_values ();
+ rhs_function.vector_value_list (fe_values.get_quadrature_points(), rhs_values);
+
+ cell_vector = 0;
+ for (unsigned int point=0; point<n_q_points; ++point)
+ for (unsigned int i=0; i<dofs_per_cell; ++i)
+ for (unsigned int comp_i = 0; comp_i < fe.n_components ();
+ ++comp_i)
+ // if (fe.get_nonzero_components(i)[comp_i] == true)
+ {
+ cell_vector(i) += rhs_values[point](comp_i) *
+ fe_values.shape_value_component(i,point,comp_i) *
+ weights[point];
+ }
+
+ cell->get_dof_indices (dofs);
+
+ for (unsigned int i=0; i<dofs_per_cell; ++i)
+ rhs_vector(dofs[i]) += cell_vector(i);
+ }
+ }
+}
+
+
+
+//
+// This function replaces the deal.II implementation of the projection.
+// The purpose is to have more freedom in assembling the matrix.
+//
+
+template <int dim>
+void project (const Mapping<dim> &mapping,
+ const DoFHandler<dim> &dof,
+ const ConstraintMatrix &constraints,
+ const Quadrature<dim> &quadrature,
+ const Function<dim> &function,
+ Vector<double> &vec,
+ const bool enforce_zero_boundary = false,
+ const Quadrature<dim-1> & = QGauss2<dim-1>(),
+ const bool project_to_boundary_first = false)
+{
+ Assert (dof.get_fe().n_components() == function.n_components,
+ ExcInternalError());
+
+ const FiniteElement<dim> &fe = dof.get_fe();
+
+ // make up boundary values
+ std::map<unsigned int,double> boundary_values;
+
+ if (enforce_zero_boundary == true)
+ // no need to project boundary
+ // values, but enforce
+ // homogeneous boundary values
+ // anyway
+ {
+ // loop over all boundary faces
+ // to get all dof indices of
+ // dofs on the boundary. note
+ // that in 3d there are cases
+ // where a face is not at the
+ // boundary, yet one of its
+ // lines is, and we should
+ // consider the degrees of
+ // freedom on it as boundary
+ // nodes. likewise, in 2d and
+ // 3d there are cases where a
+ // cell is only at the boundary
+ // by one vertex. nevertheless,
+ // since we do not support
+ // boundaries with dimension
+ // less or equal to dim-2, each
+ // such boundary dof is also
+ // found from some other face
+ // that is actually wholly on
+ // the boundary, not only by
+ // one line or one vertex
+ typename DoFHandler<dim>::active_face_iterator face = dof.begin_active_face(),
+ endf = dof.end_face();
+ std::vector<unsigned int> face_dof_indices (fe.dofs_per_face);
+ for (; face!=endf; ++face)
+ if (face->at_boundary())
+ {
+ face->get_dof_indices (face_dof_indices);
+ for (unsigned int i=0; i<fe.dofs_per_face; ++i)
+ // enter zero boundary values
+ // for all boundary nodes
+ //
+ // we need not care about
+ // vector valued elements here,
+ // since we set all components
+ boundary_values[face_dof_indices[i]] = 0.;
+ };
+ }
+ else
+ // no homogeneous boundary values
+ if (project_to_boundary_first == true)
+ // boundary projection required
+ {
+/*
+ // set up a list of boundary functions for
+ // the different boundary parts. We want the
+ // @p{function} to hold on all parts of the
+ // boundary
+ typename FunctionMap<dim>::type boundary_functions;
+ for (unsigned char c=0; c<255; ++c)
+ boundary_functions[c] = &function;
+ project_boundary_values (dof, boundary_functions, q_boundary,
+ boundary_values);
+*/
+ }
+
+
+ // set up mass matrix and right hand side
+ vec.reinit (dof.n_dofs());
+ SparsityPattern sparsity(dof.n_dofs(),
+ dof.n_dofs(),
+ dof.max_couplings_between_dofs());
+ DoFTools::make_sparsity_pattern (dof, sparsity);
+ constraints.condense (sparsity);
+
+ SparseMatrix<double> mass_matrix (sparsity);
+ Vector<double> tmp (mass_matrix.n());
+
+ create_mass_matrix (mapping, dof, quadrature, mass_matrix, function, tmp);
+ sprintf (buf, "MM created\n");
+ deallog << buf;
+ create_right_hand_side (mapping, dof, quadrature, function, tmp);
+ sprintf (buf, "RHS created\n");
+ deallog << buf;
+
+ constraints.condense (mass_matrix);
+ constraints.condense (tmp);
+ if (boundary_values.size() != 0)
+ MatrixTools::apply_boundary_values (boundary_values,
+ mass_matrix, vec, tmp,
+ true);
+
+ SolverControl control(1000,1e-16);
+ PrimitiveVectorMemory<> memory;
+ SolverCG<> cg(control,memory);
+
+ PreconditionSSOR<> prec;
+ prec.initialize(mass_matrix, 1.2);
+ // solve
+ cg.solve (mass_matrix, vec, tmp, prec);
+
+ // distribute solution
+ constraints.distribute (vec);
+}
+
+
+int create_tria (unsigned int elm, Triangulation<2> &tria)
+{
+ std::vector<Point<2> > points_glob;
+ std::vector<Point<2> > points;
+
+ points_glob.push_back (Point<2> (0.0, 0.0));
+ points_glob.push_back (Point<2> (1.0, 0.0));
+ points_glob.push_back (Point<2> (1.0, 0.5));
+ points_glob.push_back (Point<2> (1.0, 1.0));
+ points_glob.push_back (Point<2> (0.6, 0.5));
+ points_glob.push_back (Point<2> (0.5, 1.0));
+ points_glob.push_back (Point<2> (0.0, 1.0));
+
+ // Prepare cell data
+ std::vector<CellData<2> > cells (1);
+
+ switch (elm)
+ {
+ case 0:
+ cells[0].vertices[0] = 0;
+ cells[0].vertices[1] = 1;
+ cells[0].vertices[2] = 4;
+ cells[0].vertices[3] = 2;
+ cells[0].material_id = 0;
+ break;
+ case 1:
+ cells[0].vertices[0] = 4;
+ cells[0].vertices[1] = 2;
+ cells[0].vertices[2] = 5;
+ cells[0].vertices[3] = 3;
+ cells[0].material_id = 0;
+ break;
+ case 2:
+ cells[0].vertices[0] = 0;
+ cells[0].vertices[1] = 4;
+ cells[0].vertices[2] = 6;
+ cells[0].vertices[3] = 5;
+ cells[0].material_id = 0;
+ break;
+ }
+
+ for (unsigned int i = 0; i < 4; ++i)
+ {
+ points.push_back (points_glob[cells[0].vertices[i]]);
+ cells[0].vertices[i] = i;
+ }
+
+ tria.create_triangulation (points, cells, SubCellData());
+
+ return (0);
+}
+
+
+int plot_shapes (DoFHandler<2> &dof_handler)
+{
+ Vector<double> solution (dof_handler.n_dofs ());
+ std::set<unsigned int> face_dofs;
+
+ // Create set of all DoFs, which are on the boundary.
+ DoFHandler<2>::active_face_iterator face = dof_handler.begin_active_face(),
+ endf = dof_handler.end_face();
+ std::vector<unsigned int> face_dof_indices (dof_handler.get_fe().dofs_per_face);
+ for (; face!=endf; ++face)
+ {
+ face->get_dof_indices (face_dof_indices);
+ for (unsigned int i=0; i<dof_handler.get_fe().dofs_per_face; ++i)
+ face_dofs.insert (face_dof_indices[i]);
+ }
+
+ // Now set a 1 at the place of the different DoFs and
+ // output the solution.
+ std::set<unsigned int>::iterator face_dof_iter;
+ for (face_dof_iter = face_dofs.begin ();
+ face_dof_iter != face_dofs.end (); ++face_dof_iter)
+ {
+ unsigned int dof = *face_dof_iter;
+
+ sprintf (buf, "%i\n", dof);
+ deallog << buf;
+
+ solution (dof) = 1.0;
+
+ // Test the core functionality2
+ DataOut<2> *data_out = new DataOut<2>;
+ data_out->attach_dof_handler (dof_handler);
+ data_out->add_data_vector (solution, "solution");
+ data_out->build_patches (4, 0);
+
+ data_out->write_gnuplot (deallog.get_file_stream());
+
+ delete data_out;
+
+ solution (dof) = 0.0;
+ }
+
+ return (0);
+}
+
+
+int main (int /*argc*/, char **/*argv*/)
+{
+ logfile.precision (PRECISION);
+ logfile.setf(std::ios::fixed);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ Triangulation<2> tria_test;
+ DoFHandler<2> *dof_handler;
+
+ FE_RaviartThomas<2> fe (0);
+ //FESystem<2> fe (FE_Q<2>(3), 2);
+ //FE_ABF<2> fe (0);
+ deallog << "Dofs/cell " << fe.dofs_per_cell
+ << "Dofs/face " << fe.dofs_per_face << std::endl;
+
+ for (unsigned int elm = 0; elm < 3; ++elm)
+ {
+ create_tria (elm, tria_test);
+
+ // Create a DoFHandler
+ dof_handler = new DoFHandler<2> (tria_test);
+ dof_handler->distribute_dofs (fe);
+
+ deallog << "Dofs total " << dof_handler->n_dofs () << std::endl;
+
+ // Alloc some DoFs
+ Vector<double> solution;
+ solution.reinit (dof_handler->n_dofs ());
+
+ // Project solution onto FE field
+ ConstraintMatrix hn_constraints;
+ hn_constraints.clear ();
+ DoFTools::make_hanging_node_constraints (*dof_handler,
+ hn_constraints);
+ hn_constraints.close ();
+
+ MappingQ1<2> map_default;
+
+ project (map_default, *dof_handler, hn_constraints,
+ QGauss6<2> (), TestMap1<2>(2),
+ solution);
+
+ // Test the core functionality
+ DataOut<2> *data_out = new DataOut<2>;
+ data_out->attach_dof_handler (*dof_handler);
+ data_out->add_data_vector (solution, "solution");
+ data_out->build_patches (4);
+
+ data_out->write_gnuplot (deallog.get_file_stream());
+
+ // Now write face DoFs ..
+ for (unsigned int i = 0; i < 4; ++i)
+ {
+ sprintf (buf, "%i %e\n", i, solution (i));
+ deallog << buf;
+ }
+
+ // Clean up ...
+ delete data_out;
+ delete (dof_handler);
+ tria_test.clear ();
+ }
+
+ return (0);
+}
--- /dev/null
+#!/usr/bin/gnuplot -persist
+#
+#
+# G N U P L O T
+# Version 4.0 patchlevel 0
+# last modified Thu Apr 15 14:44:22 CEST 2004
+# System: Linux 2.6.11.4-21.11-smp
+#
+# Copyright (C) 1986 - 1993, 1998, 2004, 2006
+# Thomas Williams, Colin Kelley and many others
+#
+# This is gnuplot version 4.0. Please refer to the documentation
+# for command syntax changes. The old syntax will be accepted
+# throughout the 4.0 series, but all save files use the new syntax.
+#
+# Type `help` to access the on-line reference manual.
+# The gnuplot FAQ is available from
+# http://www.gnuplot.info/faq/
+#
+# Send comments and requests for help to
+# <gnuplot-info@lists.sourceforge.net>
+# Send bugs, suggestions and mods to
+# <gnuplot-bugs@lists.sourceforge.net>
+#
+set terminal postscript eps color solid enhanced 20
+# set output
+unset clip points
+set clip one
+unset clip two
+set bar 1.000000
+set border 31 lt -1 lw 1.000
+set xdata
+set ydata
+set zdata
+set x2data
+set y2data
+set timefmt x "%d/%m/%y,%H:%M"
+set timefmt y "%d/%m/%y,%H:%M"
+set timefmt z "%d/%m/%y,%H:%M"
+set timefmt x2 "%d/%m/%y,%H:%M"
+set timefmt y2 "%d/%m/%y,%H:%M"
+set timefmt cb "%d/%m/%y,%H:%M"
+set boxwidth
+set style fill empty border
+set dummy x,y
+set format x "% g"
+set format y "% g"
+set format x2 "% g"
+set format y2 "% g"
+set format z "% g"
+set format cb "% g"
+set angles radians
+unset grid
+set key title ""
+set key right top Right noreverse enhanced box linetype -2 linewidth 1.000 samplen 4 spacing 1 width 0 height 0 autotitles
+unset label
+unset arrow
+unset style line
+unset style arrow
+unset logscale
+set offsets 0, 0, 0, 0
+set pointsize 1
+set encoding default
+unset polar
+unset parametric
+unset decimalsign
+set view 60, 20, 1, 1
+set samples 100, 100
+set isosamples 10, 10
+set surface
+unset contour
+set clabel '%8.3g'
+set mapping cartesian
+set datafile separator whitespace
+set hidden3d offset 1 trianglepattern 3 undefined 1 altdiagonal bentover
+set cntrparam order 4
+set cntrparam linear
+set cntrparam levels auto 5
+set cntrparam points 5
+set size ratio 0 1,1
+set origin 0,0
+set style data lines
+set style function lines
+set xzeroaxis lt -2 lw 1.000
+set yzeroaxis lt -2 lw 1.000
+set x2zeroaxis lt -2 lw 1.000
+set y2zeroaxis lt -2 lw 1.000
+set tics in
+set ticslevel 0.5
+set ticscale 1 0.5
+set mxtics default
+set mytics default
+set mztics default
+set mx2tics default
+set my2tics default
+set mcbtics default
+set xtics border mirror norotate autofreq
+set ytics border mirror norotate autofreq
+set ztics border nomirror norotate autofreq
+set nox2tics
+set noy2tics
+set cbtics border mirror norotate autofreq
+set title "" 0.000000,0.000000 font ""
+set timestamp "" bottom norotate 0.000000,0.000000 ""
+set rrange [ * : * ] noreverse nowriteback # (currently [0.00000:10.0000] )
+set trange [ * : * ] noreverse nowriteback # (currently [-5.00000:5.00000] )
+set urange [ * : * ] noreverse nowriteback # (currently [-5.00000:5.00000] )
+set vrange [ * : * ] noreverse nowriteback # (currently [-5.00000:5.00000] )
+set xlabel "x" 0.000000,0.000000 font ""
+set x2label "" 0.000000,0.000000 font ""
+set xrange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] )
+set x2range [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] )
+set ylabel "y" 0.000000,0.000000 font ""
+set y2label "" 0.000000,0.000000 font ""
+set yrange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] )
+set y2range [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] )
+set zlabel "" 0.000000,0.000000 font ""
+set zrange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] )
+set cblabel "" 0.000000,0.000000 font ""
+set cbrange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] )
+set zero 1e-08
+set lmargin -1
+set bmargin -1
+set rmargin -1
+set tmargin -1
+set locale "C"
+set pm3d scansautomatic flush begin noftriangles nohidden3d implicit corners2color mean
+unset pm3d
+set palette positive nops_allcF maxcolors 0 gamma 1.5 color model RGB
+set palette rgbformulae 7, 5, 15
+set colorbox default
+set colorbox vertical origin 0.9,0.2 size 0.1,0.63 bdefault
+set loadpath
+set fontpath
+set fit noerrorvariables
+set output "RT1_00_x.eps"
+splot "< perl -ne \'print if s/DEAL:RT<2>.1.::value//;\' output" using 1:2:3 title "v0_x"
+set output "RT1_00_y.eps"
+splot "< perl -ne \'print if s/DEAL:RT<2>.1.::value//;\' output" using 1:2:4 title "v0_y"
+set output "RT1_01_x.eps"
+splot "< perl -ne \'print if s/DEAL:RT<2>.1.::value//;\' output" using 1:2:5 title "v1_x"
+set output "RT1_01_y.eps"
+splot "< perl -ne \'print if s/DEAL:RT<2>.1.::value//;\' output" using 1:2:6 title "v1_y"
+set output "RT1_02_x.eps"
+splot "< perl -ne \'print if s/DEAL:RT<2>.1.::value//;\' output" using 1:2:7 title "v2_x"
+set output "RT1_02_y.eps"
+splot "< perl -ne \'print if s/DEAL:RT<2>.1.::value//;\' output" using 1:2:8 title "v2_y"
+set output "RT1_03_x.eps"
+splot "< perl -ne \'print if s/DEAL:RT<2>.1.::value//;\' output" using 1:2:9 title "v3_x"
+set output "RT1_03_y.eps"
+splot "< perl -ne \'print if s/DEAL:RT<2>.1.::value//;\' output" using 1:2:10 title "v3_y"
+set output "RT1_04_x.eps"
+splot "< perl -ne \'print if s/DEAL:RT<2>.1.::value//;\' output" using 1:2:11 title "v4_x"
+set output "RT1_04_y.eps"
+splot "< perl -ne \'print if s/DEAL:RT<2>.1.::value//;\' output" using 1:2:12 title "v4_y"
+set output "RT1_05_x.eps"
+splot "< perl -ne \'print if s/DEAL:RT<2>.1.::value//;\' output" using 1:2:13 title "v5_x"
+set output "RT1_05_y.eps"
+splot "< perl -ne \'print if s/DEAL:RT<2>.1.::value//;\' output" using 1:2:14 title "v5_y"
+set output "RT1_06_x.eps"
+splot "< perl -ne \'print if s/DEAL:RT<2>.1.::value//;\' output" using 1:2:15 title "v6_x"
+set output "RT1_06_y.eps"
+splot "< perl -ne \'print if s/DEAL:RT<2>.1.::value//;\' output" using 1:2:16 title "v6_y"
+set output "RT1_07_x.eps"
+splot "< perl -ne \'print if s/DEAL:RT<2>.1.::value//;\' output" using 1:2:17 title "v7_x"
+set output "RT1_07_y.eps"
+splot "< perl -ne \'print if s/DEAL:RT<2>.1.::value//;\' output" using 1:2:18 title "v7_y"
+set output "RT1_08_x.eps"
+splot "< perl -ne \'print if s/DEAL:RT<2>.1.::value//;\' output" using 1:2:19 title "v8_x"
+set output "RT1_08_y.eps"
+splot "< perl -ne \'print if s/DEAL:RT<2>.1.::value//;\' output" using 1:2:20 title "v8_y"
+set output "RT1_09_x.eps"
+splot "< perl -ne \'print if s/DEAL:RT<2>.1.::value//;\' output" using 1:2:21 title "v9_x"
+set output "RT1_09_y.eps"
+splot "< perl -ne \'print if s/DEAL:RT<2>.1.::value//;\' output" using 1:2:22 title "v9_y"
+set output "RT1_10_x.eps"
+splot "< perl -ne \'print if s/DEAL:RT<2>.1.::value//;\' output" using 1:2:23 title "v10_x"
+set output "RT1_10_y.eps"
+splot "< perl -ne \'print if s/DEAL:RT<2>.1.::value//;\' output" using 1:2:24 title "v10_y"
+set output "RT1_11_x.eps"
+splot "< perl -ne \'print if s/DEAL:RT<2>.1.::value//;\' output" using 1:2:25 title "v11_x"
+set output "RT1_11_y.eps"
+splot "< perl -ne \'print if s/DEAL:RT<2>.1.::value//;\' output" using 1:2:26 title "v11_y"
+# EOF