CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Matrix manipulation (https://www.cfd-online.com/Forums/openfoam-programming-development/204242-matrix-manipulation.html)

Za-ck July 18, 2018 05:44

Matrix manipulation
 
Hi Foamers!

I would like to manipulate my matrix using an implicit relaxation. The relaxation factor is individual for each cell and may also be 0. My solution is working very good, but only for serial simulations not in parallel simulations. I assume the problem are the coupled boundaries. Maybe somebody can tell me, how to manipulate the matrix correctly, and how the neighbor elements are stored if the belonging cell is on a different processor.

Here is my current approach:

r is a volScalarField and represents the relaxation factor 0 <= r <= 1.0

Code:

        const unallocLabelList& l = omegaEqn().lduAddr().lowerAddr();
        const unallocLabelList& u = omegaEqn().lduAddr().upperAddr();

        omegaEqn().source() = (r * omegaEqn().source()) + ((1-r) * omegaEqn().diag() * omegaTarget);

        if(omegaEqn().hasLower())
        {
            scalarField& lower = omegaEqn().lower();

            for (label face_=0; face_<l.size(); face_++)
            {
                {
                    lower[face_] *= r[l[face_]];
                }
            }
        }

        if(omegaEqn().hasUpper())
        {
            scalarField& upper = omegaEqn().upper();

            for (label face_=0; face_<u.size(); face_++)
            {
                {
                    upper[face_] *= r[u[face_]];
                }
            }
        }

Best regards,
Za-ck


All times are GMT -4. The time now is 12:36.