67 comm_(ldum.
mesh().comm())
91 auto& mat = lduMatrices.emplace_set(proci);
111 convert(ldum, interfaceCoeffs, interfaces);
117 const label numRows =
nRows();
118 const label numCols =
nCols();
120 Pout<<
"LUscalarMatrix : size:" << numRows <<
endl;
121 for (label rowi = 0; rowi < numRows; ++rowi)
125 Pout<<
"cell:" << rowi <<
" diagCoeff:" << row[rowi] <<
nl;
127 Pout<<
" connects to upper cells :";
128 for (label coli = rowi+1; coli < numCols; ++coli)
130 if (
mag(row[coli]) > SMALL)
132 Pout<<
' ' << coli <<
" (coeff:" << row[coli] <<
')';
136 Pout<<
" connects to lower cells :";
137 for (label coli = 0; coli < rowi; ++coli)
139 if (
mag(row[coli]) > SMALL)
141 Pout<<
' ' << coli <<
" (coeff:" << row[coli] <<
')';
158void Foam::LUscalarMatrix::convert
169 const label* __restrict__ uPtr = ldum.lduAddr().upperAddr().
begin();
170 const label* __restrict__ lPtr = ldum.lduAddr().lowerAddr().
begin();
172 const scalar* __restrict__ diagPtr = ldum.diag().
begin();
173 const scalar* __restrict__ upperPtr = ldum.upper().
begin();
174 const scalar* __restrict__ lowerPtr = ldum.lower().
begin();
176 const label nCells = ldum.diag().
size();
177 const label nFaces = ldum.upper().size();
186 label uCell = uPtr[
face];
187 label lCell = lPtr[
face];
189 operator[](uCell)[lCell] = lowerPtr[
face];
190 operator[](lCell)[uCell] = upperPtr[
face];
195 if (interfaces.set(inti))
201 const label* __restrict__ lPtr =
interface.faceCells().begin();
205 label nbrInt = cycInterface.neighbPatchID();
206 const label* __restrict__ uPtr =
207 interfaces[nbrInt].interface().faceCells().begin();
209 const scalar* __restrict__ nbrUpperLowerPtr =
210 interfaceCoeffs[nbrInt].begin();
212 label inFaces =
interface.faceCells().size();
216 label uCell = lPtr[
face];
217 label lCell = uPtr[
face];
219 operator[](uCell)[lCell] -= nbrUpperLowerPtr[
face];
226void Foam::LUscalarMatrix::convert
231 procOffsets_.resize_nocopy(lduMatrices.size() + 1);
234 auto iter = procOffsets_.begin();
236 label nCellsTotal = 0;
237 *iter++ = nCellsTotal;
239 for (
const auto& mat : lduMatrices)
241 nCellsTotal += mat.size();
242 *iter++ = nCellsTotal;
251 forAll(lduMatrices, ldumi)
254 label offset = procOffsets_[ldumi];
256 const label* __restrict__ uPtr = lduMatrixi.upperAddr_.
begin();
257 const label* __restrict__ lPtr = lduMatrixi.lowerAddr_.
begin();
259 const scalar* __restrict__ diagPtr = lduMatrixi.diag_.
begin();
260 const scalar* __restrict__ upperPtr = lduMatrixi.upper_.
begin();
261 const scalar* __restrict__ lowerPtr = lduMatrixi.lower_.
begin();
263 const label nCells = lduMatrixi.
size();
264 const label nFaces = lduMatrixi.upper_.size();
268 label globalCell =
cell + offset;
269 operator[](globalCell)[globalCell] = diagPtr[
cell];
274 label uCell = uPtr[
face] + offset;
275 label lCell = lPtr[
face] + offset;
277 operator[](uCell)[lCell] = lowerPtr[
face];
278 operator[](lCell)[uCell] = upperPtr[
face];
282 lduMatrixi.interfaces_;
290 const label* __restrict__ ulPtr =
interface.faceCells_.begin();
292 const scalar* __restrict__ upperLowerPtr =
295 label inFaces =
interface.faceCells_.size()/2;
299 label uCell = ulPtr[
face] + offset;
300 label lCell = ulPtr[
face + inFaces] + offset;
302 operator[](uCell)[lCell] -= upperLowerPtr[
face + inFaces];
303 operator[](lCell)[uCell] -= upperLowerPtr[
face];
314 lduMatrices[
interface.neighbProcNo_].interfaces_;
316 label neiInterfacei = -1;
318 forAll(neiInterfaces, ninti)
323 neiInterfaces[ninti].neighbProcNo_
326 && (neiInterfaces[ninti].tag_ ==
interface.tag_)
329 neiInterfacei = ninti;
334 if (neiInterfacei == -1)
340 neiInterfaces[neiInterfacei];
342 const label* __restrict__ uPtr =
interface.faceCells_.begin();
343 const label* __restrict__ lPtr =
344 neiInterface.faceCells_.begin();
346 const scalar* __restrict__ upperPtr =
interface.coeffs_.begin();
347 const scalar* __restrict__ lowerPtr =
348 neiInterface.coeffs_.begin();
350 label inFaces =
interface.faceCells_.size();
351 label neiOffset = procOffsets_[
interface.neighbProcNo_];
355 label uCell = uPtr[
face] + offset;
356 label lCell = lPtr[
face] + neiOffset;
358 operator[](uCell)[lCell] -= lowerPtr[
face];
359 operator[](lCell)[uCell] -= upperPtr[
face];
367void Foam::LUscalarMatrix::printDiagonalDominance()
const
369 for (label i=0; i<m(); i++)
372 for (label j=0; j<m(); j++)
376 sum += operator[](i)[j];
395 for (label j=0; j<m(); j++)
400 for (label i=0; i<m(); i++)
A field of fields is a PtrList of fields with reference counting.
static void recv(Type &value, const int fromProcNo, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
Receive and deserialize a value. Uses operator>> for de-serialization.
Class to perform the LU decomposition on a symmetric matrix.
LUscalarMatrix() noexcept
Default construct.
void decompose(const scalarSquareMatrix &mat)
Perform the LU decomposition of the matrix.
void inv(scalarSquareMatrix &M) const
Set M to the inverse of this square matrix.
label m() const noexcept
The number of rows.
iterator begin() noexcept
Return an iterator to begin traversing a Matrix.
label nCols() const noexcept
The number of columns.
label nRows() const noexcept
The number of rows.
const Type * operator[](const label irow) const
Return const pointer to data in the specified row - rowData().
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
T & emplace_set(const label i, Args &&... args)
Construct and set a new element at given position, (discard old element at that location).
void resize_nocopy(const label n)
SquareMatrix & operator=(const SquareMatrix &)=default
iterator begin() noexcept
Return an iterator to begin traversing the UList.
void size(const label n)
Older name for setAddressableSize.
bool send()
Send buffer contents now and not in destructor [advanced usage]. Returns true on success.
Inter-processor communications stream.
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
static int & msgType() noexcept
Message tag of standard messages.
static constexpr int masterNo() noexcept
Relative rank for the master process - is always 0.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
static rangeType subProcs(const label communicator=worldComm)
Range of process indices for sub-processes.
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
iterator begin()
Return iterator to begin traversal of non-nullptr entries.
A cell is defined as a list of faces with extra functionality.
An abstract base class for cyclic coupled interfaces.
A face is a list of labels corresponding to mesh vertices.
virtual const labelUList & upperAddr() const =0
Return upper addressing.
virtual const labelUList & lowerAddr() const =0
Return lower addressing.
label size() const noexcept
Return number of equations.
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches.
lduMatrix is a general matrix class in which the coefficients are stored as three arrays,...
const lduAddressing & lduAddr() const
Return the LDU addressing.
const scalarField & diag() const
const scalarField & upper() const
const scalarField & lower() const
IO interface for processorLduInterface.
I/O for lduMatrix and interface values.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Namespace for handling debugging switches.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
void LUBacksubstitute(const scalarSquareMatrix &luMmatrix, const labelList &pivotIndices, List< Type > &source)
LU back-substitution with given source, returning the solution in the source.
void LUDecompose(scalarSquareMatrix &matrix, labelList &pivotIndices)
LU decompose the matrix with pivoting.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
SquareMatrix< scalar > scalarSquareMatrix
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UPtrList< const lduInterfaceField > lduInterfaceFieldPtrsList
List of coupled interface fields to be used in coupling.
constexpr char nl
The newline '\n' character (0x0a).
interfaceProperties interface(alpha1, U, thermo->transportPropertiesDict())
#define forAll(list, i)
Loop across all elements in list.