CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Convective outlet boundary condition for Unsteady flows (https://www.cfd-online.com/Forums/openfoam-solving/57840-convective-outlet-boundary-condition-unsteady-flows.html)

msrinath80 July 5, 2006 17:20

Has anyone implemented a bound
 
Has anyone implemented a boundary condition of the following type in OpenFOAM?

http://www.cfd-online.com/OpenFOAM_D...ges/1/2696.jpg

Where (from Ferziger and Peric [page 273]):

phi = any dependent variable (e.g. velocity, pressure etc.)

U = A velocity that is independent of location on the outflow surface and is chosen so that overall conservation is maintained (i.e. it is the velocity required to make the outflow mass flux equal to the incoming mass flux).

If nobody has done this, I would like to do it. However I would appreciate some guidelines. I am farily OK with C; C++ is fairly new to me. Any help in this regard is most appreciated. Thanks http://www.cfd-online.com/OpenFOAM_D...part/happy.gif

aurelia July 6, 2006 02:34

Hello I also need that kind o
 
Hello
I also need that kind of boundary condition, so if you manage to write it, it would be nice to share ;)
When I thought about writing it, I was told that the pressureTransmissive boundary condition ( even if it is for compressible flow), could help to begin with...
Good luck
Aurelia

msrinath80 July 6, 2006 08:57

Thanks for the tip Aurelia. I'
 
Thanks for the tip Aurelia. I'll give it a shot. The only reason I chose OpenFOAM despite my 3-year experience with Fluent is that it offers much more freedom to learn and share http://www.cfd-online.com/OpenFOAM_D...part/happy.gif

eugene July 7, 2006 07:35

First derive the discretised i
 
First derive the discretised implementation of the BC using fluxes, face values, etc. If you can come up with something half-decent, I will be glad to help you implement it )on the condition that you do the testing!).

hjasak July 7, 2006 07:49

Hi Eugene, You're going to
 
Hi Eugene,

You're going to have fun trying to get the time derivative to be consistent with the temporal disretisation scheme (requires the change of the virtual function interface + you need to implement it in all the schemes). Apart from that, there's no derivation involved - it already tells you what to do. :-)

Have fun,

Hrv

eugene July 7, 2006 09:29

Aaarg! I didn't think that far
 
Aaarg! I didn't think that far ahead.

Time centred was all I had in my head. I have been pining for this BC for quite some time though, so it might just be worth the effort (even if it takes up the rest of my discretionary time this year).

(PS. I know it tells me what to do I just wanted some commitment from the OP!)

hjasak July 7, 2006 09:38

If you want it, I can do it in
 
If you want it, I can do it in a few minutes, but you will need an updated version of the library - at least until the next release. Alternatively, you can get into my bad books and hack it with the first-order ddt term :-)

For all those interested Foam-ers out there, the b.c. will be a fixed gradient type and I get the gradient by rewriting the expression in the following form:

d phi/d n = -ddt \phi |Sf| / F

with the stabilisation for zero flux. And that's it :-)

Hrv

eugene July 7, 2006 09:53

In that case I retract my prev
 
In that case I retract my previous offer!

Which classes require an updated interface for this to work?

The description of U in the original post also leaves me slightly confused.

msrinath80 July 7, 2006 12:46

Hrv: Indeed if you can do this
 
Hrv: Indeed if you can do this in a few minutes, it would be great. I am more than willing to test it as soon as possible http://www.cfd-online.com/OpenFOAM_D...part/happy.gif

Eugene: The description of U is verbatim from the textbook. I have not bothered to get into the details yet http://www.cfd-online.com/OpenFOAM_D...lipart/sad.gif

PS: I wonder why Fluent does not have this B/C built-in (given the fact that Ferziger and Peric recommend this B/C, as it appears to work well for most unsteady cases).

msrinath80 July 13, 2006 13:23

@Eugene: I just pulled out
 
@Eugene:

I just pulled out an excerpt from a very recent paper in Journal of Computational Physics (Vol: 206, page 661), and I can see now what you mean by 'slightly confused'.

"...The Convective Boundary Condition (CBC) has been used by Najjar and Vanka [4] and Najjar and Balachandran [5] in computing uniform flow past a normal flat plate. Cheng and Armfield [6] have employed it in computing uniform, two-dimensional flow past a circular cylinder. It has also been employed by Pauley et al. [7], Arnal et al. [8], Sohankar et al. [9] and Biswas and co-workers [10] for the computations of uniform, two-dimensional flow past a square cylinder. However, it is felt that the CBC lacks in a proper physical basis for elliptic and parabolic problems and it is also somewhat awkward to implement. The quantity U in the Equation is loosely defined in the literature as different authors have defined it in a different manner [4-*7]. The value of U, which yields minimum distortion in the vorticity structure at the exit, has to be determined by trial..."

