|
[Sponsors] |
September 21, 2016, 06:18 |
of4 refCast complains
|
#1 |
New Member
Dan
Join Date: Nov 2013
Posts: 24
Rep Power: 13 |
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]) 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 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 |
|
September 21, 2016, 21:16 |
|
#2 |
Senior Member
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33 |
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
__________________
Hrvoje Jasak Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk |
|
October 19, 2016, 07:08 |
|
#3 |
New Member
Markus Bösenhofer
Join Date: Mar 2016
Posts: 2
Rep Power: 0 |
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]) |
|
March 7, 2017, 00:06 |
|
#4 |
New Member
Jean Lachaud
Join Date: Mar 2009
Location: Moffett Field, Ca
Posts: 6
Rep Power: 17 |
Thanks Hrv and Markus. It's very useful.
So, to sum up, we just need to add "Ref" in previous code. Jean |
|
Tags |
refcast of4 preprocessing |
|
|
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 |