1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
5 \\ / A nd | 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 \*---------------------------------------------------------------------------*/
27 #include "twoStrokeEngine.H"
28 #include "slidingInterface.H"
29 #include "layerAdditionRemoval.H"
30 #include "surfaceFields.H"
31 #include "regionSplit.H"
32 #include "componentMixedTetPolyPatchVectorField.H"
33 #include "mapPolyMesh.H"
35 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
36 void Foam::twoStrokeEngine::checkMotionFluxes()
40 //checking the motion fluxes for the cutFaceZone
42 Info << "Checking the motion fluxes in the cut-face zone" << endl;
44 const labelList& cutFaceZoneAddressing =
45 faceZones()[faceZones().findZoneID("cutFaceZone")];
47 boolList calculatedMeshPhi(V().size(), false);
48 scalarField sumMeshPhi(V().size(), 0.0);
50 forAll(cutFaceZoneAddressing, i)
52 label facei = cutFaceZoneAddressing[i];
54 calculatedMeshPhi[owner()[facei]] = true;
55 calculatedMeshPhi[neighbour()[facei]] = true;
58 Info << "Checking the motion fluxes in the liner zone" << endl;
60 const labelList& linerAddressing =
61 faceZones()[faceZones().findZoneID(scavInCylPatchName_ + "Zone")];
63 forAll(linerAddressing, i)
65 label facei = linerAddressing[i];
67 calculatedMeshPhi[owner()[facei]] = true;
68 calculatedMeshPhi[neighbour()[facei]] = true;
71 const polyPatch& wallPatch =
72 boundaryMesh()[boundaryMesh().findPatchID("wall")];
74 labelList wallLabels(wallPatch.size());
76 forAll (wallLabels, i)
78 wallLabels[i] = wallPatch.start() + i;
83 label facei = wallLabels[i];
85 calculatedMeshPhi[owner()[facei]] = true;
86 calculatedMeshPhi[neighbour()[facei]] = true;
89 forAll(owner(), facei)
91 sumMeshPhi[owner()[facei]] += phi()[facei];
92 sumMeshPhi[neighbour()[facei]] -= phi()[facei];
95 forAll(boundary(), patchi)
97 const unallocLabelList& pFaceCells =
98 boundary()[patchi].faceCells();
100 const fvsPatchField<scalar>& pssf = phi().boundaryField()[patchi];
102 forAll(boundary()[patchi], facei)
104 sumMeshPhi[pFaceCells[facei]] += pssf[facei];
110 DynamicList<label> checkMeshPhi;
111 label checkMeshPhiSize = 0;
113 forAll(calculatedMeshPhi, i)
115 if(calculatedMeshPhi[i] == true)
117 checkMeshPhi.append(i);
122 Info << "checkMeshPhiSize = " << checkMeshPhiSize << endl;
124 checkMeshPhi.setSize(checkMeshPhiSize);
126 scalarField dVdt(checkMeshPhiSize, 0.0);
130 label celli = checkMeshPhi[i];
132 dVdt[i] = (1.0 - V0()[celli]/V()[celli])/engTime().deltaT().value();
135 Info << "checking mesh flux in the cutFaces" << endl;
139 forAll(checkMeshPhi, i)
141 scalar sumCheck = dVdt[i] - sumMeshPhi[checkMeshPhi[i]];
142 if(mag(sumCheck) > 1)
144 Info<< "LOCAL sumCheck[" << checkMeshPhi[i] << "] = "
150 Info<< "found " << nOutCheck << " cells with inconsistent motion fluxes"
152 Info << "end " << endl;
157 scalarField dVdt = (1.0 - V0()/V())/engTime().deltaT();
159 scalarField sumMeshPhi(V().size(), 0.0);
161 forAll(owner(), facei)
163 sumMeshPhi[owner()[facei]] += phi()[facei];
164 sumMeshPhi[neighbour()[facei]] -= phi()[facei];
167 forAll(boundary(), patchi)
169 const unallocLabelList& pFaceCells =
170 boundary()[patchi].faceCells();
172 const fvsPatchField<scalar>& pssf = phi().boundaryField()[patchi];
174 forAll(boundary()[patchi], facei)
176 sumMeshPhi[pFaceCells[facei]] += pssf[facei];
182 scalarField sumCheck = dVdt - sumMeshPhi;
186 forAll(sumCheck, celli)
188 if(mag(sumCheck[celli]) > 1)
190 Info<< "sumCheck GLOBAL[" << celli << "] = "
191 << sumCheck[celli] << endl;
196 Info<< "found " << nOutCheck
197 << " cells with inconsistent motion fluxes GLOBAL" << endl;