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

Defining additionally variables of U in OF 1.6

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 3, 2011, 07:44
Default Defining additionally variables of U in OF 1.6
  #1
Member
 
sirLentschi
Join Date: Nov 2010
Posts: 79
Rep Power: 15
lentschi is on a distinguished road
Hello,

I am an OF Newbie and want to set up a case of a pump turbine in OF 1.6.
Therefor I have to integrate some additionally variables of the Velocity in 3 different local coordinate systems, such as:

U_new1=Ux*cos(10°)+Uy*sin(10°)
U_new2=Ux*cos(12°)+Uy*sin(12°)
U_new3=Ux*cos(30°)+Uy*sin(30°)

Can anyone tell me, where I have to define this 3 velocities and in which Script I have to perform this Integration?
Or do you think it's better to output the standard Velocity U and transform it later during post?

Thanks in advance.

Regards Markus
lentschi is offline   Reply With Quote

Old   March 5, 2011, 07:51
Default
  #2
Senior Member
 
Gijsbert Wierink
Join Date: Mar 2009
Posts: 383
Rep Power: 18
gwierink is on a distinguished road
Hi Markus,

The x-component of a field, here U, is U.component(0). The y- and z-components would be U.component(1) and U.component(2), respectively. Now, the way you have written it gives a volScalarField, not a volVectorField (like U itself). For instance, you could plug the following in the solver after U is solved:
Code:
scalar angle1 = mathematicalConstant::pi/6.0;

volScalarField Unew =
    U.component(0) * Foam::cos(angle1)
 + U.component(1) * Foam::sin(angle1);
This calculates a field of scalars that consist of Ux*cos(pi/6) + Uy*sin(pi/6), where cos and sin use rad. But the field is not written every time step. For that you need to put
Code:
Info << "Reading field Unew\n" << endl;

volScalarField Unew
(
    IOobject
    (
        "Unew",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ,
        IOobject::AUTO_WRITE
    ),
    mesh
);
in createFields.H. Then, you don't need to specify the type of Unew in the code, i.e. leave out "volScalarField" in the code that calculates Unew. If you use "MUST_READ" in createFields.H you need to make a file in the 0 folder of the case, where the initial and boundary conditions of Unew are specified.

If you'd like to write every time step, function objects are handy. In your case probably the turboPerformance function objects. Hope this helps you on your way a bit!
__________________
Regards, Gijs
gwierink is offline   Reply With Quote

Old   March 7, 2011, 08:56
Default
  #3
Member
 
sirLentschi
Join Date: Nov 2010
Posts: 79
Rep Power: 15
lentschi is on a distinguished road
Hy Gijsbert,

thank you very much for your instruction!Now, I have to think about if it's necessary to perfom the transformation during solving - in my opinion this may rise the calculation time?!
For this reason I think it's much easier to output only the velocity U and to create a script in python during post,which transform it to local coordinate systems.

Regards Markus
lentschi is offline   Reply With Quote

Old   March 7, 2011, 09:10
Default
  #4
Senior Member
 
Gijsbert Wierink
Join Date: Mar 2009
Posts: 383
Rep Power: 18
gwierink is on a distinguished road
Hi Markus,

Sure, the calculation, although small, will take some time. You could use the U file in the time step directories. This, however, only gives you data at write time. If you need data at every time step I suggest to either use a function object or put the above code in and write out the data in an info statement to a log file. For that simply add
Code:
Info << "Unew = " << Unew << endl;
to the solver, run the solver with
Code:
somethingFoam > log &
and grep Unew from the log file.
__________________
Regards, Gijs
gwierink is offline   Reply With Quote

Reply


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
Accessing other variables in defining boundary condition Cynthia Poon OpenFOAM Running, Solving & CFD 1 September 27, 2021 06:28
k-omega-SST model (OF 1.6) - turbulent flat plate cboss OpenFOAM Running, Solving & CFD 25 August 9, 2016 09:53
Defining New Variables Tim Phoenics 0 September 30, 2003 14:52
PHI file structure Eugene Phoenics 9 November 2, 2001 22:00
Saving variables on a user patch with physical coordinates Zoltan Turzo CFX 2 April 20, 2000 15:05


All times are GMT -4. The time now is 16:38.