change the k at first grid?
-
@东岳 Hi, dongyue. Thanks a lot. I understood this method but can I use it in a kwallfunction? After I tried the code you suggested, the compiling error is mesh not decalred in this scope. If I would like to update the first grid value in the kwallfunction like epsilonwallfunction did, is it possible?
-
the compiling error is mesh not decalred in this scope
Looks you used that in a Class. Try to include the following code snippet before you use it:
const fvMesh& mesh = k.mesh();
If I would like to update the first grid value in the kwallfunction like epsilonwallfunction did, is it possible?
Everything is possible as long as it is physical.
-
@东岳
derivedFvPatchFields/wallFunctions/kqRWallFunctions/kOngWallFunction/kOngWallFunctionFvPatchScalarField.C: In member function 'virtual void Foam::kOngWallFunctionFvPatchScalarField::updateCoeffs()': derivedFvPatchFields/wallFunctions/kqRWallFunctions/kOngWallFunction/kOngWallFunctionFvPatchScalarField.C:190:40: error: 'class Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >' has no member named 'mesh' const fvMesh& mesh = turbModel.k().mesh();
-
@东岳
derivedFvPatchFields/wallFunctions/kqRWallFunctions/kOngWallFunction/kOngWallFunctionFvPatchScalarField.C: In member function 'virtual void Foam::kOngWallFunctionFvPatchScalarField::updateCoeffs()': derivedFvPatchFields/wallFunctions/kqRWallFunctions/kOngWallFunction/kOngWallFunctionFvPatchScalarField.C:204:22: error: 'p' was not declared in this scope const fvMesh& mesh = p.boundaryMesh().mesh(); ^ derivedFvPatchFields/wallFunctions/kqRWallFunctions/kOngWallFunction/kOngWallFunctionFvPatchScalarField.C:209:28: error: passing 'const volScalarField {aka const Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}' as 'this' argument discards qualifiers [-fpermissive] k.boundaryFieldRef()[patchID] = 0;
-
You should highlight you code yourself. Otherwise I need modify it everytime.
The above code runs well if your put it inside the following
template<class Type> Foam::kqRWallFunctionFvPatchField<Type>::kqRWallFunctionFvPatchField ( const kqRWallFunctionFvPatchField& ptf, const fvPatch& p, const DimensionedField<Type, volMesh>& iF, const fvPatchFieldMapper& mapper ) : zeroGradientFvPatchField<Type>(ptf, p, iF, mapper) { const fvMesh& mesh = p.boundaryMesh().mesh(); }
-
Hi Dongyue, I changed the codes as following, but the result dosn't change, k in the first grid is still not calculated by my formulation. I cannot understand.
tmp<volScalarField> tk = turbModel.k(); volScalarField k = tk; const tmp<scalarField> tnuw = turbModel.nu(patchi); const scalarField& nuw = tnuw(); const tmp<scalarField> tnutw = turbModel.nut(patchi); const scalarField& nutw = tnutw(); const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi]; const scalarField magGradUw(mag(Uw.snGrad())); const scalar Cmu25 = pow025(Cmu_); scalarField& kw = *this; forAll(nutw,facei) { label celli = patch().faceCells()[facei]; k[celli] = ((nutw[facei] + nuw[facei])*magGradUw[facei])*((nutw[facei] + nuw[facei])*magGradUw[facei])/(Cmu25*Cmu25); }
-
@东岳 I tried to write these codes in simpleFoam.C,
label patchID = mesh.boundaryMesh().findPatchID("wall"); turbulence->k().boundaryFieldRef()[patchID] = 0; And I got the error: newsimpleFoam.C: In function 'int main(int, char**)': newsimpleFoam.C:77:25: error: 'class Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >' has no member named 'boundaryFieldRef' turbulence->k().boundaryFieldRef()[patchID] = 0;