CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

fvMeshSubset and labelHashSet: mapping fields between the meshes

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By Arnoldinho

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 18, 2012, 12:40
Default fvMeshSubset and labelHashSet: mapping fields between the meshes
  #1
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 17
Arnoldinho is on a distinguished road
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 is offline   Reply With Quote

Old   February 19, 2012, 10:05
Default
  #2
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 17
Arnoldinho is on a distinguished road
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
yuhan1991 likes this.
Arnoldinho is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 06:33.