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

Draglift and logfile

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By hjasak

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 5, 2006, 03:31
Default What is the easiest way to wri
  #1
Senior Member
 
Frank Bos
Join Date: Mar 2009
Location: The Netherlands
Posts: 340
Rep Power: 18
lr103476 is on a distinguished road
What is the easiest way to write the drag/lift to the log file, each time-step, for post-processing.

Do I have to point to the function dragCoefficient in the main loop of icoFoam (for example) ?

Thanks, Frank
__________________
Frank Bos
lr103476 is offline   Reply With Quote

Old   January 5, 2006, 05:37
Default Yes, edit the top-level code a
  #2
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,905
Rep Power: 33
hjasak will become famous soon enough
Yes, edit the top-level code and add all the post-processing you wish to do for every time-step at the end of the time loop, somewhere around runTime.write();

You can write your data into the same place as everything else using

Info << "blah blah" << endl;

Alternatively, you can open yourself a file using

#include "OFstream.H"

in the header section and something like:

OFstream logSummaryFile
(
runTime.path()/("logSummary." + runTime.timeName() + ".dat")
);

logSummaryFile
<< runTime.theta() << tab
<< p.weightedAverage(mesh.V()).value() << tab
<< T.weightedAverage(mesh.V()).value() << tab
<<>k()))().weightedAverage(mesh.V()).value()
<< tab
<< 1 - b.weightedAverage(mesh.V()).value()
<< endl;

(taken from combustion/engineFoam/logSummary.H)

You can, of course, write and format your lift and drag data as well in the same way.

Enjoy,

Hrv
hua1015 likes this.
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Old   January 6, 2006, 08:09
Default Thank you, the structure of Op
  #3
Senior Member
 
Frank Bos
Join Date: Mar 2009
Location: The Netherlands
Posts: 340
Rep Power: 18
lr103476 is on a distinguished road
Thank you, the structure of OpenFOAM becomes clearer and clearer to me. Nevertheless I got another question.

How can one call the liftDrag function from within the main function in icoFoam? Or needs the complete drag routine from within liftDrag.C be copied to icoFoam.C

I am not very familiar with C++, but still learning.

Thanks,
Frank
__________________
Frank Bos
lr103476 is offline   Reply With Quote

Old   December 15, 2006, 08:13
Default Hi Hrv, I followed your sug
  #4
Senior Member
 
Srinath Madhavan (a.k.a pUl|)
Join Date: Mar 2009
Location: Edmonton, AB, Canada
Posts: 703
Rep Power: 21
msrinath80 is on a distinguished road
Hi Hrv,

I followed your suggestion and included the calculation of lift and drag coefficients within icoFoam with Frank's help. Basically, just after

runTime.write();

I include a file:

#include "computeForces.H"

which performs calculations for lift and drag using routines from liftDrag.H and prints them out as follows:

Info
<< "\nWall patch = " << patchI << "\n"
<< "Wall patch name = " << patches[patchI].name() << "\n"
<< "Uav = " << Uav << "\n"
<< "Aref = " << Aref << "\n"
<< "DragCoefficient = " << dragCoefficient(U,p,nu,patches[patchI].name(),Uav,Aref)<<"\n"
<< endl;

etc.

However, I notice that during a parallel run, the lift and drag coefficients printed in the log file are different than those of the serial run. As I change the number of CPUs using the -np argument in mpirun (of course after performing a lamboot for the same number of CPUs), I get different values as well. Is there anything more to be done in terms of parallelizing the output as well?

For instance if the partitioning leaves one half of a set of walls in 1 CPU and another half split in two other CPUs, how does one concert all the computed lift and drag coefficients from all CPUs and put them together in a single log file?

Alternatively, is there anyway to get mpirun to print the output of each icoFoam instance to a separate log file or some such?

Please bear with me here. Thanks for your patience!
msrinath80 is offline   Reply With Quote

Old   December 15, 2006, 08:23
Default Have a look at lift and drag c
  #5
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,905
Rep Power: 33
hjasak will become famous soon enough
Have a look at lift and drag calculation: at every point where it says "sum" put gSum. Now you will get the identical results. The file lives in:

/home/hjasak/OpenFOAM/OpenFOAM-1.3/src/postProcessing/incompressible/liftDrag/

A copy of the bug fix is attached + apologies for the trouble.



Hrv
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Old   December 15, 2006, 12:03
Default Brilliant! It worked like a ch
  #6
Senior Member
 
