Error passing <variable> as 'this' argument discards qualifiers [-fpermissive]
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>); 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! |
This kind of problem is mostly related to
Code:
const I suggest you refer to this post . |
tmp files are not for direct manipulation
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( ... ); I hope that helps you! |
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. |
Alternative method
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 |
Try ref instead of ()
Quote:
Code:
tmp<vectorField> tmp_tangentialVelocity( ... ); 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( ... ); |
Thank you!!!
Thank you so much! it worked and now I get a perfect Rankine-Vortex.
|
Quote:
You will sleep better tonight ;) |
All times are GMT -4. The time now is 19:41. |