matrixWrite.H
Go to the documentation of this file.
1 // Investigate the Coefficient Matrix
2 label Nc = mesh.nCells(); //Total number of cells
3 simpleMatrix<scalar> A(Nc); //Coefficient matrix
4 // Initialization of matrix
5 for(label i=0; i<Nc; i++)
6 {
7  A.source()[i] = 0.0;
8  for(label j=0; j<Nc; j++)
9  {
10  A[i][j] = 0.0;
11  }
12 }
13 // Assigning diagonal coefficients
14 for(label i=0; i<Nc; i++)
15 {
16  A[i][i] = TEqn.diag()[i];
17 }
18 // Assigning off-diagonal coefficients
19 for(label faceI=0; faceI<TEqn.lduAddr().lowerAddr().size(); faceI++)
20 {
21  label l = TEqn.lduAddr().lowerAddr()[faceI];
22  label u = TEqn.lduAddr().upperAddr()[faceI];
23  A[l][u] = TEqn.upper()[faceI];
24  A[u][l] = TEqn.upper()[faceI];
25 }
26 // Assigning contribution from BC
27 forAll(T.boundaryField(), patchI)
28 {
29  const fvPatch &pp = T.boundaryField()[patchI].patch();
30  forAll(pp, faceI)
31  {
32  label cellI = pp.faceCells()[faceI];
33  A[cellI][cellI] += TEqn.internalCoeffs()[patchI][faceI];
34  A.source()[cellI] += TEqn.boundaryCoeffs()[patchI][faceI];
35  }
36 }
37 
38 Info<< "¥n==Coefficient Matrix==" << endl;
39 for(label i=0; i<Nc; i++)
40 {
41 for(label j=0; j<Nc; j++)
42 {
43 Info<< A[i][j] << " ";
44 }
45 Info<< A.source()[i] << endl;
46 }
47 //Info<< A << endl;
48 Info<< "Solution: " << A.solve() << endl;
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
A
simpleMatrix< scalar > A(Nc)
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Info
messageStream Info
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
TEqn
fvScalarMatrix TEqn(fvm::div(phi, T) - fvm::laplacian(alphaEff, T)==radiation->ST(rhoCpRef, T)+fvOptions(T))
T
const volScalarField & T
Definition: createFields.H:25
forAll
forAll(T.boundaryField(), patchI)
Definition: matrixWrite.H:27
Nc
label Nc
Definition: matrixWrite.H:2