CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

of4 refCast complains

Register Blogs Community New Posts Updated Threads Search

Like Tree7Likes
  • 2 Post By hjasak
  • 5 Post By mboesi

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 21, 2016, 06:18
Default of4 refCast complains
  #1
New Member
 
Dan
Join Date: Nov 2013
Posts: 27
Rep Power: 13
Danubi is on a distinguished road
Hi all,

I have recently moved from OF240 to OF4 and I am compiling the solvers and utilities I used to use. I am encountering problems with on preProcessing in particular.

I have these two lines in one of the utility's file:
Code:
fixedValueFvPatchVectorField& Upatch = refCast<fixedValueFvPatchVectorField>(U.boundaryField()[patchi]);
calculatedFvPatchVectorField& Uhpatch = refCast<calculatedFvPatchVectorField>(Uh.boundaryField()[patchi])
When compiling (wmake) I find these complains:

Code:
Making dependency list for source file mhdHunt.C
g++ -std=c++0x -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam4/src/finiteVolume/lnInclude -I/opt/openfoam4/src/meshTools/lnInclude -I/opt/openfoam4/src/sampling/lnInclude  -IlnInclude -I. -I/opt/openfoam4/src/OpenFOAM/lnInclude -I/opt/openfoam4/src/OSspecific/POSIX/lnInclude   -fPIC -c mhdHunt.C -o Make/linux64GccDPInt32Opt/mhdHunt.o
In file included from /opt/openfoam4/src/OpenFOAM/lnInclude/token.H:46:0,
                 from /opt/openfoam4/src/OpenFOAM/lnInclude/UListIO.C:28,
                 from /opt/openfoam4/src/OpenFOAM/lnInclude/UList.C:233,
                 from /opt/openfoam4/src/OpenFOAM/lnInclude/UList.H:484,
                 from /opt/openfoam4/src/OpenFOAM/lnInclude/List.H:43,
                 from /opt/openfoam4/src/OpenFOAM/lnInclude/labelList.H:48,
                 from /opt/openfoam4/src/OpenFOAM/lnInclude/UPstream.H:42,
                 from /opt/openfoam4/src/OpenFOAM/lnInclude/Pstream.H:42,
                 from /opt/openfoam4/src/OpenFOAM/lnInclude/parRun.H:35,
                 from /opt/openfoam4/src/finiteVolume/lnInclude/fvCFD.H:4,
                 from mhdHunt.C:26:
/opt/openfoam4/src/OpenFOAM/lnInclude/typeInfo.H: In instantiation of ‘To& Foam::refCast(From&) [with To = Foam::fixedValueFvPatchField<Foam::Vector<double> >; From = const Foam::fvPatchField<Foam::Vector<double> >]’:
inletHuntAnalysis.H:20:103:   required from here
/opt/openfoam4/src/OpenFOAM/lnInclude/typeInfo.H:110:35: error: cannot dynamic_cast ‘r’ (of type ‘const class Foam::fvPatchField<Foam::Vector<double> >’) to type ‘class Foam::fixedValueFvPatchField<Foam::Vector<double> >&’ (conversion casts away constness)
         return dynamic_cast<To&>(r);
                                   ^
/opt/openfoam4/src/OpenFOAM/lnInclude/typeInfo.H:119:35: error: cannot dynamic_cast ‘r’ (of type ‘const class Foam::fvPatchField<Foam::Vector<double> >’) to type ‘class Foam::fixedValueFvPatchField<Foam::Vector<double> >&’ (conversion casts away constness)
         return dynamic_cast<To&>(r);
                                   ^
/opt/openfoam4/src/OpenFOAM/lnInclude/typeInfo.H: In instantiation of ‘To& Foam::refCast(From&) [with To = Foam::calculatedFvPatchField<Foam::Vector<double> >; From = const Foam::fvPatchField<Foam::Vector<double> >]’:
inletHuntAnalysis.H:21:105:   required from here
/opt/openfoam4/src/OpenFOAM/lnInclude/typeInfo.H:110:35: error: cannot dynamic_cast ‘r’ (of type ‘const class Foam::fvPatchField<Foam::Vector<double> >’) to type ‘class Foam::calculatedFvPatchField<Foam::Vector<double> >&’ (conversion casts away constness)
         return dynamic_cast<To&>(r);
                                   ^
/opt/openfoam4/src/OpenFOAM/lnInclude/typeInfo.H:119:35: error: cannot dynamic_cast ‘r’ (of type ‘const class Foam::fvPatchField<Foam::Vector<double> >’) to type ‘class Foam::calculatedFvPatchField<Foam::Vector<double> >&’ (conversion casts away constness)
         return dynamic_cast<To&>(r);
                                   ^
/opt/openfoam4/wmake/rules/General/transform:8: recipe for target 'Make/linux64GccDPInt32Opt/mhdHunt.o' failed
make: *** [Make/linux64GccDPInt32Opt/mhdHunt.o] Error 1
I have properly wcleaned the folder.

I have solved some issues related to how times are declared within the utility. I suspect the problem should be related to the new syntaxis of of4.

Does anyone have a clue of what is going on?

Thanks all
Danubi is offline   Reply With Quote

Old   September 21, 2016, 21:16
Default
  #2
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33
hjasak will become famous soon enough
Yes. First case into const fixedValueFvPatchVectorField&

(see const) and then if you really have to, cast away const. If you don't know the second one, google it

Hrv
Hisham and serles like this.
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Old   October 19, 2016, 07:08
Default
  #3
New Member
 
Markus Bösenhofer
Join Date: Mar 2016
Posts: 2
Rep Power: 0
mboesi is on a distinguished road
since it took me some time to cast away the const, I thought it would be a good idea to post the solution here. In my case this worked to remove the constness:

Code:
fixedValueFvPatchVectorField& Upatch = 
    refCast<fixedValueFvPatchVectorField>(U.boundaryFieldRef()[patchi]);

calculatedFvPatchVectorField& Uhpatch = 
    refCast<calculatedFvPatchVectorField>(Uh.boundaryFieldRef()[patchi])
Hisham, serles, anperri and 2 others like this.
mboesi is offline   Reply With Quote

Old   March 7, 2017, 00:06
Default
  #4
New Member
 
Jean Lachaud
Join Date: Mar 2009
Location: Moffett Field, Ca
Posts: 6
Rep Power: 17
jano is on a distinguished road
Thanks Hrv and Markus. It's very useful.

So, to sum up, we just need to add "Ref" in previous code.

Jean
jano is offline   Reply With Quote

Reply

Tags
refcast of4 preprocessing


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
refCast compilation and understanding error Martin_K_lalelu OpenFOAM Programming & Development 1 April 26, 2018 20:14
error when calculating values at boundary using refCast prabhu OpenFOAM 7 March 12, 2018 09:31
Doubts about refCast diegosene OpenFOAM Programming & Development 5 July 23, 2017 18:38
New BC patch definition: typeInfo problem with refCast Matt_B OpenFOAM 1 April 26, 2014 11:46
Problem with creation of new BC fixing it to a patch using refCast Matt_B OpenFOAM Running, Solving & CFD 0 April 26, 2014 11:44


All times are GMT -4. The time now is 23:06.