DAFvSourceUniformPressureGradient.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2 
3  DAFoam : Discrete Adjoint with OpenFOAM
4  Version : v3
5 
6 \*---------------------------------------------------------------------------*/
7 
9 
10 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
11 
12 namespace Foam
13 {
14 
15 defineTypeNameAndDebug(DAFvSourceUniformPressureGradient, 0);
16 addToRunTimeSelectionTable(DAFvSource, DAFvSourceUniformPressureGradient, 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  : DAFvSource(modelType, mesh, daOption, daModel, daIndex)
26 {
27 }
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
31 {
32  /*
33  Description:
34  Just add a uniform pressure gradient to fvSource
35 
36  Example:
37  An example of the fvSource in pyOptions in pyDAFoam can be
38  defOptions =
39  {
40  "fvSource"
41  {
42  "gradP"
43  {
44  "type": "uniformPressureGradient",
45  "value": 1e-3,
46  "direction": [1.0, 0.0, 0.0],
47  },
48  }
49  }
50  */
51 
52  forAll(fvSource, idxI)
53  {
54  fvSource[idxI] = vector::zero;
55  }
56 
57  const dictionary& allOptions = daOption_.getAllOptions();
58 
59  dictionary fvSourceSubDict = allOptions.subDict("fvSource");
60 
61  word gradPName = fvSourceSubDict.toc()[0];
62  scalar gradPValue = fvSourceSubDict.subDict(gradPName).getScalar("value");
63  scalarList direction;
64  fvSourceSubDict.subDict(gradPName).readEntry<scalarList>("direction", direction);
65 
66  vector directionVec = {direction[0], direction[1], direction[2]};
67 
68  forAll(fvSource, idxI)
69  {
70  fvSource[idxI] = gradPValue * directionVec;
71  }
72 
73  fvSource.correctBoundaryConditions();
74 }
75 
76 } // End namespace Foam
77 
78 // ************************************************************************* //
Foam::DAFvSource
Definition: DAFvSource.H:34
allOptions
const dictionary & allOptions
Definition: createRefsRhoSimpleC.H:15
Foam::DAFvSourceUniformPressureGradient::DAFvSourceUniformPressureGradient
DAFvSourceUniformPressureGradient(const word modelType, const fvMesh &mesh, const DAOption &daOption, const DAModel &daModel, const DAIndex &daIndex)
Definition: DAFvSourceUniformPressureGradient.C:19
forAll
forAll(pseudoP.boundaryField(), patchI)
Definition: solvePseudoPEqn.H:10
Foam::DAFvSourceUniformPressureGradient::calcFvSource
virtual void calcFvSource(volVectorField &fvSource)
compute the FvSource term
Definition: DAFvSourceUniformPressureGradient.C:30
Foam::DAFvSource::daOption_
const DAOption & daOption_
DAOption object.
Definition: DAFvSource.H:53
Foam::DAOption
Definition: DAOption.H:29
daOption
DAOption daOption(mesh, pyOptions_)
fvSource
volScalarField & fvSource
Definition: createRefsHeatTransfer.H:7
Foam::DAOption::getAllOptions
const dictionary & getAllOptions() const
return a reference of allOptions_ dictionary
Definition: DAOption.H:56
mesh
fvMesh & mesh
Definition: createRefsHeatTransfer.H:4
Foam::DAIndex
Definition: DAIndex.H:32
Foam::DAModel
Definition: DAModel.H:59
Foam
Definition: multiFreqScalarFvPatchField.C:144
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(DAFvSource, 0)
DAFvSourceUniformPressureGradient.H
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(DAFvSource, DAFvSourceActuatorDisk, dictionary)
daModel
DAModel daModel(mesh, daOption)
daIndex
DAIndex daIndex(mesh, daOption, daModel)