|
[Sponsors] |
Make wall-function read a newly defined field inside modified kEpsilon model |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 29, 2017, 00:29 |
Make wall-function read a newly defined field inside modified kEpsilon model
|
#1 |
New Member
William Corrêa Radünz
Join Date: Jun 2016
Posts: 2
Rep Power: 0 |
Greetings everyone,
I have been working on a modified kEpsilon model for wind flow modeling and it was necessary to redefine the once constant Cmu and as height-dependent field i.e. a volScalarField. I have also created it as an IObject to plot it along with the remaining fields and all works fine. The problems begin now. It just so happens that epsilonWallFunction and nutkRoughWallFunction depend on Cmu and as such the must access the modified kEpsilon height-dependent Cmu, which I will name after Cmu(z). I am well aware that the wall functions are general and thus have no information about the selected turbulence model so they access turbulence fields through their base class turbulenceModel.H through this lines, as example (turbulence kinectic energy, viscosity and turbulent viscosity fields): @epsilonWallFunction const tmp<volScalarField> tk = turbulence.k(); const volScalarField& k = tk(); const tmp<scalarField> tnuw = turbulence.nu(patchi); const scalarField& nuw = tnuw(); const tmp<scalarField> tnutw = turbulence.nut(patchi); const scalarField& nutw = tnutw(); However, when I try to access the newly created Cmu(z) through this const tmp<volScalarField> tCmuw = turbulence.CmuZ(); The compiler complains saying basically that "error: ‘const class Foam::turbulenceModel’ has no member named ‘CmuZ’". This is attached as "log.withoutTurbulenceModel". So what have I done? I realized the call above led to the base class turbulenceModel so I declared CmuZ as a virtual function there. @turbulenceModel.H virtual tmp<volScalarField> CmuZ() const = 0; When I compile, I get more issues. In my view, the issue is that somehow turbulenceModel's derived classes (turbulence models) are scanned after the CmuZ() field which is only implemented in kEpsilon model through run-time selection tables. There are some lines as "error: cannot allocate an object of abstract type ‘Foam::incompressible::RASModels::qZeta’ return autoPtr<baseType>(new baseType##Type parList); \ ^ ../turbulenceModels/lnInclude/RASModel.H:111:9: note: in expansion of macro ‘declareRunTimeSelectionTable’" and that's when I get lost. I've been trying so solve this for two weeks, read about polymorphism and so on but stagnated. Best regards. |
|
July 1, 2017, 01:54 |
|
#2 |
Senior Member
Join Date: Sep 2015
Location: Singapore
Posts: 102
Rep Power: 11 |
Hi there,
You are correct that the "cannot allocate an object of abstract type" error occurs because you are trying to a create an object which has a pure virtual function, i.e. one which ends with '= 0'. I think that means that each of the derived class is required to provide an implementation of the CmuZ() which is not what you want to do. Try writing the function body of the CmuZ() function in turbulenceModel.H to return a tmp<volScalarField> with the some dummy Cmu value like 0.09. Code:
tmp<volScalarField> CmuZ() { return ( new volScalarField ( volScalarField ( IOobject("Cmu", ...), mesh, dimensionedScalar("dummy", dimless, 0.09) ) ) ); } An even more straightforward way could be to access the Cmu volScalarField by looking up the object from its object registry, e.g. Code:
const volScalarField& Cmu = mesh.lookupObject<volScalarField>("Cmu"); USV |
|
July 18, 2017, 23:39 |
|
#3 | |
New Member
William Corrêa Radünz
Join Date: Jun 2016
Posts: 2
Rep Power: 0 |
Quote:
Code:
const volScalarField& Cmu = mesh.lookupObject<volScalarField>("Cmu"); |
||
Tags |
runtimeselection, turbulence, wallfunction |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Wrong flow in ratating domain problem | Sanyo | CFX | 17 | August 15, 2015 07:20 |
[blockMesh] non-orthogonal faces and incorrect orientation? | nennbs | OpenFOAM Meshing & Mesh Conversion | 7 | April 17, 2013 06:42 |
Water subcooled boiling | Attesz | CFX | 7 | January 5, 2013 04:32 |
[blockMesh] error message with modeling a cube with a hold at the center | hsingtzu | OpenFOAM Meshing & Mesh Conversion | 2 | March 14, 2012 10:56 |
meshing F1 front wing | Steve | FLUENT | 0 | April 17, 2003 13:37 |