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

[swak4Foam] calculating velocity transformations

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By santoshgoku
  • 1 Post By gschaider

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 19, 2012, 13:15
Default calculating velocity transformations
  #1
New Member
 
Santosh
Join Date: Nov 2009
Location: Netherlands
Posts: 16
Rep Power: 17
santoshgoku is on a distinguished road
Hi,

I am trying to calculate a new transformed velocity field
as a post processing step according to the following expression: dU/dt = c*dUz/dx, where c is a constant. I am trying it using swak4Foam, in which I had a couple of questions,

- how to add the dUz/dx term? I can add the div(U) term, but how to ensure that I get dUz/dx alone?
- for the dU/dt term, is it possible to use an explicit formulation like, U=U-delta(T)*c*<term for dUz/dx>?

I went through the slides on swak4Foam (No C++, please. We’re users!, Bernhard F.W. Gschaider, June 2011), and found multiple ways to obtain such expressions.

- using libswakFunctionObject and expressionField kind formulations (slide number 61/176)

Ustar
{
functionObjectLibs ("libswakFunctionObjects.so");
type expressionField;
outputControl timeStep;
fieldName Ustar;
expression "U = U - c*div(U)*deltaT()";
autowrite true;
}

- using storedValues and patchExpression (slide 131/176)

Which of the above will be apt for this formulation?

Lastly, I was trying to compile swak4Foam for OpenFoam v. 2.0.1, and I get the following errors (related to swakcodedFunctionObject) while compiling:

swakCodedFunctionObject.C:299: error: no matching function for call to ‘Foam::swakCodedFunctionObject::updateLibrary(Foam ::word&)’
/home/OpenFOAM/OpenFOAM-2.0.1/src//postProcessing/functionObjects/utilities/lnInclude/codedFunctionObject.H:111: note: candidates are: void Foam::codedFunctionObject::updateLibrary() const
make: *** [Make/linux64GccDPOpt/swakCodedFunctionObject.o] Error 1

I removed the last parameter to the =codedFunctionObject=-constructor in =swakCodedFunctionObject.C= as mentioned in the README, but still continue to get this error. Due to this, I am unable to use the expressionField kind of formulation as well. Rest of the functions are compiled fine, the problem is only with the codedFunctionObject.

Looking forward to some directions.

Thanks,
Santosh

manuc likes this.
santoshgoku is offline   Reply With Quote

Old   June 19, 2012, 15:58
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by santoshgoku View Post
Hi,

I am trying to calculate a new transformed velocity field
as a post processing step according to the following expression: dU/dt = c*dUz/dx, where c is a constant. I am trying it using swak4Foam, in which I had a couple of questions,

- how to add the dUz/dx term? I can add the div(U) term, but how to ensure that I get dUz/dx alone?


What speaks against "grad(U.z).x" ?

Quote:
Originally Posted by santoshgoku View Post
- for the dU/dt term, is it possible to use an explicit formulation like, U=U-delta(T)*c*<term for dUz/dx>?
No. But some months ago field expressions can also do "ddt(U)" (provided the solver stores the old value of U). You can also access the old time value of U (again: if stored) with "oldTime(U)"

Quote:
Originally Posted by santoshgoku View Post
I went through the slides on swak4Foam (No C++, please. We’re users!, Bernhard F.W. Gschaider, June 2011), and found multiple ways to obtain such expressions.

- using libswakFunctionObject and expressionField kind formulations (slide number 61/176)

Ustar
{
functionObjectLibs ("libswakFunctionObjects.so");
type expressionField;
outputControl timeStep;
fieldName Ustar;
expression "U = U - c*div(U)*deltaT()";
autowrite true;
}
That would involve equation solving and swak doesn't do that. So: no "=" in expression

Quote:
Originally Posted by santoshgoku View Post
- using storedValues and patchExpression (slide 131/176)
If the solver doesn't store the old U a sequence like this (yeah. This is weird) in the variables
Code:
"oldU=storedU;"
"oldU=U;"
and stordeU being declared as a stored variable will give you the U of the previous timestep as oldU to use in your expressions

Quote:
Originally Posted by santoshgoku View Post
Quote:
Originally Posted by santoshgoku View Post
Which of the above will be apt for this formulation?

Lastly, I was trying to compile swak4Foam for OpenFoam v. 2.0.1, and I get the following errors (related to swakcodedFunctionObject) while compiling:

