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] GroovyBC doesn't read variables and Expression (https://www.cfd-online.com/Forums/openfoam-community-contributions/162768-groovybc-doesnt-read-variables-expression.html)

S.M.H November 17, 2015 03:52

GroovyBC doesn't read variables and Expression
 
hi
i changed buoyantBoussinesqSimpleFoam and add a heat source to it
Code:

fvScalarMatrix TEqn
    (
        fvm::div(phi, T)
      - fvm::Sp(fvc::div(phi), T)
      - fvm::laplacian(kappaEff, T)
      == Qt
   
    );

then i changed createFields.H to read Qt from 0 file
Code:

Info<< "Reading field Qt\n" << endl;
    volScalarField Qt
    (
        IOobject
        (
            "Qt",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );

now i want that Qt in 0 file change with groovyBC in each iteration

Code:

type            groovyBC;
    variables  "Tzone{cellZone'poool}=average(T);Uzone{cellZone'poool}=average(mag(U));q=(((0.0888+(0.0783*Uzone))*((3363)-((0.6)*((exp((20.386)-((5132)/(Tzone))))*(133.3224)))))/(31.2));";
       
        valueExpression  "297.15";
        gradientExpression "-q";
        fractionExpression "1";
        value      uniform 297.15 ;

i used this expression in boundry file T, too
but in the results groovyBC calculated expression in T but in Qt all values set to 0
result for T :
Code:

{
        type            groovyBC;
        refValue        uniform 297.15;
        refGradient    uniform -3.57777;
        valueFraction  uniform 1;
        value          uniform 297.15;
        valueExpression "297.15";
        gradientExpression "-q";
        fractionExpression "1";
        evaluateDuringConstruction 0;
        variables      "Tzone{cellZone'poool}=average(T);Uzone{cellZone'poool}=average(mag(U));q=(((0.0888+(0.0783*Uzone))*((3363)-((0.6)*((exp((20.386)-((5132)/(Tzone))))*(133.3224)))))/(31.2));";
        timelines      (
);
        lookuptables    (
);
    }

result for Qt:
Code:

{
        type            groovyBC;
        refValue        uniform 0;
        refGradient    uniform 0;
        valueFraction  uniform 1;
        value          uniform 297.15;
        valueExpression "297.15";
        gradientExpression "-q";
        fractionExpression "1";
        evaluateDuringConstruction 0;
        variables      "Tzone{cellZone'poool}=average(T);Uzone{cellZone'poool}=average(mag(U));q=(((0.0888+(0.0783*Uzone))*((3363)-((0.6)*((exp((20.386)-((5132)/(Tzone))))*(133.3224)))))/(31.2));";
        timelines      (
);
        lookuptables    (
);
    }

then i noticed that if i add a semicolon or a braket in variables and make a syntax error code compile without any errors that means code doesn't read groovyBC variables and Expression

any suggestion?

thanks

Nicole November 18, 2015 05:20

Hi Seyyed,

I added a heat source to buoyantBoussinesqPimpleFoam and also called it Qt! :)

I have been working with groovyBC a bit and found that it is pretty smart, and can take a couple of different syntaxes, are you sure that this is not happening with you?

And what do you mean by the "code compiles without any errors"? Can you run your solver on this case with the groovyBC boundary conditions?

S.M.H November 18, 2015 17:11

Quote:

Originally Posted by Nicole (Post 573821)
Hi Seyyed,

I added a heat source to buoyantBoussinesqPimpleFoam and also called it Qt! :)

I have been working with groovyBC a bit and found that it is pretty smart, and can take a couple of different syntaxes, are you sure that this is not happening with you?

And what do you mean by the "code compiles without any errors"? Can you run your solver on this case with the groovyBC boundary conditions?

it works properly for T and the expression are the same

"code compiles without any errors" i mean that when i make a syntax error on variables in groovyBC in Qt file the code dosnt show any error .

do you enter Qt on your boundaries or in a volume ?

Nicole November 19, 2015 01:53

Hi Seyyed,

Quick question, is your solver compiling when you wmake it? My Qt is a volScalarField which I added in the createFields.H file as follows so that my solver reads it in when I run my solver:

Code:

    Info<< "Calculating field QT (Joule heating in K/s)\n" << endl;
    volScalarField QT
    (
        IOobject
        (
            "QT",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );


I still do not understand your comment about your groovyBC "code compiling". Something would only happen when you run your solver, and if your solver is in fact trying to read your 0/Qt file. I still don't quite understand what exactly your problem is.

S.M.H November 21, 2015 03:19

Quote:

Originally Posted by Nicole (Post 573977)
Hi Seyyed,

Quick question, is your solver compiling when you wmake it? My Qt is a volScalarField which I added in the createFields.H file as follows so that my solver reads it in when I run my solver:

Code:

    Info<< "Calculating field QT (Joule heating in K/s)\n" << endl;
    volScalarField QT
    (
        IOobject
        (
            "QT",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );

I still do not understand your comment about your groovyBC "code compiling". Something would only happen when you run your solver, and if your solver is in fact trying to read your 0/Qt file. I still don't quite understand what exactly your problem is.

Quote:

is your solver compiling when you wmake it?
yes it compile perfect


Quote:

I still do not understand your comment about your groovyBC "code compiling". Something would only happen when you run your solver, and if your solver is in fact trying to read your 0/Qt file. I still don't quite understand what exactly your problem is
i wmake the solver and it compile
after that i made a case and in that case i used groovyBC for T and Qt
groovyBC worked for T but not for Qt

i think because i used Qt on a boundry my solver didnt read it
i mean Qt must set in internalfield in a volume not surface

Quote:

Info<< "Calculating field QT
can u attch your Qt file?
how do you calculate Qt?

thanks for your reply :)

S.M.H November 21, 2015 03:27

2 Attachment(s)
Attachment 43628
Attachment 43629

i attach my T and Qt file in 0 file and in 10 file after 10 iterations

Nicole November 24, 2015 03:08

Hi Seyyed,

Is your Qt heating inside the volume at any point in time? It looks like, from the files that you sent, that Qt is zero everywhere except on one boundary. Could you not just implement this heat source using the boundary conditions for T and leave out Qt altogether?

My Qt is a volScalarField for resistive heating from electrical current that passes through my domain. I calculate it using a separate electrical solver and then just use the volScalarField in my flow solver.


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