createROMfields.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 -------------------------------------------------------------------------------
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 Application
27  createROMfields
28 
29 Group
30  grpPostProcessingUtilities
31 
32 Description
33  Create fields using reduced-order modelling (ROM) data
34  at specific time instants without requiring any CFD computations.
35 
36 Usage
37  Minimal example by using \c system/ROMfieldsDict:
38  \verbatim
39  // Mandatory entries
40  ROMmodel <word>;
41 
42  // Inherited entries
43  // See DMD.H for the 'DMD' ROMmodel
44  ...
45  \endverbatim
46 
47  where the entries mean:
48  \table
49  Property | Description | Type | Reqd | Deflt
50  ROMmodel | Type of reduced-order model | word | yes | -
51  \endtable
52 
53  Options for the \c ROMmodel entry:
54  \verbatim
55  DMD | Streaming total dynamic mode decomposition
56  \endverbatim
57 
58  The inherited entries are elaborated in:
59  - \link ROMmodel.H \endlink
60  - \link DMD.H \endlink
61 
62 Note
63  - The quality of results depends on the capabilities of the underlying
64  reduced-order model, and the quality of the input data.
65  - Warning: Reduced-order modelling is an active research area at the time of
66  writing; therefore, there could be cases whereat oddities can be seen.
67 
68 \*---------------------------------------------------------------------------*/
69 
70 #include "argList.H"
71 #include "timeSelector.H"
72 #include "fvCFD.H"
74 
75 using namespace Foam;
76 
77 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
78 
79 int main(int argc, char *argv[])
80 {
82  (
83  "Create fields using reduced-order modelling (ROM) data at specific "
84  "time instants without requiring any CFD computations."
85  );
86 
88  (
89  "dict",
90  "file",
91  "Alternative dictionary for ROMfieldsDict"
92  );
93 
94  // No -constant, no special treatment for 0/
96 
97  // Remove treatments unnecessary for this utility
99  argList::removeOption("noZero");
100  argList::removeOption("world");
101 
102 
103  #include "addRegionOption.H"
104 
105  #include "setRootCase.H"
106  #include "createTime.H"
107 
108  const word dictName("ROMfieldsDict");
110  Info<< "Reading " << dictIO.name() << nl << endl;
112 
114  if (times.empty())
115  {
117  << "No times selected." << nl
118  << exit(FatalError);
119  }
120 
121  #include "createNamedMesh.H"
122 
123  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124 
125  auto ROMptr = ROMmodel::New(runTime, mesh, dict, times);
126 
127  ROMptr->read(dict);
128 
129  ROMptr->createAndWrite();
130 
131 
132  Info<< nl;
134 
135  Info<< "End\n" << endl;
136 
137  return 0;
138 }
139 
140 
141 // ************************************************************************* //
dictionary dict
static void noFunctionObjects(bool addWithOption=false)
Remove &#39;-noFunctionObjects&#39; option and ignore any occurrences.
Definition: argList.C:547
static void addNote(const string &note)
Add extra notes for the usage information.
Definition: argList.C:462
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:608
static autoPtr< ROMmodel > New(Time &runTime, fvMesh &mesh, const dictionary &dict, const instantList &times)
Return a reference to the selected ROMmodel.
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:195
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
bool empty() const noexcept
True if List is empty (ie, size() is zero)
Definition: UList.H:675
const word dictName("faMeshDefinition")
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
Required Classes.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:50
static void removeOption(const word &optName)
Remove option from validOptions and from optionUsage.
Definition: argList.C:471
Required Classes.
dynamicFvMesh & mesh
A class for handling words, derived from Foam::string.
Definition: word.H:63
static void addOption(const word &optName, const string &param="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
Definition: argList.C:385
Ostream & printExecutionTime(OSstream &os) const
Print the elapsed ExecutionTime (cpu-time), ClockTime.
Definition: TimeIO.C:607
static instantList select0(Time &runTime, const argList &args)
Return the set of times selected based on the argList options and also set the runTime to the first i...
Definition: timeSelector.C:260
messageStream Info
Information stream (stdout output on master, null elsewhere)
IOobject dictIO
Foam::argList args(argc, argv)
static void addOptions(const bool constant=true, const bool withZero=false)
Add timeSelector options to argList::validOptions.
Definition: timeSelector.C:101
Namespace for OpenFOAM.