DAResidualRhoPimpleFoam.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2 
3  DAFoam : Discrete Adjoint with OpenFOAM
4  Version : v4
5 
6 \*---------------------------------------------------------------------------*/
7 
9 
10 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
11 
12 namespace Foam
13 {
14 
15 defineTypeNameAndDebug(DAResidualRhoPimpleFoam, 0);
16 addToRunTimeSelectionTable(DAResidual, DAResidualRhoPimpleFoam, dictionary);
17 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
18 
20  const word modelType,
21  const fvMesh& mesh,
22  const DAOption& daOption,
23  const DAModel& daModel,
24  const DAIndex& daIndex)
25  : DAResidual(modelType, mesh, daOption, daModel, daIndex),
26  // initialize and register state variables and their residuals, we use macros defined in macroFunctions.H
27  setResidualClassMemberVector(U, dimensionSet(1, -2, -2, 0, 0, 0, 0)),
28  setResidualClassMemberScalar(p, dimensionSet(1, -3, -1, 0, 0, 0, 0)),
29  setResidualClassMemberScalar(T, dimensionSet(1, -1, -3, 0, 0, 0, 0)),
31  fvSource_(const_cast<volVectorField&>(
32  mesh_.thisDb().lookupObject<volVectorField>("fvSource"))),
33  fvSourceEnergy_(const_cast<volScalarField&>(
34  mesh_.thisDb().lookupObject<volScalarField>("fvSourceEnergy"))),
35  thermo_(const_cast<fluidThermo&>(
36  mesh_.thisDb().lookupObject<fluidThermo>("thermophysicalProperties"))),
37  he_(thermo_.he()),
38  rho_(const_cast<volScalarField&>(
39  mesh_.thisDb().lookupObject<volScalarField>("rho"))),
40  alphat_(const_cast<volScalarField&>(
41  mesh_.thisDb().lookupObject<volScalarField>("alphat"))),
42  psi_(const_cast<volScalarField&>(
43  mesh_.thisDb().lookupObject<volScalarField>("thermo:psi"))),
44  dpdt_(const_cast<volScalarField&>(
45  mesh_.thisDb().lookupObject<volScalarField>("dpdt"))),
46  K_(const_cast<volScalarField&>(
47  mesh_.thisDb().lookupObject<volScalarField>("K"))),
48  daTurb_(const_cast<DATurbulenceModel&>(daModel.getDATurbulenceModel())),
49  // create pimpleControl
50  pimple_(const_cast<fvMesh&>(mesh))
51 {
52 
53  // initialize fvSource
54  const dictionary& allOptions = daOption.getAllOptions();
55  if (allOptions.subDict("fvSource").toc().size() != 0)
56  {
57  hasFvSource_ = 1;
58  }
59 
60  // get molWeight and Cp from thermophysicalProperties
61  const IOdictionary& thermoDict = mesh.thisDb().lookupObject<IOdictionary>("thermophysicalProperties");
62  dictionary mixSubDict = thermoDict.subDict("mixture");
63  dictionary specieSubDict = mixSubDict.subDict("specie");
64  molWeight_ = specieSubDict.getScalar("molWeight");
65  dictionary thermodynamicsSubDict = mixSubDict.subDict("thermodynamics");
66  Cp_ = thermodynamicsSubDict.getScalar("Cp");
67 
68  if (daOption_.getOption<label>("debug"))
69  {
70  Info << "molWeight " << molWeight_ << endl;
71  Info << "Cp " << Cp_ << endl;
72  }
73 }
74 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
75 
77 {
78  /*
79  Description:
80  Clear all members to avoid memory leak because we will initalize
81  multiple objects of DAResidual. Here we need to delete all members
82  in the parent and child classes
83  */
84  URes_.clear();
85  pRes_.clear();
86  TRes_.clear();
87  phiRes_.clear();
88 }
89 
90 void DAResidualRhoPimpleFoam::calcResiduals(const dictionary& options)
91 {
92  /*
93  Description:
94  This is the function to compute residuals.
95 
96  Input:
97  options.isPC: 1 means computing residuals for preconditioner matrix.
98  This essentially use the first order scheme for div(phi,U), div(phi,e)
99 
100  p_, T_, U_, phi_, etc: State variables in OpenFOAM
101 
102  Output:
103  URes_, pRes_, TRes_, phiRes_: residual field variables
104  */
105 
106  label isPC = options.getLabel("isPC");
107 
108  word divUScheme = "div(phi,U)";
109  word divHEScheme = "div(phi,e)";
110 
111  if (he_.name() == "h")
112  {
113  divHEScheme = "div(phi,h)";
114  }
115 
116  if (isPC)
117  {
118  divUScheme = "div(pc)";
119  divHEScheme = "div(pc)";
120  }
121 
122  // ******** U Residuals **********
123  // copied and modified from UEqn.H
124 
125  if (hasFvSource_)
126  {
127  DAFvSource& daFvSource(const_cast<DAFvSource&>(
128  mesh_.thisDb().lookupObject<DAFvSource>("DAFvSource")));
129  daFvSource.calcFvSource(fvSource_);
131  }
132 
133  tmp<fvVectorMatrix> tUEqn(
134  fvm::ddt(rho_, U_)
135  + fvm::div(phi_, U_, divUScheme)
137  - fvSource_);
138  fvVectorMatrix& UEqn = tUEqn.ref();
139 
140  UEqn.relax(1.0);
141 
142  URes_ = (UEqn & U_) + fvc::grad(p_);
143  normalizeResiduals(URes);
144 
145  // ******** e Residuals **********
146  // copied and modified from EEqn.H
147  volScalarField alphaEff("alphaEff", thermo_.alphaEff(alphat_));
148 
149  K_ = 0.5 * magSqr(U_);
150  dpdt_ = fvc::ddt(p_);
151 
152  fvScalarMatrix EEqn(
153  fvm::ddt(rho_, he_)
154  + fvm::div(phi_, he_, divHEScheme)
155  + fvc::ddt(rho_, K_)
156  + fvc::div(phi_, K_)
157  + (he_.name() == "e"
158  ? fvc::div(
159  fvc::absolute(phi_ / fvc::interpolate(rho_), U_),
160  p_,
161  "div(phiv,p)")
162  : -dpdt_)
163  - fvm::laplacian(alphaEff, he_)
164  - fvSourceEnergy_);
165 
166  EEqn.relax(1.0);
167 
168  TRes_ = EEqn & he_;
169  normalizeResiduals(TRes);
170 
171  // ******** p and phi Residuals **********
172  // copied and modified from pEqn.H
173  volScalarField rAU(1.0 / UEqn.A());
174  surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho_ * rAU));
175  //***************** NOTE *******************
176  // constrainHbyA has been used since OpenFOAM-v1606; however, it may degrade the accuracy of derivatives
177  // because constraining variables will create discontinuity. Here we have a option to use the old
178  // implementation in OpenFOAM-3.0+ and before (no constraint for HbyA)
179  autoPtr<volVectorField> HbyAPtr = nullptr;
180  label useConstrainHbyA = daOption_.getOption<label>("useConstrainHbyA");
181  if (useConstrainHbyA)
182  {
183  HbyAPtr.reset(new volVectorField(constrainHbyA(rAU * UEqn.H(), U_, p_)));
184  }
185  else
186  {
187  HbyAPtr.reset(new volVectorField("HbyA", U_));
188  HbyAPtr() = rAU * UEqn.H();
189  }
190  volVectorField& HbyA = HbyAPtr();
191 
192  tUEqn.clear();
193 
194  surfaceScalarField phiHbyA("phiHbyA", fvc::interpolate(rho_) * fvc::flux(HbyA));
195 
196  // NOTE: we don't support transonic = true
197 
198  fvScalarMatrix pEqn(
199  fvm::ddt(psi_, p_)
200  + fvc::div(phiHbyA)
201  - fvm::laplacian(rhorAUf, p_));
202 
203  pRes_ = pEqn & p_;
204  normalizeResiduals(pRes);
205 
206  // ******** phi Residuals **********
207  // copied and modified from pEqn.H
208  phiRes_ = phiHbyA + pEqn.flux() - phi_;
209  normalizePhiResiduals(phiRes);
210 }
211 
213 {
214  /*
215  Description:
216  Update the intermediate variables that depend on the state variables
217 
218  ********************** NOTE *****************
219  we assume hePsiThermo, pureMixture, perfectGas, hConst, and const transport
220  TODO: need to do this using built-in openfoam functions.
221 
222  we need to:
223  1, update psi based on T, psi=1/(R*T)
224  2, update rho based on p and psi, rho=psi*p
225  3, update E based on T, p and rho, E=Cp*T-p/rho
226  4, update velocity boundary based on MRF
227  */
228 
229  // 8314.4700665 gas constant in OpenFOAM
230  // src/OpenFOAM/global/constants/thermodynamic/thermodynamicConstants.H
231  scalar RR = Foam::constant::thermodynamic::RR;
232 
233  // R = RR/molWeight
234  // Foam::specie::R() function in src/thermophysicalModels/specie/specie/specieI.H
235  dimensionedScalar R(
236  "R1",
237  dimensionSet(0, 2, -2, -1, 0, 0, 0),
238  RR / molWeight_);
239 
240  // psi = 1/T/R
241  // see src/thermophysicalModels/specie/equationOfState/perfectGas/perfectGasI.H
242  psi_ = 1.0 / T_ / R;
243  psi_.oldTime() = 1.0 / T_.oldTime() / R;
244  psi_.oldTime().oldTime() = 1.0 / T_.oldTime().oldTime() / R;
245 
246  // rho = psi*p
247  // see src/thermophysicalModels/basic/psiThermo/psiThermo.C
248  rho_ = psi_ * p_;
249  rho_.oldTime() = psi_.oldTime() * p_.oldTime();
250  rho_.oldTime().oldTime() = psi_.oldTime().oldTime() * p_.oldTime().oldTime();
251 
252  // **************** NOTE ****************
253  // need to relax rho to be consistent with the primal solver
254  // However, the rho.relax() will mess up perturbation
255  // That being said, we comment out the rho.relax() call to
256  // get the correct perturbed rho; however, the E residual will
257  // be a bit off compared with the ERes at the converged state
258  // from the primal solver. TODO. Need to figure out how to improve this
259  // **************** NOTE ****************
260  // rho_.relax();
261 
262  dimensionedScalar Cp(
263  "Cp1",
264  dimensionSet(0, 2, -2, -1, 0, 0, 0),
265  Cp_);
266 
267  // Hs = Cp*T
268  // see Hs() in src/thermophysicalModels/specie/thermo/hConst/hConstThermoI.H
269  // here the H departure EquationOfState::H(p, T) will be zero for perfectGas
270  // Es = Hs - p/rho = Hs - T * R;
271  // see Es() in src/thermophysicalModels/specie/thermo/thermo/thermoI.H
272  // **************** NOTE ****************
273  // See the comment from the rho.relax() call, if we write he_=Cp*T-p/rho, the
274  // accuracy of he_ may be impact by the inaccurate rho. So here we want to
275  // rewrite he_ as he_ = Cp * T_ - T_ * R instead, such that we dont include rho
276  // **************** NOTE ****************
277  if (he_.name() == "e")
278  {
279  he_ = Cp * T_ - T_ * R;
280  he_.oldTime() = Cp * T_.oldTime() - T_.oldTime() * R;
281  he_.oldTime().oldTime() = Cp * T_.oldTime().oldTime() - T_.oldTime().oldTime() * R;
282  }
283  else
284  {
285  he_ = Cp * T_;
286  he_.oldTime() = Cp * T_.oldTime();
287  he_.oldTime().oldTime() = Cp * T_.oldTime().oldTime();
288  }
289  he_.correctBoundaryConditions();
290 
291  K_ = 0.5 * magSqr(U_);
292  K_.oldTime() = 0.5 * magSqr(U_.oldTime());
293  K_.oldTime().oldTime() = 0.5 * magSqr(U_.oldTime().oldTime());
294 
295  dpdt_ = fvc::ddt(p_);
296 
297  // NOTE: alphat is updated in the correctNut function in DATurbulenceModel child classes
298 }
299 
301 {
302  /*
303  Description:
304  Update the boundary condition for all the states in the selected solver
305  */
306 
307  U_.correctBoundaryConditions();
308  p_.correctBoundaryConditions();
309  T_.correctBoundaryConditions();
310 }
311 
313 {
314  /*
315  Description:
316  Calculate the diagonal block of the preconditioner matrix dRdWTPC using the fvMatrix
317  */
318 
319  const labelUList& owner = mesh_.owner();
320  const labelUList& neighbour = mesh_.neighbour();
321 
322  PetscScalar val;
323 
324  dictionary normStateDict = daOption_.getAllOptions().subDict("normalizeStates");
325  wordList normResDict = daOption_.getOption<wordList>("normalizeResiduals");
326 
327  // ******** U Residuals **********
328  if (hasFvSource_)
329  {
330  DAFvSource& daFvSource(const_cast<DAFvSource&>(
331  mesh_.thisDb().lookupObject<DAFvSource>("DAFvSource")));
332  daFvSource.calcFvSource(fvSource_);
334  }
335 
336  fvVectorMatrix UEqn(
337  fvm::ddt(rho_, U_)
338  + fvm::div(phi_, U_, "div(pc)")
340  - fvSource_);
341 
342  // force 1.0 relaxation
343  UEqn.relax(1.0);
344 
345  scalar UScaling = 1.0;
346  if (normStateDict.found("U"))
347  {
348  UScaling = normStateDict.getScalar("U");
349  }
350  scalar UResScaling = 1.0;
351 
352  // set diag
353  forAll(U_, cellI)
354  {
355  if (normResDict.found("URes"))
356  {
357  UResScaling = mesh_.V()[cellI];
358  }
359  for (label i = 0; i < 3; i++)
360  {
361  PetscInt rowI = daIndex_.getGlobalAdjointStateIndex("U", cellI, i);
362  PetscInt colI = rowI;
363  scalarField D = UEqn.D();
364  scalar val1 = D[cellI] * UScaling / UResScaling;
365  assignValueCheckAD(val, val1);
366  MatSetValues(PCMat, 1, &rowI, 1, &colI, &val, INSERT_VALUES);
367  }
368  }
369 
370  // set lower/owner
371  for (label faceI = 0; faceI < daIndex_.nLocalInternalFaces; faceI++)
372  {
373  label ownerCellI = owner[faceI];
374  label neighbourCellI = neighbour[faceI];
375 
376  if (normResDict.found("URes"))
377  {
378  UResScaling = mesh_.V()[neighbourCellI];
379  }
380 
381  for (label i = 0; i < 3; i++)
382  {
383  PetscInt rowI = daIndex_.getGlobalAdjointStateIndex("U", neighbourCellI, i);
384  PetscInt colI = daIndex_.getGlobalAdjointStateIndex("U", ownerCellI, i);
385  scalar val1 = UEqn.lower()[faceI] * UScaling / UResScaling;
386  assignValueCheckAD(val, val1);
387  MatSetValues(PCMat, 1, &colI, 1, &rowI, &val, INSERT_VALUES);
388  }
389  }
390 
391  // set upper/neighbour
392  for (label faceI = 0; faceI < daIndex_.nLocalInternalFaces; faceI++)
393  {
394  label ownerCellI = owner[faceI];
395  label neighbourCellI = neighbour[faceI];
396 
397  if (normResDict.found("URes"))
398  {
399  UResScaling = mesh_.V()[ownerCellI];
400  }
401 
402  for (label i = 0; i < 3; i++)
403  {
404  PetscInt rowI = daIndex_.getGlobalAdjointStateIndex("U", ownerCellI, i);
405  PetscInt colI = daIndex_.getGlobalAdjointStateIndex("U", neighbourCellI, i);
406  scalar val1 = UEqn.upper()[faceI] * UScaling / UResScaling;
407  assignValueCheckAD(val, val1);
408  MatSetValues(PCMat, 1, &colI, 1, &rowI, &val, INSERT_VALUES);
409  }
410  }
411 
412  /*
413  // NOTE: the PCMatFVMatrix calculation for the EEqn is somehow way off
414  // so we comment it out for now...
415  // ******** e Residuals **********
416  volScalarField alphaEff("alphaEff", thermo_.alphaEff(alphat_));
417 
418  K_ = 0.5 * magSqr(U_);
419  dpdt_ = fvc::ddt(p_);
420 
421  fvScalarMatrix EEqn(
422  fvm::ddt(rho_, he_)
423  + fvm::div(phi_, he_, "div(pc)")
424  + fvc::ddt(rho_, K_)
425  + fvc::div(phi_, K_)
426  + (he_.name() == "e"
427  ? fvc::div(
428  fvc::absolute(phi_ / fvc::interpolate(rho_), U_),
429  p_,
430  "div(phiv,p)")
431  : -dpdt_)
432  - fvm::laplacian(alphaEff, he_)
433  - fvSourceEnergy_);
434 
435  EEqn.relax(1.0);
436 
437  scalar TScaling = 1.0;
438  if (normStateDict.found("T"))
439  {
440  TScaling = normStateDict.getScalar("T");
441  }
442  scalar TResScaling = 1.0;
443 
444  // set diag
445  forAll(T_, cellI)
446  {
447  if (normResDict.found("TRes"))
448  {
449  TResScaling = mesh_.V()[cellI];
450  }
451 
452  PetscInt rowI = daIndex_.getGlobalAdjointStateIndex("T", cellI);
453  PetscInt colI = rowI;
454  scalarField D = EEqn.D();
455  scalar val1 = D[cellI] * TScaling / TResScaling;
456  assignValueCheckAD(val, val1);
457  MatSetValues(PCMat, 1, &rowI, 1, &colI, &val, INSERT_VALUES);
458  }
459 
460  // set lower/owner
461  for (label faceI = 0; faceI < daIndex_.nLocalInternalFaces; faceI++)
462  {
463  label ownerCellI = owner[faceI];
464  label neighbourCellI = neighbour[faceI];
465 
466  if (normResDict.found("TRes"))
467  {
468  TResScaling = mesh_.V()[neighbourCellI];
469  }
470 
471  PetscInt rowI = daIndex_.getGlobalAdjointStateIndex("T", neighbourCellI);
472  PetscInt colI = daIndex_.getGlobalAdjointStateIndex("T", ownerCellI);
473  scalar val1 = EEqn.lower()[faceI] * TScaling / TResScaling;
474  assignValueCheckAD(val, val1);
475  MatSetValues(PCMat, 1, &colI, 1, &rowI, &val, INSERT_VALUES);
476  }
477 
478  // set upper/neighbour
479  for (label faceI = 0; faceI < daIndex_.nLocalInternalFaces; faceI++)
480  {
481  label ownerCellI = owner[faceI];
482  label neighbourCellI = neighbour[faceI];
483 
484  if (normResDict.found("TRes"))
485  {
486  TResScaling = mesh_.V()[ownerCellI];
487  }
488 
489  PetscInt rowI = daIndex_.getGlobalAdjointStateIndex("T", ownerCellI);
490  PetscInt colI = daIndex_.getGlobalAdjointStateIndex("T", neighbourCellI);
491  scalar val1 = EEqn.upper()[faceI] * TScaling / TResScaling;
492  assignValueCheckAD(val, val1);
493  MatSetValues(PCMat, 1, &colI, 1, &rowI, &val, INSERT_VALUES);
494  }
495  */
496 
497  // ******** p Residuals **********
498  volScalarField rAU(1.0 / UEqn.A());
499  surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho_ * rAU));
500  //***************** NOTE *******************
501  // constrainHbyA has been used since OpenFOAM-v1606; however, it may degrade the accuracy of derivatives
502  // because constraining variables will create discontinuity. Here we have a option to use the old
503  // implementation in OpenFOAM-3.0+ and before (no constraint for HbyA)
504  autoPtr<volVectorField> HbyAPtr = nullptr;
505  label useConstrainHbyA = daOption_.getOption<label>("useConstrainHbyA");
506  if (useConstrainHbyA)
507  {
508  HbyAPtr.reset(new volVectorField(constrainHbyA(rAU * UEqn.H(), U_, p_)));
509  }
510  else
511  {
512  HbyAPtr.reset(new volVectorField("HbyA", U_));
513  HbyAPtr() = rAU * UEqn.H();
514  }
515  volVectorField& HbyA = HbyAPtr();
516 
517  surfaceScalarField phiHbyA("phiHbyA", fvc::interpolate(rho_) * fvc::flux(HbyA));
518 
519  // NOTE: we don't support transonic = true
520 
521  fvScalarMatrix pEqn(
522  fvm::ddt(psi_, p_)
523  + fvc::div(phiHbyA)
524  - fvm::laplacian(rhorAUf, p_));
525 
526  scalar pScaling = 1.0;
527  if (normStateDict.found("p"))
528  {
529  pScaling = normStateDict.getScalar("p");
530  }
531  scalar pResScaling = 1.0;
532  // set diag
533  forAll(p_, cellI)
534  {
535  if (normResDict.found("pRes"))
536  {
537  pResScaling = mesh_.V()[cellI];
538  }
539 
540  PetscInt rowI = daIndex_.getGlobalAdjointStateIndex("p", cellI);
541  PetscInt colI = rowI;
542  scalarField D = pEqn.D();
543  scalar val1 = D[cellI] * pScaling / pResScaling;
544  assignValueCheckAD(val, val1);
545  MatSetValues(PCMat, 1, &rowI, 1, &colI, &val, INSERT_VALUES);
546  }
547 
548  // set lower/owner
549  for (label faceI = 0; faceI < daIndex_.nLocalInternalFaces; faceI++)
550  {
551  label ownerCellI = owner[faceI];
552  label neighbourCellI = neighbour[faceI];
553 
554  if (normResDict.found("pRes"))
555  {
556  pResScaling = mesh_.V()[neighbourCellI];
557  }
558 
559  PetscInt rowI = daIndex_.getGlobalAdjointStateIndex("p", neighbourCellI);
560  PetscInt colI = daIndex_.getGlobalAdjointStateIndex("p", ownerCellI);
561  scalar val1 = pEqn.lower()[faceI] * pScaling / pResScaling;
562  assignValueCheckAD(val, val1);
563  MatSetValues(PCMat, 1, &colI, 1, &rowI, &val, INSERT_VALUES);
564  }
565 
566  // set upper/neighbour
567  for (label faceI = 0; faceI < daIndex_.nLocalInternalFaces; faceI++)
568  {
569  label ownerCellI = owner[faceI];
570  label neighbourCellI = neighbour[faceI];
571 
572  if (normResDict.found("pRes"))
573  {
574  pResScaling = mesh_.V()[ownerCellI];
575  }
576 
577  PetscInt rowI = daIndex_.getGlobalAdjointStateIndex("p", ownerCellI);
578  PetscInt colI = daIndex_.getGlobalAdjointStateIndex("p", neighbourCellI);
579  scalar val1 = pEqn.upper()[faceI] * pScaling / pResScaling;
580  assignValueCheckAD(val, val1);
581  MatSetValues(PCMat, 1, &colI, 1, &rowI, &val, INSERT_VALUES);
582  }
583 }
584 
585 } // End namespace Foam
586 
587 // ************************************************************************* //
Foam::DAResidualRhoPimpleFoam::U_
volVectorField & U_
Definition: DAResidualRhoPimpleFoam.H:38
Foam::DAResidualRhoPimpleFoam::alphat_
volScalarField & alphat_
Definition: DAResidualRhoPimpleFoam.H:64
Foam::DAFvSource
Definition: DAFvSource.H:34
Foam::DAResidualRhoPimpleFoam::Cp_
scalar Cp_
Definition: DAResidualRhoPimpleFoam.H:79
U
volVectorField & U
Definition: createRefsPimpleDyM.H:7
Foam::DAResidualRhoPimpleFoam::psi_
volScalarField & psi_
Definition: DAResidualRhoPimpleFoam.H:65
useConstrainHbyA
label useConstrainHbyA
Definition: pEqnPimpleDyM.H:7
Foam::DATurbulenceModel::divDevRhoReff
tmp< fvVectorMatrix > divDevRhoReff(volVectorField &U)
divDev terms
Definition: DATurbulenceModel.C:389
Foam::DAResidualRhoPimpleFoam::URes_
volVectorField URes_
Definition: DAResidualRhoPimpleFoam.H:39
Foam::DAResidual::mesh_
const fvMesh & mesh_
fvMesh
Definition: DAResidual.H:49
rhorAUf
surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho *rAU))
Foam::DAResidualRhoPimpleFoam::daTurb_
DATurbulenceModel & daTurb_
DATurbulenceModel object.
Definition: DAResidualRhoPimpleFoam.H:71
D
volVectorField & D
Definition: createRefsSolidDisplacement.H:8
Foam::DAResidualRhoPimpleFoam::fvSource_
volVectorField & fvSource_
fvSource term
Definition: DAResidualRhoPimpleFoam.H:52
Foam::DAOption
Definition: DAOption.H:29
Foam::DAResidualRhoPimpleFoam::hasFvSource_
label hasFvSource_
whether to have fvSource term
Definition: DAResidualRhoPimpleFoam.H:83
Foam::DAIndex::getGlobalAdjointStateIndex
label getGlobalAdjointStateIndex(const word stateName, const label idxI, const label comp=-1) const
get global adjoint index for a given state name, cell/face indxI and its component (optional,...
Definition: DAIndex.C:661
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(DAFunction, DAFunctionForce, dictionary)
UEqn
fvVectorMatrix & UEqn
Definition: UEqnPimpleDyM.H:15
Foam::DAFvSource::calcFvSource
virtual void calcFvSource(volVectorField &fvSource)
compute the FvSource term
Definition: DAFvSource.C:90
he
volScalarField & he
Definition: EEqnRhoPimple.H:5
Foam::DAResidualRhoPimpleFoam::thermo_
fluidThermo & thermo_
thermophysical property
Definition: DAResidualRhoPimpleFoam.H:58
normalizeResiduals
#define normalizeResiduals(resName)
Definition: DAMacroFunctions.H:28
Foam::DAResidualRhoPimpleFoam::clear
virtual void clear()
clear the members
Definition: DAResidualRhoPimpleFoam.C:76
Foam::DAOption::getOption
classType getOption(const word key) const
get an option from subDict and key
Definition: DAOption.H:92
Foam::DAResidualRhoPimpleFoam::K_
volScalarField & K_
Definition: DAResidualRhoPimpleFoam.H:67
Foam::DAResidualRhoPimpleFoam::fvSourceEnergy_
volScalarField & fvSourceEnergy_
fvSource term for the energy equation
Definition: DAResidualRhoPimpleFoam.H:55
Foam::DAResidualRhoPimpleFoam::updateIntermediateVariables
virtual void updateIntermediateVariables()
update any intermediate variables that are dependent on state variables and are used in calcResiduals
Definition: DAResidualRhoPimpleFoam.C:212
Foam::DAResidualRhoPimpleFoam::p_
volScalarField & p_
Definition: DAResidualRhoPimpleFoam.H:41
Foam::DAResidual::daIndex_
const DAIndex & daIndex_
DAIndex.
Definition: DAResidual.H:58
Foam::DAOption::getAllOptions
const dictionary & getAllOptions() const
return a reference of allOptions_ dictionary
Definition: DAOption.H:56
Foam::DAResidual::daOption_
const DAOption & daOption_
DAOption object.
Definition: DAResidual.H:52
HbyA
volVectorField & HbyA
Definition: pEqnPimpleDyM.H:17
Foam::DAResidualRhoPimpleFoam::phiRes_
surfaceScalarField phiRes_
Definition: DAResidualRhoPimpleFoam.H:48
mesh
fvMesh & mesh
Definition: createRefsHeatTransfer.H:4
Foam::DAResidualRhoPimpleFoam::TRes_
volScalarField TRes_
Definition: DAResidualRhoPimpleFoam.H:45
setResidualClassMemberPhi
#define setResidualClassMemberPhi(stateName)
Definition: DAMacroFunctions.H:83
Foam::DAResidualRhoPimpleFoam::calcPCMatWithFvMatrix
virtual void calcPCMatWithFvMatrix(Mat PCMat)
calculating the adjoint preconditioner matrix using fvMatrix
Definition: DAResidualRhoPimpleFoam.C:312
Foam::DAResidualRhoPimpleFoam::DAResidualRhoPimpleFoam
DAResidualRhoPimpleFoam(const word modelType, const fvMesh &mesh, const DAOption &daOption, const DAModel &daModel, const DAIndex &daIndex)
Definition: DAResidualRhoPimpleFoam.C:19
phiHbyA
phiHbyA
Definition: pEqnRhoSimpleC.H:36
Foam::DAResidualRhoPimpleFoam::correctBoundaryConditions
virtual void correctBoundaryConditions()
update the boundary condition for all the states in the selected solver
Definition: DAResidualRhoPimpleFoam.C:300
Foam::DAIndex
Definition: DAIndex.H:32
p
volScalarField & p
Definition: createRefsPimpleDyM.H:6
assignValueCheckAD
#define assignValueCheckAD(valA, valB)
Definition: DAMacroFunctions.H:103
Foam::DAResidualRhoPimpleFoam::molWeight_
scalar molWeight_
Definition: DAResidualRhoPimpleFoam.H:78
Foam::DAResidualRhoPimpleFoam::pRes_
volScalarField pRes_
Definition: DAResidualRhoPimpleFoam.H:42
setResidualClassMemberVector
#define setResidualClassMemberVector(stateName, stateUnit)
Definition: DAMacroFunctions.H:68
Foam::DAModel
Definition: DAModel.H:57
Foam::DAResidualRhoPimpleFoam::T_
volScalarField & T_
Definition: DAResidualRhoPimpleFoam.H:44
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(DAFunction, 0)
phi
surfaceScalarField & phi
Definition: createRefsPimpleDyM.H:8
Foam
Definition: checkGeometry.C:32
T
volScalarField & T
Definition: createRefsHeatTransfer.H:5
Foam::DAResidualRhoPimpleFoam::rho_
volScalarField & rho_
Definition: DAResidualRhoPimpleFoam.H:63
tUEqn
tmp< fvVectorMatrix > tUEqn(fvm::ddt(U)+fvm::div(phi, U)+turbulencePtr_->divDevReff(U) - fvSource)
allOptions
const dictionary & allOptions
Definition: createRefsPimpleDyM.H:14
Foam::DAResidualRhoPimpleFoam::dpdt_
volScalarField & dpdt_
Definition: DAResidualRhoPimpleFoam.H:66
alphaEff
volScalarField alphaEff("alphaEff", turbulencePtr_->nu()/Pr+alphat)
forAll
forAll(nuTilda1, cellI)
Definition: nuTilda1EqnIrkPimple.H:19
Foam::DAIndex::nLocalInternalFaces
label nLocalInternalFaces
local internal face size
Definition: DAIndex.H:98
Foam::DAResidual
Definition: DAResidual.H:36
Foam::DAResidualRhoPimpleFoam::phi_
surfaceScalarField & phi_
Definition: DAResidualRhoPimpleFoam.H:47
Foam::DATurbulenceModel
Definition: DATurbulenceModel.H:52
Foam::DAResidualRhoPimpleFoam::calcResiduals
virtual void calcResiduals(const dictionary &options)
compute residual
Definition: DAResidualRhoPimpleFoam.C:90
rAU
volScalarField rAU(1.0/UEqn.A())
DAResidualRhoPimpleFoam.H
Foam::DAResidualRhoPimpleFoam::he_
volScalarField & he_
Definition: DAResidualRhoPimpleFoam.H:62
HbyAPtr
autoPtr< volVectorField > HbyAPtr
Definition: pEqnPimpleDyM.H:6
setResidualClassMemberScalar
#define setResidualClassMemberScalar(stateName, stateUnit)
Definition: DAMacroFunctions.H:53
normalizePhiResiduals
#define normalizePhiResiduals(resName)
Definition: DAMacroFunctions.H:37
EEqn
fvScalarMatrix EEqn(fvm::ddt(rho, he)+fvm::div(phi, he)+fvc::ddt(rho, K)+fvc::div(phi, K)+(he.name()=="e" ? fvc::div(fvc::absolute(phi/fvc::interpolate(rho), U), p, "div(phiv,p)") :-dpdt) - fvm::laplacian(turbulencePtr_->alphaEff(), he) - fvSourceEnergy)