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/)
-   -   Boundary Function (https://www.cfd-online.com/Forums/openfoam-solving/59863-boundary-function.html)

7islands January 10, 2007 00:12

Hi, I've also been struggling
 
Hi,
I've also been struggling these days in writing my first solver for basic linear acoustic wave propagation problems using OpenFOAM and just now I could make its very preliminary version to work. Since this is an acoustic solver this includes so-called normal incidence acoustic impedance b. c. which is represented in exactly the same form as yours, p = z * Un where z is a scalar constant called normal incidence acoustic impedance and Un is outward normal component of U to the patch.

I post the essential parts of the boundary condition code and boundary condition dictionaries in hope that they might be of some help to your problem and that someone points me out if I'm doing something wrong.

While the code updates U by U = p / z * n and sets p to zeroGradient, you can do the reverse i. e. p = z * (U • n) and setting U to zeroGradient. But actually I can't understand why setting the other variable to zeroGradient works. I'm very interested if someone kindly offer any suggestions.

Thanks,
Takuya

normalIncidenceAcousticImpedanceFvPatchVectorField .C:
<pre>void normalIncidenceAcousticImpedanceFvPatchVectorField ::updateCoeffs()
{
if (updated())
{
return;
}

const fvPatchField<scalar>& pp =
lookupPatchField<volscalarfield,>("p");
const vectorField& n = patch().nf();
operator==(pp / z_ * n);

fixedValueFvPatchVectorField::updateCoeffs();
}</pre>
normalIncidenceAcousticImpedanceFvPatchVectorField .H:
<pre>class normalIncidenceAcousticImpedanceFvPatchVectorField
: public fixedValueFvPatchVectorField
{
// Normal incidence acoustic impedance
scalarField z_;
public:
TypeName("normalIncidenceAcousticImpedance");
......
};</pre>
0/U:
<pre>boundaryField
{
outlet
{
type normalIncidenceAcousticImpedance;
z uniform 414.16;
value uniform (0 0 0);
}
}</pre>
0/p:
<pre>boundaryField
{
outlet
{
type zeroGradient;
}
}</pre>

jan January 11, 2007 10:11

Hi, thank you very much. Mo
 
Hi,

thank you very much. More or less exactly what I need http://www.cfd-online.com/OpenFOAM_D...part/happy.gif
Unfortunately, I get a linking error for the TypeName(".."); command. Do I have to include / define something special? The compling works fine.
Do you have any reference for programming own boundary conditions? I don't really understand the structure for that in OpenFOAM and the implemented boundary codes (fixedValue etc.) are a bit too confusing to me ;)

Thanks,
Jan

7islands January 12, 2007 03:26

Hi, It's because I posted onl
 
Hi,
It's because I posted only essential parts, not all of the code thinking that posting all the code might be too lengthy.

Here's the full code of the b.c. It also includes the reverse updating (p = z * (U & n)). Usage is as I mentioned above (specify "uniform 0" instead of "uniform (0 0 0)" if you want to update p).

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

All and only references I used for the b. c. programming were codes under $FOAM_SRC/finiteVolume/fields/fvPatchFields/derivedFvPatchFields , especially the pressureInletVelocity and the totalPressure codes. So please point me out if anyone notice I'm doing something wrong.

And again, I'll appreciate if anyone have suggestions why setting the other variable to zeroGradient works...

Thanks,
Takuya

jan January 12, 2007 04:30

Ok, I misunderstood a part of
 
Ok, I misunderstood a part of the C structure. Now, with your example, it's much clearer to me. Thank you very much.

Too your question regarding the zeroGradient: I'm not sure, but maybe it is a reasonable b.c. since it is the "natural" b.c. for your problem in solving-theory ( -> weak formulation of the equations)

Greetings,
Jan

7islands January 14, 2007 23:00

Natural b.c.: thanks - I've mi
 
Natural b.c.: thanks - I've missed that point of view because I've been so occupied in programming. In finite difference discretization I've had good results by coupling U = p / z * n and the momentum equation [1], but in finite volumes (weak formulation) that kind of formulation seems too difficult for me. Anyway the code above is giving "reasonable" results so I'll go this way for the time being.

[1]: C. K. W. Tam et al.: Time-domain impedance boundary conditions for computational aeroacoustics, AIAA Journal 34-5, pp. 917-923, 1996.

Thanks,
Takuya


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