# Creating a symmTensorField from a scalarField

 User Name Remember Me Password
 Register Blogs Members List Search Today's Posts Mark Forums Read

 September 29, 2011, 11:51 Creating a symmTensorField from a scalarField #1 New Member   Bill Join Date: Jun 2011 Location: UK Posts: 16 Rep Power: 14 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(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.

 September 29, 2011, 14:11 #2 Senior Member   Bernhard Join Date: Sep 2009 Location: Delft Posts: 790 Rep Power: 21 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.

 September 30, 2011, 04:13 #3 New Member   Bill Join Date: Jun 2011 Location: UK Posts: 16 Rep Power: 14 The second of those works. Thank you very much.

October 17, 2018, 18:19
questions
#4
New Member

meihuazhang
Join Date: Oct 2018
Posts: 8
Rep Power: 7
Quote:
 Originally Posted by maninthemail 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(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?

Meihua

 October 18, 2018, 04:11 #5 New Member   Bill Join Date: Jun 2011 Location: UK Posts: 16 Rep Power: 14 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.

October 19, 2018, 00:06
#6
New Member

meihuazhang
Join Date: Oct 2018
Posts: 8
Rep Power: 7
Quote:
 Originally Posted by maninthemail 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.

October 29, 2018, 23:21
#7
New Member

meihuazhang
Join Date: Oct 2018
Posts: 8
Rep Power: 7
Quote:
 Originally Posted by maninthemail 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!

 November 15, 2018, 03:37 #8 New Member   Bill Join Date: Jun 2011 Location: UK Posts: 16 Rep Power: 14 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.

November 26, 2018, 15:29
version of openfoam?
#9
New Member

Join Date: Aug 2016
Posts: 16
Blog Entries: 68
Rep Power: 9
This command seems not to be in OF-2.3.x.

Is it new ?

Quote:
 Originally Posted by maninthemail 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`

November 26, 2018, 15:32
#10
New Member

meihuazhang
Join Date: Oct 2018
Posts: 8
Rep Power: 7
Quote:
 Originally Posted by kindle This command seems not to be in OF-2.3.x. Is it new ?
For OF 5.0, it works.

November 26, 2018, 15:33
#11
New Member

meihuazhang
Join Date: Oct 2018
Posts: 8
Rep Power: 7
Quote:
 Originally Posted by kindle This command seems not to be in OF-2.3.x. Is it new ?
Are you also developing some symmtensor boundary?

 November 26, 2018, 16:03 #12 New Member   Join Date: Aug 2016 Posts: 16 Blog Entries: 68 Rep Power: 9 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".

 November 26, 2018, 16:18 Tensorial BC #13 New Member   Join Date: Aug 2016 Posts: 16 Blog Entries: 68 Rep Power: 9 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.

 April 22, 2023, 06:43 #14 Member   Join Date: Apr 2019 Location: India Posts: 81 Rep Power: 7 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 >&’} 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’ and ‘Foam::symmTensor’ {aka ‘Foam::SymmTensor’})``` 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.

 Tags boundary, condition, rstm, scalar, tensor

 Thread Tools Search this Thread Search this Thread: Advanced Search Display Modes Linear Mode

 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 OffTrackbacks are Off Pingbacks are On Refbacks are On Forum Rules

 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 Tarak OpenFOAM 6 September 9, 2011 17:51 Emmanuel Resch Siemens 1 July 30, 2007 03:02 mer Main CFD Forum 2 November 12, 2005 08:50

All times are GMT -4. The time now is 22:58.

 Contact Us - CFD Online - Privacy Statement - Top