CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Pre-Processing (https://www.cfd-online.com/Forums/openfoam-pre-processing/)
-   -   time dependence - inlet velocity - validation (paper) (https://www.cfd-online.com/Forums/openfoam-pre-processing/144177-time-dependence-inlet-velocity-validation-paper.html)

vitorspadetoventurin November 9, 2014 23:25

time dependence - inlet velocity - validation (paper)
 
Hi. how can I use this velocity profile(inlet) in my simulation? My code gives error( as follows).
This is the picture of my profile (please, see FIG. 2 ):

http://www.ijens.org/Vol_13_I_03/133...JMME-IJENS.pdf


I tried use this code:

Code:

nlet
    {
        type            timeVaryingUniformFixedValue;
        fileName        "$FOAM_CASE/time-series";
        outOfBounds    clamp;          // (error|warn|clamp|repeat)
    }


And the time-series example file:

Code:

(
(0 1.3332)
(0.05 10)
(0.1 0)
)


But gives the following error:

HTML Code:

a@a-Aspire-V3-571:~/Desktop/teste_time_series/pitzDaily$ pimpleFoam
/*---------------------------------------------------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.3.0                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
Build  : 2.3.0-f5222ca19ce6
Exec  : pimpleFoam
Date  : Nov 10 2014
Time  : 02:23:50
Host  : "a-Aspire-V3-571"
PID    : 26336
Case  : /home/a/Desktop/teste_time_series/pitzDaily
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Disallowing user-supplied system call operations

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

Create mesh for time = 0

Reading field p

Reading field U



--> FOAM FATAL IO ERROR:
Unknown patchField type timeVaryingUniformFixedValue for patch type patch

Valid patchField types are :

74
(
SRFFreestreamVelocity
SRFVelocity
activeBaffleVelocity
activePressureForceBaffleVelocity
advective
atmBoundaryLayerInletVelocity
calculated
codedFixedValue
codedMixed
cyclic
cyclicACMI
cyclicAMI
cyclicSlip
cylindricalInletVelocity
directionMixed
empty
externalCoupled
fixedGradient
fixedInternalValue
fixedJump
fixedJumpAMI
fixedMean
fixedNormalSlip
fixedValue
flowRateInletVelocity
fluxCorrectedVelocity
freestream
inletOutlet
interstitialInletVelocity
kqRWallFunction
mapped
mappedField
mappedFixedInternalValue
mappedFixedPushedInternalValue
mappedFlowRate
mappedVelocityFlux
mixed
movingWallVelocity
nonuniformTransformCyclic
oscillatingFixedValue
outletInlet
outletMappedUniformInlet
outletPhaseMeanVelocity
partialSlip
pressureDirectedInletOutletVelocity
pressureDirectedInletVelocity
pressureInletOutletParSlipVelocity
pressureInletOutletVelocity
pressureInletUniformVelocity
pressureInletVelocity
pressureNormalInletOutletVelocity
processor
processorCyclic
rotatingPressureInletOutletVelocity
rotatingWallVelocity
sliced
slip
supersonicFreestream
surfaceNormalFixedValue
swirlFlowRateInletVelocity
symmetry
symmetryPlane
timeVaryingMappedFixedValue
translatingWallVelocity
turbulentInlet
uniformFixedGradient
uniformFixedValue
uniformInletOutlet
uniformJump
uniformJumpAMI
variableHeightFlowRateInletVelocity
waveTransmissive
wedge
zeroGradient
)


file: /home/a/Desktop/teste_time_series/pitzDaily/0/U.boundaryField.inlet from line 36 to line 38.

    From function fvPatchField<Type>::New(const fvPatch&, const DimensionedField<Type, volMesh>&, const dictionary&)
    in file /home/opencfd/OpenFOAM/OpenFOAM-2.3.0/src/finiteVolume/lnInclude/fvPatchFieldNew.C at line 143.

FOAM exiting

Can you help write a correct code for me?

Best Regards,
Vitor

alexeym November 10, 2014 03:50

Hi,

it's just

Code:

uniformFixedValue
the rest seems to be correct.

vitorspadetoventurin November 10, 2014 10:04

alexmye, gives erros again...:(
see:
Code:

a@a-Aspire-V3-571:~/Desktop/teste_time_series/pitzDaily$ pimpleFoam
/*---------------------------------------------------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.3.0                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
Build  : 2.3.0-f5222ca19ce6
Exec  : pimpleFoam
Date  : Nov 10 2014
Time  : 12:54:23
Host  : "a-Aspire-V3-571"
PID    : 3892
Case  : /home/a/Desktop/teste_time_series/pitzDaily
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Disallowing user-supplied system call operations

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

Create mesh for time = 0

Reading field p

Reading field U



--> FOAM FATAL IO ERROR:
keyword uniformValue is undefined in dictionary "/home/a/Desktop/teste_time_series/pitzDaily/0/U.boundaryField.inlet"

file: /home/a/Desktop/teste_time_series/pitzDaily/0/U.boundaryField.inlet from line 42 to line 44.

    From function dictionary::lookupEntry(const word&, bool, bool) const
    in file db/dictionary/dictionary.C at line 437.

FOAM exiting

My U file is:

Code:

FoamFile
{
    version    2.0;
    format      ascii;
    class      volVectorField;
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 1 -1 0 0 0 0];

internalField  uniform (0 0 0);

boundaryField
{
    inlet
  {
        type            uniformFixedValue;
        fileName        "$FOAM_CASE/time-series";
        outOfBounds    clamp;          // (error|warn|clamp|repeat)
  }

    outlet
    {
        type            zeroGradient;
    }
...

time-series has this form:
Code:

(
time0 velocity0
time1 velocity1
time2 velocity2
time3 velocity3
time4 velocity4
)

or

Code:

(
(time0 velocity0)
(time1 velocity1)
(time2 velocity2)
(time3 velocity3)
(time4 velocity4)
)


alexeym November 10, 2014 10:21

Hi,

guess I missed it ;) So let's go to source file of the BC and check syntax:

this is for constant (uniformFixedValueFvPatchField.H)
Code:

    myPatch
    {
        type            uniformFixedValue;
        uniformValue    constant 0.2;
    }

in case of file it should be something like:

Code:

    myPatch
    {
        type            uniformFixedValue;
        uniformValue    tableFile;
        tableFileCoeffs
        {
            dimensions          [0 0 1 0 0]; // optional dimensions
            fileName            dataFile;    // name of data file
            outOfBounds        clamp;      // optional out-of-bounds handling
            interpolationScheme linear;      // optional interpolation method
        };
        value uniform (0 0 0); // placeholder
  }

And about data format (tableFile.H):

Quote:

Items are stored in a list of Tuple2's. First column is always stored as
scalar entries. Data is read in the form, e.g. for an entry \<entryName\>
that is (scalar, vector):

(
0.0 (1 2 3)
1.0 (4 5 6)
);

vitorspadetoventurin November 10, 2014 11:52

ok.. My mesh is from pitzDaily tutorial case. My inlet is exactly the same from the case, with normal vector = (1,0,0) , as you can see:

http://postimg.org/image/r6ouivpuf/

But, I did not undertand well how would be my time-serie file...

For example, If my intention is to generate the following inlet velocity time-serie:
0 seconds = (1 0 0) -> velocity vector to the patch face of 1m/s in x direction,because normal face is (1,0,0)
0.5 seconds = (5 0 0) -> velocity vector to the patch face of 5m/s in x direction
1 seconds = (10 0 0) -> velocity vector to the patch face of 10m/s in x direction
1.5 seconds = (0 0 0) -> velocity vector to the patch face of 0m/s in x direction

My file would be:
Code:

(
0.0 (1 0 0)
0.5 (5 0 0)
1.0 (10 0 0)
1.5 (0 0 0)
);

And U file:

Code:

 
inlet
 {
        type            uniformFixedValue;
        uniformValue    tableFile;
        tableFileCoeffs
        {
            dimensions          [0 0 1 0 0]; // optional dimensions
            fileName            time-series;    // name of data file
            outOfBounds        clamp;      // optional out-of-bounds handling
            interpolationScheme linear;      // optional interpolation method
        };
        value uniform (0 0 0); // placeholder
  }

right? Am I undestanding wrong? Because gives error, again .. :(:

Code:

/*---------------------------------------------------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.3.0                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
Build  : 2.3.0-f5222ca19ce6
Exec  : pimpleFoam
Date  : Nov 10 2014
Time  : 14:48:17
Host  : "a-Aspire-V3-571"
PID    : 8328
Case  : /home/a/Desktop/teste_time_series/pitzDaily
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Disallowing user-supplied system call operations

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

Create mesh for time = 0

Reading field p

Reading field U



--> FOAM FATAL IO ERROR:
wrong token type - expected string, found on line 60 the word 'time-series'

file: /home/a/Desktop/teste_time_series/pitzDaily/0/U.boundaryField.inlet.tableFileCoeffs.fileName at line 60.

    From function operator>>(Istream&, fileName&)
    in file primitives/strings/fileName/fileNameIO.C at line 56.

FOAM exiting

thanks alexeym!

alexeym November 10, 2014 12:15

Hi,

the error is quite obvious (and the reason for it was explained in error message), you have to specify file name as a string (i.e. use quotation marks).

Concerning your first question, it depends on how you'd like the velocity to change. With the file you've posted it'll linearly increase from 1 to 5 during 0.5 s, the to 10 during next 0.5 s and finally linearly go to zero during next 0.5 s. If it's what you want, yes, file is right.

About format, it seems to be correct. Also you can try to use csvFile, it has more clear configuration dictionary:

Code:

        csvFileCoeffs
        {
            nHeaderLine        4;
            refColumn          0;          // reference column index
            componentColumns    (1 2 3);    // component column indices
            separator          ",";        // optional (defaults to ",")
            mergeSeparators    no;        // merge multiple separators
            fileName            "fileXYZ";  // name of csv data file
            outOfBounds        clamp;      // optional out-of-bounds handling
            interpolationScheme linear;    // optional interpolation scheme
        }


vitorspadetoventurin November 10, 2014 19:27

ok.

For those in the future have the same question that I follow the solution to my original question. The solution was given by our friend Alexeym. Thank you Alex! I just had to make a correction in the time series file, inserting brackets as seen below. Then follows my test case to other beginers (like me). I changed the name of "time-series" for "time"):

Here is it:
http://www.4shared.com/rar/IM-5z-lzb...ity_chang.html


Alex, can you tell me the other schemes beyond the linear interpolation? They are mentioned in the documentation or some other file?

I am studying the openfoam shortly. Sorry, I'm still very novice. Thank you!
I hope this post can help others.

alexeym November 11, 2014 02:16

Hi,

Quote:

Originally Posted by vitorspadetoventurin (Post 518435)
Alex, can you tell me the other schemes beyond the linear interpolation? They are mentioned in the documentation or some other file?

https://openfoamwiki.net/index.php/O...de/Use_bananas

In your case put banana instead of linear for interpolationScheme.

Or you can go to $WM_PROJECT_DIR/src/OpenFOAM/primitives/functions/DataEntry/TableFile/TableFile.H (well, not exactly TableFile/TableFile.H but Table/Table.H, as TableFile is more-or-less just responsible for I/O), learn that interpolation is done via interpolationWeights class, then go to $WM_PROJECT_DIR/src/OpenFOAM/interpolations/interpolationWeights and learn that there are two subclasses: linear and spline. I guess, first method is simpler.

fredf November 16, 2014 17:48

Pressure instead of velocity
 
Hello. How would the syntax be if I was to load pressure at inlet from a .csv?
for instance something like this?
t=0 : p=0
t=0.1:p=1
t=0.2:p=2

also I guess that the time set in contradict would have to match time in 0-directory?

alexeym November 17, 2014 01:35

Hi,

in general CSV files have the following format (http://tools.ietf.org/html/rfc4180):

val11,val12
val21,val22
...

So your pressure CSV file should be something like:

0,0
0.1,1
0.2,2
...

Didn't quite get the second part of the question.

fredf November 17, 2014 14:34

Hello. I I´m trying to do this now, and my code looks like this:


PHP Code:

boundaryField
{
 
inlet
    
{
     
type        uniformFixedValue;
        
uniformValue    csvFile;
        
csvFileCoeffs
        
{
        
fileName    "~/Table_Pressure"
            
hasHeaderLine    false;
            
refColumn    0;
            
componentColumns    (0 1);
        }
    } 

But then I get the following error message:

PHP Code:

--> FOAM FATAL IO ERROR
keyword nHeaderLine is undefined in dictionary "/home/fredrik/OpenFOAM/fredrik-2.3.0/run/cavityOscPdata/0/p.boundaryField.inlet.csvFileCoeffs"

file: /home/fredrik/OpenFOAM/fredrik-2.3.0/run/cavityOscPdata/0/p.boundaryField.inlet.csvFileCoeffs from line 29 to line 32.

    From 
function dictionary::lookupEntry(const word&, boolbool) const
    
in file db/dictionary/dictionary.C at line 437.

FOAM exiting 

I tried changing to nHeaderLine 4; but this gave the same error

alexeym November 17, 2014 14:37

Eh... you've forgotten semicolon after

Code:

fileName    "~/Table_Pressure"

fredf November 17, 2014 15:05

componentColumns
 
aha. Thanks:)
Now it manages to read the file and solving, but it seems like it only uses the value in the first row:
0,4

which is time=0, pressure=4
from then on the pressure is constant and does not change according to the .csv file

next couple of rows are:
0.04,3.5052
0.08,2.1433
0.12,0.2511

but from the solution the pressure is kept constant at the inlet
my code is as follows:
PHP Code:

boundaryField
{
 
inlet
    
{
     
type        uniformFixedValue;
        
uniformValue    csvFile;
        
csvFileCoeffs
        
{
        
fileName    "~/Table_Pressure";
            
nHeaderLine    0;
            
mergeSeparators    no;
            
refColumn    0;
            
componentColumns    (1);
        }
    } 

Do you know might solve this. Thanks a lot for quick respond :)

alexeym November 18, 2014 03:18

Post your case. I've just created test case and pressure follows CSV-file values.

fredf November 18, 2014 05:07

Cavity_Case_Pessure_From_CSV
 
1 Attachment(s)
Here it is. Tried with and without having commas after the pressures in the csv file.
Thanks
Fred

alexeym November 18, 2014 05:49

Well ;)

1. You've got wrong line endings (Windows?), so I guess OpenFOAM reads the file as a single line (then takes 0 as a single time value in the table and 4 as a single pressure value).

2. When I corrected line ending, I also found that after 0.96 you go back in time to 0.1. This also makes OpenFOAM quite unhappy.

fredf November 18, 2014 07:00

Aha. yeah I made a new file now, which works. I made the original in excel and than exported as .csv, maybe something went wrong. Thanks a lot for your help:)
Fred

meth November 4, 2015 22:04

Quote:

Originally Posted by vitorspadetoventurin (Post 518435)
ok.

For those in the future have the same question that I follow the solution to my original question. The solution was given by our friend Alexeym. Thank you Alex! I just had to make a correction in the time series file, inserting brackets as seen below. Then follows my test case to other beginers (like me). I changed the name of "time-series" for "time"):

Here is it:
http://www.4shared.com/rar/IM-5z-lzb...ity_chang.html

Hi vitor spadeto,

I have the same question. I would like to see your files since it gives me an error when I run the decomposePar. I could not get it from the link you mentions, so can you please give me your files to have a look?

Thank you very much

Methma

meth November 4, 2015 22:36

Quote:

Originally Posted by fredf (Post 519756)
Aha. yeah I made a new file now, which works. I made the original in excel and than exported as .csv, maybe something went wrong. Thanks a lot for your help:)
Fred

Can you please share your file with me?

Thanks,

Methma

Lorenzo92 April 23, 2016 08:57

hello,

I know the thread is old but maybe you can help me with a very similar issue.
My inlet patch, under the name "throat" has a uniformFixedValue BC.
My settings are:

throat
{
type uniformFixedValue;
uniformValue csvFile;
csvFileCoeffs
{
fileName "~/Documenti/Lorenzo/Materie_quinto_anno/Tesi_Les_Naso/Manara_Copia/DeltaPTot/pressure_profile.dat";
nHeaderLine 0;
mergeSeparators no;
oufOfBounds clamp;
refColumn 0;
componentColumns (1);
}
}

I just copied them from the uploaded cavityOscPcsv case. Using pimpleFoam as solver for my case I get the following error:

FOAM FATAL IO ERROR:
keyword uniformValueCoeffs is undefined in dictionary "/home/user/Documenti/Lorenzo/Materie_quinto_anno/Tesi_Les_Naso/Manara_Copia/DeltaPTot/0/p.boundaryField.throat"

file: /home/user/Documenti/Lorenzo/Materie_quinto_anno/Tesi_Les_Naso/Manara_Copia/DeltaPTot/0/p.boundaryField.throat from line 76 to line 85.

From function dictionary::subDict(const word& keyword) const
in file db/dictionary/dictionary.C at line 648.

FOAM exiting

What am I missing to specify?

Thanks

Qihao December 29, 2017 04:15

Quote:

Originally Posted by alexeym (Post 518383)
Hi,

the error is quite obvious (and the reason for it was explained in error message), you have to specify file name as a string (i.e. use quotation marks).

Concerning your first question, it depends on how you'd like the velocity to change. With the file you've posted it'll linearly increase from 1 to 5 during 0.5 s, the to 10 during next 0.5 s and finally linearly go to zero during next 0.5 s. If it's what you want, yes, file is right.

About format, it seems to be correct. Also you can try to use csvFile, it has more clear configuration dictionary:

Code:

        csvFileCoeffs
        {
            nHeaderLine        4;
            refColumn          0;          // reference column index
            componentColumns    (1 2 3);    // component column indices
            separator          ",";        // optional (defaults to ",")
            mergeSeparators    no;        // merge multiple separators
            fileName            "fileXYZ";  // name of csv data file
            outOfBounds        clamp;      // optional out-of-bounds handling
            interpolationScheme linear;    // optional interpolation scheme
        }


hi ,can I use this format to define the boundary condition of spatial varying, which my time is not vary? only the pressure value vary in the x direction. and the file is scatter and also need to interpolate and then use it


All times are GMT -4. The time now is 09:29.