OUForce.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2023 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 "OUForce.H"
27 #include "fvMatrices.H"
28 #include "fft.H"
29 #include "writeEk.H"
31 
32 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace fv
37 {
39 
41  (
42  fvModel,
43  OUForce,
45  );
46 }
47 }
48 
49 
50 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
51 
52 void Foam::fv::OUForce::readCoeffs()
53 {
54  UName_ = coeffs().lookupOrDefault<word>("U", "U");
55 }
56 
57 
58 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
59 
61 (
62  const word& name,
63  const word& modelType,
64  const fvMesh& mesh,
65  const dictionary& dict
66 )
67 :
68  fvModel(name, modelType, mesh, dict),
69  UName_(word::null),
70  K_(mesh),
71  forceGen_(K_, mesh.time().deltaTValue(), dict)
72 {
73  readCoeffs();
74 }
75 
76 
77 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
78 
80 {
81  return wordList(1, UName_);
82 }
83 
84 
86 (
87  const volVectorField& field,
88  fvMatrix<vector>& eqn
89 ) const
90 {
92  (
93  IOobject
94  (
95  "OUForce",
96  mesh().time().name(),
97  mesh()
98  ),
99  mesh(),
101  ReImSum
102  (
104  (
105  (K_/(mag(K_) + 1.0e-6))
106  ^ forceGen_.newField(mesh().time().deltaTValue()), K_.nn()
107  )
108  )
109  );
110 }
111 
112 
114 {
115  return true;
116 }
117 
118 
120 {}
121 
122 
124 {}
125 
126 
128 {}
129 
130 
132 {
133  if (fvModel::read(dict))
134  {
135  readCoeffs();
136  return true;
137  }
138  else
139  {
140  return false;
141  }
142 }
143 
144 
145 bool Foam::fv::OUForce::write(const bool write) const
146 {
147  const volVectorField& U = mesh().lookupObject<volVectorField>(UName_);
148  writeEk(U, K_);
149 
150  return true;
151 }
152 
153 
154 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Generic GeometricField class.
DimensionedField< Type, GeoMesh > Internal
Type of the internal field from which this GeometricField is derived.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T, if not found return the given default.
static tmp< complexField > reverseTransform(const tmp< complexField > &field, const labelList &nn)
Definition: fft.C:203
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:99
Finite volume model abstract base class.
Definition: fvModel.H:59
const dictionary & coeffs() const
Return dictionary.
Definition: fvModelI.H:59
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: fvModel.C:199
Calculates and applies the random OU (Ornstein-Uhlenbeck) process force to the momentum equation for ...
Definition: OUForce.H:81
virtual bool movePoints()
Update for mesh motion.
Definition: OUForce.C:113
virtual wordList addSupFields() const
Return the list of fields for which the fvModel adds source term.
Definition: OUForce.C:79
virtual void addSup(const volVectorField &field, fvMatrix< vector > &eqn) const
Add explicit contribution to incompressible momentum equation.
Definition: OUForce.C:86
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
Definition: OUForce.C:119
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: OUForce.C:127
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: OUForce.C:131
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: OUForce.C:123
virtual bool write(const bool write=true) const
Write energy spectrum.
Definition: OUForce.C:145
OUForce(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from explicit source name and mesh.
Definition: OUForce.C:61
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for handling words, derived from string.
Definition: word.H:62
A special matrix type and solver, designed for finite volume solutions of scalar equations.
U
Definition: pEqn.H:72
addToRunTimeSelectionTable(fvConstraint, bound, dictionary)
defineTypeNameAndDebug(bound, 0)
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:54
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
const dimensionSet dimAcceleration
dimensioned< scalar > mag(const dimensioned< Type > &)
void writeEk(const volVectorField &U, const Kmesh &K)
Definition: writeEk.C:41
scalarField ReImSum(const UList< complex > &cf)
Definition: complexFields.C:84
labelList fv(nPoints)
dictionary dict
This function evaluates q(k) (McComb, p61) by summing all wavevectors in a k-shell....