codedFixedValue中如何获得主程序中的常量或者从边界条件里的dict获得
-
我想在codedFixedValue中的获得主程序中的常量,比如下面这个边界条件里。
type codedFixedValue; value uniform 0; name f4_f2; code #{ const fvPatch& boundaryPatch = patch(); scalar c = 0.5; scalar cs2 = 3.0/c/c; scalar cs4 = 4.5/c/c/c/c; dimensionedVector U4("U4", dimensionSet(0, 0, 0, 0, 0), vector(0, -c, 0)); fvPatchField<scalar> f4 = boundaryPatch.lookupPatchField<volScalarField,scalar>("f4"); const fvPatchField<scalar> rho = boundaryPatch.lookupPatchField<volScalarField,scalar>("rho"); const fvPatchField<vector> U = boundaryPatch.lookupPatchField<volVectorField,vector>("U"); const scalarField f4Internal = boundaryPatch.lookupPatchField<volScalarField,scalar>("f4").patchInternalField(); const scalarField rhoInternal = boundaryPatch.lookupPatchField<volScalarField,scalar>("rho").patchInternalField(); const vectorField UInternal = boundaryPatch.lookupPatchField<volVectorField,vector>("U").patchInternalField(); dimensionedScalar feq4; dimensionedScalar feq4Internal; forAll(boundaryPatch, faceI) { feq4 = rho[faceI]*1.0/9.0*(1.0+cs2*(U4&U[faceI])+cs4*(U4&U[faceI])*(U4&U[faceI])-cs2/2*(U[faceI]&U[faceI])); feq4Internal = rhoInternal[faceI]*1.0/9.0*(1+cs2*(U4&UInternal[faceI])+cs4*(U4&UInternal[faceI])*(U4&UInternal[faceI])-cs2/2*(UInternal[faceI]&UInternal[faceI])); f4[faceI] = feq4.value() + f4Internal[faceI] - feq4Internal.value(); } operator==(f4); #};
c在求解器里通过transportProperties进行了定义,我想获得它。
dimensionedScalar c ( "c", dimensionSet(0, 0, 0, 0, 0, 0, 0), transportProperties );
如果不行,退而求其次,能否在边界条件里,通过设置c value;来获得呢,这样就不用每次改c值都得重新编译边界条件了。就像下面这个图里的样子
用的OpenFOAM-v2012
-
http://dyfluid.com/code.html#id1
wall { type codedFixedValue; value uniform (10 0 0); name linearTBC1; code #{ const fvMesh& mesh = this->patch().boundaryMesh().mesh(); dictionary C = mesh.lookupObject<dictionary>("physicalProperties"); scalar test(readScalar(C.lookup("test"))); #}; }
-
谢谢岳哥,成了,牛牛牛