Loading...
Searching...
No Matches
usmsrProblem.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#include "usmsrProblem.H"
31// Construct Null
33
34usmsrProblem::usmsrProblem(int argc, char* argv[])
35{
36#include "setRootCase.H"
37#include "createTime.H"
38#include "createMesh.H"
39 _pimple = autoPtr<pimpleControl>
40 (
41 new pimpleControl
42 (
43 mesh
44 )
45 );
46 _npimple = autoPtr<pimpleControl>
47 (
48 new pimpleControl
49 (
50 mesh,
51 "NPIMPLE"
52 )
53 );
54#include "createFields.H"
57#include "createConstants.H"
58#include "createFvOptions.H"
61}
62
63void usmsrProblem::truthSolve(List<scalar> mu_now)
64{
65 label cc_p = 0;
66 Time& runTime = _runTime();
67 fvMesh& mesh = _mesh();
68#include "initContinuityErrs.H"
69 volScalarField& p = _p();
70 volVectorField& U = _U();
71 surfaceScalarField& phi = _phi();
72 fv::options& fvOptions = _fvOptions();
73 pimpleControl& pimple = _pimple();
74 pimpleControl& npimple = _npimple();
75 IOMRFZoneList& MRF = _MRF();
76 singlePhaseTransportModel& laminarTransport = _laminarTransport();
77 dimensionedScalar& IV1 = _IV1();
78 dimensionedScalar& Keff = _Keff();
79 volScalarField& flux = _flux();
80 volScalarField flux_old = _flux();
81 dimensionedScalar& betaTot = _betaTot();
82 volScalarField& SP = _SP();
83 dimensionedScalar& SP1_0 = _SP1_0();
84 dimensionedScalar& alfa_SP1 = _alfa_SP1();
85 volScalarField& D = _D();
86 dimensionedScalar& D1_0 = _D1_0();
87 dimensionedScalar& alfa_D1 = _alfa_D1();
88 volScalarField& NSF = _NSF();
89 dimensionedScalar& NSF1_0 = _NSF1_0();
90 dimensionedScalar& alfa_NSF1 = _alfa_NSF1();
91 volScalarField& A = _A();
92 dimensionedScalar& A1_0 = _A1_0();
93 dimensionedScalar& alfa_A1 = _alfa_A1();
94 volScalarField& prec1 = _prec1();
95 dimensionedScalar& Sc = _Sc();
96 dimensionedScalar& Sct = _Sct();
97 dimensionedScalar& lam1 = _lam1();
98 dimensionedScalar& beta1 = _beta1();
99 volScalarField& prec2 = _prec2();
100 dimensionedScalar& lam2 = _lam2();
101 dimensionedScalar& beta2 = _beta2();
102 volScalarField& prec3 = _prec3();
103 dimensionedScalar& lam3 = _lam3();
104 dimensionedScalar& beta3 = _beta3();
105 volScalarField& prec4 = _prec4();
106 dimensionedScalar& lam4 = _lam4();
107 dimensionedScalar& beta4 = _beta4();
108 volScalarField& prec5 = _prec5();
109 dimensionedScalar& lam5 = _lam5();
110 dimensionedScalar& beta5 = _beta5();
111 volScalarField& prec6 = _prec6();
112 dimensionedScalar& lam6 = _lam6();
113 dimensionedScalar& beta6 = _beta6();
114 volScalarField& prec7 = _prec7();
115 dimensionedScalar& lam7 = _lam7();
116 dimensionedScalar& beta7 = _beta7();
117 volScalarField& prec8 = _prec8();
118 dimensionedScalar& lam8 = _lam8();
119 dimensionedScalar& beta8 = _beta8();
120 volScalarField& T = _T();
121 dimensionedScalar& Pr = _Pr();
122 dimensionedScalar& Prt = _Prt();
123 volScalarField& dec1 = _dec1();
124 dimensionedScalar& decLam1 = _decLam1();
125 dimensionedScalar& decBeta1 = _decBeta1();
126 volScalarField& dec2 = _dec2();
127 dimensionedScalar& decLam2 = _decLam2();
128 dimensionedScalar& decBeta2 = _decBeta2();
129 volScalarField& dec3 = _dec3();
130 dimensionedScalar& decLam3 = _decLam3();
131 dimensionedScalar& decBeta3 = _decBeta3();
132 dimensionedScalar& decbetaTot = _decbetaTot();
133 dimensionedScalar& rhoRef = _rhoRef();
134 dimensionedScalar& CpRef = _CpRef();
135 volScalarField v = _v();
136 volScalarField TXS = _TXS();
137 dimensionedScalar& nu = _nu();
138 dimensionedScalar& betaTE = _betaTE();
139 dimensionedScalar& Tref = _Tref();
140 dimensionedScalar& TrefXS = _TrefXS();
141 volScalarField& logT = _logT();
142 volScalarField& alphat = _alphat();
143 volScalarField& difft = _difft();
144 dimensionedScalar& tau = _tau();
145 volScalarField powerDens = ((1 - decbetaTot) * flux * SP +
146 (decLam1 * dec1 + decLam2 * dec2 + decLam3 * dec3)).ref();
147 powerDens.rename("powerDens");
149 startTime = para->ITHACAdict->lookupOrDefault("startTime", 0);
150 finalTime = para->ITHACAdict->lookupOrDefault("finalTime", 1);
151 timeStep = para->ITHACAdict->lookupOrDefault("timeStep", 0.1);
152 writeEvery = para->ITHACAdict->lookupOrDefault("writeEvery", 0.1);
153 instantList Times = runTime.times();
154 runTime.setEndTime(finalTime);
155 runTime.setTime(Times[1], 1);
156 runTime.setDeltaT(timeStep);
158 label Ntau = static_cast<int> (tau.value() / timeStep);
159 label Ntot = static_cast<int> (finalTime / timeStep);
160 bc_prec.resize(8, Ntot + 1);
161 bool flagBC = false;
162 label nsnapshots = 0;
163
164 while (runTime.run())
165 {
166#include "readTimeControls.H"
167#include "CourantNo.H"
168#include "setDeltaT.H"
169 runTime.setEndTime(finalTime + timeStep);
170 Info << "Time = " << runTime.timeName() << nl << endl;
171
172 while (pimple.loop())
173 {
174#include "UEqn.H"
175#include "TEqn.H"
176
177 // --- Pressure corrector loop
178 while (pimple.correct())
179 {
180#include "pEqn.H"
181 }
182
183 if (pimple.turbCorr())
184 {
185 laminarTransport.correct();
186 turbulence->correct();
187 }
188 }
189
190 flux_old = flux;
191
192 while (npimple.loop())
193 {
194#include "updateConsts.H"
195#include "DiffEqn.H"
196#include "precEqns.H"
197#include "TEqn.H"
198#include "decEqns.H"
199 }
200
201#include "updateK.H"
202 Info << "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
203 << " ClockTime = " << runTime.elapsedClockTime() << " s"
204 << nl << endl;
205 powerDens = (1 - decbetaTot) * flux * SP + (decLam1 * dec1 + decLam2 * dec2 +
206 decLam3 * dec3);
207
208 if (checkWrite(runTime))
209 {
210 nsnapshots += 1;
211 ITHACAstream::exportSolution(U, name(counter), "./ITHACAoutput/Offline/");
212 ITHACAstream::exportSolution(p, name(counter), "./ITHACAoutput/Offline/");
213 ITHACAstream::exportSolution(flux, name(counter), "./ITHACAoutput/Offline/");
214 ITHACAstream::exportSolution(prec1, name(counter), "./ITHACAoutput/Offline/");
215 ITHACAstream::exportSolution(prec2, name(counter), "./ITHACAoutput/Offline/");
216 ITHACAstream::exportSolution(prec3, name(counter), "./ITHACAoutput/Offline/");
217 ITHACAstream::exportSolution(prec4, name(counter), "./ITHACAoutput/Offline/");
218 ITHACAstream::exportSolution(prec5, name(counter), "./ITHACAoutput/Offline/");
219 ITHACAstream::exportSolution(prec6, name(counter), "./ITHACAoutput/Offline/");
220 ITHACAstream::exportSolution(prec7, name(counter), "./ITHACAoutput/Offline/");
221 ITHACAstream::exportSolution(prec8, name(counter), "./ITHACAoutput/Offline/");
222 ITHACAstream::exportSolution(T, name(counter), "./ITHACAoutput/Offline/");
223 ITHACAstream::exportSolution(dec1, name(counter), "./ITHACAoutput/Offline/");
224 ITHACAstream::exportSolution(dec2, name(counter), "./ITHACAoutput/Offline/");
225 ITHACAstream::exportSolution(dec3, name(counter), "./ITHACAoutput/Offline/");
227 "./ITHACAoutput/Offline/");
228 ITHACAstream::exportSolution(v, name(counter), "./ITHACAoutput/Offline/");
229 ITHACAstream::exportSolution(D, name(counter), "./ITHACAoutput/Offline/");
230 ITHACAstream::exportSolution(NSF, name(counter), "./ITHACAoutput/Offline/");
231 ITHACAstream::exportSolution(A, name(counter), "./ITHACAoutput/Offline/");
232 ITHACAstream::exportSolution(SP, name(counter), "./ITHACAoutput/Offline/");
233 ITHACAstream::exportSolution(TXS, name(counter), "./ITHACAoutput/Offline/");
234 std::ofstream of("./ITHACAoutput/Offline/" + name(counter) + "/" +
235 runTime.timeName());
236 std::ofstream ofk("./ITHACAoutput/Offline/" + name(counter) + "/" + name(
237 Keff.value()));
238 Ufield.append(U.clone());
239 Pfield.append(p.clone());
240 Fluxfield.append(flux.clone());
241 Prec1field.append(prec1.clone());
242 Prec2field.append(prec2.clone());
243 Prec3field.append(prec3.clone());
244 Prec4field.append(prec4.clone());
245 Prec5field.append(prec5.clone());
246 Prec6field.append(prec6.clone());
247 Prec7field.append(prec7.clone());
248 Prec8field.append(prec8.clone());
249 Tfield.append(T.clone());
250 Dec1field.append(dec1.clone());
251 Dec2field.append(dec2.clone());
252 Dec3field.append(dec3.clone());
253 PowerDensfield.append(powerDens.clone());
254 vFields.append(v.clone());
255 DFields.append(D.clone());
256 NSFFields.append(NSF.clone());
257 AFields.append(A.clone());
258 SPFields.append(SP.clone());
259 TXSFields.append(TXS.clone());
260 counter++;
262 writeMu(mu_now);
263 // --- Fill in the mu_samples with parameters (time, mu) to be used for the PODI sample points
264 mu_samples.conservativeResize(mu_samples.rows() + 1, mu_now.size() + 1);
265 mu_samples(mu_samples.rows() - 1, 0) = atof(runTime.timeName().c_str());
266
267 for (label i = 0; i < mu_now.size(); i++)
268 {
269 mu_samples(mu_samples.rows() - 1, i + 1) = mu_now[i];
270 }
271 }
272
273 if (precInBool == true)
274 {
275 computePrecsBC(cc_p);
276 }
277
278 if (runTime.value() >= tau.value() && precInBool == true)
279 {
280 if (flagBC == false)
281 {
282 flagBC = true;
284 }
285
286 assignPrecsBC(cc_p, Ntau);
287 }
288
289 cc_p++;
290 runTime++;
291 }
292
293 // Resize to Unitary if not initialized by user (i.e. non-parametric problem)
294 if (mu.cols() == 0)
295 {
296 mu.resize(1, 1);
297 }
298
299 if (mu_samples.rows() == nsnapshots * mu.cols())
300 {
301 ITHACAstream::exportMatrix(mu_samples, "mu_samples", "eigen",
302 "./ITHACAoutput/Offline");
303 }
304}
305
306
307bool usmsrProblem::checkWrite(Time& timeObject)
308{
309 scalar diffnow = mag(nextWrite - atof(timeObject.timeName().c_str()));
310 scalar diffnext = mag(nextWrite - atof(timeObject.timeName().c_str()) -
311 timeObject.deltaTValue());
312
313 if ( diffnow < diffnext)
314 {
315 return true;
316 }
317 else
318 {
319 return false;
320 }
321}
322
323
324
325void usmsrProblem::truthSolve(List<scalar> mu_now, std::string folder)
326{
327 mkDir(folder);
329 counter = 1;
330#include "initContinuityErrs.H"
331 label cc_p = 0;
332 Time& runTime = _runTime();
333 fvMesh& mesh = _mesh();
334 volScalarField& p = _p();
335 volVectorField& U = _U();
336 surfaceScalarField& phi = _phi();
337 fv::options& fvOptions = _fvOptions();
338 pimpleControl& pimple = _pimple();
339 pimpleControl& npimple = _npimple();
340 IOMRFZoneList& MRF = _MRF();
341 singlePhaseTransportModel& laminarTransport = _laminarTransport();
342 dimensionedScalar& IV1 = _IV1();
343 dimensionedScalar& Keff = _Keff();
344 volScalarField& flux = _flux();
345 volScalarField flux_old = _flux();
346 dimensionedScalar& betaTot = _betaTot();
347 volScalarField& SP = _SP();
348 dimensionedScalar& SP1_0 = _SP1_0();
349 dimensionedScalar& alfa_SP1 = _alfa_SP1();
350 volScalarField& D = _D();
351 dimensionedScalar& D1_0 = _D1_0();
352 dimensionedScalar& alfa_D1 = _alfa_D1();
353 volScalarField& NSF = _NSF();
354 dimensionedScalar& NSF1_0 = _NSF1_0();
355 dimensionedScalar& alfa_NSF1 = _alfa_NSF1();
356 volScalarField& A = _A();
357 dimensionedScalar& A1_0 = _A1_0();
358 dimensionedScalar& alfa_A1 = _alfa_A1();
359 volScalarField& prec1 = _prec1();
360 dimensionedScalar& Sc = _Sc();
361 dimensionedScalar& Sct = _Sct();
362 dimensionedScalar& lam1 = _lam1();
363 dimensionedScalar& beta1 = _beta1();
364 volScalarField& prec2 = _prec2();
365 dimensionedScalar& lam2 = _lam2();
366 dimensionedScalar& beta2 = _beta2();
367 volScalarField& prec3 = _prec3();
368 dimensionedScalar& lam3 = _lam3();
369 dimensionedScalar& beta3 = _beta3();
370 volScalarField& prec4 = _prec4();
371 dimensionedScalar& lam4 = _lam4();
372 dimensionedScalar& beta4 = _beta4();
373 volScalarField& prec5 = _prec5();
374 dimensionedScalar& lam5 = _lam5();
375 dimensionedScalar& beta5 = _beta5();
376 volScalarField& prec6 = _prec6();
377 dimensionedScalar& lam6 = _lam6();
378 dimensionedScalar& beta6 = _beta6();
379 volScalarField& prec7 = _prec7();
380 dimensionedScalar& lam7 = _lam7();
381 dimensionedScalar& beta7 = _beta7();
382 volScalarField& prec8 = _prec8();
383 dimensionedScalar& lam8 = _lam8();
384 dimensionedScalar& beta8 = _beta8();
385 volScalarField& T = _T();
386 dimensionedScalar& Pr = _Pr();
387 dimensionedScalar& Prt = _Prt();
388 volScalarField& dec1 = _dec1();
389 dimensionedScalar& decLam1 = _decLam1();
390 dimensionedScalar& decBeta1 = _decBeta1();
391 volScalarField& dec2 = _dec2();
392 dimensionedScalar& decLam2 = _decLam2();
393 dimensionedScalar& decBeta2 = _decBeta2();
394 volScalarField& dec3 = _dec3();
395 dimensionedScalar& decLam3 = _decLam3();
396 dimensionedScalar& decBeta3 = _decBeta3();
397 dimensionedScalar& decbetaTot = _decbetaTot();
398 dimensionedScalar& rhoRef = _rhoRef();
399 dimensionedScalar& CpRef = _CpRef();
400 volScalarField v = _v();
401 volScalarField TXS = _TXS();
402 dimensionedScalar& nu = _nu();
403 dimensionedScalar& betaTE = _betaTE();
404 dimensionedScalar& Tref = _Tref();
405 dimensionedScalar& TrefXS = _TrefXS();
406 volScalarField& logT = _logT();
407 volScalarField& alphat = _alphat();
408 volScalarField& difft = _difft();
409 volScalarField powerDens = ((1 - decbetaTot) * flux * SP +
410 (decLam1 * dec1 + decLam2 * dec2 + decLam3 * dec3)).ref();
411 powerDens.rename("powerDens");
412 dimensionedScalar& tau = _tau();
414 startTime = para->ITHACAdict->lookupOrDefault("startTime", 0);
415 finalTime = para->ITHACAdict->lookupOrDefault("finalTime", 1);
416 timeStep = para->ITHACAdict->lookupOrDefault("timeStep", 0.1);
417 writeEvery = para->ITHACAdict->lookupOrDefault("writeEvery", 0.1);
418 instantList Times = runTime.times();
419 runTime.setEndTime(finalTime);
420 runTime.setTime(Times[1], 1);
421 runTime.setDeltaT(timeStep);
423 label Ntau = static_cast<int> (tau.value() / timeStep);
424 label Ntot = static_cast<int> (finalTime / timeStep);
425 bc_prec.resize(8, Ntot + 1);
426 bool flagBC = false;
427 label nsnapshots = 0;
428
429 while (runTime.run())
430 {
431#include "readTimeControls.H"
432#include "CourantNo.H"
433#include "setDeltaT.H"
434 runTime.setEndTime(finalTime + timeStep);
435 Info << "Time = " << runTime.timeName() << nl << endl;
436
437 while (pimple.loop())
438 {
439#include "UEqn.H"
440#include "TEqn.H"
441
442 // --- Pressure corrector loop
443 while (pimple.correct())
444 {
445#include "pEqn.H"
446 }
447
448 if (pimple.turbCorr())
449 {
450 laminarTransport.correct();
451 turbulence->correct();
452 }
453 }
454
455 flux_old = flux;
456
457 while (npimple.loop())
458 {
459#include "updateConsts.H"
460#include "DiffEqn.H"
461#include "precEqns.H"
462#include "TEqn.H"
463#include "decEqns.H"
464 }
465
466#include "updateK.H"
467 Info << "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
468 << " ClockTime = " << runTime.elapsedClockTime() << " s"
469 << nl << endl;
470 powerDens = (1 - decbetaTot) * flux * SP + (decLam1 * dec1 + decLam2 * dec2 +
471 decLam3 * dec3);
472
473 if (checkWrite(runTime))
474 {
475 nsnapshots += 1;
476 ITHACAstream::exportSolution(U, name(counter), folder);
477 ITHACAstream::exportSolution(p, name(counter), folder);
487 ITHACAstream::exportSolution(T, name(counter), folder);
492 ITHACAstream::exportSolution(v, name(counter), folder);
493 ITHACAstream::exportSolution(D, name(counter), folder);
495 ITHACAstream::exportSolution(A, name(counter), folder);
498 std::ofstream of(folder + "/" + name(counter) + "/" + runTime.timeName());
499 std::ofstream ofk(folder + "/" + name(counter) + "/" + name(Keff.value()));
500 Ufield.append(U.clone());
501 Pfield.append(p.clone());
502 Fluxfield.append(flux.clone());
503 Prec1field.append(prec1.clone());
504 Prec2field.append(prec2.clone());
505 Prec3field.append(prec3.clone());
506 Prec4field.append(prec4.clone());
507 Prec5field.append(prec5.clone());
508 Prec6field.append(prec6.clone());
509 Prec7field.append(prec7.clone());
510 Prec8field.append(prec8.clone());
511 Tfield.append(T.clone());
512 Dec1field.append(dec1.clone());
513 Dec2field.append(dec2.clone());
514 Dec3field.append(dec3.clone());
515 PowerDensfield.append(powerDens.clone());
516 vFields.append(v.clone());
517 DFields.append(D.clone());
518 NSFFields.append(NSF.clone());
519 AFields.append(A.clone());
520 SPFields.append(SP.clone());
521 TXSFields.append(TXS.clone());;
522 counter++;
524 writeMu(mu_now);
525 // --- Fill in the mu_samples with parameters (time, mu) to be used for the PODI sample points
526 mu_samples.conservativeResize(mu_samples.rows() + 1, mu_now.size() + 1);
527 mu_samples(mu_samples.rows() - 1, 0) = atof(runTime.timeName().c_str());
528
529 for (label i = 0; i < mu_now.size(); i++)
530 {
531 mu_samples(mu_samples.rows() - 1, i + 1) = mu_now[i];
532 }
533 }
534
535 if (precInBool == true)
536 {
537 computePrecsBC(cc_p);
538 }
539
540 if (runTime.value() >= tau.value() && precInBool == true)
541 {
542 if (flagBC == false)
543 {
544 flagBC = true;
546 }
547
548 assignPrecsBC(cc_p, Ntau);
549 }
550
551 cc_p++;
552 runTime++;
553 }
554}
555
556
558{
559 fvMesh& mesh = _mesh();
560 volScalarField& prec1 = _prec1();
561 volScalarField& prec2 = _prec2();
562 volScalarField& prec3 = _prec3();
563 volScalarField& prec4 = _prec4();
564 volScalarField& prec5 = _prec5();
565 volScalarField& prec6 = _prec6();
566 volScalarField& prec7 = _prec7();
567 volScalarField& prec8 = _prec8();
568 prec1.boundaryFieldRef().set(precinIndex,
569 fvPatchField<scalar>::New("fixedValue", mesh.boundary()[precinIndex], prec1));
570 prec2.boundaryFieldRef().set(precinIndex,
571 fvPatchField<scalar>::New("fixedValue", mesh.boundary()[precinIndex], prec2));
572 prec3.boundaryFieldRef().set(precinIndex,
573 fvPatchField<scalar>::New("fixedValue", mesh.boundary()[precinIndex], prec3));
574 prec4.boundaryFieldRef().set(precinIndex,
575 fvPatchField<scalar>::New("fixedValue", mesh.boundary()[precinIndex], prec4));
576 prec5.boundaryFieldRef().set(precinIndex,
577 fvPatchField<scalar>::New("fixedValue", mesh.boundary()[precinIndex], prec5));
578 prec6.boundaryFieldRef().set(precinIndex,
579 fvPatchField<scalar>::New("fixedValue", mesh.boundary()[precinIndex], prec6));
580 prec7.boundaryFieldRef().set(precinIndex,
581 fvPatchField<scalar>::New("fixedValue", mesh.boundary()[precinIndex], prec7));
582 prec8.boundaryFieldRef().set(precinIndex,
583 fvPatchField<scalar>::New("fixedValue", mesh.boundary()[precinIndex], prec8));
584}
585
587{
588 fvMesh& mesh = _mesh();
589 volScalarField& prec1 = _prec1();
590 volScalarField& prec2 = _prec2();
591 volScalarField& prec3 = _prec3();
592 volScalarField& prec4 = _prec4();
593 volScalarField& prec5 = _prec5();
594 volScalarField& prec6 = _prec6();
595 volScalarField& prec7 = _prec7();
596 volScalarField& prec8 = _prec8();
597 dimensionedScalar& lam1 = _lam1();
598 dimensionedScalar& lam2 = _lam2();
599 dimensionedScalar& lam3 = _lam3();
600 dimensionedScalar& lam4 = _lam4();
601 dimensionedScalar& lam5 = _lam5();
602 dimensionedScalar& lam6 = _lam6();
603 dimensionedScalar& lam7 = _lam7();
604 dimensionedScalar& lam8 = _lam8();
605 dimensionedScalar& tau = _tau();
606 bc_prec(0, call) = gSum(prec1.boundaryField()[precoutIndex] *
607 mesh.magSf().boundaryField()[precoutIndex]) / gSum(
608 mesh.magSf().boundaryField()[precoutIndex]) * std::exp(-lam1.value() *
609 tau.value());
610 bc_prec(1, call) = gSum(prec2.boundaryField()[precoutIndex] *
611 mesh.magSf().boundaryField()[precoutIndex]) / gSum(
612 mesh.magSf().boundaryField()[precoutIndex]) * std::exp(-lam2.value() *
613 tau.value());
614 bc_prec(2, call) = gSum(prec3.boundaryField()[precoutIndex] *
615 mesh.magSf().boundaryField()[precoutIndex]) / gSum(
616 mesh.magSf().boundaryField()[precoutIndex]) * std::exp(-lam3.value() *
617 tau.value());
618 bc_prec(3, call) = gSum(prec4.boundaryField()[precoutIndex] *
619 mesh.magSf().boundaryField()[precoutIndex]) / gSum(
620 mesh.magSf().boundaryField()[precoutIndex]) * std::exp(-lam4.value() *
621 tau.value());
622 bc_prec(4, call) = gSum(prec5.boundaryField()[precoutIndex] *
623 mesh.magSf().boundaryField()[precoutIndex]) / gSum(
624 mesh.magSf().boundaryField()[precoutIndex]) * std::exp(-lam5.value() *
625 tau.value());
626 bc_prec(5, call) = gSum(prec6.boundaryField()[precoutIndex] *
627 mesh.magSf().boundaryField()[precoutIndex]) / gSum(
628 mesh.magSf().boundaryField()[precoutIndex]) * std::exp(-lam6.value() *
629 tau.value());
630 bc_prec(6, call) = gSum(prec7.boundaryField()[precoutIndex] *
631 mesh.magSf().boundaryField()[precoutIndex]) / gSum(
632 mesh.magSf().boundaryField()[precoutIndex]) * std::exp(-lam7.value() *
633 tau.value());
634 bc_prec(7, call) = gSum(prec8.boundaryField()[precoutIndex] *
635 mesh.magSf().boundaryField()[precoutIndex]) / gSum(
636 mesh.magSf().boundaryField()[precoutIndex]) * std::exp(-lam8.value() *
637 tau.value());
638}
639
640void usmsrProblem::assignPrecsBC(label call, label Ntau)
641{
642 volScalarField& prec1 = _prec1();
643 volScalarField& prec2 = _prec2();
644 volScalarField& prec3 = _prec3();
645 volScalarField& prec4 = _prec4();
646 volScalarField& prec5 = _prec5();
647 volScalarField& prec6 = _prec6();
648 volScalarField& prec7 = _prec7();
649 volScalarField& prec8 = _prec8();
650 assignBC(prec1, precinIndex, bc_prec(0, call - Ntau));
651 assignBC(prec2, precinIndex, bc_prec(1, call - Ntau));
652 assignBC(prec3, precinIndex, bc_prec(2, call - Ntau));
653 assignBC(prec4, precinIndex, bc_prec(3, call - Ntau));
654 assignBC(prec5, precinIndex, bc_prec(4, call - Ntau));
655 assignBC(prec6, precinIndex, bc_prec(5, call - Ntau));
656 assignBC(prec7, precinIndex, bc_prec(6, call - Ntau));
657 assignBC(prec8, precinIndex, bc_prec(7, call - Ntau));
658}
Foam::fvMesh & mesh
Definition createMesh.H:47
Foam::Time & runTime
Definition createTime.H:33
IOdictionary * ITHACAdict
Dictionary for input objects from file.
static ITHACAparameters * getInstance()
Gets an instance of ITHACAparameters, to be used if the instance is already existing.
scalar startTime
Start Time (initial time to start storing the snapshots)
scalar writeEvery
Time step of the writing procedure.
scalar timeStep
Time step of the simulation.
scalar nextWrite
Auxiliary variable to store the next writing instant.
scalar finalTime
Final time (final time of the simulation and consequently of the acquisition of the snapshots)
autoPtr< dimensionedScalar > _betaTot
Definition msrProblem.H:130
autoPtr< volScalarField > _NSF
Definition msrProblem.H:109
PtrList< volScalarField > Prec6field
List of pointers used to form the prec6 snapshots matrix.
Definition msrProblem.H:219
autoPtr< volScalarField > _prec8
Definition msrProblem.H:147
autoPtr< volScalarField > _dec3
Definition msrProblem.H:163
autoPtr< volScalarField > _SP
Definition msrProblem.H:112
autoPtr< dimensionedScalar > _rhoRef
Definition msrProblem.H:66
autoPtr< dimensionedScalar > _betaTE
Definition msrProblem.H:139
autoPtr< dimensionedScalar > _Pr
Definition msrProblem.H:64
autoPtr< volScalarField > _T
Definition msrProblem.H:159
PtrList< volScalarField > Prec8field
List of pointers used to form the prec8 snapshots matrix.
Definition msrProblem.H:225
autoPtr< dimensionedScalar > _beta8
Definition msrProblem.H:129
autoPtr< volScalarField > _dec2
Definition msrProblem.H:162
label precoutIndex
Definition msrProblem.H:185
autoPtr< dimensionedScalar > _Tref
Definition msrProblem.H:69
autoPtr< dimensionedScalar > _CpRef
Definition msrProblem.H:68
autoPtr< dimensionedScalar > _decBeta2
Definition msrProblem.H:136
autoPtr< dimensionedScalar > _beta5
Definition msrProblem.H:126
autoPtr< dimensionedScalar > _lam7
Definition msrProblem.H:120
PtrList< volScalarField > vFields
List of pointers used to form the v snapshosts matrix.
Definition msrProblem.H:243
ITHACAparameters * para
Definition msrProblem.H:370
autoPtr< dimensionedScalar > _SP1_0
Definition msrProblem.H:111
label precinIndex
indexes of inlet and outlet to adopt for precursors boundary conditions
Definition msrProblem.H:184
autoPtr< volScalarField > _prec2
Definition msrProblem.H:141
autoPtr< dimensionedScalar > _lam3
Definition msrProblem.H:116
autoPtr< dimensionedScalar > _Keff
Definition msrProblem.H:100
PtrList< volScalarField > Fluxfield
List of pointers used to form the flux snapshots matrix.
Definition msrProblem.H:201
autoPtr< volScalarField > _prec4
Definition msrProblem.H:143
autoPtr< volScalarField > _alphat
Definition msrProblem.H:150
autoPtr< dimensionedScalar > _beta2
Definition msrProblem.H:123
PtrList< volScalarField > Prec4field
List of pointers used to form the prec4 snapshots matrix.
Definition msrProblem.H:213
autoPtr< dimensionedScalar > _Sc
Definition msrProblem.H:148
PtrList< volScalarField > DFields
List of pointers used to form the D snapshosts matrix.
Definition msrProblem.H:246
autoPtr< dimensionedScalar > _lam6
Definition msrProblem.H:119
autoPtr< IOMRFZoneList > _MRF
Definition msrProblem.H:59
PtrList< volScalarField > AFields
List of pointers used to form the A snapshosts matrix.
Definition msrProblem.H:252
autoPtr< dimensionedScalar > _beta3
Definition msrProblem.H:124
autoPtr< dimensionedScalar > _TrefXS
Definition msrProblem.H:70
PtrList< volScalarField > Dec3field
List of pointers used to form the dec3 snapshots matrix.
Definition msrProblem.H:237
autoPtr< dimensionedScalar > _Prt
Definition msrProblem.H:65
autoPtr< dimensionedScalar > _IV1
Definition msrProblem.H:101
autoPtr< volVectorField > _U
Definition msrProblem.H:55
autoPtr< dimensionedScalar > _D1_0
Definition msrProblem.H:102
autoPtr< dimensionedScalar > _beta7
Definition msrProblem.H:128
autoPtr< dimensionedScalar > _lam4
Definition msrProblem.H:117
autoPtr< dimensionedScalar > _beta1
Definition msrProblem.H:122
autoPtr< volScalarField > _difft
Definition msrProblem.H:151
autoPtr< dimensionedScalar > _decLam3
Definition msrProblem.H:134
autoPtr< volScalarField > _prec5
Definition msrProblem.H:144
autoPtr< volScalarField > _v
Definition msrProblem.H:67
autoPtr< dimensionedScalar > _beta4
Definition msrProblem.H:125
autoPtr< fv::options > _fvOptions
fvOptions
Definition msrProblem.H:168
autoPtr< fvMesh > _mesh
Definition msrProblem.H:51
PtrList< volScalarField > Dec1field
List of pointers used to form the dec1 snapshots matrix.
Definition msrProblem.H:231
autoPtr< dimensionedScalar > _alfa_NSF1
Definition msrProblem.H:110
autoPtr< dimensionedScalar > _lam5
Definition msrProblem.H:118
autoPtr< dimensionedScalar > _lam1
Definition msrProblem.H:114
autoPtr< dimensionedScalar > _Sct
Definition msrProblem.H:149
autoPtr< volScalarField > _prec3
Definition msrProblem.H:142
PtrList< volScalarField > PowerDensfield
List of pointers used to form the powerDens snapshots matrix.
Definition msrProblem.H:240
autoPtr< dimensionedScalar > _NSF1_0
Definition msrProblem.H:108
autoPtr< dimensionedScalar > _decBeta3
Definition msrProblem.H:137
autoPtr< volScalarField > _prec6
Definition msrProblem.H:145
autoPtr< volScalarField > _D
Definition msrProblem.H:103
PtrList< volScalarField > Prec7field
List of pointers used to form the prec7 snapshots matrix.
Definition msrProblem.H:222
autoPtr< dimensionedScalar > _alfa_A1
Definition msrProblem.H:107
autoPtr< volScalarField > _prec7
Definition msrProblem.H:146
double tau
Definition msrProblem.H:154
autoPtr< dimensionedScalar > _lam8
Definition msrProblem.H:121
autoPtr< dimensionedScalar > _nu
Definition msrProblem.H:63
autoPtr< volScalarField > _TXS
Definition msrProblem.H:71
autoPtr< dimensionedScalar > _decbetaTot
Definition msrProblem.H:138
autoPtr< volScalarField > _p
Definition msrProblem.H:60
PtrList< volScalarField > Pfield
List of pointers used to form the pressure snapshots matrix.
Definition msrProblem.H:195
autoPtr< dimensionedScalar > _decBeta1
Definition msrProblem.H:135
autoPtr< dimensionedScalar > _decLam2
Definition msrProblem.H:133
autoPtr< dimensionedScalar > _lam2
Definition msrProblem.H:115
PtrList< volScalarField > NSFFields
List of pointers used to form the NSF snapshosts matrix.
Definition msrProblem.H:249
PtrList< volScalarField > Prec3field
List of pointers used to form the prec3 snapshots matrix.
Definition msrProblem.H:210
autoPtr< dimensionedScalar > _decLam1
Definition msrProblem.H:132
autoPtr< Time > _runTime
Definition msrProblem.H:47
PtrList< volScalarField > Tfield
List of pointers used to form the temperature snapshots matrix.
Definition msrProblem.H:228
PtrList< volVectorField > Ufield
List of pointers used to form the velocity snapshots matrix.
Definition msrProblem.H:198
PtrList< volScalarField > Prec1field
List of pointers used to form the prec1 snapshots matrix.
Definition msrProblem.H:204
autoPtr< dimensionedScalar > _alfa_D1
Definition msrProblem.H:104
autoPtr< volScalarField > _prec1
Definition msrProblem.H:140
PtrList< volScalarField > SPFields
List of pointers used to form the SP snapshosts matrix.
Definition msrProblem.H:255
autoPtr< dimensionedScalar > _A1_0
Definition msrProblem.H:105
PtrList< volScalarField > Dec2field
List of pointers used to form the dec2 snapshots matrix.
Definition msrProblem.H:234
PtrList< volScalarField > Prec5field
List of pointers used to form the prec5 snapshots matrix.
Definition msrProblem.H:216
bool precInBool
boolean variable to decide if apply prec inlet BC
Definition msrProblem.H:182
PtrList< volScalarField > TXSFields
List of pointers used to form the SP snapshosts matrix.
Definition msrProblem.H:258
autoPtr< dimensionedScalar > _alfa_SP1
Definition msrProblem.H:113
autoPtr< surfaceScalarField > _phi
Definition msrProblem.H:56
PtrList< volScalarField > Prec2field
List of pointers used to form the prec2 snapshots matrix.
Definition msrProblem.H:207
autoPtr< volScalarField > _logT
Definition msrProblem.H:160
autoPtr< volScalarField > _flux
Definition msrProblem.H:131
autoPtr< volScalarField > _A
Definition msrProblem.H:106
autoPtr< dimensionedScalar > _beta6
Definition msrProblem.H:127
Eigen::MatrixXd bc_prec
matrix to store the values of precursors BC inlet conditions
Definition msrProblem.H:187
autoPtr< singlePhaseTransportModel > _laminarTransport
Definition msrProblem.H:57
autoPtr< volScalarField > _dec1
Definition msrProblem.H:161
void writeMu(List< scalar > mu_now)
Write out a list of scalar corresponding to the parameters used in the truthSolve.
Eigen::MatrixXd mu_samples
Matrix of parameters to be used for PODI, where each row corresponds to a sample point....
label counter
Counter used for the output of the full order solutions.
void assignBC(volVectorField &s, label BC_ind, Vector< double > &value)
Assign Boundary Condition to a volVectorField.
bool offline
Boolean variable, it is 1 if the Offline phase has already been computed, else 0.
Eigen::MatrixXd mu
Row matrix of parameters.
bool podex
Boolean variable, it is 1 if the POD has already been computed, else 0.
void truthSolve()
Perform a TruthSolve.
bool checkWrite(Time &timeObject)
Function to check if the solution must be exported.
autoPtr< pimpleControl > _pimple
pimpleControl
autoPtr< dimensionedScalar > _tau
usmsrProblem()
Construct Null.
void assignPrecsBC(label call, label Ntau)
Method to assign the inlet BC to all precursors it assigns prec_i(x=inlet,t)=prec_i(x=outlet,...
void changePrecsBC()
Method to change the precursors' "precinIndex" (i.e.
void computePrecsBC(label call)
Method to compute the precursors inlet bc as: prec_i(x=outlet,t)exp(-lam_i*tau) where prec_i(x=outlet...
autoPtr< pimpleControl > _npimple
autoPtr< incompressible::turbulenceModel > turbulence
Turbulence model.
volScalarField & T
Definition createT.H:46
volScalarField & powerDens
volScalarField & logT
volScalarField & SP
dimensionedScalar & decbetaTot
volScalarField & NSF
volScalarField & A
dimensionedScalar & betaTot
volScalarField & D
volScalarField & v
volScalarField & TXS
volScalarField & difft
volScalarField & alphat
volScalarField & prec5
volScalarField & prec6
volScalarField & prec8
volScalarField & flux
volScalarField & prec3
volScalarField & prec2
volScalarField & prec7
volScalarField & prec4
volScalarField & prec1
volScalarField & dec3
volScalarField & dec1
volScalarField & dec2
dimensionedScalar & Sc
dimensionedScalar & Tref
dimensionedScalar & rhoRef
dimensionedScalar & CpRef
dimensionedScalar & betaTE
dimensionedScalar & nu
dimensionedScalar & Prt
dimensionedScalar & Pr
dimensionedScalar & Sct
dimensionedScalar & beta1
dimensionedScalar & beta3
dimensionedScalar & D1_0
dimensionedScalar & A1_0
dimensionedScalar & beta2
dimensionedScalar & Keff
dimensionedScalar & lam2
dimensionedScalar & beta5
dimensionedScalar & beta4
dimensionedScalar & beta8
dimensionedScalar & lam6
dimensionedScalar & IV1
dimensionedScalar & lam4
dimensionedScalar & lam8
dimensionedScalar & alfa_NSF1
dimensionedScalar & lam1
dimensionedScalar & alfa_A1
dimensionedScalar & beta6
dimensionedScalar & NSF1_0
dimensionedScalar & TrefXS
dimensionedScalar & lam5
dimensionedScalar & lam7
dimensionedScalar & lam3
dimensionedScalar & beta7
dimensionedScalar & alfa_D1
dimensionedScalar & alfa_SP1
dimensionedScalar & SP1_0
dimensionedScalar & decLam1
dimensionedScalar & decBeta3
dimensionedScalar & decBeta1
dimensionedScalar & decBeta2
dimensionedScalar & decLam3
dimensionedScalar & decLam2
void exportSolution(GeometricField< Type, PatchField, GeoMesh > &s, fileName subfolder, fileName folder, word fieldName)
Export a field to file in a certain folder and subfolder.
void exportMatrix(Eigen::Matrix< T, -1, dim > &matrix, word Name, word type, word folder)
Export the reduced matrices in numpy (type=python), matlab (type=matlab) and txt (type=eigen) format ...
bool check_pod()
Check if the POD data folder "./ITHACAoutput/POD" exists.
bool check_off()
Check if the offline data folder "./ITHACAoutput/Offline" exists.
void createSymLink(word folder)
Creates symbolic links to 0, system and constant.
surfaceScalarField & phi
volVectorField & U
pimpleControl & pimple
volScalarField & p
singlePhaseTransportModel & laminarTransport
label i
Definition pEqn.H:46