1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM 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 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
28 #include "twoStrokeEngine.H"
29 #include "slidingInterface.H"
30 #include "layerAdditionRemoval.H"
31 #include "surfaceFields.H"
32 #include "regionSplit.H"
33 #include "componentMixedTetPolyPatchVectorField.H"
34 #include "mapPolyMesh.H"
36 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
37 void Foam::twoStrokeEngine::checkMotionFluxes()
41 //checking the motion fluxes for the cutFaceZone
43 Info << "Checking the motion fluxes in the cut-face zone" << endl;
45 const labelList& cutFaceZoneAddressing =
46 faceZones()[faceZones().findZoneID("cutFaceZone")];
48 boolList calculatedMeshPhi(V().size(), false);
49 scalarField sumMeshPhi(V().size(), 0.0);
51 forAll(cutFaceZoneAddressing, i)
53 label facei = cutFaceZoneAddressing[i];
55 calculatedMeshPhi[owner()[facei]] = true;
56 calculatedMeshPhi[neighbour()[facei]] = true;
59 Info << "Checking the motion fluxes in the liner zone" << endl;
61 const labelList& linerAddressing =
62 faceZones()[faceZones().findZoneID(scavInCylPatchName_ + "Zone")];
64 forAll(linerAddressing, i)
66 label facei = linerAddressing[i];
68 calculatedMeshPhi[owner()[facei]] = true;
69 calculatedMeshPhi[neighbour()[facei]] = true;
72 const polyPatch& wallPatch =
73 boundaryMesh()[boundaryMesh().findPatchID("wall")];
75 labelList wallLabels(wallPatch.size());
77 forAll (wallLabels, i)
79 wallLabels[i] = wallPatch.start() + i;
84 label facei = wallLabels[i];
86 calculatedMeshPhi[owner()[facei]] = true;
87 calculatedMeshPhi[neighbour()[facei]] = true;
90 forAll(owner(), facei)
92 sumMeshPhi[owner()[facei]] += phi()[facei];
93 sumMeshPhi[neighbour()[facei]] -= phi()[facei];
96 forAll(boundary(), patchi)
98 const unallocLabelList& pFaceCells =
99 boundary()[patchi].faceCells();
101 const fvsPatchField<scalar>& pssf = phi().boundaryField()[patchi];
103 forAll(boundary()[patchi], facei)
105 sumMeshPhi[pFaceCells[facei]] += pssf[facei];
111 DynamicList<label> checkMeshPhi;
112 label checkMeshPhiSize = 0;
114 forAll(calculatedMeshPhi, i)
116 if(calculatedMeshPhi[i] == true)
118 checkMeshPhi.append(i);
123 Info << "checkMeshPhiSize = " << checkMeshPhiSize << endl;
125 checkMeshPhi.setSize(checkMeshPhiSize);
127 scalarField dVdt(checkMeshPhiSize, 0.0);
131 label celli = checkMeshPhi[i];
133 dVdt[i] = (1.0 - V0()[celli]/V()[celli])/engTime().deltaT().value();
136 Info << "checking mesh flux in the cutFaces" << endl;
140 forAll(checkMeshPhi, i)
142 scalar sumCheck = dVdt[i] - sumMeshPhi[checkMeshPhi[i]];
143 if(mag(sumCheck) > 1)
145 Info<< "LOCAL sumCheck[" << checkMeshPhi[i] << "] = "
151 Info<< "found " << nOutCheck << " cells with inconsistent motion fluxes"
153 Info << "end " << endl;
158 scalarField dVdt = (1.0 - V0()/V())/engTime().deltaT();
160 scalarField sumMeshPhi(V().size(), 0.0);
162 forAll(owner(), facei)
164 sumMeshPhi[owner()[facei]] += phi()[facei];
165 sumMeshPhi[neighbour()[facei]] -= phi()[facei];
168 forAll(boundary(), patchi)
170 const unallocLabelList& pFaceCells =
171 boundary()[patchi].faceCells();
173 const fvsPatchField<scalar>& pssf = phi().boundaryField()[patchi];
175 forAll(boundary()[patchi], facei)
177 sumMeshPhi[pFaceCells[facei]] += pssf[facei];
183 scalarField sumCheck = dVdt - sumMeshPhi;
187 forAll(sumCheck, celli)
189 if(mag(sumCheck[celli]) > 1)
191 Info<< "sumCheck GLOBAL[" << celli << "] = "
192 << sumCheck[celli] << endl;
197 Info<< "found " << nOutCheck
198 << " cells with inconsistent motion fluxes GLOBAL" << endl;