LifeV
GradientRecovery.hpp
Go to the documentation of this file.
1
//@HEADER
2
/*
3
*******************************************************************************
4
5
Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6
Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
7
8
This file is part of LifeV.
9
10
LifeV is free software; you can redistribute it and/or modify
11
it under the terms of the GNU Lesser General Public License as published by
12
the Free Software Foundation, either version 3 of the License, or
13
(at your option) any later version.
14
15
LifeV is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
Lesser General Public License for more details.
19
20
You should have received a copy of the GNU Lesser General Public License
21
along with LifeV. If not, see <http://www.gnu.org/licenses/>.
22
23
*******************************************************************************
24
*/
25
//@HEADER
26
27
/*!
28
@file
29
@brief This file contains the definition of the methods for gradient recovery procedures
30
31
@author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
32
@date 10 Jan 2012
33
*/
34
35
#
ifndef
GRADIENT_RECOVERY_HPP
36
#
define
GRADIENT_RECOVERY_HPP
1
37
38
#
include
<
lifev
/
core
/
LifeV
.
hpp
>
39
40
#
include
<
lifev
/
core
/
fem
/
CurrentFE
.
hpp
>
41
42
#
include
<
lifev
/
core
/
fem
/
QuadratureRule
.
hpp
>
43
#
include
<
lifev
/
core
/
fem
/
ReferenceElement
.
hpp
>
44
45
#
include
<
boost
/
shared_ptr
.
hpp
>
46
47
namespace
LifeV
48
{
49
50
namespace
GradientRecovery
51
{
52
53
/*! Gradient recovery procedure from Zienkiewicz and Zhu.
54
55
@param fespace The finite element space describing the data
56
@param inputData The vector of data (pass it as repeated if possible)
57
@param dxi The component to be recovered
58
@return recovered gradient (unique map!)
59
60
*/
61
template
<
typename
FESpaceType
,
typename
VectorType
>
62
VectorType
ZZGradient
(
std
::
shared_ptr
<
FESpaceType
>
fespace
,
63
const
VectorType
&
inputData
,
64
const
UInt
&
dxi
)
65
{
66
// Repeated vector is needed
67
if
(
inputData
.
mapType
() !=
Repeated
)
68
{
69
return
ZZGradient
(
fespace
,
VectorType
(
inputData
,
Repeated
),
dxi
);
70
};
71
72
// Get the area of the reference element
73
Real
refElemArea
(0);
74
75
switch
(
fespace
->
refFE
().
shape
() )
76
{
77
case
TETRA
:
78
refElemArea
= 1.0 / 6.0;
79
break
;
80
case
PRISM
:
81
refElemArea
= 1.0 / 2.0;
82
break
;
83
case
HEXA
:
84
refElemArea
= 1.0;
85
break
;
86
case
QUAD
:
87
refElemArea
= 1.0;
88
break
;
89
case
TRIANGLE
:
90
refElemArea
= 1.0 / 2.0;
91
break
;
92
case
LINE
:
93
refElemArea
= 1.0;
94
break
;
95
case
POINT
:
96
refElemArea
= 1.0;
// Makes things consistent afterwards
97
break
;
98
default
:
99
std
::
cerr
<<
"ZZ Gradient Recovery: unknown shape! Aborting. "
<<
std
::
endl
;
100
std
::
abort
();
101
}
102
103
// Define the specific QR to be used
104
// so that values in the QR correspond to
105
// the values in the nodes
106
107
QuadratureRule
interpQuad
;
108
interpQuad
.
setDimensionShape
(
shapeDimension
(
fespace
->
refFE
().
shape
() ) ,
fespace
->
refFE
().
shape
() );
109
110
Real
wQuad
(
refElemArea
/
fespace
->
refFE
().
nbDof
() );
111
112
for
(
UInt
iQuadPt
(0);
iQuadPt
<
fespace
->
refFE
().
nbDof
(); ++
iQuadPt
)
113
{
114
interpQuad
.
addPoint
(
QuadraturePoint
(
fespace
->
refFE
().
xi
(
iQuadPt
),
115
fespace
->
refFE
().
eta
(
iQuadPt
),
116
fespace
->
refFE
().
zeta
(
iQuadPt
),
117
wQuad
) );
118
}
119
120
// Initialization of the two vectors
121
122
VectorType
patchArea
(
inputData
,
Repeated
);
123
patchArea
*= 0.0;
124
125
VectorType
gradientSum
(
inputData
,
Repeated
);
126
gradientSum
*= 0.0;
127
128
// Build the structure and the constants
129
130
CurrentFE
interpCFE
(
fespace
->
refFE
(),
getGeometricMap
(*
fespace
->
mesh
() ),
interpQuad
);
131
132
const
UInt
nbElement
(
fespace
->
mesh
()->
numElements
() );
133
const
UInt
nbLocalDof
(
fespace
->
dof
().
numLocalDof
() );
134
135
// Now loop over the elements
136
137
for
(
UInt
iElement
(0);
iElement
<
nbElement
; ++
iElement
)
138
{
139
interpCFE
.
update
(
fespace
->
mesh
()->
element
(
iElement
),
UPDATE_DPHI
|
UPDATE_WDET
);
140
141
for
(
UInt
iDof
(0);
iDof
<
nbLocalDof
; ++
iDof
)
142
{
143
for
(
UInt
iDim
(0);
iDim
<
fespace
->
fieldDim
(); ++
iDim
)
144
{
145
UInt
globaliDofID
(
fespace
->
dof
().
localToGlobalMap
(
iElement
,
iDof
)
146
+
iDim
*
fespace
->
dof
().
numTotalDof
() );
147
148
patchArea
[
globaliDofID
] +=
interpCFE
.
measure
();
149
150
for
(
UInt
jDof
(0);
jDof
<
nbLocalDof
; ++
jDof
)
151
{
152
UInt
globaljDofID
(
fespace
->
dof
().
localToGlobalMap
(
iElement
,
jDof
)
153
+
iDim
*
fespace
->
dof
().
numTotalDof
() );
154
155
gradientSum
[
globaliDofID
] +=
interpCFE
.
measure
()
156
*
inputData
[
globaljDofID
]
157
*
interpCFE
.
dphi
(
jDof
,
dxi
,
iDof
);
158
}
159
}
160
}
161
}
162
163
// Assembly
164
165
return
VectorType
(
gradientSum
,
Unique
,
Add
) /
VectorType
(
patchArea
,
Unique
,
Add
);
166
}
167
168
169
/*! Laplacian recovery following Zienkiewicz and Zhu.
170
171
@param fespace The finite element space describing the data
172
@param inputData The vector of data (pass it as repeated if possible)
173
@return recovered laplacian (unique map!)
174
175
*/
176
template
<
typename
FESpaceType
,
typename
VectorType
>
177
VectorType
ZZLaplacian
(
std
::
shared_ptr
<
FESpaceType
>
fespace
,
178
const
VectorType
&
inputData
)
179
{
180
// Need a repeated input
181
if
(
inputData
.
mapType
() !=
Repeated
)
182
{
183
return
ZZLaplacian
(
fespace
,
VectorType
(
inputData
,
Repeated
) );
184
}
185
186
VectorType
laplacian
(
inputData
,
Unique
);
187
laplacian
*= 0.0;
188
189
// Loop over the components
190
for
(
UInt
iDim
(0);
iDim
<
fespace
->
fieldDim
(); ++
iDim
)
191
{
192
laplacian
+=
ZZGradient
(
fespace
,
ZZGradient
(
fespace
,
inputData
,
iDim
) ,
iDim
);
193
}
194
195
return
laplacian
;
196
}
197
198
199
}
// Namespace GradientRecovery
200
201
}
// Namespace LifeV
202
203
#
endif
/* GRADIENTRECOVERY_H */
LifeV::GradientRecovery
Definition:
GradientRecovery.hpp:50
LifeV::GradientRecovery::ZZLaplacian
VectorType ZZLaplacian(std::shared_ptr< FESpaceType > fespace, const VectorType &inputData)
Definition:
GradientRecovery.hpp:177
LifeV::GradientRecovery::ZZGradient
VectorType ZZGradient(std::shared_ptr< FESpaceType > fespace, const VectorType &inputData, const UInt &dxi)
Definition:
GradientRecovery.hpp:62
lifev-release-doc
lifev
core
fem
GradientRecovery.hpp
Generated on Wed Mar 7 2018 19:44:19 for LifeV by
1.8.13