|
[Sponsors] |
September 6, 2012, 11:04 |
Calling a method from derived BC
|
#1 |
Senior Member
Pawel Sosnowski
Join Date: Mar 2009
Location: Munich, Germany
Posts: 105
Rep Power: 18 |
Dear Foamers,
I implemented a derived boundary condition, and added a new method. Now I am trying to use this new method "from the main code". In general, the derived patch field is: Code:
class myDerivedPatchField : public fixedGradientFvPatchScalarField { TypeName("myDerivedPatch"); //(...) some standard overloading of updateCoeffs(), constructors, etc public: bool myMethod() { return true; } } Code:
//(...) int main(int argc, char *argv[]) { //(...) declarations, loading, creating volScalarField F forAll(F.boundaryField(),b) { if(isA<myDerivedPatchField>(F.boundaryField()[b])) { Info << refCast<myDerivedPatchField>(F.boundaryField()[b]).myMethod() <<endl; } } } What should I do to cast an added method in the main code? Thank you in advance! Pawel |
|
December 4, 2013, 03:48 |
|
#2 |
Member
Hua
Join Date: May 2012
Posts: 31
Rep Power: 13 |
Dear Psosnows,
I also met this problem but failed to correct it. Have you got the right way?I will be thankful for your suggestions. |
|
December 26, 2013, 14:38 |
|
#3 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
Greetings to all!
Can either one of you attach the 3 things necessary for replicating this issue? Namely:
Best regards, Bruno
__________________
|
|
December 26, 2013, 17:44 |
|
#4 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37 |
Good evening,
I do not have access to a prober computer, so I do not have the means of checking the hypothesis, but...: You should carefully check the "isA<>()" command, because if it take a patchField and not a fvPatchField it makes all the difference. Your boundary condition is derived from a patchField deep down, so you might encounter this problem, because the many derived levels are merely ignored. Good luck, Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request. |
|
December 26, 2013, 18:02 |
|
#5 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37 |
Also, it might be that isA asks for the physical type of the boundary condition, i.e. you might want to check on the typeName instead,. Something like this:
Code:
if (F.boundaryField()[p]::typeName == Foam::myDerivedFvPatchField::typeName) Kind regards, Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Gmsh] discretizer - gmshToFoam | Andyjoe | OpenFOAM Meshing & Mesh Conversion | 13 | March 14, 2012 04:35 |
Comparison: Finite Volume Method vs. Analytic Method | m-fry | Main CFD Forum | 1 | April 20, 2010 14:40 |
Code for most powerfull FDV Method | D.S.Nasan | Main CFD Forum | 6 | September 4, 2008 02:08 |
Help about the preconditioner in gmres method | Dan Gao | Main CFD Forum | 3 | July 5, 2008 01:18 |
hess-smith method and fvm method | yangqing | FLUENT | 0 | March 20, 2002 19:25 |