73 comm_(ldum.mesh().comm())
143 nCells += lduMatrices[i].
size();
148 convert(lduMatrices);
156 convert(ldum, interfaceCoeffs, interfaces);
166 Pout<<
"LUscalarMatrix : size:" << mRows <<
endl;
167 for (
label rowI = 0; rowI < mRows; rowI++)
171 Pout<<
"cell:" << rowI <<
" diagCoeff:" << row[rowI] <<
endl;
173 Pout<<
" connects to upper cells :";
174 for (
label columnI = rowI+1; columnI < nColumns; columnI++)
176 if (
mag(row[columnI]) > small)
178 Pout<<
' ' << columnI <<
" (coeff:" << row[columnI]
183 Pout<<
" connects to lower cells :";
184 for (
label columnI = 0; columnI < rowI; columnI++)
186 if (
mag(row[columnI]) > small)
188 Pout<<
' ' << columnI <<
" (coeff:" << row[columnI]
205 void Foam::LUscalarMatrix::convert
215 const scalar* __restrict__ diagPtr = ldum.
diag().
begin();
216 const scalar* __restrict__ upperPtr = ldum.
upper().
begin();
217 const scalar* __restrict__ lowerPtr = ldum.
lower().
begin();
227 for (
label face=0; face<nFaces; face++)
229 label uCell = uPtr[face];
230 label lCell = lPtr[face];
232 operator[](uCell)[lCell] = lowerPtr[face];
233 operator[](lCell)[uCell] = upperPtr[face];
238 if (interfaces.
set(inti))
240 const lduInterface&
interface = interfaces[inti].interface();
244 const label* __restrict__ lPtr = interface.faceCells().begin();
246 const cyclicLduInterface& cycInterface =
247 refCast<const cyclicLduInterface>(interface);
248 label nbrInt = cycInterface.nbrPatchIndex();
249 const label* __restrict__ uPtr =
250 interfaces[nbrInt].interface().faceCells().
begin();
252 const scalar* __restrict__ nbrUpperLowerPtr =
253 interfaceCoeffs[nbrInt].
begin();
255 label inFaces = interface.faceCells().size();
257 for (
label face=0; face<inFaces; face++)
259 label uCell = lPtr[face];
260 label lCell = uPtr[face];
262 operator[](uCell)[lCell] -= nbrUpperLowerPtr[face];
269 void Foam::LUscalarMatrix::convert
271 const PtrList<procLduMatrix>& lduMatrices
274 procOffsets_.setSize(lduMatrices.size() + 1);
277 forAll(lduMatrices, ldumi)
279 procOffsets_[ldumi+1] = procOffsets_[ldumi] + lduMatrices[ldumi].size();
282 forAll(lduMatrices, ldumi)
284 const procLduMatrix& lduMatrixi = lduMatrices[ldumi];
287 const label* __restrict__ uPtr = lduMatrixi.upperAddr_.begin();
288 const label* __restrict__ lPtr = lduMatrixi.lowerAddr_.begin();
290 const scalar* __restrict__ diagPtr = lduMatrixi.diag_.begin();
291 const scalar* __restrict__ upperPtr = lduMatrixi.upper_.begin();
292 const scalar* __restrict__ lowerPtr = lduMatrixi.lower_.begin();
295 const label nFaces = lduMatrixi.upper_.size();
297 for (
label cell=0; cell<nCells; cell++)
300 operator[](globalCell)[globalCell] = diagPtr[cell];
303 for (
label face=0; face<nFaces; face++)
308 operator[](uCell)[lCell] = lowerPtr[face];
309 operator[](lCell)[uCell] = upperPtr[face];
312 const PtrList<procLduInterface>& interfaces =
313 lduMatrixi.interfaces_;
317 const procLduInterface&
interface = interfaces[inti];
319 if (interface.myProcNo_ == interface.neighbProcNo_)
321 const label* __restrict__ ulPtr = interface.faceCells_.begin();
323 const scalar* __restrict__ upperLowerPtr =
324 interface.coeffs_.begin();
326 label inFaces = interface.faceCells_.size()/2;
328 for (
label face=0; face<inFaces; face++)
333 operator[](uCell)[lCell] -= upperLowerPtr[face + inFaces];
334 operator[](lCell)[uCell] -= upperLowerPtr[face];
337 else if (interface.myProcNo_ < interface.neighbProcNo_)
344 const PtrList<procLduInterface>& neiInterfaces =
345 lduMatrices[interface.neighbProcNo_].interfaces_;
347 label neiInterfacei = -1;
349 forAll(neiInterfaces, ninti)
354 neiInterfaces[ninti].neighbProcNo_
355 == interface.myProcNo_
357 && (neiInterfaces[ninti].tag_ == interface.tag_)
360 neiInterfacei = ninti;
365 if (neiInterfacei == -1)
370 const procLduInterface& neiInterface =
371 neiInterfaces[neiInterfacei];
373 const label* __restrict__ uPtr = interface.faceCells_.begin();
374 const label* __restrict__ lPtr =
375 neiInterface.faceCells_.begin();
377 const scalar* __restrict__ upperPtr = interface.coeffs_.begin();
378 const scalar* __restrict__ lowerPtr =
379 neiInterface.coeffs_.begin();
381 label inFaces = interface.faceCells_.size();
382 label neiOffset = procOffsets_[interface.neighbProcNo_];
384 for (
label face=0; face<inFaces; face++)
387 label lCell = lPtr[face] + neiOffset;
389 operator[](uCell)[lCell] -= lowerPtr[face];
390 operator[](lCell)[uCell] -= upperPtr[face];
398 void Foam::LUscalarMatrix::printDiagonalDominance()
const
400 for (
label i=0; i<m(); i++)
403 for (
label j=0; j<m(); j++)
407 sum += operator[](i)[j];
417 pivotIndices_.setSize(m());
425 pivotIndices_.setSize(m());
434 for (
label j=0; j<m(); j++)
439 for (
label i=0; i<m(); i++)
#define forAll(list, i)
Loop across all elements in list.
Input inter-processor communications stream.
Class to perform the LU decomposition on a symmetric matrix.
LUscalarMatrix()
Construct null.
void inv(scalarSquareMatrix &M) const
Set M to the inverse of this square matrix.
void decompose()
Perform the LU decomposition of the matrix.
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
label n() const
Return the number of columns.
label m() const
Return the number of rows.
void transfer(mType &)
Transfer the contents of the argument Matrix into this Matrix.
Type * operator[](const label)
Return subscript-checked row of Matrix.
Output inter-processor communications stream.
Inter-processor communications stream.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
bool set(const label) const
Is element set.
void operator=(const zero)
Assignment of all elements to zero.
iterator begin()
Return an iterator to begin traversing the UList.
static int masterNo()
Process index of the master.
static bool master(const label communicator=0)
Am I the master process.
static int lastSlave(const label communicator=0)
Process index of last slave.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
static int firstSlave()
Process index of first slave.
static bool & parRun()
Is this a parallel run?
static int & msgType()
Message tag of standard messages.
iterator begin()
Return an iterator to begin traversing the UPtrList.
bool set(const label) const
Is element set.
label size() const
Return the number of elements in the UPtrList.
A cell is defined as a list of faces with extra functionality.
label size() const
Return number of equations.
virtual const labelUList & upperAddr() const =0
Return upper addressing.
virtual const labelUList & lowerAddr() const =0
Return lower addressing.
lduMatrix is a general matrix class in which the coefficients are stored as three arrays,...
const lduAddressing & lduAddr() const
Return the LDU addressing.
I/O for lduMatrix and interface values.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
errorManipArg< error, int > exit(error &err, const int errNo=1)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void LUBacksubstitute(const scalarSquareMatrix &luMmatrix, const labelList &pivotIndices, List< Type > &source)
LU back-substitution with given source, returning the solution.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
void LUDecompose(scalarSquareMatrix &matrix, labelList &pivotIndices)
LU decompose the matrix with pivoting.
dimensioned< scalar > mag(const dimensioned< Type > &)
defineTypeNameAndDebug(combustionModel, 0)
prefixOSstream Pout(cout, "Pout")
void offset(label &lst, const label o)