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/)
-   -   Problem in fvMesh.C when using topological changes. OpenFoam 2-2-x (https://www.cfd-online.com/Forums/openfoam-programming-development/122216-problem-fvmesh-c-when-using-topological-changes-openfoam-2-2-x.html)

Horacio Aguerre August 14, 2013 12:57

Problem in fvMesh.C when using topological changes. OpenFoam 2-2-x
 
Hi All,

I have the following problem when I run cases with topological changes on the mesh (I have implemented a layering strategy which uses the layerAdditionRemoval class).

OpenFoam Version: 2.2.0

File: fvMesh.C

Method: mapFields(const mapPolyMesh& meshMap)


When mapping the old cells volume ,(just mapping to new cell labels), (fvMesh.C:562)

Code:

if (V0Ptr_)
    {
        scalarField& V0 = *V0Ptr_;

        scalarField savedV0(V0);
        V0.setSize(nCells());

        forAll(V0, i)
        {
            if (cellMap[i] > -1)
            {
                V0[i] = savedV0[cellMap[i]];
            }
            else
            {
                V0[i] = 0.0;
            }
        }
    }

Here it is waited that V0PTr_ to be the old time level pointer to cells volume. However V0Ptr_ is mapped previously by, (fvMesh.C:550)

Code:

MapDimensionedFields<scalar, fvMeshMapper, volMesh>(mapper);
and then the V0PTr_, which is assigned to savedV0, looses its relation with cellMap and the mapping

Code:

V0[i] = savedV0[cellMap[i]];
results uncorrect. (When cells are removed due to topological changes on the mesh, the program crashes due to try to access to a wrong memory position because now cellMap[i] is bigger than list savedV0 size).

I have seen that in the previous OpenFOAM version 2.0-x, the MapDimensionedFields was not use in fvMesh.C. But, after OpenFoam version 2.1-x the MapDimensionedFields were added.

The cases run without problems when i comment either the line (fvMesh.C:550) or the group after (fvMesh.C:562).

Is the "mapping", that is done from (fvMesh.C:562), no more necessary when the MapDimensionedFields is used before?

Thanks, Horacio.


All times are GMT -4. The time now is 08:54.