View Issue Details

IDProjectCategoryView StatusLast Update
0003558OpenFOAMBugpublic2020-09-29 21:46
Reporterjoegi Assigned Tohenry  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformopensuseOSOtherOS Version15.2
Fixed in Versiondev 
Summary0003558: cacheTemporaryObjects with complex name
DescriptionThis was already addresed in one update but I think the fix is not complete.

For instance if you try the same cacheTemporaryObjects as in the fix, it won't work if you try to open the field with paraFoam. That is:

    cacheTemporaryObjects
    (
        "((interpolate(((1|((1|(1|A(U)))-H(1)))-(1|A(U))))*snGrad(p))*magSf)"
    );

With the regex option off.

The fix to this is to erase the parentheses in the header of the output file, as,

      object interpolate(((1|((1|(1|A(U)))-H(1)))-(1|A(U))))*snGrad(p)*magSf;

I think an easy fit to this is to give the user the ability to save the field with a different name such as:

outputName whatever_name;

Of course, in the name the user shouldn't use parentheses at the beginning.

Currently I have a fix using bash utilities but adding this option could be very useful.

By the way, this problem happens with all fields that stars with parentheses or funny characters, eg,

"(betaStar*omega)"
"(nut+nu)"

and so on.

Steps To ReproduceI don't add an example because the developers can use the same one as in the fix.
Additional InformationI dont add an example because the developers can use the same one as in the fix.
TagsNo tags attached.

Activities

henry

2020-09-27 10:20

manager   ~0011528

I cannot reproduce the problem as you have specified it, for me the "((interpolate(((1|((1|(1|A(U)))-H(1)))-(1|A(U))))*snGrad(p))*magSf)" object is not written:

writeObjects writeObjects(regExp=off,((interpolate(((1|((1|(1|A(U)))-H(1)))-(1|A(U))))*snGrad(p))*magSf)) write:
--> FOAM Warning :
    From function virtual Foam::wordList Foam::functionObjects::writeObjectsBase::objectNames()
    in file db/functionObjects/writeObjectsBase/writeObjectsBase.C at line 65
    Object "((interpolate(((1|((1|(1|A(U)))-H(1)))-(1|A(U))))*snGrad(p))*magSf)" not found in database. Available objects:

