zhulianhua |
August 15, 2014 22:58 |
Do we need special treatment for empty patch?
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
|