swakCodedFunctionObject.C:299: error: no matching function for call to ‘Foam::swakCodedFunctionObject::updateLibrary(Foam ::word&)’
/home/OpenFOAM/OpenFOAM-2.0.1/src//postProcessing/functionObjects/utilities/lnInclude/codedFunctionObject.H:111: note: candidates are: void Foam::codedFunctionObject::updateLibrary() const
make: *** [Make/linux64GccDPOpt/swakCodedFunctionObject.o] Error 1

I removed the last parameter to the =codedFunctionObject=-constructor in =swakCodedFunctionObject.C= as mentioned in the README, but still continue to get this error. Due to this, I am unable to use the expressionField kind of formulation as well. Rest of the functions are compiled fine, the problem is only with the codedFunctionObject.

There was a change in that interface some time after 2.0.1 but before 2.1 and I never bothered to support both versions as users with a fairly up-to-date 2.0.x would have the new interface. Sorry
manuc likes this.
gschaider is offline   Reply With Quote

Old   June 19, 2012, 17:26
Default
  #3
New Member
 
Santosh
Join Date: Nov 2009
Location: Netherlands
Posts: 16
Rep Power: 17
santoshgoku is on a distinguished road
thanks for the reply Bernhard, really appreciated.

So, if I understand correct,

1. If U is stored in the previous time step, then I can use the expressionField, with the following expression,

Code:
expression "oldTime(U) - c*grad(U.z).x*deltaT()";
2. In case U is not stored in the previous timestep, I can use stored variables function as follows,

Code:
variables (
"oldU=storedU;"
"oldU=U;"
"storedU =oldU - deltaT()*c*grad(U.z).x;"
)

storedVariables (
{
name storedU;
initialValue "0";
}
)

expression "storedU"
But then, in the example in the slides, the above expression is used only as a patchExpression, with some "accumulation" term. Can it be used as a modified form of expressionField or swakExpression?

I will try upgrading my version of OpenFoam, and hope it works.

Thanks again.
Santosh
santoshgoku is offline   Reply With Quote

Old   June 20, 2012, 06:18
Default
  #4
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by santoshgoku View Post
thanks for the reply Bernhard, really appreciated.

So, if I understand correct,

1. If U is stored in the previous time step, then I can use the expressionField, with the following expression,

Code:
expression "oldTime(U) - c*grad(U.z).x*deltaT()";
2. In case U is not stored in the previous timestep, I can use stored variables function as follows,

Code:
variables (
"oldU=storedU;"
"oldU=U;"
"storedU =oldU - deltaT()*c*grad(U.z).x;"
)

storedVariables (
{
name storedU;
initialValue "0";
}
)

expression "storedU"
But then, in the example in the slides, the above expression is used only as a patchExpression, with some "accumulation" term. Can it be used as a modified form of expressionField or swakExpression?
accumulations is only needed if you need "a single number" to print to the screen. For instance if you use a swakExpression-FO to print the maximum and minimum of your field to the screen.

Concerning your variables: I think you'll want to exchange the last two assignments (overwrite oldU AFTER it was used. But I still don't quite understand what exactly you're trying to calculate here
gschaider is offline   Reply With Quote

Old   June 20, 2012, 06:39
Default
  #5
New Member
 
Santosh
Join Date: Nov 2009
Location: Netherlands
Posts: 16
Rep Power: 17
santoshgoku is on a distinguished road
I am trying to calculate a transformation which will lead to a new steady velocity field. The constant "c" in my expression is the velocity of structures I observe in the flow. After this transformation, I will be able to obtain a velocity field which does not change with time.
santoshgoku is offline   Reply With Quote

Old   April 19, 2016, 13:57
Default
  #6
Member
 
Sami
Join Date: Nov 2012
Location: Cap Town, South Africa
Posts: 87
Rep Power: 14
Mehrez is on a distinguished road
Hi,
I think there is a bug when using swak4Foam "storedVariables" in parallel.
The stored variables are not defined in all the sub-meshes and cause a crash.
Mhrz
Mehrez 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
Expression for calculating friction velocity Divyaprakash Main CFD Forum 0 October 1, 2015 03:03
Calculating average velocity for multiphase flows using CFD-Post amin.z FLUENT 1 July 15, 2015 08:34
Derivative of velocity and mean velocity hiuluom OpenFOAM Post-Processing 1 May 30, 2015 00:42
[General] Calculating average velocity in paraview haghgoo_reza ParaView 0 October 22, 2013 21:03
Calculating the Friction Velocity cbarry OpenFOAM 7 November 17, 2009 12:24


All times are GMT -4. The time now is 03:19.