anisotropicFilter.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "anisotropicFilter.H"
29 #include "wallFvPatch.H"
30 #include "fvc.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(anisotropicFilter, 0);
37  addToRunTimeSelectionTable(LESfilter, anisotropicFilter, dictionary);
38 }
39 
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
44 (
45  const fvMesh& mesh,
46  scalar widthCoeff
47 )
48 :
49  LESfilter(mesh),
50  widthCoeff_(widthCoeff),
51  coeff_
52  (
53  IOobject
54  (
55  "anisotropicFilterCoeff",
56  mesh.time().timeName(),
57  mesh
58  ),
59  mesh,
60  dimensionedVector("zero", dimLength*dimLength, vector::zero),
61  calculatedFvPatchVectorField::typeName
62  )
63 {
64  for (direction d=0; d<vector::nComponents; d++)
65  {
66  coeff_.internalField().replace
67  (
68  d,
69  (1/widthCoeff_)*
70  sqr
71  (
72  2.0*mesh.V()
73  /fvc::surfaceSum(mag(mesh.Sf().component(d)))().internalField()
74  )
75  );
76  }
77 }
78 
79 
81 (
82  const fvMesh& mesh,
83  const dictionary& bd
84 )
85 :
86  LESfilter(mesh),
87  widthCoeff_(readScalar(bd.subDict(type() + "Coeffs").lookup("widthCoeff"))),
88  coeff_
89  (
90  IOobject
91  (
92  "anisotropicFilterCoeff",
93  mesh.time().timeName(),
94  mesh
95  ),
96  mesh,
97  dimensionedVector("zero", dimLength*dimLength, vector::zero),
98  calculatedFvPatchScalarField::typeName
99  )
100 {
101  for (direction d=0; d<vector::nComponents; d++)
102  {
103  coeff_.internalField().replace
104  (
105  d,
106  (1/widthCoeff_)*
107  sqr
108  (
109  2.0*mesh.V()
110  /fvc::surfaceSum(mag(mesh.Sf().component(d)))().internalField()
111  )
112  );
113  }
114 }
115 
116 
117 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
118 
120 {
121  bd.subDict(type() + "Coeffs").lookup("widthCoeff") >> widthCoeff_;
122 }
123 
124 
125 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
126 
127 Foam::tmp<Foam::volScalarField> Foam::anisotropicFilter::operator()
128 (
129  const tmp<volScalarField>& unFilteredField
130 ) const
131 {
132  tmp<volScalarField> tmpFilteredField =
133  unFilteredField
134  + (
135  coeff_
137  (
138  mesh().Sf()
139  *fvc::snGrad(unFilteredField())
140  )
141  );
142 
143  unFilteredField.clear();
144 
145  return tmpFilteredField;
146 }
147 
148 
149 Foam::tmp<Foam::volVectorField> Foam::anisotropicFilter::operator()
150 (
151  const tmp<volVectorField>& unFilteredField
152 ) const
153 {
154  tmp<volVectorField> tmpFilteredField =
155  unFilteredField
156  + (
157  coeff_
159  (
160  mesh().Sf()
161  *fvc::snGrad(unFilteredField())
162  )
163  );
164 
165  unFilteredField.clear();
166 
167  return tmpFilteredField;
168 }
169 
170 
171 Foam::tmp<Foam::volSymmTensorField> Foam::anisotropicFilter::operator()
172 (
173  const tmp<volSymmTensorField>& unFilteredField
174 ) const
175 {
176  tmp<volSymmTensorField> tmpFilteredField
177  (
179  (
180  IOobject
181  (
182  "anisotropicFilteredSymmTensorField",
183  mesh().time().timeName(),
184  mesh()
185  ),
186  mesh(),
187  unFilteredField().dimensions()
188  )
189  );
190 
191  for (direction d=0; d<symmTensor::nComponents; d++)
192  {
193  tmpFilteredField().replace
194  (
195  d, anisotropicFilter::operator()(unFilteredField().component(d))
196  );
197  }
198 
199  unFilteredField.clear();
200 
201  return tmpFilteredField;
202 }
203 
204 
205 Foam::tmp<Foam::volTensorField> Foam::anisotropicFilter::operator()
206 (
207  const tmp<volTensorField>& unFilteredField
208 ) const
209 {
210  tmp<volTensorField> tmpFilteredField
211  (
212  new volTensorField
213  (
214  IOobject
215  (
216  "anisotropicFilteredTensorField",
217  mesh().time().timeName(),
218  mesh()
219  ),
220  mesh(),
221  unFilteredField().dimensions()
222  )
223  );
224 
225  for (direction d=0; d<tensor::nComponents; d++)
226  {
227  tmpFilteredField().replace
228  (
229  d, anisotropicFilter::operator()(unFilteredField().component(d))
230  );
231  }
232 
233  unFilteredField.clear();
234 
235  return tmpFilteredField;
236 }
237 
238 
239 // ************************************************************************* //
Foam::fvc::snGrad
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > snGrad(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvcSnGrad.C:45
Foam::fvc::surfaceSum
tmp< GeometricField< Type, fvPatchField, volMesh > > surfaceSum(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcSurfaceIntegrate.C:138
Foam::volTensorField
GeometricField< tensor, fvPatchField, volMesh > volTensorField
Definition: volFieldsFwd.H:59
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::component
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
Definition: FieldFieldFunctions.C:41
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
Foam::anisotropicFilter::widthCoeff_
scalar widthCoeff_
Definition: anisotropicFilter.H:62
wallFvPatch.H
Foam::VectorSpace< SymmTensor< scalar >, scalar, 6 >::nComponents
@ nComponents
Number of components in this vector space.
Definition: VectorSpace.H:88
Foam::anisotropicFilter::anisotropicFilter
anisotropicFilter(const anisotropicFilter &)
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
anisotropicFilter.H
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::LESfilter
Abstract class for LES filters.
Definition: LESfilter.H:54
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:41
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
readScalar
#define readScalar
Definition: doubleScalar.C:38
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:49
Foam::fvc::surfaceIntegrate
void surfaceIntegrate(Field< Type > &ivf, const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcSurfaceIntegrate.C:44
timeName
word timeName
Definition: getTimeIndex.H:3
Foam::direction
unsigned char direction
Definition: direction.H:43
fvc.H
Foam::type
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:588
Foam::dictionary::subDict
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:631
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::anisotropicFilter::read
virtual void read(const dictionary &)
Read the LESfilter dictionary.
Definition: anisotropicFilter.C:119
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::tmp::clear
void clear() const
If object pointer points to valid object:
Definition: tmpI.H:172
zeroGradientFvPatchFields.H
lookup
stressControl lookup("compactNormalStress") >> compactNormalStress