CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   Reynolds Stress Custom BC (http://www.cfd-online.com/Forums/openfoam/92300-reynolds-stress-custom-bc.html)

maninthemail September 9, 2011 07:50

Reynolds Stress Custom BC
 
Greetings. What I'm trying to do is have an inlet BC calculated in the same way as "turbulentIntensityKineticEnergyInlet" (k calculated using a fractional fluctuation from the mean velocity). Instead of applying the calculated value to k, I'd like to divide it by 3 and apply it to each normal (diagonal) component of the Reynolds stress tensor. I can't find an existing BC which does this. If I'm just being unobservant, please could you point me in the right direction then read no further.

Right, so my custom BC is pretty much just a copy of "$FOAM_SRC/finiteVolume/fields/fvPatchFields/derived/turbulentIntensityKineticEnergyInlet/turbulentIntensityKineticEnergyInletFvPatchScalarF ield.C" with the word "scalar" replaced with "symmtensor" pretty much everywhere. There are two things I can't figure out how to do. The first is actually how to apply the calculated normal stresses to the tensor in the "updateCoeffs()" function.

Code:

void Foam::turbulentIntensityRInletFvPatchSymmTensorField::updateCoeffs()
{
        if (updated()) return;

        const fvPatchVectorField& Up = patch().lookupPatchField<volVectorField, vector>(UName_);

        const fvsPatchScalarField& phip = patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);

        /*
        * //ORIGINAL SCALAR K CALCULATION
        * this->refValue() = 1.5*sqr(intensity_)*magSqr(Up);
        * this->valueFraction() = 1.0 - pos(phip);
        * inletOutletFvPatchScalarField::updateCoeffs();
        */

        /*
        * //NEW TENSOR CALCULATION GOES HERE ?????????
        * want to apply "0.5*sqr(intensity_)*magSqr(Up)" to the diagonal components of R
        */

        fixedValueFvPatchSymmTensorField::updateCoeffs();
}

Secondly, I can't seem too link even a non-functioning version. I can compile it, I can't link it. Previously, all I've had to do for custom BCs is to have the Make directory contain the files "files" and "options" which look something like

Code:

customBoundaryConditionFvPatchVectorField.C
LIB = $(FOAM_USER_LIBBIN)/libcustomBoundaryCondition

and

Code:

EXE_INC = -I$(LIB_SRC)/finiteVolume/lnInclude
LIB_LIBS = -lfiniteVolume

respectively. That's not working with the new thing, so presumably there's something else needs including for symmetric tensors. I have no idea what that is, so if someone could point me in the right direction, I'd be chuffed. Linking errors are below.

Many thanks

Will

----

Code:

/usr/lib64/gcc/x86_64-suse-linux/4.5/../../../../lib64/crt1.o: In function `_start':
/usr/src/packages/BUILD/glibc-2.11.2/csu/../sysdeps/x86_64/elf/start.S:109: undefined reference to `main'
Make/linux64IccDPOpt/turbulentIntensityRInletFvPatchSymmTensorField.o: In function `Foam::turbulentIntensityRInletFvPatchSymmTensorField::updateCoeffs()':
turbulentIntensityRInletFvPatchSymmTensorField.C:(.text+0x2155): undefined reference to `Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>::typeName'
turbulentIntensityRInletFvPatchSymmTensorField.C:(.text+0x221c): undefined reference to `Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>::typeName'
turbulentIntensityRInletFvPatchSymmTensorField.C:(.text+0x260e): undefined reference to `Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh>::typeName'
turbulentIntensityRInletFvPatchSymmTensorField.C:(.text+0x26d5): undefined reference to `Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh>::typeName'
Make/linux64IccDPOpt/turbulentIntensityRInletFvPatchSymmTensorField.o: In function `__sti__$E':
turbulentIntensityRInletFvPatchSymmTensorField.C:(.text+0x3389): undefined reference to `Foam::fvPatchField<Foam::SymmTensor<double> >::constructpatchConstructorTables()'
turbulentIntensityRInletFvPatchSymmTensorField.C:(.text+0x3390): undefined reference to `Foam::fvPatchField<Foam::SymmTensor<double> >::patchConstructorTablePtr_'
turbulentIntensityRInletFvPatchSymmTensorField.C:(.text+0x34f0): undefined reference to `Foam::fvPatchField<Foam::SymmTensor<double> >::constructpatchMapperConstructorTables()'
turbulentIntensityRInletFvPatchSymmTensorField.C:(.text+0x34f7): undefined reference to `Foam::fvPatchField<Foam::SymmTensor<double> >::patchMapperConstructorTablePtr_'
turbulentIntensityRInletFvPatchSymmTensorField.C:(.text+0x3651): undefined reference to `Foam::fvPatchField<Foam::SymmTensor<double> >::constructdictionaryConstructorTables()'
turbulentIntensityRInletFvPatchSymmTensorField.C:(.text+0x3658): undefined reference to `Foam::fvPatchField<Foam::SymmTensor<double> >::dictionaryConstructorTablePtr_'
Make/linux64IccDPOpt/turbulentIntensityRInletFvPatchSymmTensorField.o: In function `Foam::fixedValueFvPatchField<Foam::SymmTensor<double> >::type() const':
turbulentIntensityRInletFvPatchSymmTensorField.C:(.gnu.linkonce.t._ZNK4Foam22fixedValueFvPatchFieldINS_10SymmTensorIdEEE4typeEv[.gnu.linkonce.t._ZNK4Foam22fixedValueFvPatchFieldINS_10SymmTensorIdEEE4typeEv]+0x3): undefined reference to `Foam::fixedValueFvPatchField<Foam::SymmTensor<double> >::typeName'
Make/linux64IccDPOpt/turbulentIntensityRInletFvPatchSymmTensorField.o: In function `Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const& Foam::objectRegistry::lookupObject<Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> >(Foam::word const&) const':
turbulentIntensityRInletFvPatchSymmTensorField.C:(.gnu.linkonce.t._ZNK4Foam14objectRegistry12lookupObjectINS_14GeometricFieldINS_6VectorIdEENS_12fvPatchFieldENS_7volMeshEEEEERKT_RKNS_4wordE[.gnu.linkonce.t._ZNK4Foam14objectRegistry12lookupObjectINS_14GeometricFieldINS_6VectorIdEENS_12fvPatchFieldENS_7volMeshEEEEERKT_RKNS_4wordE]+0x1c2): undefined reference to `Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>::typeName'
turbulentIntensityRInletFvPatchSymmTensorField.C:(.gnu.linkonce.t._ZNK4Foam14objectRegistry12lookupObjectINS_14GeometricFieldINS_6VectorIdEENS_12fvPatchFieldENS_7volMeshEEEEERKT_RKNS_4wordE[.gnu.linkonce.t._ZNK4Foam14objectRegistry12lookupObjectINS_14GeometricFieldINS_6VectorIdEENS_12fvPatchFieldENS_7volMeshEEEEERKT_RKNS_4wordE]+0x288): undefined reference to `Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>::typeName'
Make/linux64IccDPOpt/turbulentIntensityRInletFvPatchSymmTensorField.o: In function `Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const& Foam::objectRegistry::lookupObject<Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> >(Foam::word const&) const':
turbulentIntensityRInletFvPatchSymmTensorField.C:(.gnu.linkonce.t._ZNK4Foam14objectRegistry12lookupObjectINS_14GeometricFieldIdNS_13fvsPatchFieldENS_11surfaceMeshEEEEERKT_RKNS_4wordE[.gnu.linkonce.t._ZNK4Foam14objectRegistry12lookupObjectINS_14GeometricFieldIdNS_13fvsPatchFieldENS_11surfaceMeshEEEEERKT_RKNS_4wordE]+0x1c2): undefined reference to `Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh>::typeName'
turbulentIntensityRInletFvPatchSymmTensorField.C:(.gnu.linkonce.t._ZNK4Foam14objectRegistry12lookupObjectINS_14GeometricFieldIdNS_13fvsPatchFieldENS_11surfaceMeshEEEEERKT_RKNS_4wordE[.gnu.linkonce.t._ZNK4Foam14objectRegistry12lookupObjectINS_14GeometricFieldIdNS_13fvsPatchFieldENS_11surfaceMeshEEEEERKT_RKNS_4wordE]+0x288): undefined reference to `Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh>::typeName'
Make/linux64IccDPOpt/turbulentIntensityRInletFvPatchSymmTensorField.o: In function `Foam::fvPatchField<Foam::SymmTensor<double> >::type() const':
turbulentIntensityRInletFvPatchSymmTensorField.C:(.gnu.linkonce.t._ZNK4Foam12fvPatchFieldINS_10SymmTensorIdEEE4typeEv[.gnu.linkonce.t._ZNK4Foam12fvPatchFieldINS_10SymmTensorIdEEE4typeEv]+0x3): undefined reference to `Foam::fvPatchField<Foam::SymmTensor<double> >::typeName'
Make/linux64IccDPOpt/turbulentIntensityRInletFvPatchSymmTensorField.o: In function `Foam::fvPatchField<Foam::SymmTensor<double> >::addpatchConstructorToTable<Foam::turbulentIntensityRInletFvPatchSymmTensorField>::~addpatchConstructorToTable()':
turbulentIntensityRInletFvPatchSymmTensorField.C:(.gnu.linkonce.t._ZN4Foam12fvPatchFieldINS_10SymmTensorIdEEE26addpatchConstructorToTableINS_46turbulentIntensityRInletFvPatchSymmTensorFieldEED1Ev[.gnu.linkonce.t._ZN4Foam12fvPatchFieldINS_10SymmTensorIdEEE26addpatchConstructorToTableINS_46turbulentIntensityRInletFvPatchSymmTensorFieldEED1Ev]+0x2): undefined reference to `Foam::fvPatchField<Foam::SymmTensor<double> >::destroypatchConstructorTables()'
Make/linux64IccDPOpt/turbulentIntensityRInletFvPatchSymmTensorField.o: In function `Foam::fixedValueFvPatchField<Foam::SymmTensor<double> >::gradientInternalCoeffs() const':
turbulentIntensityRInletFvPatchSymmTensorField.C:(.gnu.linkonce.t._ZNK4Foam22fixedValueFvPatchFieldINS_10SymmTensorIdEEE22gradientInternalCoeffsEv[.gnu.linkonce.t._ZNK4Foam22fixedValueFvPatchFieldINS_10SymmTensorIdEEE22gradientInternalCoeffsEv]+0x6d): undefined reference to `Foam::fvPatch::deltaCoeffs() const'
Make/linux64IccDPOpt/turbulentIntensityRInletFvPatchSymmTensorField.o: In function `Foam::fixedValueFvPatchField<Foam::SymmTensor<double> >::gradientBoundaryCoeffs() const':
turbulentIntensityRInletFvPatchSymmTensorField.C:(.gnu.linkonce.t._ZNK4Foam22fixedValueFvPatchFieldINS_10SymmTensorIdEEE22gradientBoundaryCoeffsEv[.gnu.linkonce.t._ZNK4Foam22fixedValueFvPatchFieldINS_10SymmTensorIdEEE22gradientBoundaryCoeffsEv]+0x18): undefined reference to `Foam::fvPatch::deltaCoeffs() const'
Make/linux64IccDPOpt/turbulentIntensityRInletFvPatchSymmTensorField.o: In function `Foam::fvPatchField<Foam::SymmTensor<double> >::addpatchMapperConstructorToTable<Foam::turbulentIntensityRInletFvPatchSymmTensorField>::~addpatchMapperConstructorToTable()':
turbulentIntensityRInletFvPatchSymmTensorField.C:(.gnu.linkonce.t._ZN4Foam12fvPatchFieldINS_10SymmTensorIdEEE32addpatchMapperConstructorToTableINS_46turbulentIntensityRInletFvPatchSymmTensorFieldEED1Ev[.gnu.linkonce.t._ZN4Foam12fvPatchFieldINS_10SymmTensorIdEEE32addpatchMapperConstructorToTableINS_46turbulentIntensityRInletFvPatchSymmTensorFieldEED1Ev]+0x2): undefined reference to `Foam::fvPatchField<Foam::SymmTensor<double> >::destroypatchMapperConstructorTables()'
Make/linux64IccDPOpt/turbulentIntensityRInletFvPatchSymmTensorField.o: In function `Foam::fvPatchField<Foam::SymmTensor<double> >::adddictionaryConstructorToTable<Foam::turbulentIntensityRInletFvPatchSymmTensorField>::~adddictionaryConstructorToTable()':
turbulentIntensityRInletFvPatchSymmTensorField.C:(.gnu.linkonce.t._ZN4Foam12fvPatchFieldINS_10SymmTensorIdEEE31adddictionaryConstructorToTableINS_46turbulentIntensityRInletFvPatchSymmTensorFieldEED1Ev[.gnu.linkonce.t._ZN4Foam12fvPatchFieldINS_10SymmTensorIdEEE31adddictionaryConstructorToTableINS_46turbulentIntensityRInletFvPatchSymmTensorFieldEED1Ev]+0x2): undefined reference to `Foam::fvPatchField<Foam::SymmTensor<double> >::destroydictionaryConstructorTables()'
Make/linux64IccDPOpt/turbulentIntensityRInletFvPatchSymmTensorField.o: In function `Foam::fvPatchField<Foam::SymmTensor<double> >::snGrad() const':
turbulentIntensityRInletFvPatchSymmTensorField.C:(.gnu.linkonce.t._ZNK4Foam12fvPatchFieldINS_10SymmTensorIdEEE6snGradEv[.gnu.linkonce.t._ZNK4Foam12fvPatchFieldINS_10SymmTensorIdEEE6snGradEv]+0x47b): undefined reference to `Foam::fvPatch::deltaCoeffs() const'
make: *** [OpenFOAM.out] Error 1


