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

FoamCalc writing a new function wakeField

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 4 Post By markc

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 15, 2008, 08:27
Default Dear All, I am in need of s
  #1
Senior Member
 
Mark Couwenberg
Join Date: Mar 2009
Location: Netherlands
Posts: 130
Rep Power: 17
markc is on a distinguished road
Dear All,

I am in need of some help regarding writing a new add on for foamCalc, called "wakeField". The function is to perform a very simple calculation:

wakeField = 1 - Ux / U(farfield).

I used the folder "components" as a starting point and modified step by step until I ran into problems.

I was able to perform : wakeField = Ux / U(farfield). However, next is that I do 1- Ux/U(farfield) by adding the following in the writeWakeField.C:
>>>
scalar(1) - (field.component(i) / scalar(5))
<<<

wmake libso works well but running the utility (foamCalc wakeField U) gives the next error:
>>>
LHS and RHS of - have different dimensions
dimensions : [0 0 0 0 0 0 0] - [0 1 -1 0 0 0 0]
<<<
Well, this is a very clear error message: the "1" has no dimensions while a U field has. But I do not know how to solve this problem.

Furthermore: so far I assumed for simplicity that my farfield velocity is 5. However this should be read from the time directory/U file under the head belonging to the inlet patch.
So as extra input I would ask the user for "inletPatchName". The utility should search in this inlet patch for the correct U value. How to program this?

I hope I made myself clear enough and anyone is able to comment,

Brgds,

Mark
markc is offline   Reply With Quote

Old   December 15, 2008, 09:06
Default Hi Mark, You should use a d
  #2
New Member
 
Luiz Fernando L. R. Silva
Join Date: Mar 2009
Location: Rio de Janeiro, RJ, Brazil
Posts: 10
Rep Power: 17
silva is on a distinguished road
Hi Mark,

You should use a dimensioned variable to define U(farfield) (after all, it has velocity units, right?). Then, the Ux/U(farfield) division will be dimensionless as the subtracting operation.

At this time, define it in your code as:

dimensionedScalar Ufarfield
(
"Ufarfield", // the name
[0 1 -1 0 0 0 0], // its dimensions (L / T)
5.0 // the value
);

I suppose you will have to change or create a code for the boundary condition if you want to read Ufarfield from the 'time/U' file. If not, probably, there is an easy way to read this variable, but I don't know it (and it would take some time for me to dig it out). Let's see if someone out there knows it better.

On the other hand, if 'Ufarfield' is a variable that does not change in time, you could store it in a file in the constant directory...

Hope it helped,
Luiz F.
silva is offline   Reply With Quote

Old   December 15, 2008, 10:25
Default Hi Luiz, Thanks for your ef
  #3
Senior Member
 
Mark Couwenberg
Join Date: Mar 2009
Location: Netherlands
Posts: 130
Rep Power: 17
markc is on a distinguished road
Hi Luiz,

Thanks for your effort. Unfortunately it did not work for me, I probably have not enough knowledge about C++ qualifiers etc. However your comments brought me a step further again.
And yes, you're right: the value 5 shall be read from the time directory.
I should incorporate something like:
>>>
surfaceScalarField Ufarfield
(
IOobject
(
"Ufarfield",
mesh.time().timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
),
dimensionedscalar("Ufarfield", [0 1 -1 0 0 0 0], 5.0)
);
<<<
in the main .C file (wakeField.C). But so far I did not succeed. I have to tell the utility that has to read the value from the entry:
>>>
Inlet
{
type pressureInletVelocity;
value uniform (5 0 0);
}
<<<

Any help would be greatly appreciated.

Brgds,

Mark
markc is offline   Reply With Quote

Old   December 16, 2008, 07:12
Default Hi Mark, Maybe you can hav
  #4
Senior Member
 
Cedric DUPRAT
Join Date: Mar 2009
Location: Nantes, France
Posts: 195
Rep Power: 17
cedric_duprat is on a distinguished road
Hi Mark,

Maybe you can have a look at the channelOodles solver (solvers/DNSandLES/channelOodles).
In this solver at each time step a scalar (gradP) is written in runTime.path()/runTime.timeName()/

And when you start your calculation, the solver read this file.

So you can adapt it to your case, write it every time step and read it not only when you start the calculation but at each time step.

I hope I've got well understand your problem and that it will help


Cedric
cedric_duprat is offline   Reply With Quote

Old   December 16, 2008, 08:57
Default Cedric, All little pieces h
  #5
Senior Member
 
Mark Couwenberg
Join Date: Mar 2009
Location: Netherlands
Posts: 130
Rep Power: 17
markc is on a distinguished road
Cedric,

All little pieces help, thanks for your advice. However, channelOodles reads a datafile (gradP.raw), which works a little different from reading a BC file.
Well, for the experienced C programmers here it will surely be something simple, but I get stuck here.

Thanks anyway,

Mark
markc is offline   Reply With Quote

Old   December 24, 2008, 04:09
Default Hello All, The utility is f
  #6
Senior Member
 
Mark Couwenberg
Join Date: Mar 2009
Location: Netherlands
Posts: 130
Rep Power: 17
markc is on a distinguished road
Hello All,

The utility is finished. I made a simple stand-alone though, so it is not available via foamCalc.
For reference the files are attached here:

wakeField.zip

Thanks for the assistance,

Mark
markc 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
Writing y christian OpenFOAM Running, Solving & CFD 29 June 1, 2010 06:55
New with writing UDF/Need help pls mac FLUENT 6 June 14, 2007 06:11
New to writing UDF Sandilya FLUENT 0 May 31, 2007 12:03
UFD writing help Nelly FLUENT 1 January 19, 2007 11:29
Stream Function - Potential Function coordinates harish Main CFD Forum 8 June 25, 2005 13:18


All times are GMT -4. The time now is 01:37.