createFields.H
Go to the documentation of this file.
1 Info<< "Reading velocity field U\n" << endl;
3 (
4  IOobject
5  (
6  "U",
7  runTime.timeName(),
8  mesh,
9  IOobject::MUST_READ,
10  IOobject::AUTO_WRITE
11  ),
12  mesh
13  );
14 
15 // Initialise the velocity internal field to zero
16 U = dimensionedVector("0", U.dimensions(), vector::zero);
17 
19 (
20  IOobject
21  (
22  "phi",
23  runTime.timeName(),
24  mesh,
25  IOobject::NO_READ,
26  IOobject::AUTO_WRITE
27  ),
28  fvc::interpolate(U) & mesh.Sf()
29  );
30 
31 if (args.optionFound("initialiseUBCs"))
32 {
33  U.correctBoundaryConditions();
34  phi = fvc::interpolate(U) & mesh.Sf();
35 }
36 
37 
38 // Construct a pressure field
39 // If it is available read it otherwise construct from the velocity BCs
40 // converting fixed-value BCs to zero-gradient and vice versa.
41 word pName("p");
42 
43 // Update name of the pressure field from the command-line option
44 args.optionReadIfPresent("pName", pName);
45 
46 // Infer the pressure BCs from the velocity BCs
47 wordList pBCTypes
48 (
49  U.boundaryField().size(),
50  fixedValueFvPatchScalarField::typeName
51  );
52 
53 forAll(U.boundaryField(), patchi)
54 {
55  if (U.boundaryField()[patchi].fixesValue())
56  {
57  pBCTypes[patchi] = zeroGradientFvPatchScalarField::typeName;
58  }
59 }
60 
61 // Note that registerObject is false for the pressure field. The pressure
62 // field in this solver doesn't have a physical value during the solution.
63 // It shouldn't be looked up and used by sub models or boundary conditions.
64 Info<< "Constructing pressure field " << pName << nl << endl;
66 (
67  IOobject
68  (
69  pName,
70  runTime.timeName(),
71  mesh,
72  IOobject::READ_IF_PRESENT,
73  IOobject::NO_WRITE,
74  false
75  ),
76  mesh,
77  dimensionedScalar(pName, sqr(dimVelocity), 0),
78  pBCTypes
79  );
80 
81 label pRefCell = 0;
82 scalar pRefValue = 0.0;
83 if (args.optionFound("writep"))
84 {
86  (
87  p,
88  potentialFlow.dict(),
89  pRefCell,
90  pRefValue
91  );
92 }
93 
94 
95 // Infer the velocity potential BCs from the pressure
96 wordList PhiBCTypes
97 (
98  p.boundaryField().size(),
99  zeroGradientFvPatchScalarField::typeName
100  );
101 
102 forAll(p.boundaryField(), patchi)
103 {
104  if (p.boundaryField()[patchi].fixesValue())
105  {
106  PhiBCTypes[patchi] = fixedValueFvPatchScalarField::typeName;
107  }
108 }
109 
110 
111 
112 Info<< "Constructing velocity potential field Phi\n" << endl;
113 volScalarField Phi
114 (
115  IOobject
116  (
117  "Phi",
118  runTime.timeName(),
119  mesh,
120  IOobject::READ_IF_PRESENT,
121  //IOobject::NO_WRITE
122  IOobject::AUTO_WRITE
123  ),
124  mesh,
126  //p.boundaryField().types()
127  PhiBCTypes
128  );
129 
130 label PhiRefCell = 0;
131 scalar PhiRefValue = 0;
133 (
134  Phi,
135  potentialFlow.dict(),
136  PhiRefCell,
137  PhiRefValue
138  );
139 mesh.setFluxRequired(Phi.name());
pRefCell
label pRefCell
Definition: createFields.H:112
pRefValue
scalar pRefValue
Definition: createFields.H:113
forAll
forAll(Y, i)
Definition: createFields.H:129
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
Foam::dimVelocity
const dimensionSet dimVelocity
setRefCell
setRefCell(p, p_rgh, pimple.dict(), pRefCell, pRefValue)
phi
surfaceScalarField & phi
Definition: createFields.H:13
Foam::MULES::interpolate
tmp< surfaceScalarField > interpolate(const RhoType &rho)
Definition: IMULESTemplates.C:40
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::dimensionedVector
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
Definition: dimensionedVector.H:48
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:54
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:41
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
p
volScalarField & p
Definition: createFields.H:51
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::volVectorField
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:55
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:49
Foam::surfaceScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Definition: surfaceFieldsFwd.H:52
patchi
label patchi
Definition: getPatchFieldScalar.H:1
Foam::argList::optionFound
bool optionFound(const word &opt) const
Return true if the named option is found.
Definition: argListI.H:108
args
Foam::argList args(argc, argv)
U
volVectorField U(IOobject("U", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), Urel+SRF->U())
Foam::argList::optionReadIfPresent
bool optionReadIfPresent(const word &opt, T &) const
Read a value from the named option if present.
Definition: argListI.H:198