/
get_functions_gl.cc
90 lines (75 loc) · 3.27 KB
/
get_functions_gl.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// ---------------------------------------------------------------------
//
// Copyright (C) 2013 - 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.
//
// ---------------------------------------------------------------------
// this function tests the correctness of the implementation of matrix free
// operations in getting the function values, the function gradients, and the
// function Laplacians on a hyperball mesh for Gauss-Lobatto elements
// (identity values transformation). The test case includes hanging node
// constraints, but no constraints from boundary conditions
#include "../tests.h"
#include "get_functions_common.h"
template <int dim, int fe_degree>
void
test()
{
typedef double number;
const SphericalManifold<dim> manifold;
Triangulation<dim> tria;
GridGenerator::hyper_ball(tria);
typename Triangulation<dim>::active_cell_iterator cell = tria.begin_active(),
endc = tria.end();
for (; cell != endc; ++cell)
for (const unsigned int f : GeometryInfo<dim>::face_indices())
if (cell->at_boundary(f))
cell->face(f)->set_all_manifold_ids(0);
tria.set_manifold(0, manifold);
// refine first and last cell
tria.begin(tria.n_levels() - 1)->set_refine_flag();
tria.last()->set_refine_flag();
tria.execute_coarsening_and_refinement();
tria.refine_global(4 - dim);
FE_Q<dim> fe(QGaussLobatto<1>(fe_degree + 1));
DoFHandler<dim> dof(tria);
dof.distribute_dofs(fe);
AffineConstraints<double> constraints;
DoFTools::make_hanging_node_constraints(dof, constraints);
constraints.close();
deallog << "Testing " << dof.get_fe().get_name() << std::endl;
// std::cout << "Number of cells: " <<
// dof.get_triangulation().n_active_cells()
// << std::endl;
// std::cout << "Number of degrees of freedom: " << dof.n_dofs() << std::endl;
// std::cout << "Number of constraints: " << constraints.n_constraints() <<
// std::endl;
Vector<number> solution(dof.n_dofs());
// create vector with random entries
for (unsigned int i = 0; i < dof.n_dofs(); ++i)
{
if (constraints.is_constrained(i))
continue;
const double entry = random_value<double>();
solution(i) = entry;
}
constraints.distribute(solution);
MatrixFree<dim, number> mf_data;
deallog << "Test with fe_degree " << fe_degree << std::endl;
const QGaussLobatto<1> quad(fe_degree + 1);
MappingQ<dim> mapping(2);
typename MatrixFree<dim, number>::AdditionalData data;
data.tasks_parallel_scheme = MatrixFree<dim, number>::AdditionalData::none;
data.mapping_update_flags = update_gradients | update_hessians;
mf_data.reinit(mapping, dof, constraints, quad, data);
MatrixFreeTest<dim, fe_degree, fe_degree + 1, number> mf(mf_data, mapping);
mf.test_functions(solution);
}