View Issue Details

IDProjectCategoryView StatusLast Update
0003421OpenFOAMBugpublic2020-01-07 10:47
ReporterSamMallinson Assigned Tohenry  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionno change required 
PlatformLinuxOSDebianOS Versionbullseye
Summary0003421: Cannot #include parameters in system/forces
DescriptionTo avoid errors associated with repeating oneself (see https://en.wikipedia.org/wiki/Don%27t_repeat_yourself), it is preferred to #include parameters from a single file across many OpenFOAM dictionaries.

It appears, however, that this is not alway possible. In particular, if you try to #include a parameters file in system/forces, it does not recognize it and instead gives an error. For example, for the pimpleFoam tutorial propellor, if we have the following in a file system/parameters:

density 1.0;
CRx 0;
CRy 0;
CRz 0;

and we #include "./system/parameters" in system/forces:

#include "./system/parameters"

forces
{
    type forces;

    libs ("libforces.so");

    writeControl timeStep;
    timeInterval 1;

    log yes;

    patches ("propeller.*");
    rho rhoInf; // Indicates incompressible
    log true;
    rhoInf $density; // Redundant for incompressible

    CofR ($CRx $CRy $CRz); // Rotation around centre line of propeller
    pitchAxis (0 1 0);
}

then we get an error:

....
Reading surface description:
    zNormal
    isoQ
    propeller

--> FOAM Warning :
    From function bool Foam::functionObjectList::read()
    in file db/functionObjects/functionObjectList/functionObjectList.C at line 682
    Reading "/mnt/simulations/sam/propeller/system/controlDict" from line 18 to line 28
    Entry density is not a dictionary
--> FOAM Warning :
    From function bool Foam::functionObjectList::read()
    in file db/functionObjects/functionObjectList/functionObjectList.C at line 682
    Reading "/mnt/simulations/sam/propeller/system/controlDict" from line 18 to line 28
    Entry CRx is not a dictionary
--> FOAM Warning :
    From function bool Foam::functionObjectList::read()
    in file db/functionObjects/functionObjectList/functionObjectList.C at line 682
    Reading "/mnt/simulations/sam/propeller/system/controlDict" from line 18 to line 28
    Entry CRy is not a dictionary
--> FOAM Warning :
    From function bool Foam::functionObjectList::read()
    in file db/functionObjects/functionObjectList/functionObjectList.C at line 682
    Reading "/mnt/simulations/sam/propeller/system/controlDict" from line 18 to line 28
    Entry CRz is not a dictionary
forces forces:
    Not including porosity effects

Starting time loop
....

Steps To Reproduce1. copy tutorial to separate directory
2. add file system/parameters
3. modify system/forces
4. ./Allrun
TagsNo tags attached.

Activities

SamMallinson

2020-01-06 03:28

reporter   ~0011038

adding files system/parameters (new) and system/forces (modified)
parameters (34 bytes)   
density 1.0;
CRx 0;
CRy 0;
CRz 0;
parameters (34 bytes)   
forces (952 bytes)   
/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  7
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/

#include "./system/parameters"

forces
{
    type          forces;

    libs          ("libforces.so");

    writeControl  timeStep;
    timeInterval  1;

    log           yes;

    patches       ("propeller.*");
    rho           rhoInf;     // Indicates incompressible
    log           true;
    rhoInf        $density;          // Redundant for incompressible

    CofR          ($CRx $CRy $CRz);    // Rotation around centre line of propeller
    pitchAxis     (0 1 0);
}


// ************************************************************************* //
forces (952 bytes)   

henry

2020-01-06 09:22

manager   ~0011039

forces
{
    #include "./system/parameters"
    .
    .
    .

SamMallinson

2020-01-06 23:09

reporter   ~0011040

I can confirm that works - many thanks!

henry

2020-01-07 10:47

manager   ~0011042

User error

Issue History

Date Modified Username Field Change
2020-01-06 03:27 SamMallinson New Issue
2020-01-06 03:28 SamMallinson File Added: parameters
2020-01-06 03:28 SamMallinson File Added: forces
2020-01-06 03:28 SamMallinson Note Added: 0011038
2020-01-06 09:22 henry Note Added: 0011039
2020-01-06 23:09 SamMallinson Note Added: 0011040
2020-01-07 10:47 henry Assigned To => henry
2020-01-07 10:47 henry Status new => closed
2020-01-07 10:47 henry Resolution open => no change required
2020-01-07 10:47 henry Note Added: 0011042