CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Creating a symmTensorField from a scalarField (https://www.cfd-online.com/Forums/openfoam/92935-creating-symmtensorfield-scalarfield.html)

maninthemail September 29, 2011 12:51

Creating a symmTensorField from a scalarField
 
Greetings,

I'm implementing a boundary condition for a symmTensor variable. I calculate a scalarField, and then want to apply it to the diagonal components of the symmTensorField. The fields are turbulent intensity and reynolds stress, though that really isn't important. The relevant (updateCoeffs) part of the code is as follows...

Code:


if (updated()) return;

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

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

// "stress" is a symmetric tensor field with diagonal elements equal to "value"
symmTensorField stress;

// I don't know how to set the values in the tensor
/*
 *          / value  0.0  0.0  \
 * stress = |  0.0  value  0.0  |
 *          \  0.0  0.0  value /
 */

operator==(stress);

fixedValueFvPatchSymmTensorField::updateCoeffs();

As you can see, it is transferring the scalarField values to the symmTensorField which I can't work out how to do. There are no existing derived tensor boundary conditions to copy off, so I'm stuck for ideas. If anyone could help, I'd be eternally grateful.

Many thanks, and apologies for reposting this. No-one replied to the last post I made, and I've had some time to re-formulate the question, hopefully a little more clearly.

Bernhard September 29, 2011 15:11

Did you already try something like this:
Code:

symmTensorField stress(value,0,0,value,0,value);
I am not sure if it works like this, but otherwise you may want to try:
Code:

symmTensor I(1,0,0,1,0,1);
symmTensorField stress=value*I;

However, for both I am not sure if it works, but it may give you some directions, good luck!

maninthemail September 30, 2011 05:13

The second of those works. Thank you very much.

meihua October 17, 2018 19:19

questions
 
Quote:

Originally Posted by maninthemail (Post 326088)
Greetings,

I'm implementing a boundary condition for a symmTensor variable. I calculate a scalarField, and then want to apply it to the diagonal components of the symmTensorField. The fields are turbulent intensity and reynolds stress, though that really isn't important. The relevant (updateCoeffs) part of the code is as follows...

Code:


if (updated()) return;

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

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

// "stress" is a symmetric tensor field with diagonal elements equal to "value"
symmTensorField stress;

// I don't know how to set the values in the tensor
/*
 *          / value  0.0  0.0  \
 * stress = |  0.0  value  0.0  |
 *          \  0.0  0.0  value /
 */

operator==(stress);

fixedValueFvPatchSymmTensorField::updateCoeffs();

As you can see, it is transferring the scalarField values to the symmTensorField which I can't work out how to do. There are no existing derived tensor boundary conditions to copy off, so I'm stuck for ideas. If anyone could help, I'd be eternally grateful.

Many thanks, and apologies for reposting this. No-one replied to the last post I made, and I've had some time to re-formulate the question, hopefully a little more clearly.


Hi Bill,
I'm implementing a boundary condition for a symmTensor variable now, but I do not know how to start. Could you share your solver or case?

Thanks in advance.

Meihua

maninthemail October 18, 2018 05:11

This post is 7 years old. I don't have the files any more.



If you want to write a boundary condition for a symmetric tensor, you can run the following to get you started...


Code:

foamNewBC -f -symmTensor myBoundaryCondition

meihua October 19, 2018 01:06

Quote:

Originally Posted by maninthemail (Post 710449)
This post is 7 years old. I don't have the files any more.



If you want to write a boundary condition for a symmetric tensor, you can run the following to get you started...


Code:

foamNewBC -f -symmTensor myBoundaryCondition


Thank you, Bill.

meihua October 30, 2018 00:21

Quote:

Originally Posted by maninthemail (Post 710449)
This post is 7 years old. I don't have the files any more.



If you want to write a boundary condition for a symmetric tensor, you can run the following to get you started...


Code:

foamNewBC -f -symmTensor myBoundaryCondition

Hi Bill,

Another question about tensor boundary condition. If I set a tensor on the boundary, how can it exist? I mean it seems that a tensor cannot exist on a surface, but in OpenFoam, the boundaries are surfaces. Maybe my understanding is wrong. Thanks in advance!

maninthemail November 15, 2018 04:37

The geometry that the field is associated with does not impose any limit on the data type. The field in question is just a list of symmTensors, one per patch face. How they relate to the patch geometry (face normals, areas, etc...) depends on your implementation.

kindle November 26, 2018 16:29

version of openfoam?
 
This command seems not to be in OF-2.3.x.

Is it new ?

Quote:

Originally Posted by maninthemail (Post 710449)
This post is 7 years old. I don't have the files any more.



If you want to write a boundary condition for a symmetric tensor, you can run the following to get you started...


Code:

foamNewBC -f -symmTensor myBoundaryCondition


meihua November 26, 2018 16:32

Quote:

Originally Posted by kindle (Post 716923)
This command seems not to be in OF-2.3.x.

Is it new ?

For OF 5.0, it works.

meihua November 26, 2018 16:33

Quote:

Originally Posted by kindle (Post 716923)
This command seems not to be in OF-2.3.x.

Is it new ?

Are you also developing some symmtensor boundary?

kindle November 26, 2018 17:03

Not for now. I'm actually working on simple non-newtonian turbulent mixing.

I was targeting the FENE model where there are symmTensor tau. But I dropped that... Programming in OpenFOAM is not evident. At the time I was interested in creating a moving BC for FENE for specific type "symmTensor".

kindle November 26, 2018 17:18

Tensorial BC
 
Tensorial BC exists.

Take a look at http://https://github.com/fppimenta/rheoTool/blob/master/of40/tutorials/rheoFoam/Cavity/Oldroyd-BLog/0/tau

Where tau (That I mentioned in previous post) is a symmTensor.

Pavithra April 22, 2023 07:43

Hi Everyone,

Is it possible to use codedFixedValue boundary condition to define boundary value of a symmTensor field ?

I am working on rheoTool and I need to set Poiseuille stress profile at the inlet.

Code:

    inlet
    {
        type            codedFixedValue;
        value                uniform (0 0 0 0 0 0);
       
        name                poisStress;
       
        code
        #{
                        const vectorField& Cf = patch().Cf();
                        vectorField& field = *this;
                       
                        const scalar q = 1e-06;
                        const scalar h0 = 0.4e-03;
                        const scalar l = 0.4e-03;
                                       
                        forAll(Cf, faceI)
                        {
                                const scalar y = Cf[faceI][1];
                               
                                field[faceI] = symmTensor((1 + 4.50 * ((l*q*y)/(h0*h0*h0)) * ((l*q*y)/(h0*h0*h0))),(-(3*l*q*y)/(2*h0*h0*h0)),0,1,0,0);
                        }
                       
        #};     
    }

This is what I have tried and I am geting the following error.

Code:

Using dynamicCode for codedFixedValue poisStress at line 24 in "/home/pavi/OpenFOAM/pavi-9/run/De03/0/tau/boundaryField/inlet"
Creating new library in "dynamicCode/poisStress/platforms/linux64GccDPInt32Opt/lib/libpoisStress_abc86e80ab96b5188231ac88cede6087b6e5bd77.so"
"/opt/openfoam9/etc/codeTemplates/dynamicCode/codedFixedValueFvPatchFieldTemplate.C" "/home/pavi/OpenFOAM/pavi-9/run/De03/dynamicCode/poisStress/codedFixedValueFvPatchFieldTemplate.C"
"/opt/openfoam9/etc/codeTemplates/dynamicCode/codedFixedValueFvPatchFieldTemplate.H" "/home/pavi/OpenFOAM/pavi-9/run/De03/dynamicCode/poisStress/codedFixedValueFvPatchFieldTemplate.H"
Invoking "wmake -s libso /home/pavi/OpenFOAM/pavi-9/run/De03/dynamicCode/poisStress"
wmake libso /home/pavi/OpenFOAM/pavi-9/run/De03/dynamicCode/poisStress
    ln: ./lnInclude
    wmkdep: codedFixedValueFvPatchFieldTemplate.C
    Ctoo: codedFixedValueFvPatchFieldTemplate.C
/home/pavi/OpenFOAM/pavi-9/run/De03/0/tau/boundaryField/inlet: In member function ‘virtual void Foam::poisStressFixedValueFvPatchSymmTensorField::updateCoeffs()’:
/home/pavi/OpenFOAM/pavi-9/run/De03/0/tau/boundaryField/inlet:32:25: error: invalid initialization of reference of type ‘Foam::vectorField&’ {aka ‘Foam::Field<Foam::Vector<double> >&’} from expression of type ‘Foam::poisStressFixedValueFvPatchSymmTensorField’
/home/pavi/OpenFOAM/pavi-9/run/De03/0/tau/boundaryField/inlet:42:42: error: no match for ‘operator=’ (operand types are ‘Foam::Vector<double>’ and ‘Foam::symmTensor’ {aka ‘Foam::SymmTensor<double>’})

I understand that the error message states that I am initializing a vector field as a tensor field. Someone please help me with the right syntax.

Thank You.


All times are GMT -4. The time now is 10:40.