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) 2019-2020 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
29 #include "Time.H"
30 #include "rawIOField.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 template<class Type>
36 Foam::turbulentDigitalFilterInletFvPatchVectorField::interpolateOrRead
37 (
38  const word& fieldName,
39  const dictionary& dict,
40  bool& interpolateField
41 ) const
42 {
43  if (dict.found(fieldName))
44  {
45  tmp<Field<Type>> tFld
46  (
47  new Field<Type>
48  (
49  fieldName,
50  dict,
51  this->patch().size()
52  )
53  );
54 
55  interpolateField = false;
56  return tFld;
57  }
58  else
59  {
60  interpolateField = true;
61  return interpolateBoundaryData<Type>(fieldName);
62  }
63 }
64 
65 
66 template<class Type>
68 Foam::turbulentDigitalFilterInletFvPatchVectorField::interpolateBoundaryData
69 (
70  const word& fieldName
71 ) const
72 {
73  const word& patchName = this->patch().name();
74 
75  // Reread values and interpolate
76  const fileName valsFile
77  (
78  this->db().time().globalPath()
79  /this->db().time().constant()
80  /"boundaryData"
81  /patchName
82  /"0"
83  /fieldName
84  );
85 
86  IOobject io
87  (
88  valsFile, // absolute path
89  this->db().time(),
90  IOobject::MUST_READ,
91  IOobject::NO_WRITE,
92  false, // no need to register
93  true // is global object (currently not used)
94  );
95 
96  const rawIOField<Type> vals(io, false);
97 
98 
99  Info<< "turbulentDigitalFilterInlet patch " << patchName
100  << ": Interpolating field " << fieldName
101  << " from " << valsFile << endl;
102 
103  return patchMapper().interpolate(vals);
104 }
105 
106 
107 template<class Form, class Type>
108 Form Foam::turbulentDigitalFilterInletFvPatchVectorField::randomSet
109 (
110  const label len
111 )
112 {
113  Form randomSet(len);
114 
115  std::generate
116  (
117  randomSet.begin(),
118  randomSet.end(),
119  [&]{return rndGen_.GaussNormal<Type>();}
120  );
121 
122  return randomSet;
123 }
124 
125 
126 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::Random::GaussNormal
Type GaussNormal()
Definition: RandomTemplates.C:49
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
rawIOField.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::rawIOField
Like IOField but falls back to raw IFstream if no header found. Optionally reads average value....
Definition: rawIOField.H:52
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
pointToPointPlanarInterpolation.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:123
Time.H
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
constant
constant condensation/saturation model.