|
[Sponsors] |
Initialization of symmTensor by a coded function |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
August 10, 2016, 13:42 |
Initialization of symmTensor by a coded function
|
#1 | ||||
New Member
Javier Sierra Ausin
Join Date: Jul 2016
Location: Toulouse
Posts: 1
Rep Power: 0 |
Hi, I am trying to implement an utility that calculate time averages of different fields. So what I am doing is to compute the fields I need with a coded function in my ControlDict and after I use fieldAverage function Object.
By now, I am being inspired by this post where eelcovv and gschaider prupose different solutions for a similar issue. My final goal is to be able to write volSymmTensorFields, volScalarFields and volVectorFields. However, I am not able to figure out the way to initialize volSymmTensorFields. what I do to initialize a volScalarField is as follows: Quote:
Nevertheless, this is not the case for volsymmTensorFields. So what I do so far for symmTensorFields is: Quote:
Quote:
Quote:
Thank you very much. |
|||||
August 12, 2016, 11:45 |
|
#2 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Hi,
to initialize a symmTensorField: Code:
//- Create a symmTensorField with 100 entries symmTensorField a(100); forAll(a, i) { a[i] = symmTensor(1,2,3,4,5,6); } // or simpler symmTensorField a(100, symmTensor(1,2,3,4,5,6));
__________________
Keep foaming, Tobias Holzmann |
|
January 9, 2019, 09:02 |
|
#3 | |||
Senior Member
Guilherme
Join Date: Apr 2017
Posts: 245
Rep Power: 10 |
Tobi,
I would like to know how to extract the xy element from the strain rate tensor: Quote:
I wrote like this: Quote:
Quote:
ty |
||||
January 9, 2019, 12:12 |
|
#4 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Hi, you have to define the variable before.
Code:
// Option 1 forAll(D , i) { const Dxy = D[i].xy(); //- Use Dxy inside the forAll loop } // Option 2 scalarField Dxy(0, D.size()); // Not sure if the initialization is correct, but should be forAll(D , i) { const Dxy[i] = D[i].xy(); } //- Use Dxy outside the forAll loop
__________________
Keep foaming, Tobias Holzmann |
|
January 9, 2019, 13:19 |
|
#5 | ||
Senior Member
Guilherme
Join Date: Apr 2017
Posts: 245
Rep Power: 10 |
Thanks Tobi,
It worked, but I did it "differently", because I need to extract those values later. However, I noticed that the gradient on the wall (Dxy) is giving zero, which is not right, since I need tauxy. I have attached the snippet of my code, maybe you can help me in this 'error'. Quote:
Quote:
|
|||
April 22, 2023, 07:21 |
symmTensorField + codedFixedValue
|
#6 |
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); } #}; } 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>’}) Thank You. |
|
Tags |
controldict, fieldaverage, function, initialization, tensor |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[blockMesh] edges not aligned with or perpendicular to non-empty directions | ynos | OpenFOAM Meshing & Mesh Conversion | 6 | March 26, 2020 16:02 |
Question about Initialization of Signed Distance Function (LEVEL SET) | jl21_87 | Main CFD Forum | 0 | January 10, 2012 22:50 |
channelFoam for a 3D pipe | AlmostSurelyRob | OpenFOAM | 3 | June 24, 2011 14:06 |
Compilation errors in ThirdPartymallochoard | feng_w | OpenFOAM Installation | 1 | January 25, 2009 07:59 |
Problem with compile the setParabolicInlet | ivanyao | OpenFOAM Running, Solving & CFD | 6 | September 5, 2008 21:50 |