maninthemail September 15, 2011 05:37

Bump
 
Bump. Still stuck on this problem. Anyone?

vonboett November 14, 2011 08:41

I had a similar problem when introducing a new visosity model. I used to call 'wmake' from the folder where the 'Make' directory was placed, in this case transportModels/incompressible, after including my model to the 'files' file in the Make folder. The problem was solved by calling 'wmake libso incompressibl' from one folder above (transportModels) where the Allwmake file was stored.

maninthemail November 14, 2011 14:58

Solved
 
Yes, sorry, I figured all this out a while ago now. "wmake libso" is precisely what I should have been typing. Also, setting of the tensor variable was achieved using the code below.

Code:

void Foam::turbulentIntensityRInletFvPatchSymmTensorField::updateCoeffs()
{
        if (updated()) return;

        // boundary velocity and phi
        const fvPatchVectorField& Up = patch().lookupPatchField<volVectorField, vector>(UName_);
        const fvsPatchScalarField& phip = patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);

        // one third of the turbulent intensity
        scalarField value = 0.5*sqr(intensity_)*magSqr(Up);

        // identity matix as a symmTensor
        symmTensor I(1,0,0,1,0,1);

        // the stress is then a symmetric tensor field with non-zero diagonal elements equal to "value"
        this->refValue() = value * I;
        this->valueFraction() = 1.0 - pos(phip);
}



All times are GMT -4. The time now is 13:47.