aurelia September 29, 2006 03:23

hello I need to use a convect
 
hello
I need to use a convective boundary and don't manage to make it work like discribed in the thread.
According to Hrvoje, it should be easy...
could you share it if you wrote such a boundary condition?
Thanks
aurelia

msrinath80 October 4, 2006 11:39

No, I have not written it yet.
 
No, I have not written it yet. Hrv, if you've written it, can you post it on the forum? Thanks!

7islands January 19, 2007 21:35

Hi again, I did a little math
 
Hi again, I did a little math and now I've got satisfactory results by applying a predictor-corrector method in patch-normal direction (not in usual temporal direction). The problem seems to be solved.

Regards,
Takuya

msrinath80 January 19, 2007 21:37

Takuya, It would be nice if
 
Takuya,

It would be nice if you could post your code so others can test it as well.

Thanks!

7islands January 20, 2007 00:00

Hi pUl|, Of course I could do
 
Hi pUl|,
Of course I could do so but the code is currently a total gabage for CFD people because it can only handle scalar variables (= the velocity potential). To handle vectors I have to rewrite the whole code using C++ templates. My estimate is that it won't take so much effort but at least I need some test cases including unsteady outlet flows (I myself don't have any such cases in handy http://www.cfd-online.com/OpenFOAM_D...lipart/sad.gif ) - contribution welcome.

And the most important is, please don't expect too much - I'm not sure if it works for CFD at all.

Regards,
Takuya

7islands January 29, 2007 04:58

Hi all, Here's a generalized
 
Hi all,
Here's a generalized convectiveOutlet b. c. code which can handle vectors.

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

For a quick start write the initial field file (0/U etc.) as the following example. If you want to tweak the behavior of the code see the included README.

boundaryField
{
outlet
{
type convectiveOutlet;
// convectiveVelocity: the boundary-normal component of convective velocity
convectiveVelocity uniform 343.704;
snGradScheme upwind;
ddtScheme Euler;
}
}


Please don't blame me if the code doesn't work at all - as I stated above I don't have an appropreate test case in handy. Propose me a fix (or preferably a patch) instead. Thanks.

Takuya

7islands February 7, 2007 01:00

Hi again and again, I added a
 
Hi again and again,
I added a new option to snGradScheme called "normal" after doing a little elementary-school algebra which seems to be the most straightforward and reasonable discretization to me (why hasn't the idea come to me first...?). This time the default for snGradScheme is this scheme and the other options are meant for backward compatibility and for cases where the default doesn't work.

For a quick start write the initial field file (0/U etc.) as the following example.

boundaryField
{
outlet
{
type convectiveOutlet;
// convectiveVelocity: the boundary-normal component of convective velocity
convectiveVelocity uniform 343.704;
ddtScheme Euler;
}
}

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

Takuya

msrinath80 February 8, 2007 09:44

Hi Takuya, I will be testin
 
Hi Takuya,

I will be testing you new version soon. Will it work with Crank Nicholson?

7islands February 9, 2007 05:41

Hi pUl|, OK this time I tried
 
Hi pUl|,
OK this time I tried implementation of a ddtScheme which is supposed to be an equivalent discretization to Crank Nicholson.

boundaryField
{
outlet
{
type convectiveOutlet;
// convectiveVelocity: the boundary-normal component of convective velocity
convectiveVelocity uniform 343.704;
ddtScheme CrankNicholson;
}
}

To be honest, however, it's quite difficult to assure it to work in CFD (although it is giving the best results in linear acoustics - thanks to your suggestion) because in my CFD test I experienced some odd oscillations. Anyway I'd be grateful if you have patience to test the code.

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

Takuya

luca_g February 13, 2007 02:49

I'm also trying to write a new
 
I'm also trying to write a new characteristic-based boundary condition for my compressible solver centralFoam.
I've taken as an example the pressureTrasmissive and compiled the new bc in a new library and added the new library to the "options" file of the solver. However I can't make the solver finding it at run time: instead the "default" bc is called. In the solver there's no reference to any of the bc functions so I think the library doesn't get linked actually. What am I missing ?

Furthermore, in order to let FoamX know about the new bc type is it necessary to edit e.g. the "patchField/cfd.cfg" file in .OpenFOAM/apps/FoamX/types or is there a way to specify it in the FoamX folder of the application (as done for the application configuration files) ?
That is, can the defined bc types be application-dependent or they must be defined at a global level ?

Regards,

Luca

hjasak February 13, 2007 03:02

Hello Luca, Boundary condit
 
Hello Luca,

Boundary conditions (and many other things in OpenFOAM) are selected using a run-time selection mechanism). Here, all available b.c.-s register themselves to a table when you start the code and are chosen by the name in a dictionary (in your case, the type of patch field). Specifically for patch fields, if the boundary condition is not found, a "default" patch field is created for you (this helps with post-processing).

