CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   timeVaryingMappedFixedValue not working without headers! (https://www.cfd-online.com/Forums/openfoam-solving/208235-timevaryingmappedfixedvalue-not-working-without-headers.html)

PeterL89 October 12, 2018 11:38

timeVaryingMappedFixedValue not working without headers!
 
Dear all foamers,


I am trying to surface sample the seabed pressure beneath regular progressive waves and imposing this pressure data to a new domain where a constitutive soil model is solving Biots equations for pore pressure development.

I use the surface sampling utility to map the seabed pressures in the wave model as such:

Code:

functions
{
    surfaces1
    {
        type                    surfaces;
        functionObjectLibs              ("libsampling.so");
        writeControl            adjustableRunTime;
        writeInterval          1;
    enabled            true;
        surfaceFormat          boundaryData;
        fields
        (
              p_rgh
          p
        );
        interpolationScheme cellPointFace;
        surfaces
        (
            inlet
            {
                type        patch;
                patches    (bottom);
                triangulate false;
            }
        );
    }
}

And that seems to be working fine. I copy my files to my soil folder into /constant/boundaryData/top/... When I try to run OpenFOAM complains that no header is given in the boundaryData files:

Code:

/*---------------------------------------------------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM Extend Project: Open source CFD        |
|  \\    /  O peration    | Version:  1.6-ext                              |
|  \\  /    A nd          | Web:      www.extend-project.de                |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
Build  : 1.6-ext-f3027b3161e4
Exec  : twoSurfacePlastBiotFoam
Date  : Oct 12 2018
Time  : 17:35:49
Host  : n-62-27-21
PID    : 1191
Case  : /work3/s123098/soil_waveFlume_test_2
nProcs : 1
SigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

Reading soil properties

Reading pore pressure field

--> FOAM Serious Error :
    From function IOobject::readHeader(Istream&)
    in file db/IOobject/IOobjectReadHeader.C at line 90
    Reading "/work3/s123098/soil_waveFlume_test_2/constant/boundaryData/top/0/p" at line 2
    First token could not be read or is not the keyword 'FoamFile'

Check header is of the form:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM Extend Project: Open source CFD        |
|  \\    /  O peration    | Version:  1.6-ext                              |
|  \\  /    A nd          | Web:      www.extend-project.de                |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      scalarAverageField;
    location    "constant/boundaryData/top/0";
    object      p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //



--> FOAM FATAL IO ERROR:
problem while reading header for object p

file: /work3/s123098/soil_waveFlume_test_2/constant/boundaryData/top/0/p at line 2.

    From function regIOobject::readStream()
    in file db/regIOobject/regIOobjectRead.C at line 70.

FOAM exiting

Now I am using OpenFOAM v1712 with waves2foam for the generating waves, while using OpenFOAM-1.6-ext for the soil model (as it was developed for this), but untill now I haven't had any problems with compatibility.

Anybody has any idea how to generate output files from surface sampling with appropriate headers, without having to do this manually or set up a script?

Best Regards :)
Peter

wyldckat October 14, 2018 08:42

Quick answer: I haven't checked, but perhaps this is already fixed in foam-extend 4.0, so if perhaps the code you have in 1.6-ext were to build with foam-extend 4.0, it may solve this issue.


If not, then a possible workaround is that you rely on file inclusion instead:
  1. Rename the file you have with the actual data, e.g.:
    Code:

    mv constant/boundaryData/top/0/p constant/boundaryData/top/0/p.data
  2. Then create the file that will act as the wrapper, for example, place the following inside a new file "constant/boundaryData/top/0/p":
    Code:

    /*--------------------------------*- C++ -*----------------------------------*\
    | =========                |                                                |
    | \\      /  F ield        | OpenFOAM Extend Project: Open Source CFD        |
    |  \\    /  O peration    | Version:  1.6-ext                              |
    |  \\  /    A nd          | Web:      www.extend-project.de                |
    |    \\/    M anipulation  |                                                |
    \*---------------------------------------------------------------------------*/
    FoamFile
    {
        version    2.0;
        format      ascii;
        class      scalarAverageField;
        object      values;
    }
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    #include "p.data"

  3. The header is generic enough, and the last line will include the complete content of the original file that is now named "p.data". Therefore, you can copy-paste-adapt this file "p" for any other files, such as "p_rgh", but don't forget to first rename the data files first.

qi.yang@polimi.it August 1, 2021 07:27

Quote:

Originally Posted by wyldckat (Post 709960)
Quick answer: I haven't checked, but perhaps this is already fixed in foam-extend 4.0, so if perhaps the code you have in 1.6-ext were to build with foam-extend 4.0, it may solve this issue.


If not, then a possible workaround is that you rely on file inclusion instead:
  1. Rename the file you have with the actual data, e.g.:
    Code:

    mv constant/boundaryData/top/0/p constant/boundaryData/top/0/p.data
  2. Then create the file that will act as the wrapper, for example, place the following inside a new file "constant/boundaryData/top/0/p":
    Code:

    /*--------------------------------*- C++ -*----------------------------------*\
    | =========                |                                                |
    | \\      /  F ield        | OpenFOAM Extend Project: Open Source CFD        |
    |  \\    /  O peration    | Version:  1.6-ext                              |
    |  \\  /    A nd          | Web:      www.extend-project.de                |
    |    \\/    M anipulation  |                                                |
    \*---------------------------------------------------------------------------*/
    FoamFile
    {
        version    2.0;
        format      ascii;
        class      scalarAverageField;
        object      values;
    }
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    #include "p.data"

  3. The header is generic enough, and the last line will include the complete content of the original file that is now named "p.data". Therefore, you can copy-paste-adapt this file "p" for any other files, such as "p_rgh", but don't forget to first rename the data files first.


Hi, I met the following error
Code:

--> FOAM FATAL IO ERROR:
incorrect first token, expected <int> or '(', found on line 21 the word '#include'

file: /gpfs/work1/pMI21_CivGh/kimy/solids4Foam/poroelasticity/Jengseabed/constant/boundaryData/top/40/p at line 21.

    From function Foam::Istream& Foam::operator>>(Foam::Istream&, Foam::List<T>&) [with T = double]
    in file /cineca/prod/build/applications/openfoam-ext/4.1/openmpi--1.10.7--gnu--4.9.2/BA_WORK/foam/foam-4.1/src/foam/lnInclude/ListIO.C at line 148.

, according to your suggestion.

salachnaj September 8, 2021 06:55

Quote:

Originally Posted by qi.yang@polimi.it (Post 809464)
Hi, I met the following error
Code:

--> FOAM FATAL IO ERROR:
incorrect first token, expected <int> or '(', found on line 21 the word '#include'

file: /gpfs/work1/pMI21_CivGh/kimy/solids4Foam/poroelasticity/Jengseabed/constant/boundaryData/top/40/p at line 21.

    From function Foam::Istream& Foam::operator>>(Foam::Istream&, Foam::List<T>&) [with T = double]
    in file /cineca/prod/build/applications/openfoam-ext/4.1/openmpi--1.10.7--gnu--4.9.2/BA_WORK/foam/foam-4.1/src/foam/lnInclude/ListIO.C at line 148.

, according to your suggestion.

Hi. Same problem here. Did you solve the problem?

qi.yang@polimi.it September 9, 2021 03:11

Quote:

Originally Posted by salachnaj (Post 811831)
Hi. Same problem here. Did you solve the problem?

Hi, I solved the problem but there is no way to simplify the procedure. You can only add the header one by one through Matlab or another programming.

qi.yang@polimi.it September 15, 2021 05:45

Quote:

Originally Posted by salachnaj (Post 811831)
Hi. Same problem here. Did you solve the problem?

Hi, I found there is a way to solve this problem by executing the following script directly. But what I need is p_rgh-constant. Can I simply add something here?
Code:

patchname='ground'
newpatchname='top'
variableFoldername=patch_$patchname
variablename='p_rgh'
variaWriteName='p'

for d in ./postProcessing/toppressuredata/surface/*
do

mkdir -p ./constant/boundaryData/$newpatchname/$d/
#Write the default headline contents into the files
echo 'FoamFile
{
    version    2.0;
    format      ascii;
    class      scalarAverageField;
    object      values;
}
// **********************************************************************//
0.0' > ./constant/boundaryData/$newpatchname/$d/$variaWriteName

#copy values from /surface folder to /boundaryData folder
cat  ./postProcessing/toppressuredata/surface/$d/$variableFoldername/scalarField/$variablename >> ./constant/boundaryData/$newpatchname/$d/$variaWriteName

done


#Transfer the format of the corresponding 'points' file
echo 'FoamFile
{
    version 2.0;
    format  ascii;
    class  vectorField;
    object  points;
}
// ******************************************************************************************//
'  > ./constant/boundaryData/$patchname/points
cat  ./postProcessing/toppressuredata/surface/$d/$variableFoldername/points >> ./constant/boundaryData/$newpatchname/points

#Transfer the format of the corresponding 'faces' file
echo 'FoamFile
{
    version 2.0;
    format  ascii;
    class  faceList;
    object  faces;
}
// ******************************************************************************************//
' > ./constant/boundaryData/$patchname/faces
cat  ./postProcessing/toppressuredata/surface/$d/$variableFoldername/faces >> ./constant/boundaryData/$newpatchname/faces



All times are GMT -4. The time now is 07:53.