CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Error with codedFixedValue BC (http://www.cfd-online.com/Forums/openfoam-programming-development/93784-error-codedfixedvalue-bc.html)

Hisham October 26, 2011 11:01

Error with codedFixedValue BC
 
Hi Foamers,

I want to use the codedFixedValue to set boundary conditions for a volScalarField to be 0 if the Y-Co larger than 2.5 and 1 otherwise. I tried this code:

Code:

BoundaryName
    {
        type            codedFixedValue;
        value          uniform 0;
        redirectType    initialWaterSurf;
        code
          #{
          forAll(this, i)
            {operator== ((this[i]->y() > 2.5)? 0 : 1  )}
          #};
    }

I would like to know what does "this" points to ... and how can I loop the faces and face centers?
Which includes should I have as well?

By the way the error I get is:
Code:

Setting internal values of volScalarField alpha1


--> FOAM FATAL IO ERROR:
Loading a shared library using case-supplied code is not enabled by default
because of security issues. If you trust the code you can enable this
facility be adding to the InfoSwitches setting in the system controlDict:

    allowSystemOperations 1

The system controlDict is either

    ~/.OpenFOAM/$WM_PROJECT_VERSION/controlDict

or

    $WM_PROJECT_DIR/etc/controlDict

The error is generated when the dict for this BC is read (it is the error source).

Best Regards,
Hisham

JimKnopf October 28, 2011 04:39

Quote:

Originally Posted by Hisham (Post 329560)
code
#{
forAll(this, i)
{operator== ((this[i]->y() > 2.5)? 0 : 1 )}
#};

Hi Hisham,

i'm not sure aboute code fixed Value stuff but it seems to me that there are two Operators in your equation. The first is the equal introduced after operator and then there is the operator > before the 2.5 maybe you have to check the syntax
Greetz
Jim

Hisham October 28, 2011 04:58

Hi Jim,

I appreciate your answer. I think I need more tutorials on the codedBC. The only available one, is in its header file:

Code:

code
            #{
              operator==(min(10, 0.1*this->db().time().value()));
            #};

So if this is how to access time, how can patch faces be accessed and their coordinates be identified?

I had a workaround for my problem. Nevertheless, the coded BC is a nice tool to have by one's side.

Regards
Hisham

bruce January 11, 2012 01:20

hi,

codedFixedValue is like other inherited from fixedValueFvPatchField<>

I tested this below code for pitzDaily , simpeFoam solver.

U = 100 * y^2;

Code:

    inlet
    {
        type            codedFixedValue;
        value          uniform (0 0 0);
        redirectType    rampedFixedValue;
        code
        #{
            // flow direction
            vector sys = vector(1, 0, 0);

            // co-ord direction of a patch
            vector dir = vector(0, 1, 0);

            // variable to be evaluated
            scalarField var = patch().Cf() & dir;

            // evaluated value
            scalarField value = 100 * var * var;

            operator==( value * sys);
        #};
    }

hope it helps.

November March 22, 2012 02:57

Hi Bruce,

If I want to apply the codedfixedValue under icoFoam application, do I need to do something extra, like adding some library and recompiling???

Thanks.

amir.a.aliabadi March 13, 2013 22:50

The error message can be fixed by flagging "allowSystemOperations" in controlDict under /openfoam211/etc system directory. You should simply change it to 1 from 0. If permission is denied since you have installed OpenFoam under root directory then go to the above directory and type:

$ sudo gedit controlDict

This enables you to change the setting and save the file.


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