|
[Sponsors] |
Why is access to turbulence fields provided as const? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 18, 2019, 06:27 |
Why is access to turbulence fields provided as const?
|
#1 |
Member
Rishikesh
Join Date: Apr 2016
Posts: 63
Rep Power: 10 |
Short version:
In OpenFOAM-6, I am trying to work on some mesh-to-mesh interpolation of fields (using meshToMesh.H -> imDirect). The turbulence variable return const tmp access to members, which lead to problem in interpolation. How should I go about it? Details: For the kEpsilon model, the turbulence variables k and epsilon, members of turbulenceModel (src/TurbulenceModels/turbulenceModels/RAS), are protected: Code:
volScalarField k_; volScalarField epsilon_; Code:
//- Return the turbulence kinetic energy virtual tmp<volScalarField> k() const { return k_; } //- Return the turbulence kinetic energy dissipation rate virtual tmp<volScalarField> epsilon() const { return epsilon_; } Code:
//source tmp<volScalarField> tksrc = turbulenceFluid[i].k(); volScalarField& ksrc = tksrc.ref(); //tgt tmp<volScalarField> tktgt = turbulenceFluid[1-i].k(); volScalarField& ktgt = tktgt.ref(); Because of the use of tmp and const nature of access, appears to cause troubles when I try to interpolate the fields from one mesh to the other. Code:
Attempt to acquire non-const reference to const object from a tmp<N4Foam14GeometricFieldIdNS_12fvPatchFieldENS_7volMeshEEE>tionThermoMoleFractions sets surfaces ) PS: The idea of adding non-const access function comes, because I also did interpolation of volume fraction fields (src/transportModels/twoPhaseMixture model), but there the reference to alpha fields is returned via two methods, which allows manipulation via interpolation. Code:
//- Return the phase-fraction of phase 1 const volScalarField& alpha1() const { return alpha1_; } //- Return the phase-fraction of phase 1 volScalarField& alpha1() { return alpha1_; } Code:
mapF2C.mapSrcToTgt ( epsilonsrc, plusEqOp<scalar> (), epsilontgt ); |
|
December 18, 2019, 08:49 |
|
#2 | |
Senior Member
Santiago Lopez Castano
Join Date: Nov 2012
Posts: 354
Rep Power: 16 |
Quote:
|
||
December 24, 2019, 07:47 |
|
#3 |
Member
Rishikesh
Join Date: Apr 2016
Posts: 63
Rep Power: 10 |
Thanks!!! worked like a charm
|
|
January 23, 2020, 13:51 |
|
#4 |
New Member
Andreas Otto
Join Date: Sep 2009
Posts: 12
Rep Power: 17 |
How did you solve the problem. I'm facing the same issue.
Could you please post the code snippet. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Foam::error::printStack(Foam::Ostream&) with simpleFoam -parallel | U.Golling | OpenFOAM Running, Solving & CFD | 52 | September 23, 2023 04:35 |
Help with if statement | CHARLES | OpenFOAM Programming & Development | 17 | August 22, 2021 04:14 |
[snappyHexMesh] snappyHexMesh error "Cannot determine normal vector from patches." | lethu | OpenFOAM Meshing & Mesh Conversion | 1 | June 3, 2020 08:49 |
[snappyHexMesh] Error in SnappyHexMesh | gooya_kabir | OpenFOAM Meshing & Mesh Conversion | 2 | October 23, 2013 05:41 |
RunTim Error for simpleFoam | Djub | OpenFOAM Running, Solving & CFD | 2 | April 12, 2013 12:51 |