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

Initial Condition From Data File

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree9Likes
  • 1 Post By FlyBob91
  • 8 Post By FlyBob91

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 20, 2017, 06:09
Exclamation Initial Condition From Data File
  #1
Senior Member
 
FlyBob91's Avatar
 
Join Date: Mar 2016
Location: Bergamo
Posts: 157
Rep Power: 10
FlyBob91 is on a distinguished road
Hello to all,
I found this explanation to read data from file to set the initial condition

Code:
2.2.10 The #include and #inputMode directives
For example, let us say a user wishes to set an initial value of pressure once to be used as the internal field and initial value at a boundary. We could create a file, e.g. named initialConditions, which contains the following entries:

    pressure 1e+05; 
    #inputMode merge
In order to use this pressure for both the internal and initial boundary fields, the user would simply include the following macro substitutions in the pressure field file p:

    #include "initialConditions" 
    internalField uniform $pressure; 
    boundaryField 
    { 
        patch1 
        { 
            type fixedValue; 
            value $internalField; 
        } 
    }
This is a fairly trivial example that simply demonstrates how this functionality works. However, the functionality can be used in many, more powerful ways particularly as a means of generalising case data to suit the user’s needs. For example, if a user has a set of cases that require the same RAS turbulence model settings, a single file can be created with those settings which is simply included in the turbulenceProperties file of each case. Macro substitutions can extend well beyond a single value so that, for example, sets of boundary conditions can be predefined and called by a single macro. The extent to which such functionality can be used is almost endless.
How can i modify these code to read a nonuniform vecotr field at my boundary? I want to set a non uniform field for the velocity boundary condition



Thanks for help
ships26 likes this.
FlyBob91 is offline   Reply With Quote

Old   March 22, 2017, 05:43
Default
  #2
Senior Member
 
FlyBob91's Avatar
 
Join Date: Mar 2016
Location: Bergamo
Posts: 157
Rep Power: 10
FlyBob91 is on a distinguished road
Ok, i found the solution to the problem.

First, create the file where you want to store your velocity field. The file must have this format

Code:
velocityProfile         // name of your velocity prfoile
List<vector>
300                         // number of vectors (points)
(
(Ux Uy Uz)
.....
(Ux Uy Uz)
);
Second, put this file in the 0 directory (suppose to name it "inletCondition").
Now open the U file


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

internalField   uniform (0 0 0);

#include "inletCondition"

boundaryField
{
    inlet
    {
        type            fixedValue;
        value          nonuniform $velocityProfile;
    }

// ...... other boundary conditions

}
FlyBob91 is offline   Reply With Quote

Old   May 31, 2019, 08:52
Default
  #3
Senior Member
 
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 8
deepbandivadekar is on a distinguished road
Quote:
Originally Posted by FlyBob91 View Post
Ok, i found the solution to the problem.
First, create the file where you want to store your velocity field. The file must have this format
Code:
velocityProfile         // name of your velocity prfoile
List<vector>
....
Footnote to this:

Both the semi-colons are important: 1) in the list file at the end after the ")" and 2) in the inlet conditions file after the keyword. Else OF will give errors.
deepbandivadekar is offline   Reply With Quote

Old   July 11, 2019, 07:21
Default
  #4
New Member
 
Daniel Duque
Join Date: Oct 2018
Posts: 3
Rep Power: 7
ddcampayo is on a distinguished road
Quote:
Originally Posted by FlyBob91 View Post
... The file must have this format

Code:
velocityProfile         // name of your velocity prfoile
List<vector>
300                         // number of vectors (points)
(
(Ux Uy Uz)
.....
(Ux Uy Uz)
);
[/CODE]
Any ideas on how to do this efficiently. What I mean is: usually the field will depend on the position, and the latter should be read from constant/polyMesh/points. I guess this calls for a python script that reads coordinates from that file and generates the field.
ddcampayo is offline   Reply With Quote

Old   July 16, 2019, 10:06
Default
  #5
