CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   fvMeshSubset and labelHashSet: mapping fields between the meshes (http://www.cfd-online.com/Forums/openfoam-programming-development/97502-fvmeshsubset-labelhashset-mapping-fields-between-meshes.html)

Arnoldinho February 18, 2012 12:40

fvMeshSubset and labelHashSet: mapping fields between the meshes
 
Hi,

I am using a submesh within my solver. It is constructed out of selected cells from the 'normal' mesh by a labelHashSet cCells:

Code:

labelHashSet cCells;

forAll(mesh.C().internalField(), cellI)
{
    if (mesh.C().internalField()[cellI].component(2) > -0.7)
    {
        cCells.insert(cellI);
    }
}

The submesh itself is then constructed using
Code:

fvMeshSubset submesh(cSed, mesh);
submesh.setLargeCellSubset(cCells, patchi, true);
fvMesh& cMesh = submesh.subMesh();

So far, so good. Now I have to map data from the 'normal' mesh to the submesh. Therefore I am using a loop over the desired values and am (at least what I think) mapping them onto the submesh fields within each time step, like:

Code:

forAll (cCells, celli)
{
    cSed_C[celli] = cSed[cCells[celli]];
    ...
}

After this, some calculations on the submesh are done. To display the results in ParaView, I'd now like to map the values back onto the 'normal' mesh. So I was thinking of simply doing this as below, which in my eyes is just the opposite mapping:
Code:

forAll (cCells, celli)
{
    cSed[cCells[celli]] = cSed_C[celli];
}

Unfortunately this does not work! The labelHashSet seems to contain some label and boolean values, and using the above, only the first two values in cSed are overwritten with (wrong) values from cSed_C, whereas the rest is zero.

So my questions are:
1. How can I map fields between meshes ('normal' mesh and submesh) from within my solver during runtime? I'm using OF 1.6-ext.
2. Does this have to be done like above or similar, or is this done automatically by OF, as the submesh is connected to the 'normal' mesh?
3. Is there a way to display the submesh in Paraview? The values are stored (together with the submesh points, faces etc.) in a subfolder of every time-step. These can of course be copied to a separate case, but is there an easier way?

Arne

Arnoldinho February 19, 2012 10:05

After having a closer look at the fvMeshSubset source code I found that the mapping between the fields can be done using cellMap(), pointMap(), patchMap() or faceMap().

Where the mapping using the labelHashSet as described above does not work for any mapping direction, one simply creates e.g. a cellMap
Code:

const labelList & cellMap_(submesh.cellMap());
and uses that one to map the field values for both directions:
Code:

forAll (cellMap_, celli)
{
    alpha1_C[celli] = alpha1[cellMap_[celli]];
}

forAll (cellMap_, celli)
{
    alpha1[cellMap_[celli]] = alpha1_C[celli];
}

Just in case someone might need it. I nevertheless have the question if the submesh can directly be seen in paraview without making a new case for it.

Arne


All times are GMT -4. The time now is 00:20.