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

Confusion face-addressing for surfaceField

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 19, 2010, 18:41
Default Confusion face-addressing for surfaceField
  #1
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hi all

I am confused with respect to the addressing of boundary face values for surfaceFields. Assume that the index "fLabelGlobal" is for a face on a boundary in terms of global indexing and "fLabelLocal" is targeting the same face, however in term of index locally on the boundary field. Then I can produce identical results with:

mesh.Cf()[fLabelGlobal]

and

scalarField cf = mesh.Cf().boundaryField()[correctIndex];
cf[fLabelLocal];

However trying to do

phi[fLabelGlobal]

produces garbage whereas

scalarField phiw = phi.boundaryField()[correctIndex];
phiw[fLabelLocal];

produces the correct result.

Both mesh.Cf() and phi are surfaceFields, however they appear to behave differently, what am I doing wrong?

By the way, I am working on cell level and need to target phi on all faces irrespectively of them being internal or boundary faces. I have made a hack to yield phi correctly, however it is painfully slow, thus any help is appreciated.

Best regards,

Niels
ngj is offline   Reply With Quote

Old   April 20, 2010, 06:25
Default
  #2
Senior Member
 
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 17
herbert is on a distinguished road
Hi Niels,

the only difference I see is that phi is a surfaceScalarField while mesh.Cf() is a surfaceVectorField. Might this be the problem?

Maybe there is a special boundary treatment for surfaceScalarFields only. I'll keep on trying.

Regards
Stefan
herbert is offline   Reply With Quote

Old   January 19, 2011, 17:03
Default
  #3
New Member
 
Bill Rosemurgy
Join Date: Mar 2009
Location: Ann Arbor, MI
Posts: 20
Rep Power: 17
brosemu is on a distinguished road
Hi Niels,

Did you ever figure out the issue? I'm struggling with the same issue, trying to map faces on a boundaryField from a subMesh back to the full mesh.

I have an fvMeshSubset called evaluationMesh and it shares common faces on patch 3 with the full mesh.

Code:
volVectorField u(IOobject("u", runTime.timeName(), evaluationMesh.subMesh(), IOobject::NO_READ, IOobject::AUTO_WRITE), evaluationMesh.subMesh(), Foam::vector(0,0,0));

patchi = 3;

// This gives the correct mapping between patches
const label& patchI = evaluationMesh.patchMap()[patchi];

// calcU returns a vectorField
u.boundaryField()[patchi] = calcU(evaluationMesh.subMesh().C().boundaryField()[patchi]);
    
// Map back to full field
forAll(u.boundaryField()[patchi],facei)
{
        // This is where the issue is becuase facei counts from 0 -> nFaces on patchi of boundaryField
        // when I need it to index in the global sense for the mapping to be correct
        const label& faceI = evaluationMesh.faceMap()[facei];
                
        U.boundaryField()[patchI][faceI] == u.boundaryField()[patchi][facei];
}
Notice the difference between patchi / patchI and facei / faceI - capital I denotes full mesh, little i denotes submesh. Also, little u is the volVectorField on the subMesh.

Any insight?

Thanks!

Last edited by brosemu; January 19, 2011 at 17:10. Reason: clarity
brosemu is offline   Reply With Quote

Old   January 20, 2011, 04:39
Default
  #4
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hi

As you do note, you merely need to get hold on the global face-count for facei, then you will get a global faceI which needs to be transformed into a local patch faceI. I have recently done something like that:

Code:
const fvPatchList & patches = cMesh_.boundary();
const fvPatchList & gpatches = mesh_.boundary();
const label nInternalFacesGlobal = mesh_.nInternalFaces();

forAll ( patches, patchi )
{
    const fvPatch & curPatch = patches[patchi];
    
    if ( curPatch.type() != "empty" )
    {
        label start = curPatch.patch().start();
            
        scalarField & gw = gammafC.boundaryField()[patchi];
            
        forAll ( gw, facei )
        {
            label gfacei = faceMap_[start + facei];
                
            if ( gfacei >= nInternalFacesGlobal )
            {
                   
                label gpatchID = mesh_.boundaryMesh().whichPatch(gfacei);
                label gstart   = gpatches[gpatchID].patch().start();
                label lstart   = gfacei - gstart;
                    
                const scalarField & ggw = gammaf.boundaryField()[gpatchID];
                     
                gw[facei]   = ggw[lstart];
            }
            else
            {
                gw[facei]   = gammaf[gfacei];
            }
        }
    }
}
Here mesh_ is the global mesh and cMesh_ is the submesh. gammaf is a global surfaceScalarField and gammafC is a surfaceScalarField on cMesh_.

I hope this can help you overcome your problems.

Best regards,

Niels

P.S. Note that you need to consider the directions of the patch normals when mapping phi. This is due to the definition of a surface normal vector pointing to the outside on a patch, however a face on the global mesh being turned into a patch face has not been constructed originally with this constraint, hence it might be pointing in the wrong direction as a patch face.
ngj is offline   Reply With Quote

Old   January 20, 2011, 19:56
Default
  #5
New Member
 
Bill Rosemurgy
Join Date: Mar 2009
Location: Ann Arbor, MI
Posts: 20
Rep Power: 17
brosemu is on a distinguished road
Hi Niels,

That fixed it! The two pieces of information I needed where that you can access the global starting index (of course you can!) and that the globalIndex = startIndex + localIndex (of course it does!).

Thanks again.
brosemu is offline   Reply With Quote

Old   October 2, 2012, 17:40
Default addressing in surfacescalarfield
  #6
Member
 
,...
Join Date: Apr 2011
Posts: 92
Rep Power: 13
hawkeye321 is an unknown quantity at this point
Do you guys know how the elements of surfacescalarfield are addressed? for example which which position does phi[celli] exactly refer to?
hawkeye321 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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Netgen] Import netgen mesh to OpenFOAM hsieh OpenFOAM Meshing & Mesh Conversion 32 September 13, 2011 06:50
[blockMesh] BlockMeshmergePatchPairs hjasak OpenFOAM Meshing & Mesh Conversion 11 August 15, 2008 08:36
fluent add additional zones for the mesh file SSL FLUENT 2 January 26, 2008 12:55
[blockMesh] Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Meshing & Mesh Conversion 10 April 2, 2007 15:00
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Meshing & Mesh Conversion 2 July 15, 2005 05:15


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