There are 3 reasons why your boundary condition would not be picked up:
- you mis-spelled its name. Check it carefully in the field file and the header file of the patch field code
- you did not compile it correctly. For examples, look at some other boundary conditions in the library. Depending on twhat you are doing, you will need one of the following in the file you compile:

makePatchFields(fixedValue);

makePatchTypeField(fvPatchScalarField, pressureTransmissiveFvPatchScalarField);

or similar.

- the third option is that you have not linked the object or library file with the solver you are trying to use. I suspect you know how to fix this.

Hope this helps,

Hrv

luca_g February 13, 2007 03:24

Hello Hrvoje, I understood
 
Hello Hrvoje,

I understood the "default" mechanism and I checked the name many times; also the newBC.C file ends with something like:

makePatchTypeField(fvPatchScalarField, newBCFvPatchScalarField);

About compiling, the bc code is compiled to a library using wmake lib or wmake libso, and I looked at rhopSonicFoam/BCs for files and options.
About linking I added the -lxxx option to the EXE_LIBS list of the solver makefile.

However, I wonder how can the library get actually linked to the solver if nothing references it. By the way, I'm working under cygwin.

Regards,

Luca

hjasak February 13, 2007 03:39

Aha, one of those. :-) The
 
Aha, one of those. :-)

The definition of C++ language says that all static symbols in all linked libraries will be executed before the first line of the main code - this is what we use to populate the run-time selection tables. Therefore, according to the definition all should be well.

