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(U.dimensions(), Zero);
17 
19 (
20  IOobject
21  (
22  "phi",
23  runTime.timeName(),
24  mesh,
25  IOobject::NO_READ,
26  IOobject::AUTO_WRITE
27  ),
28  fvc::flux(U)
29 );
30 
31 if (args.found("initialiseUBCs"))
32 {
33  U.correctBoundaryConditions();
34  phi = fvc::flux(U);
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 
42 // Allow override from command-line -pName option
43 const word pName = args.getOrDefault<word>("pName", "p");
44 
45 // Infer the pressure BCs from the velocity
47 (
48  U.boundaryField().size(),
49  fixedValueFvPatchScalarField::typeName
50 );
51 
52 forAll(U.boundaryField(), patchi)
53 {
54  if (U.boundaryField()[patchi].fixesValue())
55  {
56  pBCTypes[patchi] = zeroGradientFvPatchScalarField::typeName;
57  }
58 }
59 
60 // Note that registerObject is false for the pressure field. The pressure
61 // field in this solver doesn't have a physical value during the solution.
62 // It shouldn't be looked up and used by sub models or boundary conditions.
63 Info<< "Constructing pressure field " << pName << nl << endl;
65 (
66  IOobject
67  (
68  pName,
69  runTime.timeName(),
70  mesh,
71  IOobject::READ_IF_PRESENT,
72  IOobject::NO_WRITE,
73  false
74  ),
75  mesh,
77  pBCTypes
78 );
79 
80 // Infer the velocity potential BCs from the pressure
81 wordList PhiBCTypes
82 (
83  p.boundaryField().size(),
84  zeroGradientFvPatchScalarField::typeName
85 );
86 
87 forAll(p.boundaryField(), patchi)
88 {
89  if (p.boundaryField()[patchi].fixesValue())
90  {
91  PhiBCTypes[patchi] = fixedValueFvPatchScalarField::typeName;
92  }
93 }
94 
95 Info<< "Constructing velocity potential field Phi\n" << endl;
97 (
98  IOobject
99  (
100  "Phi",
101  runTime.timeName(),
102  mesh,
103  IOobject::READ_IF_PRESENT,
104  IOobject::NO_WRITE
105  ),
106  mesh,
108  PhiBCTypes
109 );
110 
111 label PhiRefCell = 0;
112 scalar PhiRefValue = 0;
114 (
115  Phi,
116  potentialFlow.dict(),
117  PhiRefCell,
118  PhiRefValue
119 );
120 mesh.setFluxRequired(Phi.name());
121 
122 #include "createMRF.H"
123 
124 // Add solver-specific interpolations
125 {
126  wordHashSet& nonInt =
127  const_cast<wordHashSet&>(Stencil::New(mesh).nonInterpolatedFields());
128 
129  nonInt.insert("cellMask");
130  nonInt.insert("interpolatedCells");
131 
132 }
133 
134 // Mask field for zeroing out contributions on hole cells
135 #include "createCellMask.H"
136 
137 // Create bool field with interpolated cells
138 #include "createInterpolatedCells.H"
runTime
engineTime & runTime
Definition: createEngineTime.H:13
U
volVectorField U(IOobject("U", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), mesh, dimensionedVector(dimVelocity, Zero))
forAll
forAll(U.boundaryField(), patchi)
Definition: createFields.H:52
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
Foam::argList::getOrDefault
T getOrDefault(const word &optName, const T &deflt) const
Definition: argListI.H:300
Foam::Zero
static constexpr const zero Zero
Definition: zero.H:131
Foam::dimVelocity
const dimensionSet dimVelocity
Foam::endl
Ostream & endl(Ostream &os)
Definition: Ostream.H:381
setRefCell
setRefCell(p, pimple.dict(), pRefCell, pRefValue)
pBCTypes
wordList pBCTypes(U.boundaryField().size(), fixedValueFvPatchScalarField::typeName)
Foam::dimensionedVector
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
Definition: dimensionedVector.H:46
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:58
Foam::Info
messageStream Info
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:36
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:53
p
volScalarField & p
Definition: createFields.H:23
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Definition: DimensionedFieldReuseFunctions.H:100
Foam::volVectorField
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:58
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:44
createInterpolatedCells.H
Creates mask for interpolated cells.
Foam::nl
constexpr char nl
Definition: Ostream.H:424
Foam::surfaceScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Definition: surfaceFieldsFwd.H:50
Foam::HashSet::insert
bool insert(const Key &key)
Definition: HashSet.H:191
potentialFlow
const dictionary & potentialFlow(mesh.solutionDict().subDict("potentialFlow"))
createCellMask.H
Creates mask for blocked out cells.
Foam::wordHashSet
HashSet< word, Hash< word > > wordHashSet
A HashSet with word keys and string hasher.
Definition: HashSet.H:73
Foam::fvc::flux
tmp< surfaceScalarField > flux(const volVectorField &vvf)
Definition: fvcFlux.C:27
args
Foam::argList args(argc, argv)
Foam::argList::found
bool found(const word &optName) const
Definition: argListI.H:171