2 const fvsPatchScalarField& pistonMeshPhi =
3 phi().boundaryField()[boundaryMesh().findPatchID("piston")];
5 Info << "max piston mesh phi 2 = " << max(mag(pistonMeshPhi)) << endl;
7 const labelList& cutFaces =
8 faceZones()[faceZones().findZoneID("cutFaceZone")];
10 forAll(cutFaces, facei)
12 correctedMeshPhi[cutFaces[facei]] = 0.0;
15 // setPhi(correctedMeshPhi);
17 Info<< "max mesh phi, corrected cut faces = "
18 << max(mag(phi().internalField())) << nl
19 << "max mesh phi, corrected cut faces = "
20 << min(mag(phi().internalField())) << endl;
22 const polyPatch& wallPatch =
23 boundaryMesh()[boundaryMesh().findPatchID("wall")];
25 label wallSize = wallPatch.size();
27 fvsPatchScalarField& wallMeshPhi =
28 correctedMeshPhi.boundaryField()
30 boundaryMesh().findPatchID("wall")
33 forAll(wallMeshPhi, k)
35 if(mag(wallMeshPhi[k]) > SMALL)
41 fvsPatchScalarField& linerMeshPhi =
42 correctedMeshPhi.boundaryField()[boundaryMesh().findPatchID("liner")];
44 forAll(linerMeshPhi, k)
46 if(mag(linerMeshPhi[k]) > SMALL)
52 // setPhi(correctedMeshPhi);
54 Info<< "max mesh phi after correction = " << max(mag(phi())) << nl
55 << "min mesh phi after correction = " << min(mag(phi())) << endl;
59 scalarField dVdt = (1.0 - V0()/V())/engTime().deltaT();
61 scalarField sumMeshPhi(V().size(), 0.0);
62 scalarField sumMeshPhiCorrected(V().size(), 0.0);
64 forAll(owner(), facei)
66 sumMeshPhi[owner()[facei]] += phi()[facei];
67 sumMeshPhi[neighbour()[facei]] -= phi()[facei];
68 sumMeshPhiCorrected[owner()[facei]] += correctedMeshPhi[facei];
69 sumMeshPhiCorrected[neighbour()[facei]] -= correctedMeshPhi[facei];
72 forAll(boundary(), patchi)
74 const unallocLabelList& pFaceCells =
75 boundary()[patchi].faceCells();
77 const fvsPatchField<scalar>& pssf = phi().boundaryField()[patchi];
78 const fvsPatchField<scalar>& pssfCorrected =
79 correctedMeshPhi.boundaryField()[patchi];
81 forAll(boundary()[patchi], facei)
83 sumMeshPhi[pFaceCells[facei]] += pssf[facei];
84 sumMeshPhiCorrected[pFaceCells[facei]] += pssfCorrected[facei];
90 sumMeshPhiCorrected /= V();
92 scalarField sumCheck = dVdt - sumMeshPhi;
93 scalarField sumCheckCorrected = dVdt - sumMeshPhiCorrected;
96 label nOutCheckCorrected = 0;
98 forAll(sumCheck, celli)
100 if(mag(sumCheck[celli]) > 1)
106 forAll(sumCheckCorrected, celli)
108 if (mag(sumCheckCorrected[celli]) > 1)
110 nOutCheckCorrected++;
114 Info<< "found " << nOutCheck
115 << " cells with inconsistent motion fluxes real" << endl;
116 Info<< "found " << nOutCheckCorrected
117 << " cells with inconsistent motion fluxes CORRECTED" << endl;
121 newPoints = allPoints();
123 // movePoints(newPoints);
125 // pointField mappedOldPointsNew(newPoints.size());
126 pointField mappedOldPointsNew(points().size());
128 mappedOldPointsNew.map(oldPointsNew, topoChangeMap4->pointMap());
130 // Solve the correct mesh motion to make sure motion fluxes
131 // are solved for and not mapped
132 movePoints(mappedOldPointsNew);
136 Info << "max mesh phi after reset motion = " << max(mag(phi())) << endl;
137 Info << "max mesh phi after reset motion = " << min(mag(phi())) << endl;
140 movePoints(newPoints);
141 // pointField newPointsNew = allPoints();
142 // movePoints(newPointsNew);
144 Info << "max mesh phi after corr = " << max(mag(phi())) << endl;
145 Info << "max mesh phi after corr = " << min(mag(phi())) << endl;
149 // Changing topology by hand
150 // autoPtr<mapPolyMesh> topoChangeMap3 = topoChanger_.changeMesh();
152 Info << "Sliding interfaces coupled: " << attached() << endl;
153 Info << "max mesh phi after correction = " << max(mag(phi())) << endl;