CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Linear Solver (https://www.cfd-online.com/Forums/openfoam/93224-linear-solver.html)

 Argen October 8, 2011 19:03

Linear Solver

Assuming one linear system AX=B, where A is a matrix of NxN and B is a vector, A and B are known and vector X is unknown. How to use the linear solver in OpenFoam to solve this linear system?

 Argen October 8, 2011 20:28

I thought that two fields of X and B are probably created first as
volScalarField X
(
IOobject
(
"X",
runTime.timeName(),
mesh,
IOobject::AUTO_WRITE
),
mesh
);
while I don't know how to set up B since it is known.

Another question is how to set an equation to solve
fvScalarMatrix XEqn
(
A(X) ????
);

XEqn.solve();

If this step is properly handled, it could be easy to set up linear solver and preconditioner in fvSolution

Any idea on this problem?

 santiagomarquezd October 8, 2011 21:36

Argen, X and B creating is just as you showed in the post. Respect the matrix, as far as I know the problem is that fvMatrices in FOAM are ever related to a geometrical problem and its discretization, so that is not possible to create them only from their coefficients and positions in the matrix (Both fvMatrix and lduMatrix don't have constructors from elements and positions). It requires to use the lduAddressing at low level and would require to code your own classes to do so.

Please FOAMers correct me if I'm wrong.

Regards.

 Argen October 10, 2011 01:17

Quote:
 Originally Posted by santiagomarquezd (Post 327175) Argen, X and B creating is just as you showed in the post. Respect the matrix, as far as I know the problem is that fvMatrices in FOAM are ever related to a geometrical problem and its discretization, so that is not possible to create them only from their coefficients and positions in the matrix (Both fvMatrix and lduMatrix don't have constructors from elements and positions). It requires to use the lduAddressing at low level and would require to code your own classes to do so. Please FOAMers correct me if I'm wrong.
lduAddressing is a addressing array which is provided for the lower and upper triangles to translate their face index into a corresponding cell index. I could not figure out how to make it from the known matrix, A. As Santiago mentioned, I sense that lduMatrix and fvMatrix can't work for this case since matrix is generated in OpenFOAM directly by discretizing a certain equation.

Do you have more suggestions on it?

 All times are GMT -4. The time now is 05:37.