CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [swak4Foam] how to implement fixedMean in groovyBC? (https://www.cfd-online.com/Forums/openfoam-community-contributions/120057-how-implement-fixedmean-groovybc.html)

immortality June 29, 2013 13:33

how to implement fixedMean in groovyBC?
 
there is a BC for outlet named fixedMean.
it seema its main code is this:
Code:

void fixedMeanFvPatchField<Type>::updateCoeffs()
{
    if (this->updated())
    {
        return;
    }

    Field<Type> newValues(this->patchInternalField());

    Type meanValuePsi =
        gSum(this->patch().magSf()*newValues)
      /gSum(this->patch().magSf());

    if (mag(meanValue_) > SMALL && mag(meanValuePsi)/mag(meanValue_) > 0.5)
    {
        newValues *= mag(meanValue_)/mag(meanValuePsi);
    }
    else
    {
        newValues += (meanValue_ - meanValuePsi);
    }

    this->operator==(newValues);

    fixedValueFvPatchField<Type>::updateCoeffs();
}

what does it do exactly?is it possible to implement it to groovyBC?

cosimobianchini July 1, 2013 05:37

Well, it reads patch internal values:

Field<Type> newValues(this->patchInternalField());

It calculates and area averaged value:
Type meanValuePsi = gSum(this->patch().magSf()*newValues)/gSum(this->patch().magSf());

Then, if the prescribed reference value (meanValue_) is not zero and the difference in magnitude between internal values and meanValue_ is higher than 50%, it scales the local imposed boundary value with the ratio between the desired and the obtained mean values otherwise the adjustment of boundary values is provided with a shift to correctly set the mean value. In both cases the newValues exactly fulfill the requirements of prescribed mean value.

if (mag(meanValue_) > SMALL && mag(meanValuePsi)/mag(meanValue_) > 0.5)
{
newValues *= mag(meanValue_)/mag(meanValuePsi);
}
else
{
newValues += (meanValue_ - meanValuePsi);
}

Concerning the implementation in groovyBC, even though I'm not expert, I'm pretty sure you can implement this using the valueExpression.
As I can see in fact, all the the required functions (sum,internalField,Sf and conditional operator) are implemented in groovyBC.

immortality July 1, 2013 09:30

Hi
thanks.
newValues are replaced to the internalField,right?
I don't think such a function there is in groovyBC to change internalField values unless dear Bernhard say something else.:D

cosimobianchini July 1, 2013 10:10

No. newValues are imposed on the boundary as new fixedValue values.

this->operator==(newValues);
fixedValueFvPatchField<Type>::updateCoeffs();

and that is what valueExpression does in groovy BC (if I did correctly understand groovy BC wiki, never went inside the code for further details sorry)

immortality July 1, 2013 11:31

OK.then it fluctuate around the specified value according to internal values.
its so: BC*(neighbor value)/(mean of neighbor values)
is it useful to use such a boundary in the case I've attached in the related topic?
its a closed area that a part of right wall is opened.it seems that the pressure doesn't decrease to the value I've set.I guess its a physical feature rather than numerical if you agree.
http://www.cfd-online.com/Forums/ope...tml#post436854
I'll be thankful if you take a look into it.

cosimobianchini July 1, 2013 12:15

Rather than fluctuating (never used for transient cases) I would say it converges to a profile which is in equilibrium with the internal solution maintaining the specified mean value.
They case you posted in the other thread is barely understandable so I cannot give any suggestions.

immortality July 1, 2013 13:04

they are simple.one is a tube full of a fluid at rest in 1800000 pa that its boundary opens completely to 800000 pa BC and another opening is smaller than previous case.but if you see vectors near the opening could see a unstable situation on neighbor cells of opening patch.

cosimobianchini July 2, 2013 03:32

With such a pressure ratio I don't think it is a good idea to put a fixed pressure BC at the discharge orifice. I believe your convergence problem are not related to the type of pressure boundary conditions but to the position of the outlet.

immortality July 2, 2013 03:41

i want an outlet with minimum of pressure that can be reaced by the flow.
Then What BC you suggest other than fixed pressure BC?
I can't changeThe geometry of problem,its fixed.
Its a physical(maybe flow can't reach to a pressure lower than a limit that i don't know whats that limit) problem or numerical in your opinion?
Thanks for consideration.


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