Srinath Madhavan (a.k.a pUl|)
Join Date: Mar 2009
Location: Edmonton, AB, Canada
Posts: 703
Rep Power: 21
msrinath80 is on a distinguished road
Brilliant! It worked like a charm. Thanks very much for your help. I just had to update the libincompressiblePostProcessing.so after doing a M-x-replace-string in emacs and then rebuild the liftDrag utility.
msrinath80 is offline   Reply With Quote

Old   December 22, 2006, 05:22
Default I have one question regarding
  #7
New Member
 
Martin Karlsson
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 13
Rep Power: 17
martin is on a distinguished road
I have one question regarding gSum. In the end of each time-step I write the forces on my patches to the logfile. For each patch I call a function to calculate and write the total force to the logfile where I use gSum :

sumForce=gSum(force); //where force is a vectorField

Then when using:
Info << sumForce << endl; // gives the result for the master node.
Sout << sumForce << endl; //gives correct result for each node, but then I will need to sum all nodes before analysing the logfile

Why does not gSum(force) sum the force for each node?
Do you have any suggestions how I should rewrite my application?

Thanks,
Martin
martin is offline   Reply With Quote

Old   February 20, 2007, 08:03
Default I don't whant to open another
  #8
Senior Member
 
Francesco Del Citto
Join Date: Mar 2009
Location: Zürich Area, Switzerland
Posts: 237
Rep Power: 18
fra76 is on a distinguished road
I don't whant to open another thread, so this seems to be the right one.

I have reincluded liftDrag utility in OF 1.3 and fix the sum/gSum bug in OpenFOAM/OpenFOAM-1.3/src/postProcessing/incompressible/liftDrag/liftDrag.C,
and I would like to perform lift and drag calculation after each solver iteration, as pUl| did.
Obviously, it doesn't work to me. More in detail, the very liftDrag utility works in serial, but not in parallel!
Here follows a part of the output (I've added "Pout << Uav" in liftDrag.C):

SERIAL:
-------------------
Time = 0
Reading U

Reading p

Inlet velocity: (149.98815 0 -1.887)
Inlet velocity: (149.98815 0 -1.887)
Wall patch 0 named ground :
[...]



PARALLEL:
-------------------
Create mesh for time = 0

Time = 0
Reading U

[2] --> FOAM Warning :
[2] From function average(const UList<type>&)
[2] in file /home/fde/OpenFOAM/OpenFOAM-1.3/src/OpenFOAM/lnInclude/FieldFunctions.C at line 454
[2] empty field, returning zero
[... various ...]
[3] --> FOAM FATAL ERROR : Uinf is zero.
[3]
[3] From function vector momentCoefficient
(
const volVectorField& U,
const volScalarField& p,
const dimensionedScalar& mu,
const word& patchName,
const vector& Uinf,
const scalar& Aref,
const scalar& Lref
)
[3]
[3] in file liftDrag/liftDrag.C at line 567.
[3]
FOAM parallel run exiting


And, regarding Uav value (I have 3 patches with the same imposed velocity):
Inlet velocity: (99.9921 0 -1.258)
[0] Inlet velocity: (99.9921 0 -1.258)
[1] Inlet velocity: (149.98815 0 -1.887)
[2] Inlet velocity: (0 0 0)
[3] Inlet velocity: (0 0 0)


----------------------
I guess this is an error. All parallel processes should have the same reference value for Uinf, while each process now seems to sum only the patches that belong to it.

What's wrong with it?
pUl|, how could you perform this calculation?

Francesco
fra76 is offline   Reply With Quote

Old   February 20, 2007, 11:06
Default I basically followed Frank Bos
  #9
Senior Member
 
Srinath Madhavan (a.k.a pUl|)
Join Date: Mar 2009
Location: Edmonton, AB, Canada
Posts: 703
Rep Power: 21
msrinath80 is on a distinguished road
I basically followed Frank Bos's instructions. I will attach my modified icoFoam source later today when I get to the office. Maybe that will help
msrinath80 is offline   Reply With Quote

Old   February 20, 2007, 13:01
Default Thanks a lot! In the meanwhil
  #10
Senior Member
 
Francesco Del Citto
Join Date: Mar 2009
Location: Zürich Area, Switzerland
Posts: 237
Rep Power: 18
fra76 is on a distinguished road
Thanks a lot!
In the meanwhile, I rewrote force computation, using the code inside liftDrag.C, but without calling the routines directly.
So I have assigned a Uinf velocity and a reference area, accordingly to my case.
It seems to work in parallel now, but I'm not completly confident about results, so any suggestion will be welcome!
fra76 is offline   Reply With Quote

Old   February 21, 2007, 04:58
Default http://www.ualberta.ca/~madhav
  #11
Senior Member
 
Srinath Madhavan (a.k.a pUl|)
Join Date: Mar 2009
Location: Edmonton, AB, Canada
Posts: 703
Rep Power: 21
msrinath80 is on a distinguished road
http://www.ualberta.ca/~madhavan/icoFoam.tar.bz2
http://www.ualberta.ca/~madhavan/liftDrag.tar.bz2

The source also does time-averaging and writing out velocity/pressure probes based on the points specified in probeLocations.

Good Luck
msrinath80 is offline   Reply With Quote

Old   February 21, 2007, 05:19
Default Thank you very much! It's mor
  #12
Senior Member
 
Francesco Del Citto
Join Date: Mar 2009
Location: Zürich Area, Switzerland
Posts: 237
Rep Power: 18
fra76 is on a distinguished road
Thank you very much!
It's more or less what I did, except for the average (I'm using a steady state solver), but it's very useful to have a comaprison.
fra76 is offline   Reply With Quote

