CFD Online Logo CFD Online URL
Home > Forums > OpenFOAM Programming & Development

Do we need special treatment for empty patch?

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

LinkBack Thread Tools Display Modes
Old   August 15, 2014, 22:58
Default Do we need special treatment for empty patch?
Lianhua Zhu
Join Date: Aug 2011
Location: Wuhan, China
Posts: 35
Rep Power: 7
zhulianhua is on a distinguished road
Hi, dear FOAMers,

I have problems to understand the way OF deal with empty patches when it loops over all patches of a field.

For example in the following code:

 48     forAll(a.boundaryField(), patchi)
 49     {
 50         a.boundaryField().set(patchi, fvPatchField<scalar>::New("fixedGradient", mesh.boundary()[patchi], a));
 51     }
 53     forAll(a.boundaryField(), patchi)
 54     {
 55         fixedGradientFvPatchField<scalar>& aPatch =
 56             refCast<fixedGradientFvPatchField<scalar> >(a.boundaryField()[patchi]);
 57         Info << aPatch << endl;
 58     }
After the first forAll loops, the empty patches is still empty type, as if this loop just ignores the empty patches.

Howevre, the second loops leads to a run time error saying:

Attempt to cast type empty to type fixedGradient

    From function refCast<To>(From&)
    in file /home/lhzhu/centFOAM/OpenFOAM/OpenFOAM-2.2.x/src/OpenFOAM/lnInclude/typeInfo.H at line 114.
So my problem is :
Why does the first forAll loop ignore the empty patch, while the second doesn't ?

Best regards,

zhulianhua is offline   Reply With Quote


Thread Tools
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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
y+ and u+ values with low-Re RANS turbulence models: utility + testcase florian_krause OpenFOAM 110 April 21, 2016 11:54
createPatch Segmentation Fault (CORE DUMPED) sam.ho OpenFOAM Pre-Processing 2 April 21, 2014 02:01
CheckMeshbs errors ivanyao OpenFOAM Running, Solving & CFD 2 March 11, 2009 03:34
Import gmsh msh to Foam adorean Open Source Meshers: Gmsh, Netgen, CGNS, ... 24 April 27, 2005 08:19
Multicomponent fluid Andrea CFX 2 October 11, 2004 05:12

All times are GMT -4. The time now is 01:39.