Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • openfoam openfoam
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 426
    • Issues 426
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 8
    • Merge requests 8
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Development
  • openfoamopenfoam
  • Issues
  • #1818
Closed
Open
Issue created Aug 26, 2020 by Mike Worth@Mike.Worth

foamDictionary -set overwrites whole dictionary

Summary

Whenever foamDictionary is used to set the value of any one entry, the whole dictionary is overwritten. Any dynamic calculations are replaced with their constant value at the time this overwrite occurs. Comments are also lost.

Steps to reproduce

Have a dictionary file with comments and/or #eval lines. Use foamDictionary -set to alter a value.

Example case

This file is system/example:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v1912                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version         2;
    format          ascii;
    class           dictionary;
    location        "system";
    object          example;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

constant        5;//There is a clever physical explanation for this value

calculated      #eval{ 1 + 1 };

changed         1;


// ************************************************************************* //

Execute foamDictionary system/example -entry changed -set 2

What is the current bug behaviour?

The file becomes:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v1912                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
FoamFile
{
    version         2;
    format          ascii;
    class           dictionary;
    location        "system";
    object          example;
}

constant        5;

calculated      2;

changed         2;


// ************************************************************************* //

What is the expected correct behavior?

The file becomes:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v1912                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version         2;
    format          ascii;
    class           dictionary;
    location        "system";
    object          example;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

constant        5;//There is a clever physical explanation for this value

calculated      #eval{ 1 + 1 };

changed         2;


// ************************************************************************* //

Relevant logs and/or images

Environment information

  • OpenFOAM version :1912 (compiled from source)
  • Operating system :Ubuntu 18.04
  • Hardware info :
  • Compiler :

Possible fixes

Assignee
Assign to
Time tracking