2
2
========= |
3
3
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4
4
\\ / O peration | Website: https://openfoam.org
5
- \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
5
+ \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
6
6
\\/ M anipulation |
7
7
-------------------------------------------------------------------------------
8
8
License
@@ -37,20 +37,30 @@ Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField
37
37
const dictionary & dict
38
38
)
39
39
:
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_
50
42
(
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
+ {}
54
64
55
65
56
66
Foam ::porousBafflePressureFvPatchField ::porousBafflePressureFvPatchField
@@ -61,14 +71,14 @@ Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField
61
71
const fieldMapper & mapper
62
72
)
63
73
:
64
- fixedJumpFvPatchField < scalar > (ptf , p , iF , mapper ),
74
+ fixedJumpFvPatchScalarField (ptf , p , iF , mapper ),
65
75
phiName_ (ptf .phiName_ ),
66
76
rhoName_ (ptf .rhoName_ ),
67
77
D_ (ptf .D_ ),
68
78
I_ (ptf .I_ ),
69
79
length_ (ptf .length_ ),
70
80
relaxation_ (ptf .relaxation_ ),
71
- jump0_ (ptf .jump_ )
81
+ jump0_ (ptf .jump0_ )
72
82
{}
73
83
74
84
@@ -78,14 +88,14 @@ Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField
78
88
const DimensionedField < scalar , volMesh > & iF
79
89
)
80
90
:
81
- fixedJumpFvPatchField < scalar > (ptf , iF ),
91
+ fixedJumpFvPatchScalarField (ptf , iF ),
82
92
phiName_ (ptf .phiName_ ),
83
93
rhoName_ (ptf .rhoName_ ),
84
94
D_ (ptf .D_ ),
85
95
I_ (ptf .I_ ),
86
96
length_ (ptf .length_ ),
87
97
relaxation_ (ptf .relaxation_ ),
88
- jump0_ (ptf .jump_ )
98
+ jump0_ (ptf .jump0_ )
89
99
{}
90
100
91
101
@@ -98,68 +108,78 @@ void Foam::porousBafflePressureFvPatchField::updateCoeffs()
98
108
return ;
99
109
}
100
110
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 ())
110
112
{
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
+ }
112
162
}
113
163
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
+ }
130
166
131
- if (relaxation_ < 1 )
132
- {
133
- jump_ += (1 - relaxation_ )* (jump0_ - jump_ );
134
- }
135
167
136
- jump0_ = jump_ ;
168
+ void Foam ::porousBafflePressureFvPatchField ::write (Ostream & os ) const
169
+ {
170
+ fixedJumpFvPatchScalarField ::write (os );
137
171
138
- if (debug )
172
+ if (cyclicPatch (). owner () )
139
173
{
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_ );
148
180
}
149
181
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 );
163
183
}
164
184
165
185
@@ -174,4 +194,5 @@ namespace Foam
174
194
);
175
195
}
176
196
197
+
177
198
// ************************************************************************* //
0 commit comments