View Issue Details

IDProjectCategoryView StatusLast Update
0003555OpenFOAMBugpublic2020-09-25 17:53
Reporterlavdwall Assigned Tohenry  
Status resolvedResolutionfixed 
Fixed in Versiondev 
Summary0003555: codedFvPatchFields: codeOptions missing in codeKeys_
DescriptionBoth in codedFixedValueFvPatchFields.C and codedMixedFvPatchFields.C, the "codeOptions" key is missing from codeKeys_. Because of that, codeOptions is not written at write time, which causes problems when restarting a case or when trying to run in parallel after decomposition.

I believe it should be as follows:

const Foam::wordList
Foam::CodedBase<Foam::codedMixedFvPatchFieldBase>::codeKeys_ =

This issue also applies to the development version.

I also reported the issue on Github two weeks ago (when this bug reporting platform was down):
TagsNo tags attached.



2020-09-24 18:05

manager   ~0011523

How does the "codeOptions" entry relate to restarting a case? Could you provide details of how to reproduce the problem?

The tutorials/incompressible/simpleFoam/pipeCyclic case runs and restarts without problem, does it restart OK for you?
It contains a codedFixedValue BC:

        type codedFixedValue;
        value uniform (1 0 0);
        name swirl;
        code #{
            const vector axis(1, 0, 0);

            vectorField v(2.0*this->patch().Cf() ^ axis);
            v.replace(vector::X, 1.0);


2020-09-25 07:46

reporter   ~0011524

Dear Henry,

I am sorry, I should have given more information. The problem with restarting occurs if you need to include header files. I have the below code to set a heat flux profile at the wall of a tube. I need to include "basicThermo.H" to be able to use this piece of code. For my case to find that header file, I need to add "-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude" in codeOptions. The case runs perfectly on a single core. However, when I decompose, the codeOptions dictionary is not written so when I try to run the case in parallel, basicThermo.H is not found and it gives an error. The same thing occurs when restarting this case.

It all traces back to the file src/OpenFOAM/db/dynamicLibrary/codedBase/CodedBase.C, which defines which keywords are written at write time. It writes the keywords that are in codeKeys_. So that is why I believe "codeOptions" should be added there, as I explained above.

        type codedMixed;
        refValue $internalField;
        refGradient uniform 0;
        valueFraction uniform 0;
        name heatfluxprofile;
            scalarField z(patch().Cf().component(2)-0.444);
            const basicThermo& thermo = this->db().lookupObject<basicThermo>(basicThermo::dictName);
            scalarField kappa(thermo.kappa(patch().index()));
            scalarField grad(z.size());
            forAll(grad, facei)
                grad[facei] = z[facei] < 0.0 ? 0.0 : ((-1.3599*pow(z[facei],6)+42.266*pow(z[facei],5)-505.69*pow(z[facei],4)+3105.4*pow(z[facei],3)-11256.0*pow(z[facei],2)+15684.0*z[facei]+94495.0)*1.0)/kappa[facei];
            this->refGrad() = grad;
            #include "basicThermo.H"


2020-09-25 16:43

manager   ~0011527

Resolved by commit 8221b25875c2993823afc70d8032ebc2da5c3002

Issue History

Date Modified Username Field Change
2020-09-24 14:41 lavdwall New Issue
2020-09-24 18:05 henry Note Added: 0011523
2020-09-25 07:46 lavdwall Note Added: 0011524
2020-09-25 16:43 henry Assigned To => henry
2020-09-25 16:43 henry Status new => resolved
2020-09-25 16:43 henry Resolution open => fixed
2020-09-25 16:43 henry Fixed in Version => dev
2020-09-25 16:43 henry Note Added: 0011527