CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

changeDictionary messes it up when #include directive is used

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes
  • 2 Post By zfaraday
  • 2 Post By wyldckat
  • 1 Post By zfaraday

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 1, 2015, 23:34
Exclamation changeDictionary messes it up when #include directive is used
  #1
Senior Member
 
Alex
Join Date: Oct 2013
Posts: 337
Rep Power: 22
zfaraday will become famous soon enough
Hello,

I'm working in a chtMultiRegion case and, as it is usual in these kind of cases, I have to use changeDictionary to set up boundaries after creating the geometry with blockMesh and topoSet. So far, no problem. However, in this case I want to make use of the #include directive in order to use some values stored in a particular folder. I want to do that because some values are very common among all regions (and they are a few...) and I have to do a good amount of simulations switching them, so if I could only change the values from the file stored in an outter folder it would be very nice...

The problem is that it seems that changeDictionary is not capable to handle the #include statement. I will show you how I used it and the results it gave me:

·changeDictionaryDict where I used #include dirctive:

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.3.0                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      changeDictionaryDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
    boundary
    {
    }

    T
    {
        #include "$FOAM_CASE/include/initialCond_sum"
        internalField   uniform $Tini;

        boundaryField
        {
            ".*"
            {
                type            symmetry;
                value           $internalField;
            }
      .....
}
And here comes the result in the 0/region/T file:

Code:
dimensions      [ 0 0 0 1 0 0 0 ];

internalField   uniform 300;

boundaryField
{
   ....
    patch[i]
    {
        type            externalWallHeatFluxTemperature;
        value           $internalField;
        kappa           solidThermo;
        Ta              uniform $Tin;
        h               uniform 2;
        thicknessLayers ( );
        kappaLayers     ( );
        kappaName       none;
        QrName          none;
    }
    ....
}

#include        "$FOAM_CASE/include/initialCond_sum" internalField uniform $Tini;
Of course OpenFOAM complains...

Code:
--> FOAM FATAL IO ERROR: 
Illegal dictionary entry or environment variable name "Tin"
Valid dictionary entries are 
3
(
type
value
kappa
)


file: path_to_ file 0/region/T.boundaryField.patch[i] from line 36 to line 38.

    From function primitiveEntry::expandVariable(const string&, const dictionary&
    in file db/dictionary/primitiveEntry/primitiveEntry.C at line 96.

FOAM exiting
Why is the utility placing the #include statement at the end of the file instead of the beginning where it is suposed to be placed? Is it a bug or am I doing something wrong? Is there a procedure to make this utility take into account the #include statement correctly?

I also tried to put the statement in an upper position like outside the T keyword or even above the dictionaryReplacement keyword, but OpenFOAM complained either way. Actually, in any of the last cases the utility crushes and no dictionary is replaced.

Any word of advice will be very welcome.

Regards,

Alex
DaveD! and PanPeter like this.
__________________
Web site where I present my Master's Thesis: foamingtime.wordpress.com

The case I talk about in this site was solved with chtMultiRegionSimpleFoam solver and involves radiation. Some basic tutorials are also resolved step by step in the web. If you are interested in these matters, you are invited to come in!
zfaraday is offline   Reply With Quote

Old   February 4, 2015, 19:05
Default Not trying to spam, just asking...
  #2
Senior Member
 
Alex
Join Date: Oct 2013
Posts: 337
Rep Power: 22
zfaraday will become famous soon enough
Any idea on what the problem could be? Or directly changeDictionary utility can not handle properly the #include directive? May it be a bug?
__________________
Web site where I present my Master's Thesis: foamingtime.wordpress.com

The case I talk about in this site was solved with chtMultiRegionSimpleFoam solver and involves radiation. Some basic tutorials are also resolved step by step in the web. If you are interested in these matters, you are invited to come in!
zfaraday is offline   Reply With Quote

Old   February 5, 2015, 16:09
Default
  #3
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Alex,

If you run changeDictionary with the "-help" option, you should see this line:
Code:
  -literalRE        treat regular expressions literally (i.e., as a keyword)
If I remember correctly, by using this option, it will copy-paste the "#include" lines.

Let us know if this works as intended. I do vaguely remember having problems with this as well in the past, but it was with an older version of OpenFOAM... not sure which one.

Best regards,
Bruno
vbnhfylbh and wht like this.
__________________
wyldckat is offline   Reply With Quote

Old   February 5, 2015, 20:26
Default
  #4
Senior Member
 
Alex
Join Date: Oct 2013
Posts: 337
Rep Power: 22
zfaraday will become famous soon enough
Quote:
Originally Posted by wyldckat View Post
Hi Alex,

If you run changeDictionary with the "-help" option, you should see this line:
Code:
  -literalRE        treat regular expressions literally (i.e., as a keyword)
If I remember correctly, by using this option, it will copy-paste the "#include" lines.

Let us know if this works as intended. I do vaguely remember having problems with this as well in the past, but it was with an older version of OpenFOAM... not sure which one.

Best regards,
Bruno
Hi Bruno,

Thanks for your tip. However, after running the command changeDictionary -help the correct options seems to be

Code:
  -enableFunctionEntries       enables expansion of dictionary directives - #include, #codeStream etc
It does not copy-paste the #include statement literaly but it substitute its values in the new dictionary!

Regards,

Alex
wht likes this.
__________________
Web site where I present my Master's Thesis: foamingtime.wordpress.com

The case I talk about in this site was solved with chtMultiRegionSimpleFoam solver and involves radiation. Some basic tutorials are also resolved step by step in the web. If you are interested in these matters, you are invited to come in!
zfaraday is offline   Reply With Quote

Old   February 6, 2015, 09:50
Default
  #5
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Quick question: Which OpenFOAM version are you using?
wyldckat is offline   Reply With Quote

Old   February 6, 2015, 11:59
Default
  #6
Senior Member
 
Alex
Join Date: Oct 2013
Posts: 337
Rep Power: 22
zfaraday will become famous soon enough
Quick answer : I'm using 2.3.x version
__________________
Web site where I present my Master's Thesis: foamingtime.wordpress.com

The case I talk about in this site was solved with chtMultiRegionSimpleFoam solver and involves radiation. Some basic tutorials are also resolved step by step in the web. If you are interested in these matters, you are invited to come in!
zfaraday is offline   Reply With Quote

Old   February 7, 2015, 04:33
Default
  #7
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Alex,

Sorry, I re-read now the post you had written and yesterday I thought you were still having problems in using changeDictionary.
I quickly had thought of this because that option is provided on older versions of OpenFOAM and I very vaguely remember that the option "-enableFunctionEntries" didn't always work as intended... mmm, possibly because back then I actually wanted to preserve the original includes...

Anyway, I'm glad you've figured out the option you needed

Best regards,
Bruno
wyldckat is offline   Reply With Quote

Old   February 7, 2015, 15:06
Default
  #8
Senior Member
 
Alex
Join Date: Oct 2013
Posts: 337
Rep Power: 22
zfaraday will become famous soon enough
Quote:
Originally Posted by wyldckat View Post
Hi Alex,

Sorry, I re-read now the post you had written and yesterday I thought you were still having problems in using changeDictionary.
I quickly had thought of this because that option is provided on older versions of OpenFOAM and I very vaguely remember that the option "-enableFunctionEntries" didn't always work as intended... mmm, possibly because back then I actually wanted to preserve the original includes...

Anyway, I'm glad you've figured out the option you needed

Best regards,
Bruno
Hi Bruno,

I also wanted that the include line was copy-pasted literally instead of substituting its values in the new dictionary, but as far as I saw the effect is the same since the macro substitution is done correctly.

I also tried to use both "-enableFunctionEntries" and "-literalRE" at a time, the problem is that as it copy-pastes literally the regular expressions instead of interpreting them. Thus, it copied the character ".*" directly to the new file so all the boundaries that were to be found under the ".*" were changed to "calculated" instead...

Best regards,

Alex
__________________
Web site where I present my Master's Thesis: foamingtime.wordpress.com

The case I talk about in this site was solved with chtMultiRegionSimpleFoam solver and involves radiation. Some basic tutorials are also resolved step by step in the web. If you are interested in these matters, you are invited to come in!
zfaraday is offline   Reply With Quote

Reply

Tags
changedictionary, chtmultiregionfoam, include


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
cyclic boundary conditions for FSI kanuk OpenFOAM Programming & Development 10 April 25, 2014 03:52
OpenFoam install script Error during paraFoam installation SePe OpenFOAM Installation 10 June 19, 2010 16:15
critical error during installation of openfoam Fabio88 OpenFOAM Installation 21 June 2, 2010 04:01
Problems in compiling paraview in Suse 10.3 platform chiven OpenFOAM Installation 3 December 1, 2009 08:21
OpenFOAM15 paraFoam bug koen OpenFOAM Bugs 19 June 30, 2009 11:46


All times are GMT -4. The time now is 23:56.