Senior Member
 
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 8
deepbandivadekar is on a distinguished road
Quote:
Originally Posted by ddcampayo View Post
Any ideas on how to do this efficiently. What I mean is: usually the field will depend on the position, and the latter should be read from constant/polyMesh/points. I guess this calls for a python script that reads coordinates from that file and generates the field.

I did the same. Because I needed the field values off of a particular face. Other way is to dabble with the solver. I wasn't particularly keen to get into that muck.
deepbandivadekar is offline   Reply With Quote

Old   July 18, 2019, 06:49
Default
  #6
New Member
 
Hardik Chauhan
Join Date: Apr 2019
Posts: 3
Rep Power: 7
Chhardik94 is on a distinguished road
I want to create the vector file from the outlet patch.how can i extract that in openfoam?
Chhardik94 is offline   Reply With Quote

Old   July 19, 2019, 08:36
Default
  #7
Senior Member
 
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 8
deepbandivadekar is on a distinguished road
Quote:
Originally Posted by Chhardik94 View Post
I want to create the vector file from the outlet patch.how can i extract that in openfoam?

It's hard to figure out what exactly you want to do without many details.
It seems what you're trying to do is unrelated to this thread. I'd suggest to first search the forum for what you seek and see if you find any clues or start your own thread.
deepbandivadekar is offline   Reply With Quote

Old   July 19, 2019, 09:03
Default
  #8
New Member
 
Hardik Chauhan
Join Date: Apr 2019
Posts: 3
Rep Power: 7
Chhardik94 is on a distinguished road
Quote:
Originally Posted by ddcampayo View Post
Any ideas on how to do this efficiently. What I mean is: usually the field will depend on the position, and the latter should be read from constant/polyMesh/points. I guess this calls for a python script that reads coordinates from that file and generates the field.
I want to do this same thing but for only one patch. want to extract the foam file of the result for any boundary patch.
Chhardik94 is offline   Reply With Quote

Old   July 19, 2019, 09:18
Default
  #9
Senior Member
 
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 8
deepbandivadekar is on a distinguished road
Quote:
Originally Posted by Chhardik94 View Post
I want to do this same thing but for only one patch. want to extract the foam file of the result for any boundary patch.
If you mean, you want to get data for variables like U, p, T.. for a single patch you can use the surfaceFieldValue functionobject.

In controlDict add this:
Code:
functions
{

    inletData
    {
        type            surfaceFieldValue; //surfaceFieldValue;
        libs            ("libfieldFunctionObjects.so");
        writeControl    writeTime;
        writeFields     true;
        surfaceFormat   foam;
        regionType      patch; //faceZone;
        name            inlet;
        operation       none;
        fields
        (
            p T U
        );
    }
  }
deepbandivadekar is offline   Reply With Quote

Old   September 24, 2020, 12:08
Default
  #10
Member
 
Alex Jarosch
Join Date: Dec 2015
Location: Austria
Posts: 32
Rep Power: 10
alexj is on a distinguished road
Hi,
I am in the same position, I need to create an initial condition of an internal velocity field. How did you go about doing that.


BTW, the order in the internal field file is according to cells and therefore probably better to use cell center coordinates instead of point coordinates from constant/polyMesh/points


Any help is greatly appreciated.
alexj is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
chtMultiRegionSimpleFoam: maximum number of iterations excedeed. Nkl OpenFOAM Running, Solving & CFD 19 October 10, 2019 02:42
Cannot run the code properly: very large time step continuity error crst15 OpenFOAM Running, Solving & CFD 9 December 14, 2014 18:17
centOS 5.6 : paraFoam not working yossi OpenFOAM Installation 2 October 9, 2013 01:41
calculation stops after few time steps sivakumar OpenFOAM Running, Solving & CFD 7 March 17, 2013 06:37
pisoFoam with k-epsilon turb blows up - Some questions Heroic OpenFOAM Running, Solving & CFD 26 December 17, 2012 03:34


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