1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "fineNumericFlux.H"
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 // Construct from components
31 template<class Flux, class Limiter>
32 Foam::fineNumericFlux<Flux, Limiter>::fineNumericFlux
34 const mgMeshLevel& meshLevel,
35 const mgFieldLevel& fieldLevel
39 meshLevel_(meshLevel),
40 fieldLevel_(fieldLevel),
45 rhoFlux_(fieldLevel.rhoFlux()),
46 rhoUFlux_(fieldLevel.rhoUFlux()),
47 rhoEFlux_(fieldLevel.rhoEFlux()),
48 gradP_(fvc::grad(p_)),
49 gradU_(fvc::grad(U_)),
54 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
56 template<class Flux, class Limiter>
57 void Foam::fineNumericFlux<Flux, Limiter>::computeInteriorFlux()
59 // Get face-to-cell addressing: face area point from owner to neighbour
60 const unallocLabelList& owner = meshLevel_.owner();
61 const unallocLabelList& neighbour = meshLevel_.neighbour();
63 // Get the face area vector
64 const surfaceVectorField& Sf = mesh().Sf();
65 const surfaceScalarField& magSf = mesh().magSf();
67 const scalarField& Cv = fieldLevel_.CvVar();
68 const scalarField& R = fieldLevel_.R();
70 gradP_ = fvc::grad(p_);
71 gradP_.correctBoundaryConditions();
73 gradU_ = fvc::grad(U_);
74 gradU_.correctBoundaryConditions();
76 gradT_ = fvc::grad(T_);
77 gradT_.correctBoundaryConditions();
79 MDLimiter<scalar, Limiter> scalarPLimiter
85 MDLimiter<vector, Limiter> vectorULimiter
91 MDLimiter<scalar, Limiter> scalarTLimiter
98 const volScalarField& pLimiter = scalarPLimiter.phiLimiter();
99 const volVectorField& ULimiter = vectorULimiter.phiLimiter();
100 const volScalarField& TLimiter = scalarTLimiter.phiLimiter();
102 // Calculate fluxes at internal faces
103 forAll (owner, faceI)
105 const label own = owner[faceI];
106 const label nei = neighbour[faceI];
108 const vector deltaRLeft = faceCentre[faceI] - cellCentre[own];
109 const vector deltaRRight = faceCentre[faceI] - cellCentre[nei];
111 // calculate fluxes with reconstructed primitive variables at faces
117 p_[own] + pLimiter[own]*(deltaRLeft & gradP_[own]),
118 p_[nei] + pLimiter[nei]*(deltaRRight & gradP_[nei]),
119 U_[own] + cmptMultiply(ULimiter[own], (deltaRLeft & gradU_[own])),
120 U_[nei] + cmptMultiply(ULimiter[nei], (deltaRRight & gradU_[nei])),
121 T_[own] + TLimiter[own]*(deltaRLeft & gradT_[own]),
122 T_[nei] + TLimiter[nei]*(deltaRRight & gradT_[nei]),
132 // Update boundary field and values
133 forAll (rhoFlux_.boundaryField(), patchi)
135 const fvPatch& curPatch = p_.boundaryField()[patchi].patch();
138 fvsPatchScalarField& pRhoFlux = rhoFlux_.boundaryField()[patchi];
139 fvsPatchVectorField& pRhoUFlux = rhoUFlux_.boundaryField()[patchi];
140 fvsPatchScalarField& pRhoEFlux = rhoEFlux_.boundaryField()[patchi];
142 const scalarField& pp = fieldLevel_.patchP(patchi);
143 const vectorField& pU = fieldLevel_.patchU(patchi);
144 const scalarField& pT = fieldLevel_.patchT(patchi);
146 const scalarField& pCv = fieldLevel_.patchCv(patchi);
147 const scalarField& pR = fieldLevel_.patchR(patchi);
150 const fvPatchVectorField& pGradP = gradP_.boundaryField()[patchi];
151 const fvPatchTensorField& pGradU = gradU_.boundaryField()[patchi];
152 const fvPatchVectorField& pGradT = gradT_.boundaryField()[patchi];
155 const fvPatchScalarField& pPatchLim = pLimiter.boundaryField()[patchi];
156 const fvPatchVectorField& UPatchLim = ULimiter.boundaryField()[patchi];
157 const fvPatchScalarField& TPatchLim = TLimiter.boundaryField()[patchi];
160 const vectorField& pSf = meshLevel_.patchFaceAreas(patchi);
161 const scalarField& pMagSf = meshLevel_.magPatchFaceAreas(patchi);
163 if (p_.boundaryField()[patchi].coupled())
166 const scalarField ppLeft =
167 p_.boundaryField()[patchi].patchInternalField();
169 const scalarField ppRight =
170 p_.boundaryField()[patchi].patchNeighbourField();
172 const vectorField pULeft =
173 U_.boundaryField()[patchi].patchInternalField();
175 const vectorField pURight =
176 U_.boundaryField()[patchi].patchNeighbourField();
178 const scalarField pTLeft =
179 T_.boundaryField()[patchi].patchInternalField();
181 const scalarField pTRight =
182 T_.boundaryField()[patchi].patchNeighbourField();
185 const vectorField pgradPLeft = pGradP.patchInternalField();
186 const vectorField pgradPRight = pGradP.patchNeighbourField();
188 const tensorField pgradULeft = pGradU.patchInternalField();
189 const tensorField pgradURight = pGradU.patchNeighbourField();
191 const vectorField pgradTLeft = pGradT.patchInternalField();
192 const vectorField pgradTRight = pGradT.patchNeighbourField();
195 vectorField pDeltaRLeft = meshLevel_.patchDeltaR(patchi);
196 vectorField pDdeltaRRight =
197 meshLevel_.patchDeltaRNeighbour(patchi);
201 const scalarField ppLimiterLeft = pPatchLim.patchInternalField();
202 const scalarField ppLimiterRight = pPatchLim.patchNeighbourField();
204 const vectorField pULimiterLeft = UPatchLim.patchInternalField();
205 const vectorField pULimiterRight = UPatchLim.patchNeighbourField();
207 const scalarField pTLimiterLeft = TPatchLim.patchInternalField();
208 const scalarField pTLimiterRight = TPatchLim.patchNeighbourField();
219 + ppLimiterLeft[facei]*
220 (pDeltaRLeft[facei] & pgradPLeft[facei]),
223 + ppLimiterRight[facei]*
224 (pDdeltaRRight[facei] & pgradPRight[facei]),
229 pULimiterLeft[facei],
230 pDeltaRLeft[facei] & pgradULeft[facei]
236 pULimiterRight[facei],
237 pDdeltaRRight[facei] & pgradURight[facei]
241 + pTLimiterLeft[facei]*
242 (pDeltaRLeft[facei] & pgradTLeft[facei]),
245 + pTLimiterRight[facei]*
246 (pDdeltaRRight[facei] & pgradTRight[facei]),
286 // ************************************************************************* //