CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM

Creating a symmTensorField from a scalarField

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 2 Post By Bernhard
  • 1 Post By maninthemail

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 29, 2011, 11:51
Post Creating a symmTensorField from a scalarField
  #1
New Member
 
Bill
Join Date: Jun 2011
Location: UK
Posts: 16
Rep Power: 14
maninthemail is on a distinguished road
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.
maninthemail is offline   Reply With Quote

Old   September 29, 2011, 14:11
Default
  #2
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21
Bernhard is on a distinguished road
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!
Tushar@cfd and ashvinc9 like this.
Bernhard is offline   Reply With Quote

Old   September 30, 2011, 04:13
Default
  #3
New Member
 
Bill
Join Date: Jun 2011
Location: UK
Posts: 16
Rep Power: 14
maninthemail is on a distinguished road
The second of those works. Thank you very much.
maninthemail is offline   Reply With Quote

Old   October 17, 2018, 18:19
Default questions
  #4
New Member
 
meihuazhang
Join Date: Oct 2018
Posts: 8
Rep Power: 7
meihua is on a distinguished road
Quote:
Originally Posted by maninthemail View Post
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
meihua is offline   Reply With Quote

Old   October 18, 2018, 04:11
Default
  #5
New Member
 
Bill
Join Date: Jun 2011
Location: UK
Posts: 16
Rep Power: 14
maninthemail is on a distinguished road
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 likes this.
maninthemail is offline   Reply With Quote

Old   October 19, 2018, 00:06
Default
  #6
New Member
 
meihuazhang
Join Date: Oct 2018
Posts: 8
Rep Power: 7
meihua is on a distinguished road
Quote:
Originally Posted by maninthemail View Post
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 is offline   Reply With Quote

Old   October 29, 2018, 23:21
Default
  #7
New Member
 
meihuazhang
Join Date: Oct 2018
Posts: 8
Rep Power: 7
meihua is on a distinguished road
Quote:
Originally Posted by maninthemail View Post
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!
meihua is offline   Reply With Quote

Old   November 15, 2018, 03:37
Default
  #8
New Member
 
Bill
Join Date: Jun 2011
Location: UK
Posts: 16
Rep Power: 14
maninthemail is on a distinguished road
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.
maninthemail is offline   Reply With Quote

Old   November 26, 2018, 15:29
Default version of openfoam?
  #9
New Member
 
Join Date: Aug 2016
Posts: 16
Blog Entries: 68
Rep Power: 9
kindle is on a distinguished road
This command seems not to be in OF-2.3.x.

Is it new ?

Quote:
Originally Posted by maninthemail View Post
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
kindle is offline   Reply With Quote

Old   November 26, 2018, 15:32
Default
  #10
New Member
 
meihuazhang
Join Date: Oct 2018
Posts: 8
Rep Power: 7
meihua is on a distinguished road
Quote:
Originally Posted by kindle View Post
This command seems not to be in OF-2.3.x.

Is it new ?
For OF 5.0, it works.
meihua is offline   Reply With Quote

Old   November 26, 2018, 15:33
Default
  #11
New Member
 
meihuazhang
Join Date: Oct 2018
Posts: 8
Rep Power: 7
meihua is on a distinguished road
Quote:
Originally Posted by kindle View Post
This command seems not to be in OF-2.3.x.

Is it new ?
Are you also developing some symmtensor boundary?
meihua is offline   Reply With Quote

Old   November 26, 2018, 16:03
Default
  #12
New Member
 
Join Date: Aug 2016
Posts: 16
Blog Entries: 68
Rep Power: 9
kindle is on a distinguished road
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 is offline   Reply With Quote

Old   November 26, 2018, 16:18
Default Tensorial BC
  #13
New Member
 
Join Date: Aug 2016
Posts: 16
Blog Entries: 68
Rep Power: 9
kindle is on a distinguished road
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.
kindle is offline   Reply With Quote

Old   April 22, 2023, 06:43
Default
  #14
Member
 
Join Date: Apr 2019
Location: India
Posts: 81
Rep Power: 7
Pavithra is on a distinguished road
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.
Pavithra is offline   Reply With Quote

Reply

Tags
boundary, condition, rstm, scalar, tensor


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Commercial meshers] Fluent3DMeshToFoam simvun OpenFOAM Meshing & Mesh Conversion 50 January 19, 2020 15:33
[blockMesh] Problems in creating a wedge type mesh Joscha OpenFOAM Meshing & Mesh Conversion 28 August 3, 2019 07:59
Problem in running ICEM grid in Openfoam Tarak OpenFOAM 6 September 9, 2011 17:51
Problems with Meshing: Collapsed Cells Emmanuel Resch Siemens 1 July 30, 2007 03:02
Gerris software installation mer Main CFD Forum 2 November 12, 2005 08:50


All times are GMT -4. The time now is 14:34.