Loading...
Searching...
No Matches
Burgers.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ██╗████████╗██╗ ██╗ █████╗ ██████╗ █████╗ ███████╗██╗ ██╗
3 ██║╚══██╔══╝██║ ██║██╔══██╗██╔════╝██╔══██╗ ██╔════╝██║ ██║
4 ██║ ██║ ███████║███████║██║ ███████║█████╗█████╗ ██║ ██║
5 ██║ ██║ ██╔══██║██╔══██║██║ ██╔══██║╚════╝██╔══╝ ╚██╗ ██╔╝
6 ██║ ██║ ██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ╚████╔╝
7 ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═══╝
8
9 * In real Time Highly Advanced Computational Applications for Finite Volumes
10 * Copyright (C) 2017 by the ITHACA-FV authors
11-------------------------------------------------------------------------------
12
13 License
14 This file is part of ITHACA-FV
15
16 ITHACA-FV is free software: you can redistribute it and/or modify
17 it under the terms of the GNU Lesser General Public License as published by
18 the Free Software Foundation, either version 3 of the License, or
19 (at your option) any later version.
20
21 ITHACA-FV is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU Lesser General Public License for more details.
25
26 You should have received a copy of the GNU Lesser General Public License
27 along with ITHACA-FV. If not, see <http://www.gnu.org/licenses/>.
28
29\*---------------------------------------------------------------------------*/
30
33
34#include "Burgers.H"
35
36// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * //
37// Constructor
39
40Burgers::Burgers(int argc, char* argv[])
41 :
43{
44 _args = autoPtr<argList>
45 (
46 new argList(argc, argv)
47 );
48
49 if (!_args->checkRootCase())
50 {
51 Foam::FatalError.exit();
52 }
53
54 argList& args = _args();
55#include "createTime.H"
56#include "createMesh.H"
57 _simple = autoPtr<simpleControl>
58 (
59 new simpleControl
60 (
61 mesh
62 )
63 );
64 simpleControl& simple = _simple();
65#include "createFields.H"
66#include "createFvOptions.H"
67 ITHACAdict = new IOdictionary
68 (
69 IOobject
70 (
71 "ITHACAdict",
72 runTime.system(),
73 mesh,
74 IOobject::MUST_READ,
75 IOobject::NO_WRITE
76 )
77 );
82}
83
84void Burgers::truthSolve(word folder)
85{
86 Time& runTime = _runTime();
87 fvMesh& mesh = _mesh();
88 volVectorField& U = _U();
89 surfaceScalarField& phi = _phi();
90 fv::options& fvOptions = _fvOptions();
91 simpleControl& simple = _simple();
92 dimensionedScalar& nu = _nu();
93 counter = 1;
94 ITHACAstream::exportSolution(U, name(counter), folder + name(folderN));
95 counter++;
98
99 while (_simple().loop())
100 {
101 auto start = std::chrono::system_clock::now();
102 Info << "Time = " << _runTime().timeName() << nl << endl;
103
104 while (simple.correctNonOrthogonal())
105 {
106 solve
107 (
108 fvm::ddt(U)
109 + fvm::div(phi, U)
110 - fvm::laplacian(nu, U)
111 );
112 }
113
114 phi = linearInterpolate(U) & mesh.Sf();
115
116 auto end = std::chrono::system_clock::now();
117 auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(end - start);
118 Info << "Elapsed: " << elapsed.count() << " microseconds\n";
119
120 if (checkWrite(runTime))
121 {
122 ITHACAstream::exportSolution(U, name(counter), folder + name(folderN));
123 counter++;
124 Ufield.append(U.clone());
126 }
127 }
128
129 folderN++;
130}
131
133{
134 _U.clear();
135 _phi.clear();
136 _fvOptions.clear();
137 _nu.clear();
138 _transportProperties.clear();
139 argList& args = _args();
140 Time& runTime = _runTime();
141 runTime.setTime(0, 1);
142 Foam::fvMesh& mesh = _mesh();
143#include "createFields.H"
144#include "createFvOptions.H"
145}
Header file of the Burgers class.
Foam::fvMesh & mesh
Definition createMesh.H:47
Foam::Time & runTime
Definition createTime.H:33
TEqn solve()
autoPtr< fvMesh > _mesh
Mesh.
Definition Burgers.H:85
autoPtr< fv::options > _fvOptions
fvOptions
Definition Burgers.H:101
autoPtr< volVectorField > _U
Velocity field.
Definition Burgers.H:79
PtrList< volVectorField > Ufield
List of pointers used to form the velocity snapshots matrix.
Definition Burgers.H:73
autoPtr< dimensionedScalar > _nu
Definition Burgers.H:98
Burgers()
Null constructor.
Definition Burgers.C:38
ITHACAparameters * para
Definition Burgers.H:70
autoPtr< Time > _runTime
Time.
Definition Burgers.H:88
autoPtr< surfaceScalarField > _phi
Flux.
Definition Burgers.H:91
autoPtr< IOdictionary > _transportProperties
Definition Burgers.H:96
void restart()
Function to restart the fields of the Burgers problem.
Definition Burgers.C:132
autoPtr< simpleControl > _simple
simpleControl
Definition Burgers.H:104
static ITHACAparameters * getInstance()
Gets an instance of ITHACAparameters, to be used if the instance is already existing.
bool checkWrite(Time &timeObject)
Function to check if the solution must be exported.
scalar startTime
Start Time (initial time to start storing the snapshots)
void setTimes(Time &timeObject)
scalar writeEvery
Time step of the writing procedure.
scalar nextWrite
Auxiliary variable to store the next writing instant.
label counter
Counter used for the output of the full order solutions.
bool offline
Boolean variable, it is 1 if the Offline phase has already been computed, else 0.
label folderN
Counter to save intermediate steps in the correct folder, for unsteady and some stationary cases.
IOdictionary * ITHACAdict
dictionary to store input output infos
autoPtr< argList > _args
argList
bool podex
Boolean variable, it is 1 if the POD has already been computed, else 0.
void truthSolve()
Perform a TruthSolve.
dimensionedScalar & nu
void exportSolution(GeometricField< Type, PatchField, GeoMesh > &s, fileName subfolder, fileName folder, word fieldName)
Export a field to file in a certain folder and subfolder.
bool check_pod()
Check if the POD data folder "./ITHACAoutput/POD" exists.
bool check_off()
Check if the offline data folder "./ITHACAoutput/Offline" exists.
simpleControl simple(mesh)
surfaceScalarField & phi
volVectorField & U