Old   April 17, 2007, 11:55
Default Hi, I was wondering from wh
  #13
New Member
 
Jeff Allen
Join Date: Mar 2009
Posts: 11
Rep Power: 17
jballen is on a distinguished road
Hi,

I was wondering from what source the drag relaxation time was obtained, as incorportated in the IcoLagrangian solver?

Regards
Jeff
jballen is offline   Reply With Quote

Old   April 9, 2008, 07:59
Default Hey, I tried to compile the
  #14
New Member
 
Aamir Malik
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 1
Rep Power: 0
aamirmalik is on a distinguished road
Hey,

I tried to compile the liftDrag source files given by pUl| in version 1.4, but it gave me the following error. Can anybody figure out the error.


-lincompressiblePostProcessing -lfiniteVolume -lOpenFOAM -liberty -ldl -lm -o /scratch/amer/OpenFOAM/OpenFOAM-1.4.1/applications/bin/linux64GccDPOpt/liftDrag
/usr/lib/../lib64/crt1.o: In function `_start':
../sysdeps/x86_64/elf/start.S:109: undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [/scratch/amer/OpenFOAM/OpenFOAM-1.4.1/applications/bin/linux64GccDPOpt/liftDrag ] Error 1
aamirmalik is offline   Reply With Quote

Old   April 9, 2008, 08:12
Default Usually this type of error com
  #15
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
Usually this type of error comes from the fact that you typed wmake instead of wmake libso.

Dragos
dmoroian is offline   Reply With Quote

Old   November 18, 2008, 13:53
Default Hi all! According to liftdr
  #16
Member
 
Johan Lorentzon
Join Date: Mar 2009
Location: Lunds University, Sweden
Posts: 78
Rep Power: 23
pi06jl6 will become famous soon enough
Hi all!

According to liftdrag.H, the drag force can be evaluated for newtonian fluids.

The viscous term is -mu*(part u_i / part x_j+part u_j / part x_i ) n_j *dA

mu is the kinematic viscosity, dA is the area of the face, U is the velocity of the fluid, n is the normal vector of the face.

The liftdrag.H tells however the middle part to be sngrad(), the normal gradient of the velocity gradient, this would read grad(U)n (?), however a closer look in the code i would rather use the deviatoric part of (grad(U)+grad(U)^T) times the normal of the surface. I have been searching the code part for sngrad but ended up only at FvPatchField::snGrad which seems not doing the thing according to me, or do I owe someone an apology for this statement?

I could of course just accept the liftDrag.H as it is but i would like to have some understanding of the code.

Best Regards

Johan
pi06jl6 is offline   Reply With Quote

Old   November 18, 2008, 16:23
Default For clarification, deviatoric
  #17
Member
 
Johan Lorentzon
Join Date: Mar 2009
Location: Lunds University, Sweden
Posts: 78
Rep Power: 23
pi06jl6 will become famous soon enough
For clarification, deviatoric part was a missplaced word, taken from another text i was reading. So please kindly disregard that. What I was implicating is that from the plausible code piece FvPatchField::sngrad(), i didnt follow how that part of the could should generate the viscous term corresponding to the symmetric gradient of the velocity field times the normal vector of the surface.

Best Regards

Johan
pi06jl6 is offline   Reply With Quote

Old   November 19, 2008, 06:50
Default Greetings again, I solved t
  #18
Member
 
Johan Lorentzon
Join Date: Mar 2009
Location: Lunds University, Sweden
Posts: 78
Rep Power: 23
pi06jl6 will become famous soon enough
Greetings again,

I solved the issue! So ignore my previous two posting.

/Johan
pi06jl6 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



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