Skip to content

Commit a424c3c

Browse files
author
Henry Weller
committed
Merge branch 'master' of github.com-OpenFOAM:OpenFOAM/OpenFOAM-dev
2 parents 7a55c70 + d03f94e commit a424c3c

File tree

16 files changed

+520
-477
lines changed

16 files changed

+520
-477
lines changed

src/MomentumTransportModels/momentumTransportModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.C

Lines changed: 92 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
========= |
33
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
44
\\ / O peration | Website: https://openfoam.org
5-
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
5+
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
66
\\/ M anipulation |
77
-------------------------------------------------------------------------------
88
License
@@ -37,20 +37,30 @@ Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField
3737
const dictionary& dict
3838
)
3939
:
40-
fixedJumpFvPatchField<scalar>(p, iF),
41-
phiName_(dict.lookupOrDefault<word>("phi", "phi")),
42-
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
43-
D_(dict.lookup<scalar>("D")),
44-
I_(dict.lookup<scalar>("I")),
45-
length_(dict.lookup<scalar>("length")),
46-
relaxation_(dict.lookupOrDefault<scalar>("relaxation", 1)),
47-
jump0_(jump_)
48-
{
49-
fvPatchField<scalar>::operator=
40+
fixedJumpFvPatchScalarField(p, iF, dict, true),
41+
phiName_
5042
(
51-
Field<scalar>("value", dict, p.size())
52-
);
53-
}
43+
cyclicPatch().owner()
44+
? dict.lookupOrDefault<word>("phi", "phi")
45+
: word::null
46+
),
47+
rhoName_
48+
(
49+
cyclicPatch().owner()
50+
? dict.lookupOrDefault<word>("rho", "rho")
51+
: word::null
52+
),
53+
D_(cyclicPatch().owner() ? dict.lookup<scalar>("D") : NaN),
54+
I_(cyclicPatch().owner() ? dict.lookup<scalar>("I") : NaN),
55+
length_(cyclicPatch().owner() ? dict.lookup<scalar>("length") : NaN),
56+
relaxation_
57+
(
58+
cyclicPatch().owner()
59+
? dict.lookupOrDefault<scalar>("relaxation", 1)
60+
: NaN
61+
),
62+
jump0_(cyclicPatch().owner() ? jump()() : scalarField(p.size()))
63+
{}
5464

5565

5666
Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField
@@ -61,14 +71,14 @@ Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField
6171
const fieldMapper& mapper
6272
)
6373
:
64-
fixedJumpFvPatchField<scalar>(ptf, p, iF, mapper),
74+
fixedJumpFvPatchScalarField(ptf, p, iF, mapper),
6575
phiName_(ptf.phiName_),
6676
rhoName_(ptf.rhoName_),
6777
D_(ptf.D_),
6878
I_(ptf.I_),
6979
length_(ptf.length_),
7080
relaxation_(ptf.relaxation_),
71-
jump0_(ptf.jump_)
81+
jump0_(ptf.jump0_)
7282
{}
7383

7484

@@ -78,14 +88,14 @@ Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField
7888
const DimensionedField<scalar, volMesh>& iF
7989
)
8090
:
81-
fixedJumpFvPatchField<scalar>(ptf, iF),
91+
fixedJumpFvPatchScalarField(ptf, iF),
8292
phiName_(ptf.phiName_),
8393
rhoName_(ptf.rhoName_),
8494
D_(ptf.D_),
8595
I_(ptf.I_),
8696
length_(ptf.length_),
8797
relaxation_(ptf.relaxation_),
88-
jump0_(ptf.jump_)
98+
jump0_(ptf.jump0_)
8999
{}
90100

91101

@@ -98,68 +108,78 @@ void Foam::porousBafflePressureFvPatchField::updateCoeffs()
98108
return;
99109
}
100110

