Loading...
Searching...
No Matches
DMDImpl.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) 2023 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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
28#include "volFields.H"
29#include "surfaceFields.H"
31
32// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33
34template<class GeoType>
35bool Foam::ROMmodels::DMD::createAndWriteImpl() const
36{
37 typedef typename GeoType::value_type Type;
38
39 const wordList modeReNames(modeNames(word("Re")));
40 const wordList modeImNames(modeNames(word("Im")));
41
42 for (const label i : modes_)
43 {
44 const auto* modeRePtr = mesh_.cfindObject<GeoType>(modeReNames[i]);
45
46 if (!modeRePtr) return false;
47
48 const auto* modeImPtr = mesh_.cfindObject<GeoType>(modeImNames[i]);
49
50 if (!modeImPtr) return false;
51 }
52
53
54 forAll(times_, timei)
55 {
56 runTime_.setTime(times_[timei], timei);
57
58 Info<< "\nTime = " << runTime_.timeName() << endl;
59
60 // Calculate the eigenvalue exponent corresponding to specified time
61 const scalar k = (times_[timei].value() - startTime_)/deltaT_;
62
63 GeoType reconstructedFld
64 (
65 IOobject
66 (
67 IOobject::scopedName(fieldName_, "reconstructed"),
68 runTime_.timeName(),
69 mesh_,
73 ),
74 mesh_,
75 dimensioned<Type>(dimless, Zero),
77 );
78
79 forAll(modes_, i)
80 {
81 const label j = modes_[i];
82 const auto& modeRe = mesh_.lookupObject<GeoType>(modeReNames[j]);
83 const auto& modeIm = mesh_.lookupObject<GeoType>(modeImNames[j]);
84
85 const complex evalk(pow(evals_[i], k));
86
87 // (K:Eq. 84)
88 reconstructedFld +=
89 (
90 (modeRe*amps_[i].Re() - modeIm*amps_[i].Im())*evalk.Re()
91 - (modeRe*amps_[i].Im() + modeIm*amps_[i].Re())*evalk.Im()
92 );
93 }
94
95 reconstructedFld.correctBoundaryConditions();
96
97 reconstructedFld.dimensions().reset(dims_);
98
99 reconstructedFld.write();
100 }
101
102 return true;
103}
104
105
106// ************************************************************************* //
label k
@ NO_REGISTER
Do not request registration (bool: false).
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
static word scopedName(const std::string &scope, const word &name)
Create scope:name or scope_name string.
Definition IOobjectI.H:50
const instantList & times_
Const reference to field times.
Definition ROMmodel.H:91
Time & runTime_
Reference to the Time.
Definition ROMmodel.H:74
fvMesh & mesh_
Reference to the fvMesh.
Definition ROMmodel.H:81
static const word & zeroGradientType() noexcept
The type name for zeroGradient patch fields.
@ complex
Definition Roots.H:55
List< word > wordList
List of word.
Definition fileName.H:60
const dimensionSet dimless
Dimensionless.
scalarField Im(const UList< complex > &cmplx)
Extract imag component.
messageStream Info
Information stream (stdout output on master, null elsewhere).
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299
Foam::surfaceFields.