turbulentDigitalFilterInletFvPatchVectorFieldTemplates.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2015 OpenFOAM Foundation
9  Copyright (C) 2016 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
30 #include "Time.H"
31 #include "IFstream.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 template<class Type>
37 Foam::turbulentDigitalFilterInletFvPatchVectorField::interpolateOrRead
38 (
39  const word& fieldName,
40  const dictionary& dict,
41  bool& interpolateField
42 ) const
43 {
44  if (dict.found(fieldName))
45  {
46  tmp<Field<Type>> tFld
47  (
48  new Field<Type>
49  (
50  fieldName,
51  dict,
52  this->patch().size()
53  )
54  );
55 
56  interpolateField = false;
57  return tFld;
58  }
59  else
60  {
61  interpolateField = true;
62  return interpolateBoundaryData<Type>(fieldName);
63  }
64 }
65 
66 
67 template<class Type>
69 Foam::turbulentDigitalFilterInletFvPatchVectorField::interpolateBoundaryData
70 (
71  const word& fieldName
72 ) const
73 {
74  const word& patchName = this->patch().name();
75 
76  fileName valsFile
77  (
78  fileHandler().filePath
79  (
80  fileName
81  (
82  this->db().time().path()
83  /this->db().time().caseConstant()
84  /"boundaryData"
85  /patchName
86  /"0"
87  /fieldName
88  )
89  )
90  );
91 
92  autoPtr<ISstream> isPtr
93  (
94  fileHandler().NewIFstream
95  (
96  valsFile
97  )
98  );
99 
100  Field<Type> vals(isPtr());
101 
102  Info<< "Turbulent DFM/FSM patch " << patchName
103  << ": Interpolating field " << fieldName
104  << " from " << valsFile << endl;
105 
106  return patchMapper().interpolate(vals);
107 }
108 
109 
110 template<class Form, class Type>
111 Form Foam::turbulentDigitalFilterInletFvPatchVectorField::generateRandomSet
112 (
113  const label len
114 )
115 {
116  Form randomSet(len);
117 
118  std::generate
119  (
120  randomSet.begin(),
121  randomSet.end(),
122  [&]{return rndGen_.GaussNormal<Type>();}
123  );
124 
125  return randomSet;
126 }
127 
128 // ************************************************************************* //
Foam::Random::GaussNormal
Type GaussNormal()
Definition: RandomTemplates.C:49
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::fileHandler
const fileOperation & fileHandler()
Get current file handler.
Definition: fileOperation.C:1181
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
pointToPointPlanarInterpolation.H
IFstream.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Time.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
path
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())