101-
const surfaceScalarField& phi =
102-
db().lookupObject<surfaceScalarField>(phiName_);
103-
104-
const fvsPatchField<scalar>& phip =
105-
patch().patchField<surfaceScalarField, scalar>(phi);
106-
107-
scalarField Un(phip/patch().magSf());
108-
109-
if (phi.dimensions() == dimMassFlux)
111+
if (cyclicPatch().owner())
110112
{
111-
Un /= patch().lookupPatchField<volScalarField, scalar>(rhoName_);
113+
const surfaceScalarField& phi =
114+
db().lookupObject<surfaceScalarField>(phiName_);
115+
116+
const fvsPatchField<scalar>& phip =
117+
patch().patchField<surfaceScalarField, scalar>(phi);
118+
119+
scalarField Un(phip/patch().magSf());
120+
121+
if (phi.dimensions() == dimMassFlux)
122+
{
123+
Un /= patch().lookupPatchField<volScalarField, scalar>(rhoName_);
124+
}
125+
126+
const scalarField magUn(mag(Un));
127+
128+
const momentumTransportModel& turbModel =
129+
db().lookupType<momentumTransportModel>(internalField().group());
130+
131+
jumpRef() =
132+
-sign(Un)
133+
*(
134+
D_*turbModel.nu(patch().index())
135+
+ I_*0.5*magUn
136+
)*magUn*length_;
137+
138+
if (internalField().dimensions() == dimPressure)
139+
{
140+
jumpRef() *=
141+
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
142+
}
143+
144+
if (relaxation_ < 1)
145+
{
146+
jumpRef() += (1 - relaxation_)*(jump0_ - jumpRef());
147+
}
148+
149+
jump0_ = jumpRef();
150+
151+
if (debug)
152+
{
153+
scalar avePressureJump = gAverage(jumpRef());
154+
scalar aveVelocity = gAverage(mag(Un));
155+
156+
Info<< patch().boundaryMesh().mesh().name() << ':'
157+
<< patch().name() << ':'
158+
<< " Average pressure drop :" << avePressureJump
159+
<< " Average velocity :" << aveVelocity
160+
<< endl;
161+
}
112162
}
113163

114-
const scalarField magUn(mag(Un));
115-
116-
const momentumTransportModel& turbModel =
117-
db().lookupType<momentumTransportModel>(internalField().group());
118-
119-
jump_ =
120-
-sign(Un)
121-
*(
122-
D_*turbModel.nu(patch().index())
123-
+ I_*0.5*magUn
124-
)*magUn*length_;
125-
126-
if (internalField().dimensions() == dimPressure)
127-
{
128-
jump_ *= patch().lookupPatchField<volScalarField, scalar>(rhoName_);
129-
}
164+
fixedJumpFvPatchScalarField::updateCoeffs();
165+
}
130166

131-
if (relaxation_ < 1)
132-
{
133-
jump_ += (1 - relaxation_)*(jump0_ - jump_);
134-
}
135167

136-
jump0_ = jump_;
168+
void Foam::porousBafflePressureFvPatchField::write(Ostream& os) const
169+
{
170+
fixedJumpFvPatchScalarField::write(os);
137171

138-
if (debug)
172+
if (cyclicPatch().owner())
139173
{
140-
scalar avePressureJump = gAverage(jump_);
141-
scalar aveVelocity = gAverage(mag(Un));
142-
143-
Info<< patch().boundaryMesh().mesh().name() << ':'
144-
<< patch().name() << ':'
145-
<< " Average pressure drop :" << avePressureJump
146-
<< " Average velocity :" << aveVelocity
147-
<< endl;
174+
writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
175+
writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
176+
writeEntry(os, "D", D_);
177+
writeEntry(os, "I", I_);
178+
writeEntry(os, "length", length_);
179+
writeEntryIfDifferent(os, "relaxation", scalar(1), relaxation_);
148180
}
149181

150-
fixedJumpFvPatchField<scalar>::updateCoeffs();
151-
}
152-
153-
154-
void Foam::porousBafflePressureFvPatchField::write(Ostream& os) const
155-
{
156-
fixedJumpFvPatchField<scalar>::write(os);
157-
writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
158-
writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
159-
writeEntry(os, "D", D_);
160-
writeEntry(os, "I", I_);
161-
writeEntry(os, "length", length_);
162-
writeEntryIfDifferent(os, "relaxation", scalar(1), relaxation_);
182+
writeEntry(os, "value", *this);
163183
}
164184

165185

@@ -174,4 +194,5 @@ namespace Foam
174194
);
175195
}
176196

197+
177198
// ************************************************************************* //