However, we are talking about a Billy-boy box (that's Gates, BTW) rather than a real computer :-) so try doing an explicit dllopen() on your library at the start of the code. I'm pretty sure this would do it.

Alternatively, just link the object file from your new boundary condition straight with the top-level code, which should avoid all problems. In any case, that would be a good test.

Hrv

luca_g February 13, 2007 06:51

Thank you Hrvoje, I linked
 
Thank you Hrvoje,

I linked directly the object file and it works..

Any comment about the definition of FoamX types (although this is the wrong thread..) ?

Regards,

Luca

cedric_duprat July 2, 2007 03:00

Hi all, I 'm trying to use th
 
Hi all,
I 'm trying to use the convectiveOutlet boundary condition but ...just trying.
I put it in src/finiteVolume/fields/fvPatchFields/basicFvPatchFields and compile it, there every thing seems to be Ok.
Then, in my case, I modified the O/U and in the outlet patch I add:
type convectiveOutlet;
gradient UNIFORM 0;
convectiveVelocity uniform 11.3;
snGradScheme normal;
ddtScheme Euler;
updateValue 0;
writeValue 0;


starting FoamX, I got this error Invalid patch field type 'convectiveOutlet' for patch 'outlet' in field dictionary 'U'

Maybe I forgot to do something, any idea or hints ?
Thank you for helping ...

msrinath80 July 2, 2007 05:14

Yes, for FoamX to recognize ne
 
Yes, for FoamX to recognize newly build B/C you need to edit some of its config files. My suggestion is to simply edit all dictionaries from the command line and proceed. Ignore FoamX. When I started using OpenFOAM 1.2, I used FoamX for the first week or so. Later I found that all it did was provide a graphical interface to edit dictionary entries. So I started editing all dictionaries using emacs directly. In my opinion, FoamX is a very useful application for beginners to OpenFOAM. But as you develop new solvers, boundary conditions etc., it is usually more productive to move straight to the command line.

cedric_duprat July 2, 2007 07:02

Ok, Srinath thank you for rep
 
Ok, Srinath thank you for replying, I will try like that ...
and hope that it will work correctly http://www.cfd-online.com/OpenFOAM_D...part/happy.gif
and if I have question(s) ... I won't hesitate :o)

cedric_duprat July 18, 2007 03:24

Hi again, few days later,
 
Hi again, few days later,

I'm trying to run my case on parallel, without FoamX , but when I tryed to decompose my geometry (decomposePar), I got this error:
FOAM FATAL IO ERROR :
Cannot find 'value' entry which is required to set the values of the default patch field.
(Actual type convectiveOutlet)


my problem is that there is no "value" defined in convectiveOutlet (this is the aim of this method ...), so, is there any file I have to change to run parallel computation with other BC ?

Thanks for replying,

Cedric

msrinath80 July 18, 2007 03:39

Check this thread. Are you sti
 
Check this[1] thread. Are you still using FoamX at some point after setting up the case, because FoamX can then overwrite your settings.

[1] http://www.cfd-online.com/OpenFOAM_D...es/1/1057.html

cedric_duprat July 18, 2007 03:45

Hi Srinath, Thank for replyi
 
Hi Srinath,
Thank for replying so fast, ...
yes, I use FoamX for all my "normal" BC and then I change my "home made" BC. You are right, change my BC first then FoamX is .... not a good idea.
thank you for the link, I didn't find it ...
so, let's try like that and ....see you in one week for an other problem ... :-)

Cedric

cedric_duprat August 13, 2007 09:36

hello, I would like to know
 
hello,

I would like to know if someone tried the convectiveOutletPatch in a parallel run. Cause in my case, It's running well on a coarse grid (one processor) but, with a finer grid, It stop a the second iteration (parallel run).
what is strange is that the first iteration works correctly. (maybe no link with the convectiveOutlet patch ...but, I ask the question to confirm,.... or not)
I used decomposePar so I don't know where are the borders of my sub-domains, if the oultet patch is cut in two parts, there is a problem with the BC ... how to check this?

any idea(s) ?

Thanks,
Cedric

7islands August 16, 2007 20:02

Hi all, I also confirmed some
 
Hi all,
I also confirmed some numerical oscillations on the convectiveOutlet boundary with my solver in a parallel case... I have never tried any parallel case till now with the code.

I haven't found what's the problem as of now but have a feeling that if I could sort it out that should be quite trivial. Do anyone know what a parallel-ready b. c. code which relies only on the time-histories of boundary and patchInternalField values must satisfy?

Takuya

eugene August 17, 2007 06:49

Is the code still the same as
 
Is the code still the same as your last post (9/2/2007)? If you can confirm or post the latest I will take a quick look to see if I can spot any obvious issues.

7islands August 17, 2007 08:31

Hi Eugene, Yes, the same code
 
Hi Eugene,
Yes, the same code. Many thanks for your assistance!

Takuya

cedric_duprat August 17, 2007 08:51

Hi Takuya and Eugene, I als
 
Hi Takuya and Eugene,

I also used this code, with difficulties in parallel. I think that we can decrease the possibility of mistakes if we use OF's numerical scheme whereas these avaiable from Takuya's code but it's just an optimisation and no link with our parallel problem.
I just want to add that it is working properly on 1 processor with a fine mesh also.

Thank you for helping,

Cedric

7islands September 5, 2007 07:46

Hi, I think I have solved the
 
Hi,
I think I have solved the problem.
  • Fixed uninitialized internal variables
  • Supports OF 1.3, 1.4, 1.4.1
  • Default ddtScheme changed from backward to CrankNicholson (since the scheme has been giving the best results for me)
For detailed usage see the included README.

http://www.cfd-online.com/OpenFOAM_D...hment_icon.gif convectiveOutlet-20070905.tar.gz
Takuya

cedric_duprat September 25, 2007 11:45

Hi Takuya, thank you for the
 
Hi Takuya,
thank you for the new version of you code. I am strating to use it now.
so, I copied it in /applications/utilities/preProcessing/
It compile well (without any problems); `/craya/big/duprat/OpenFOAM/duprat-1.4.1/lib/linuxGccDPOpt/libconvectiveOutlet.s o' is up to date.

then, when I tryied to run it on a case, with OF 1.4.1, I got this message:
Starting time loop

Time = 0.001

--> FOAM FATAL ERROR :
gradientInternalCoeffs cannot be called for a defaultFvPatchField (actual type convectiveOutlet)
on patch sortie of field U in file "/craya/data/duprat/cylindre/0/U"
You are probably trying to solve for a field with a default boundary condition.

From function defaultFvPatchField<type>::gradientInternalCoeffs( ) const
in file fields/fvPatchFields/basic/default/defaultFvPatchField.C at line 694.

FOAM exiting

I added the lib in controlDict as you mensionned on your README: ("libconvectiveOutlet.so");

Well, I'm quite lose now,am I missing something?

I found a thread http://www.cfd-online.com/OpenFOAM_D....html#POST8728 with the same problem and Hrv focus on a wrong compile method but, I can't find what I did wrong ...
Any idea ?

thank you for helping,
Regards,
Cedric

PS: notice that my case worked with the last version of convectiveOutlet.

7islands September 25, 2007 18:58

Hi Cedric, I just would like
 
Hi Cedric,
I just would like to make sure you wrote libs, not lib as the keyword in controlDict. It's the standard procedure to load user libraries; see ReleaseNote-1.4.1 included in your copy of OF distribution.

Takuya

lakeat September 3, 2008 13:01

Hi Takuya! I am using OpenF
 
Hi Takuya!

I am using OpenFOAM-1.5 now.
ParaFoam can't handle convectiveOutlet BC....Crashhhhhhhh
Any ideas?

Regards, Daniel

7islands September 3, 2008 21:24

Hi Daniel, I'm not seeing any
 
Hi Daniel,
I'm not seeing any crashes so far... but on the Mac port. Do you get any error messages or whatever?

p.s. Did anyone try the new advection b.c. in 1.5?

Takuya


All times are GMT -4. The time now is 15:04.