50 additionalCellsPtr_(NULL),
51 additionalVectorsPtr_(NULL)
69 void Foam::extendedLeastSquaresVectors::makeLeastSquaresVectors()
const
73 Info<<
"extendedLeastSquaresVectors::makeLeastSquaresVectors() :"
74 <<
"Constructing least square gradient vectors"
78 const fvMesh& mesh = mesh_;
85 mesh_.pointsInstance(),
101 mesh_.pointsInstance(),
119 if (!mesh_.orthogonal())
121 d -= mesh_.correctionVectors()/mesh_.deltaCoeffs();
132 dd[owner[faceI]] += wdd;
133 dd[neighbour[faceI]] += wdd;
138 forAll(d.boundaryField(), patchI)
142 const fvPatch&
p = pd.patch();
147 dd[faceCells[patchFaceI]] +=
148 (1.0/
magSqr(pd[patchFaceI]))*
sqr(pd[patchFaceI]);
159 label maxNaddCells = 4*detdd.size();
160 additionalCellsPtr_ =
new List<labelPair>(maxNaddCells);
161 List<labelPair>& additionalCells_ = *additionalCellsPtr_;
167 while (++count < 100 && detdd[i] < minDet_)
169 if (nAddCells == maxNaddCells)
173 "extendedLeastSquaresVectors::"
174 "makeLeastSquaresVectors() const"
175 ) <<
"nAddCells exceeds maxNaddCells"
181 scalar maxDetddij = 0.0;
187 forAll(mesh.pointCells()[pointLabels[j]],
k)
189 label cellj = mesh.pointCells()[pointLabels[j]][
k];
195 vector dCij = (mesh.C()[cellj] - mesh.C()[i]);
200 scalar detddij =
det(ddij);
202 if (detddij > maxDetddij)
205 maxDetddij = detddij;
214 additionalCells_[nAddCells][0] = i;
215 additionalCells_[nAddCells++][1] = addCell;
216 vector dCij = mesh.C()[addCell] - mesh.C()[i];
218 detdd[i] =
det(dd[i]);
223 additionalCells_.setSize(nAddCells);
228 Info<<
"nAddCells/nCells = " << scalar(nAddCells)/mesh.nCells() <<
endl;
238 (1.0/
magSqr(d[faceI]))*(invDd[owner[faceI]] & d[faceI]);
241 ((-1.0)/
magSqr(d[faceI]))*(invDd[neighbour[faceI]] & d[faceI]);
244 forAll(lsP.boundaryField(), patchI)
250 const fvPatch& p = patchLsP.patch();
255 patchLsP[patchFaceI] =
256 (1.0/
magSqr(pd[patchFaceI]))
257 *(invDd[faceCells[patchFaceI]] & pd[patchFaceI]);
262 additionalVectorsPtr_ =
new vectorField(additionalCells_.size());
263 vectorField& additionalVectors_ = *additionalVectorsPtr_;
265 forAll(additionalCells_, i)
268 mesh.C()[additionalCells_[i][1]] - mesh.C()[additionalCells_[i][0]];
270 additionalVectors_[i] =
271 (1.0/
magSqr(dCij))*(invDd[additionalCells_[i][0]] & dCij);
276 Info<<
"extendedLeastSquaresVectors::makeLeastSquaresVectors() :"
277 <<
"Finished constructing least square gradient vectors"
288 makeLeastSquaresVectors();
291 return *pVectorsPtr_;
300 makeLeastSquaresVectors();
303 return *nVectorsPtr_;
310 if (!additionalCellsPtr_)
312 makeLeastSquaresVectors();
315 return *additionalCellsPtr_;
322 if (!additionalVectorsPtr_)
324 makeLeastSquaresVectors();
327 return *additionalVectorsPtr_;