CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   Error with codedFixedValue BC (

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:


        type            codedFixedValue;
        value          uniform 0;
        redirectType    initialWaterSurf;
          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:

Setting internal values of volScalarField alpha1

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




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

Best Regards,

JimKnopf October 28, 2011 04:39


Originally Posted by Hisham (Post 329560)
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

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:


              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.


bruce January 11, 2012 01:20


codedFixedValue is like other inherited from fixedValueFvPatchField<>

I tested this below code for pitzDaily , simpeFoam solver.

U = 100 * y^2;


        type            codedFixedValue;
        value          uniform (0 0 0);
        redirectType    rampedFixedValue;
            // 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???


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 09:02.