42 for (
label i=0; i<m; i++)
45 scalar largestCoeff =
mag(tmpMatrix(iMax, i));
48 for (
label j=i+1; j<m; j++)
50 if (
mag(tmpMatrix(j, i)) > largestCoeff)
53 largestCoeff =
mag(tmpMatrix(iMax, i));
61 Swap(tmpMatrix(i,
k), tmpMatrix(iMax,
k));
63 Swap(sourceSol[i], sourceSol[iMax]);
67 if (
mag(tmpMatrix(i, i)) < 1
e-20)
75 for (
label j=i+1; j<m; j++)
77 sourceSol[j] -= sourceSol[i]*(tmpMatrix(j, i)/tmpMatrix(i, i));
82 tmpMatrix(i,
k)*tmpMatrix(j, i)/tmpMatrix(i, i);
88 for (
label j=m-1; j>=0; j--)
94 ntempvec += tmpMatrix(j,
k)*sourceSol[
k];
97 sourceSol[j] = (sourceSol[j] - ntempvec)/tmpMatrix(j, j);
112 solve(tmpMatrix, psi);
128 for (
label i=0; i<m; i++)
130 label ip = pivotIndices[i];
131 Type
sum = sourceSol[ip];
132 sourceSol[ip] = sourceSol[i];
133 const scalar* __restrict__ luMatrixi = luMatrix[i];
137 for (
label j=ii-1; j<i; j++)
139 sum -= luMatrixi[j]*sourceSol[j];
150 for (
label i=m-1; i>=0; i--)
152 Type
sum = sourceSol[i];
153 const scalar* __restrict__ luMatrixi = luMatrix[i];
155 for (
label j=i+1; j<m; j++)
157 sum -= luMatrixi[j]*sourceSol[j];
160 sourceSol[i] = sum/luMatrixi[i];
176 for (
label i=0; i<m; i++)
178 Type
sum = sourceSol[i];
179 const scalar* __restrict__ luMatrixi = luMatrix[i];
183 for (
label j=ii-1; j<i; j++)
185 sum -= luMatrixi[j]*sourceSol[j];
193 sourceSol[i] = sum/luMatrixi[i];
196 for (
label i=m-1; i>=0; i--)
198 Type
sum = sourceSol[i];
199 const scalar* __restrict__ luMatrixi = luMatrix[i];
201 for (
label j=i+1; j<m; j++)
203 sum -= luMatrixi[j]*sourceSol[j];
206 sourceSol[i] = sum/luMatrixi[i];
236 template<
class Form,
class Type>
247 <<
"A and B must have identical inner dimensions but A.n = " 248 << A.
n() <<
" and B.m = " << B.
m()
254 for (
label i=0; i<A.
m(); i++)
256 for (
label j=0; j<B.
n(); j++)
258 for (
label l=0; l<B.
m(); l++)
260 ans(i, j) += A(i, l)*B(l, j);
label n() const
Return the number of columns.
void multiply(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void LUDecompose(scalarSquareMatrix &matrix, labelList &pivotIndices)
LU decompose the matrix with pivoting.
Traits class for primitives.
label k
Boltzmann constant.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
Various functions to operate on Lists.
errorManip< error > abort(error &err)
A templated (m x n) matrix of objects of <T>.
A templated 2D square symmetric matrix of objects of <T>, where the n x n matrix dimension is known a...
fvModels source(alpha1, mixture.thermo1().rho())
SolverPerformance< Type > solve(fvMatrix< Type > &, const word &)
Solve returning the solution statistics given convergence tolerance.
label m() const
Return the number of rows.
dimensioned< scalar > mag(const dimensioned< Type > &)
const dimensionedScalar e
Elementary charge.
void LUsolve(scalarSquareMatrix &matrix, List< Type > &source)
Solve the matrix using LU decomposition with pivoting.
void LUBacksubstitute(const scalarSquareMatrix &luMmatrix, const labelList &pivotIndices, List< Type > &source)
LU back-substitution with given source, returning the solution.