|
[Sponsors] |
Error passing <variable> as 'this' argument discards qualifiers [-fpermissive] |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 2, 2020, 09:09 |
Error passing <variable> as 'this' argument discards qualifiers [-fpermissive]
|
#1 |
Member
Join Date: Jun 2020
Posts: 49
Rep Power: 5 |
Hi everyone,
I am currently developing a custom boundary condition based on swirlFlowRateInletVelocity, which extends it to a Rankine-Vortex type. Therefore I Need to assign values based on a solidbody Vortex for certain regions of the inlet patch, and a potential Vortex for areas with larger distance from the center. For this I have two separate Vector Fields, which contain the Velocity data for each type of Vortex respectively. In the final step, using the ForAll-Command, I want to pass the values from the tangentialVelocity_pos() field to tangentialVelocity(), for those faces that contain the solid body Vortex. the Code Looks loke this: Code:
tmp<vectorField> tangentialVelocity( <Code describing a potential Vortex>); tmp<vectorField> tangentialVelocity_pos( <Code describing a solid body Vortex>); forAll(tangentialVelocity(), i) { if radius(current face <= critical radius) { tangentialVelocity()[i] = tangentialVelocity_pos()[i]; } } error: passing 'const Foam::Vector<double>' as 'this' Argument discards qualifiers [-fpermissive] tangentialVelocity()[i] = tangentialVelocity_pos()[i]; As far as my search has brought me, it has something to do with the Vector fields being defined as constants, but I dont know how to get around it. An attempt to use a conditional Operator within the tangentialVelocity() did not wirk, as the Operator was not known. Does anyone have an idea how to fix this? Thank you very much in advance! Last edited by Swirl; June 2, 2020 at 09:26. Reason: Corrected vector field names |
|
June 2, 2020, 10:23 |
tmp files are not for direct manipulation
|
#3 |
Senior Member
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 9 |
Hi Swirl,
I think that the instantiation of tangengialVelocity_pos as a temporal field is associated with the problem. Right now it is treating it as a temporal field, and therefore the assignament operation (operator=) is not calling what you're expecting. You have to tell OF to treat this object as a vectorField. f.e: Code:
tmp<vectorField> tmp_tangentialVelocity( ... ); tmp<vectorField> tmp_tangentialVelocity_pos( ... ); vectorField& tangentialVelocity = tmp_tangentialVelocity(); vectorField& tangentialVelocity_pos = tmp_tangentialVelocity_pos(); forAll(tangentialVelocity, i) { tangentialVelocity[i] = tangentialVelocity_pos[i]; } I hope that helps you! |
|
June 2, 2020, 11:18 |
|
#4 | |
Member
Join Date: Jun 2020
Posts: 49
Rep Power: 5 |
Quote:
It says: error: binding reference of type 'Foam::vectorField& ' to 'const Foam::Field<Foam::Vector<double> >' discards qualifiers and same error for the second line. |
||
June 2, 2020, 12:39 |
Alternative method
|
#5 |
Member
Join Date: Jun 2020
Posts: 49
Rep Power: 5 |
It appears to me, that the data inside the vectorField cannot be changed at all, once it has been set. Another way to implement the Rankine Vortex would be, to use a piecewise Definition inside the
Code:
tmp<vectorField>tangentialVelocity ( Piecewise definition here ) |
|
June 2, 2020, 13:07 |
Try ref instead of ()
|
#6 | |
Senior Member
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 9 |
Quote:
Code:
tmp<vectorField> tmp_tangentialVelocity( ... ); tmp<vectorField> tmp_tangentialVelocity_pos( ... ); vectorField& tangentialVelocity = tmp_tangentialVelocity.ref(); vectorField& tangentialVelocity_pos = tmp_tangentialVelocity_pos.ref(); forAll(tangentialVelocity, i) { tangentialVelocity[i] = tangentialVelocity_pos[i]; } EDIT: Just while writing this reply I thought about another way to access. The operator () is returning a pointer, not a reference. That why its not working properly, but you can use instead the following code and should work as welll. Code:
tmp<vectorField> tmp_tangentialVelocity( ... ); tmp<vectorField> tmp_tangentialVelocity_pos( ... ); // without the & sign! vectorField tangentialVelocity = tmp_tangentialVelocity(); vectorField tangentialVelocity_pos = tmp_tangentialVelocity_pos(); forAll(tangentialVelocity, i) { tangentialVelocity[i] = tangentialVelocity_pos[i]; } Last edited by crubio.abujas; June 2, 2020 at 13:12. Reason: Other way to work around |
||
June 2, 2020, 13:29 |
Thank you!!!
|
#7 |
Member
Join Date: Jun 2020
Posts: 49
Rep Power: 5 |
Thank you so much! it worked and now I get a perfect Rankine-Vortex.
Last edited by Swirl; June 4, 2020 at 15:22. |
|
June 2, 2020, 13:59 |
|
#8 |
Senior Member
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 9 |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
CFD by anderson, chp 10.... supersonic flow over flat plate | varunjain89 | Main CFD Forum | 18 | May 11, 2018 07:31 |
[Commercial meshers] star-ccm mesh to O\/F | DLC | OpenFOAM Meshing & Mesh Conversion | 77 | September 19, 2016 09:25 |
meshing of a compound volume in GMSH | shawn3531 | OpenFOAM | 4 | March 12, 2015 10:45 |