CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Passing calculated values in parallel run (http://www.cfd-online.com/Forums/openfoam-solving/58988-passing-calculated-values-parallel-run.html)

wese April 1, 2008 09:41

Hi, I have a problem with the
 
Hi,
I have a problem with the parallel execution of OpenFOAM.
I've written a new boundary condition with calculated the input velocity profile of a square duct.
If I run my case on one processor I just have to calculate the values a single time when starting my calculation ( if(ldb.timeIndex() < 1)... ).
If I want to run my calculation in parallel mode I need to perform the calculation every time the program accesses the boundary condition (with is very often) and so I "waste" a lot of calculation time with a problem that doesn't change over time.
If I don't do so the velocity at my patch is set to some time varying value, from with I guess that it's calculated during execution.

How can I fix this problem?
I've already consulted the forum and the wiki (I've started with the parabolicinletVelocityprofile fot writing my BC) but was unable to find an appropriate hint how to do this.
Am I right, if I guess, that the problem is connected with the exchange of informations beween the processors?

Thanks in advance
Christian

fra76 April 2, 2008 02:13

Hi Christian, why do you need
 
Hi Christian,
why do you need to calculate your BC only once in serial and many times in parallel? It sounds strange to me...
However, you can let all your processes to calculate your BC when needed. I mean, do your computation on each processor at the same time, instead of doing it on the master node and send the result to the other processes...

I hope this can help

Francesco

wese April 2, 2008 09:19

Hello Francesco, thanks for y
 
Hello Francesco,
thanks for you reply.
Could you give me a hint how I do so, because I'm neither that much familiar with OpenFOAM nor with C++.
I guess a good idea would be, that the program check whether a file with the calculated values exists and if so reads it as input.
Otherwise the program should perform the calculation and write the output to the specific file.

Thanks in advance
Christian

fra76 April 3, 2008 05:43

Hello christian. It's not eas
 
Hello christian.
It's not easy to give you some hint, because I don't know exactly which is your problem...

If you can calculate the values you need, I guess you can avoid writing them to a file.
If your serial version works as you expect, simply let all the processors of a parallel run to do the same thing. If you rely on a file, you have to be sure that it exists at the beginning of the simulation, if you want to keep thing simple. Otherwise, if the file doesn't exist, simply calculate the values and store them in the BC data structure, without writing them to a file and read them back again.
If you want to store those values for any reason, you can let only the master process to write it:


if (Pstream::master())
{
[put your code here]
}


If you want to make the master to write the file and the rest to wait for it to finish, is a bit more complicated...

I hope this can help,
Francesco

wese April 3, 2008 07:45

Hi Francesco, thanks a lot fo
 
Hi Francesco,
thanks a lot for your help.
I finally managed the problem with the parallel run by creating and writing a variable after the first calculation.
So every processor can perfom the calculation if needed.
Otherwise the data is just read out of the value variable.

For a total beginner in C++ the openFOAM code is really difficult, because everything is coded so efficently.

If you have any interest I can post my new boundary condition for the velocity profile of a square duct.

Greetings
Christian

fra76 April 3, 2008 08:47

Hi Christian, I started C++ m
 
Hi Christian,
I started C++ mainly for OpenFOAM, and from my point of view it is not so difficult, because everything is coded so efficiently and in an elegant way!
Try to put your hands in a badly written parallel code. It can be a nightmare, believe me...

It would be nice to have a look to the BC, if you can post it, thanks.

Francesco

wese April 3, 2008 10:04

Hi Francesco, maybe you're ri
 
Hi Francesco,
maybe you're right.
At the moment I'm updating the document management system of our institute, which is written in PHP.
The scripts were created quick and dirty by someone several years ago.
Even if PHP is very simple to understand, all the encoded layout options really got me rid.
Compared to that openFOAM code is more than gold http://www.cfd-online.com/OpenFOAM_D...part/happy.gif.

Attached you can find my new boundary condition which is an adaption of the parabolicVelocityProfile BC.
If you find any mayor mistakes or so please report.

http://www.cfd-online.com/OpenFOAM_D...hment_icon.gif squareVelocityProfile.tar.gz

Greetings
Christian


All times are GMT -4. The time now is 22:31.