https://linen.dev logo
Just FFS, here's a cleaned up version with followi...
# programming
q
Just FFS, here's a cleaned up version with following changes per your suggestion: removed redundant differentiation based on symmetry, removed redundant if conditions. So its basically a similar loop in the event one wants to write to file/console instead of memory. Still misses boundary values...
Copy code
const cellList& cells = mesh.cells();
    const labelUList& own = mesh.owner();
    const labelUList& nei = mesh.neighbour();

    int cellCount = cells.size();
    Info <<cellCount<<"x"<<cellCount<<" matrix needed."<<endl;
    scalarField rowI = UEqn.diag();

    forAll(cells, i)
    {
        rowI = 0.0;
        rowI[i]=UEqn.diag()[i];

        const cell& c = cells[i];
        {
            forAll(c, j)
            {
                const label facei = c[j];
                if (mesh.isInternalFace(facei))
                {
                    if(i ==nei[facei])
                    {
                      rowI[own[facei]]= UEqn.upper()[facei];
                    }
                    else
                    {
                      rowI[nei[facei]]= UEqn.lower()[facei];
                    }
               }
            }
       }
    //Add boundary contributions.
    
      //print to console, or print to file.
      forAll(rowI,j)
      {
        Info<<rowI[j]<<"\t";
      }
      Info<<endl;
    }