src/MomentumTransportModels/momentumTransportModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.H

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
========= |
33
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
44
\\ / O peration | Website: https://openfoam.org
5-
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
5+
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
66
\\/ M anipulation |
77
-------------------------------------------------------------------------------
88
License
@@ -25,10 +25,10 @@ Class
2525
Foam::porousBafflePressureFvPatchField
2626
2727
Description
28-
This boundary condition provides a jump condition, using the \c cyclic
29-
condition as a base.
3028
31-
The porous baffle introduces a pressure jump defined by:
29+
This boundary condition provides a porous baffle pressure jump condition,
30+
using the \c cyclic condition as a base. The jump in pressure is defined
31+
by:
3232
3333
\f[
3434
\Delta p = -(D \mu U + 0.5 I \rho |U|^2 )L
@@ -49,13 +49,13 @@ Description
4949
Usage
5050
\table
5151
Property | Description | Required | Default value
52-
patchType | underlying patch type should be \c cyclic| yes |
52+
patchType | underlying patch type (should be \c cyclic) | yes |
5353
phi | flux field name | no | phi
5454
rho | density field name | no | rho
5555
D | Darcy coefficient | yes |
5656
I | inertial coefficient | yes |
5757
length | porous media length in the flow direction | yes |
58-
relaxation | Relaxation factor for pressure jump | no | 1
58+
relaxation | relaxation factor for pressure jump | no | 1
5959
\endtable
6060
6161
Example of the boundary condition specification:
@@ -73,9 +73,6 @@ Usage
7373
}
7474
\endverbatim
7575
76-
Note:
77-
The underlying \c patchType should be set to \c cyclic
78-
7976
SourceFiles
8077
porousBafflePressureFvPatchField.C
8178
@@ -84,7 +81,7 @@ SourceFiles
8481
#ifndef porousBafflePressureFvPatchField_H
8582
#define porousBafflePressureFvPatchField_H
8683

87-
#include "fixedJumpFvPatchField.H"
84+
#include "fixedJumpFvPatchFields.H"
8885

8986
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
9087

@@ -97,7 +94,7 @@ namespace Foam
9794

9895
class porousBafflePressureFvPatchField
9996
:
100-
public fixedJumpFvPatchField<scalar>
97+
public fixedJumpFvPatchScalarField
10198
{
10299
// Private Data
103100

@@ -108,16 +105,16 @@ class porousBafflePressureFvPatchField
108105
const word rhoName_;
109106

110107
//- Darcy pressure loss coefficient
111-
scalar D_;
108+
const scalar D_;
112109

113110
//- Inertia pressure lost coefficient
114-
scalar I_;
111+
const scalar I_;
115112

116113
//- Porous media length
117-
scalar length_;
114+
const scalar length_;
118115

119116
//- Relaxation for pressure jump
120-
scalar relaxation_;
117+
const scalar relaxation_;
121118

122119
//- Previous iteration "jump" field for relaxation
123120
scalarField jump0_;

src/finiteVolume/fields/fvPatchFields/basic/coupled/coupledFvPatchField.C

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
========= |
33
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
44
\\ / O peration | Website: https://openfoam.org
5-
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
5+
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
66
\\/ M anipulation |
77
-------------------------------------------------------------------------------
88
License
@@ -129,6 +129,17 @@ void Foam::coupledFvPatchField<Type>::initEvaluate(const Pstream::commsTypes)
129129
}
130130

131131

132+
template<class Type>
133+
void Foam::coupledFvPatchField<Type>::evaluateNoUpdateCoeffs()
134+
{
135+
Field<Type>::operator=
136+
(
137+
this->patch().weights()*this->patchInternalField()
138+
+ (1.0 - this->patch().weights())*this->patchNeighbourField()
139+
);
140+
}
141+
142+
132143
template<class Type>
133144
void Foam::coupledFvPatchField<Type>::evaluate(const Pstream::commsTypes)
134145
{
@@ -137,11 +148,7 @@ void Foam::coupledFvPatchField<Type>::evaluate(const Pstream::commsTypes)
137148
this->updateCoeffs();
138149
}
139150

140-
Field<Type>::operator=
141-
(
142-
this->patch().weights()*this->patchInternalField()
143-
+ (1.0 - this->patch().weights())*this->patchNeighbourField()
144-
);
151+
evaluateNoUpdateCoeffs();
145152

146153
fvPatchField<Type>::evaluate();
147154
}

src/finiteVolume/fields/fvPatchFields/basic/coupled/coupledFvPatchField.H

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
========= |
33
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
44
\\ / O peration | Website: https://openfoam.org
5-
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
5+
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
66
\\/ M anipulation |
77
-------------------------------------------------------------------------------
88
License
@@ -159,6 +159,9 @@ public:
159159
const Pstream::commsTypes commsType
160160
);
161161

162+
//- Evaluate the patch field, but don't update the coeffs
163+
void evaluateNoUpdateCoeffs();
164+
162165
//- Evaluate the patch field
163166
virtual void evaluate
164167
(

0 commit comments

Comments
 (0)