30
(
((interpolate(((1|((1|(1|A(U)))-H(1)))-(1|A(U))))*snGrad(p))*magSf)
GAMGAgglomeration
MRFProperties
.
.
.

In both OpenFOAM-8 and OpenFOAM-dev

joegi

2020-09-27 14:25

reporter   ~0011529

That is just a warning in the first iteration. After the first iteration, it should work fine.

By the way, that is another issue. But for me it does not matter , it is just a warning that happens at the very beginning.

If you still cannot reproduce the case I can prepare an small example.

henry

2020-09-27 14:55

manager   ~0011530

> That is just a warning in the first iteration. After the first iteration, it should work fine.

No, for me the field is never written.

joegi

2020-09-27 18:37

reporter   ~0011531

You will be able to reproduce the issue with the attached case.

To run the case, type in the terminal:

    $> sh run_solver.sh

It will run simpleFoam only one iteration.


In the time directory 1, you will find the following additional fields:

    kOmegaSST:G
    (omega*yWall)


The only field with issues in paraFoam is (omega*yWall). If you try to open the case with paraFoam, you will get this error:

--> FOAM FATAL IO ERROR:
wrong token type - expected word, found on line 14 the punctuation token '('

file: /home/joegi/my_files/ofcases/elbow_SIMPLE/1/(omega*yWall)/object at line 14.

    From function Foam::Istream& Foam::operator>>(Foam::Istream&, Foam::word&)
    in file primitives/strings/word/wordIO.C at line 74.

FOAM exiting


To fix the issue, erase the parentheses in the object description of the file (omega*yWall). Now the header should looks like this:

FoamFile
{
    version 2.0;
    format ascii;
    class volScalarField;
    location "1";
    object omega*yWall;
}


By the way, for some reason the field (omega*yWall) is also saved in the time directory 0. You will need to modify or erase this file.

After doing this simple modification, paraFoam will open the new field.

Another issue with paraFoam, is that if you try to apply a filter calculator to the field (omega*yWall), paraFoam will complain. To fix this problem, you will need to rename the file as well. That is, you will need to erase the parentheses in the name of the file.

This is why I think adding the option to save the field with a different name will fix these issues.

In any-case, I think this is not big of a deal (at least for me) because I do the renaming using bash scripting.


Another issue related with this case (but not to the additional fields), is that if you enable the scalarTransport functionObject, the case will crash. I haven't track this issue, maybe is something stupid that I don't see right now.
elbow_SIMPLE.tar.gz (19,623 bytes)

henry

2020-09-27 18:47

manager   ~0011532

> This is why I think adding the option to save the field with a different name will fix these issues.

Can you fund this development or do you know of any company interested in funding it?

joegi

2020-09-27 18:55

reporter   ~0011533

Yes, we might be able to fund this. How much will be? Can we get in contact via private email?

In any-case, I was checking nearWallFields, and a way around is doing something similar. In this functionObject, we can save the new field using the name UNear (or whatever).

By the way, I checked with OF7 and the case will run with the scalarTransport functionObject. So I think there is something going on there with cacheTemporaryObjects and scalarTransport

henry

2020-09-27 19:10

manager   ~0011534

While the case you sent writes (omega*yWall)

    cacheTemporaryObjects
    (
        "((interpolate(((1|((1|(1|A(U)))-H(1)))-(1|A(U))))*snGrad(p))*magSf)"
    );

with the regex option off

still does not write anything, could you send the case setup corresponding to your original report?

> Yes, we might be able to fund this. How much will be? Can we get in contact via private email?

You can contact the OpenFOAM Foundation:

https://openfoam.org/news/funding-2020/
https://openfoam.org/contact/

joegi

2020-09-27 19:23

reporter   ~0011535

Add the following in controlDict:

cacheTemporaryObjects
(
    "kOmegaSST:G"
    "(omega*yWall)"
    "((interpolate(((1|((1|(1|A(U)))-H(1)))-(1|A(U))))*snGrad(p))*magSf)"
);


Then use the following functionObject,


writeObjects2
{
    type writeObjects;
    libs ("libutilityFunctionObjects.so");

    enabled on;

    writeControl outputTime;

    regExp off;

    objects
    (
        "kOmegaSST:G"
        "(omega*yWall)"
        "((interpolate(((1|((1|(1|A(U)))-H(1)))-(1|A(U))))*snGrad(p))*magSf)"
    );
}


And it should work (at least it is working on my computer).

I will try to reach the foundation using the links provided.

joegi

2020-09-27 19:27

reporter   ~0011536

Find attached my controlDict
controlDict (3,615 bytes)   
/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |				
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  8                                   	
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application     simpleFoam;

startFrom       startTime;

startTime       0;

stopAt          endTime;
//stopAt          writeNow;

endTime         1;

deltaT          1;

writeControl    timeStep;

writeInterval   1;

purgeWrite      0;

writeFormat     ascii;

writePrecision  8;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;

cacheTemporaryObjects
(
    "kOmegaSST:G"
    "(omega*yWall)"
    "((interpolate(((1|((1|(1|A(U)))-H(1)))-(1|A(U))))*snGrad(p))*magSf)"
);

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

functions
{

///////////////////////////////////////////////////////////////////////////

minmaxdomain
{
    type fieldMinMax;
    functionObjectLibs ("libfieldFunctionObjects.so");
    enabled true;
    mode component;
    writeControl timeStep;
    writeInterval 1;
    log true;
    fields (p U s1 s2 k omega nut);
}

///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////

scalar1
{
    type            scalarTransport;
    functionObjectLibs ("libsolverFunctionObjects.so");

    enabled off;

    writeControl outputTime;
    //writeControl timeStep;
    //writeInterval 1;

    log yes;

    nCorr 1;

    //difussion coefficient
    D 0;

    //name of field
    field s1;

    //use the schemes of field, in this case, U
    //schemesField U;

}

///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////

scalar2
{
    type            scalarTransport;
    functionObjectLibs ("libsolverFunctionObjects.so");

    enabled off;

    writeControl outputTime;
    //writeControl timeStep;
    //writeInterval 1;

    log yes;

    nCorr 2;

    //difussion coefficient
    D 0;

    //name of field
    field s2;

    //use the schemes of field, in this case, U
    //schemesField U;

}

///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////

yplus
{
    type yPlus;
    functionObjectLibs ("libutilityFunctionObjects.so");
    enabled off;
    log	true;
    writeControl outputTime;   
}

///////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////

writeObjects2
{
    type        writeObjects;
    libs        ("libutilityFunctionObjects.so");

    enabled           on;

    writeControl     outputTime;
    //writeControl     timeStep;
    //writeInterval    100;	
    //writeOption anyWrite;
    
//Switch-off to save complex cacheTemporaryObjects names
    regExp  off;

    objects
    (
    	"kOmegaSST:G"
        "(omega*yWall)"
"((interpolate(((1|((1|(1|A(U)))-H(1)))-(1|A(U))))*snGrad(p))*magSf)"
    );
}

///////////////////////////////////////////////////////////////////////////


};
controlDict (3,615 bytes)   

henry

2020-09-27 20:12

manager   ~0011537

When I use

functions
{
    #includeFunc writeObjects(regExp=off, "((interpolate(((1|((1|(1|A(U)))-H(1)))-(1|A(U))))*snGrad(p))*magSf)")
}

in the tutorials/incompressible/simpleFoam/pitzDaily case nothing is written.

henry

2020-09-27 20:15

manager   ~0011538

commit 081f2d57262b4616658f7ea51cc541eff449eeb0 (HEAD -> master, origin/master, origin/HEAD)
Author: Henry Weller <http://cfd.direct>
Date: Sun Sep 27 20:13:56 2020 +0100

    writeObjectsBase: Append explicit names (regExp = false) directly to the list

resolves the issue with regExp=off

joegi

2020-09-27 20:31

reporter   ~0011539

can you provide an example on how to use it?

For instance in this case.

henry

2020-09-27 20:37

manager   ~0011540

Last edited: 2020-09-27 20:38

I put

cacheTemporaryObjects
(
    "((interpolate(((1|((1|(1|A(U)))-H(1)))-(1|A(U))))*snGrad(p))*magSf)"
);

functions
{
    #includeFunc writeObjects(regExp=off, "((interpolate(((1|((1|(1|A(U)))-H(1)))-(1|A(U))))*snGrad(p))*magSf)")
}

in the controlDict of the tutorials/incompressible/simpleFoam/pitzDaily case

joegi

2020-09-27 21:00

reporter   ~0011541

OK, I see that the commit fix one issue with the regExp expression but does not fix the issue with the names nor the issue of using cacheTemporaryObjects together with scalarTransport .

henry

2020-09-27 21:29

manager   ~0011542

Last edited: 2020-09-27 21:33

No, I didn't intend for it to change the names, just ensure the field is written which previously it wasn't. Adding code to change the field names is not trivial.

henry

2020-09-27 21:34

manager   ~0011543

The issue you have with scalarTransport appears to be independent of the issue reported here as the case fails with scalarTransport with or without cacheTemporaryObjects.
You will need to arrange for some user support.

henry

2020-09-29 17:24

manager   ~0011556

commit 06af648dc37a10c02531bc8b9d481995fa41ddc6 (HEAD -> master, origin/master, origin/HEAD)
Author: Henry Weller <http://cfd.direct>
Date: Tue Sep 29 17:21:06 2020 +0100

    writeObjects: Prepend field expression names with "expr"
    
    for example
    
    cacheTemporaryObjects
    (
        "((1|((1|(1|A(U)))-H(1)))-(1|A(U)))"
    );
    
    functions
    {
        #includeFunc writeObjects(regExp=off, "((1|((1|(1|A(U)))-H(1)))-(1|A(U)))")
    }
    
    writes the temporary field with the name
    "expr((1|((1|(1|A(U)))-H(1)))-(1|A(U)))" so that it can be read by paraFoam and
    other post-processing tools.

joegi

2020-09-29 19:39

reporter   ~0011557

Ok, that seems to be a way around.

However, to make it consistent, I think you should add expr to all temporary fields. For example, if you save the field kOmegaSST:G, expr is not preprend to the field.

Another comment, in the dev version (at least on my installation), paraFoam does not open the field expr((interpolate(((1|((1|(1|A(U)))-H(1)))-(1|A(U))))*snGrad(p))*magSf) nor the field kOmegaSST:G. Instead, if I use version 8, it works ok.

henry

2020-09-29 20:04

manager   ~0011558

> I think you should add expr to all temporary fields.

Why? kOmegaSST:G is not an expression, it does not start with '('.

> paraFoam does not open the field expr((interpolate(((1|((1|(1|A(U)))-H(1)))-(1|A(U))))*snGrad(p))*magSf)

How should it? it is a surfaceScalarField. How do you open it in OpenFOAM-8?

henry

2020-09-29 20:53

manager   ~0011559

I can open an visualise kEpsilon:G in paraFoam OpenFOAM-dev and OpenFOAM-8.

I can visualise the boundary values of expr((interpolate(((1|((1|(1|A(U)))-H(1)))-(1|A(U))))*snGrad(p))*magSf) in paraFoam in both OpenFOAM-dev and OpenFOAM-8 because it is a surfaceScalarField and is defined on faces.

joegi

2020-09-29 21:38

reporter   ~0011560

Well, technically speaking I think kOmegaSST:G is an expression as you have the colon punctuation mark there (in my opinion). Even the linux bash will let you know that it is a special character.

As I said, in my installation (OF DEV) I cannot open the fields expr((interpolate(((1|((1|(1|A(U)))-H(1)))-(1|A(U))))*snGrad(p))*magSf) and kOmegaSST:G (and some other fields that I like to access). To make it clear, the fields are not available to postprocess in paraview. OF8 works fine, maybe is something related to the OF plugin, I need to check my installation. Btw, I am not trying to visualize the surface fields, I am just pointing out that they are not available in the drop-down menu or the fields browser (again, in my OF DEV installation).

henry

2020-09-29 21:45

manager   ~0011561

kOmegaSST:G is not a mathematical expression it is an identifier.

I do not have any problem viewing these fields in OpenFOAM-dev or 8, the paraFoam reader is the same in both versions.

henry

2020-09-29 21:46

manager   ~0011562

Resolved by commit 06af648dc37a10c02531bc8b9d481995fa41ddc6

Issue History

Date Modified Username Field Change
2020-09-27 02:46 joegi New Issue
2020-09-27 10:20 henry Note Added: 0011528
2020-09-27 14:25 joegi Note Added: 0011529
2020-09-27 14:55 henry Note Added: 0011530
2020-09-27 18:37 joegi File Added: elbow_SIMPLE.tar.gz
2020-09-27 18:37 joegi Note Added: 0011531
2020-09-27 18:47 henry Note Added: 0011532
2020-09-27 18:55 joegi Note Added: 0011533
2020-09-27 19:10 henry Note Added: 0011534
2020-09-27 19:23 joegi Note Added: 0011535
2020-09-27 19:27 joegi File Added: controlDict
2020-09-27 19:27 joegi Note Added: 0011536
2020-09-27 20:12 henry Note Added: 0011537
2020-09-27 20:15 henry Note Added: 0011538
2020-09-27 20:31 joegi Note Added: 0011539
2020-09-27 20:37 henry Note Added: 0011540
2020-09-27 20:38 henry Note Edited: 0011540
2020-09-27 21:00 joegi Note Added: 0011541
2020-09-27 21:29 henry Note Added: 0011542
2020-09-27 21:33 henry Note Edited: 0011542
2020-09-27 21:34 henry Note Added: 0011543
2020-09-29 17:24 henry Note Added: 0011556
2020-09-29 19:39 joegi Note Added: 0011557
2020-09-29 20:04 henry Note Added: 0011558
2020-09-29 20:53 henry Note Added: 0011559
2020-09-29 21:38 joegi Note Added: 0011560
2020-09-29 21:45 henry Note Added: 0011561
2020-09-29 21:46 henry Assigned To => henry
2020-09-29 21:46 henry Status new => resolved
2020-09-29 21:46 henry Resolution open => fixed
2020-09-29 21:46 henry Fixed in Version => dev
2020-09-29 21:46 henry Note Added: 0011562