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

Do we need special treatment for empty patch?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 15, 2014, 22:58
Default Do we need special treatment for empty patch?
  #1
Member
 
Lianhua Zhu
Join Date: Aug 2011
Location: Wuhan, China
Posts: 35
Rep Power: 14
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:

Code:
 48     forAll(a.boundaryField(), patchi)
 49     {
 50         a.boundaryField().set(patchi, fvPatchField<scalar>::New("fixedGradient", mesh.boundary()[patchi], a));
 51     }
 52
 53     forAll(a.boundaryField(), patchi)
 54     {
 55         fixedGradientFvPatchField<scalar>& aPatch =
 56             refCast<fixedGradientFvPatchField<scalar> >(a.boundaryField()[patchi]);
 57         Info << aPatch << endl;
 58     }
 59
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:

Code:
--> FOAM FATAL ERROR:
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,

Lianhua
zhulianhua is offline   Reply With Quote

Reply


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
y+ and u+ values with low-Re RANS turbulence models: utility + testcase florian_krause OpenFOAM 114 August 23, 2023 05:37
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 02:34
[Gmsh] Import gmsh msh to Foam adorean OpenFOAM Meshing & Mesh Conversion 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 09:39.