DOLFIN
DOLFIN C++ interface
Toggle main menu visibility
Loading...
Searching...
No Matches
dolfin
function
LagrangeInterpolator.h
1
// Copyright (C) 2014 Mikael Mortensen
2
//
3
// This file is part of DOLFIN.
4
//
5
// DOLFIN is free software: you can redistribute it and/or modify
6
// it under the terms of the GNU Lesser General Public License as published by
7
// the Free Software Foundation, either version 3 of the License, or
8
// (at your option) any later version.
9
//
10
// DOLFIN is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU Lesser General Public License for more details.
14
//
15
// You should have received a copy of the GNU Lesser General Public License
16
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17
18
#ifndef __LAGRANGE_INTERPOLATOR_H
19
#define __LAGRANGE_INTERPOLATOR_H
20
21
#include <algorithm>
22
#include <map>
23
#include <unordered_map>
24
#include <vector>
25
26
namespace
dolfin
27
{
28
29
class
Expression
;
30
class
Function
;
31
class
FunctionSpace
;
32
class
GenericDofMap
;
33
class
Mesh
;
34
37
38
class
LagrangeInterpolator
39
{
40
public
:
41
49
static
void
interpolate
(
Function
& u,
const
Expression
& u0);
50
58
static
void
interpolate
(
Function
& u,
const
Function
& u0);
59
60
private
:
61
62
// Comparison operator for hashing coordinates. Note that two
63
// coordinates are considered equal if equal to within specified
64
// tolerance.
65
struct
lt_coordinate
66
{
67
lt_coordinate(
double
tolerance) : TOL(tolerance) {}
68
69
bool
operator() (
const
std::vector<double>& x,
70
const
std::vector<double>& y)
const
71
{
72
const
std::size_t n = std::max(x.size(), y.size());
73
for
(std::size_t i = 0; i < n; ++i)
74
{
75
double
xx = 0.0;
76
double
yy = 0.0;
77
if
(i < x.size())
78
xx = x[i];
79
if
(i < y.size())
80
yy = y[i];
81
82
if
(xx < (yy - TOL))
83
return
true
;
84
else
if
(xx > (yy + TOL))
85
return
false
;
86
}
87
return
false
;
88
}
89
90
// Tolerance
91
const
double
TOL;
92
};
93
94
// Create a map from coordinates to a list of dofs that share the
95
// coordinate
96
static
std::map<std::vector<double>, std::vector<std::size_t>,
97
lt_coordinate>
98
tabulate_coordinates_to_dofs(
const
FunctionSpace
& V);
99
100
// Create a map from dof to its component index in Mixed Space
101
static
void
extract_dof_component_map(std::unordered_map<std::size_t,
102
std::size_t>& dof_component_map,
103
const
FunctionSpace
& V,
104
int
* component);
105
106
// Return true if point lies within bounding box
107
static
bool
in_bounding_box(
const
std::vector<double>& point,
108
const
std::vector<double>& bounding_box,
109
const
double
tol);
110
111
};
112
113
}
114
115
#endif
dolfin::Expression
Definition
Expression.h:50
dolfin::FunctionSpace
Definition
FunctionSpace.h:54
dolfin::Function
Definition
Function.h:66
dolfin::GenericDofMap
This class provides a generic interface for dof maps.
Definition
GenericDofMap.h:50
dolfin::LagrangeInterpolator
Definition
LagrangeInterpolator.h:39
dolfin::LagrangeInterpolator::interpolate
static void interpolate(Function &u, const Expression &u0)
Definition
LagrangeInterpolator.cpp:34
dolfin::Mesh
Definition
Mesh.h:83
dolfin
Definition
adapt.h:30
Generated by
1.17.0