CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   potentialFoam porousBafflePressure turbulence (https://www.cfd-online.com/Forums/openfoam-programming-development/128759-potentialfoam-porousbafflepressure-turbulence.html)

GRAUPS January 20, 2014 18:49

potentialFoam porousBafflePressure turbulence
 
Foamers,

As a preface, I'm just starting to dig into the openfoam code. So if I say something silly or ask an obvious question, please just roll with it. :cool:

I'm attempting to modify the porousBafflePressure boundary condition in OF so that it is compatible with potentialFoam. Currently the porousBafflePressure boundary condition requires that a turbulence model be present, and thus throws an error when I run potentialFoam. I'd like the BC to run with a constant nu if potentialFoam is called. A code snippet of the original incompressible half of the BC is below...

Code:

if (phi.dimensions() == dimensionSet(0, 3, -1, 0, 0))
    {
        const incompressible::turbulenceModel& turbModel =
            db().lookupObject<incompressible::turbulenceModel>
            (
                "turbulenceModel"
            );

        const scalarField nuEffw = turbModel.nuEff()().boundaryField()[patchI];

        jump_ = -sign(Un)*(I_*nuEffw + D_*0.5*magUn)*magUn*length_;
    }

... And this is what I have so far for a modification...

Code:

if (phi.dimensions() == dimensionSet(0, 3, -1, 0, 0))
    {
        if solver == potentialFoam
        {
            const dictionary& transportProperties =
                    db().lookupObject<IOdictionary>
            (
                  "transportProperties"
            );
           
            dimensionedScalar nu(transportProperties.lookup("nu"));
            jump_ = -sign(Un)*(I_*nu + D_*0.5*magUn)*magUn*length_;
        }
        else
        {
            const incompressible::turbulenceModel& turbModel =
                    db().lookupObject<incompressible::turbulenceModel>
                    (
                    "turbulenceModel"
                    );

            const scalarField nuEffw = turbModel.nuEff()().boundaryField()[patchI];
            jump_ = -sign(Un)*(I_*nuEffw + D_*0.5*magUn)*magUn*length_;
        }       
    }

I'm unsure if I did the lookup of nu correctly... but my biggest issue is I'm unsure how to identify if the solver is potentialFoam. Can someone suggest a code snippet to identify the solver? Or is there an overall better way to accomplish what I want?

I appreciate the help!

ngj January 21, 2014 15:28

Hi Brock,

As far as I know, you do know have any means of detecting, whether the solver is potentialFoam, but there might be hidden something in the Time object. You could try to track down, where the solver-name in the header of the log file is written.

That aside, I believe it is a bad approach. I would rather propose that you make use of the foundObject and its bolean return. If it returns true, then a turbulence model is found, and you are not running potentialFoam, otherwise you are running potentialFoam, and you can apply your modifications.

Kind regards,

Niels

GRAUPS January 21, 2014 19:46

Quote:

Originally Posted by ngj (Post 471129)
I would rather propose that you make use of the foundObject and its bolean return. If it returns true, then a turbulence model is found, and you are not running potentialFoam, otherwise you are running potentialFoam, and you can apply your modifications.

^^This worked great, thank you. :D

I have another question regarding the loading of the transportProperties dictionary. It appears that potentialFoam does not load this inside its createFields.H source code, and therefore isn't available to me when I try to look it up via lookupObject. I think I need to stick one of these somewhere...

Code:

IOdictionary transportProperties
        (
            IOobject
            (
                "transportProperties",
                runTime.constant(),
                mesh,
                IOobject::MUST_READ_IF_MODIFIED,
                IOobject::NO_WRITE
            )
        );

... but I'm unsure where the proper place to put it is. I was hoping to not have to modify the potentialFoam solver createFields.H.

What's the best way to load transportProperties for use by the porousBafflePressure boundary condition?

Thanks again for any suggestions you can provide!

ngj January 23, 2014 14:11

Hi Brock,

Before I answer you question, allow me to ask:

"What is the meaning of having the viscosity included in a solver, which solves for an inviscid fluid?"

Kind regards,

Niels


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