|
[Sponsors] |
March 20, 2017, 06:09 |
Initial Condition From Data File
|
#1 |
Senior Member
Join Date: Mar 2016
Location: Bergamo
Posts: 157
Rep Power: 10 |
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. Thanks for help |
|
March 22, 2017, 05:43 |
|
#2 |
Senior Member
Join Date: Mar 2016
Location: Bergamo
Posts: 157
Rep Power: 10 |
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) ); 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 } |
|
May 31, 2019, 08:52 |
|
#3 | |
Senior Member
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 8 |
Quote:
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. |
||
July 11, 2019, 07:21 |
|
#4 |
New Member
Daniel Duque
Join Date: Oct 2018
Posts: 3
Rep Power: 7 |
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.
|
|
July 16, 2019, 10:06 |
|
#5 | |
Senior Member
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 8 |
Quote:
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. |
||
July 18, 2019, 06:49 |
|
#6 |
New Member
Hardik Chauhan
Join Date: Apr 2019
Posts: 3
Rep Power: 7 |
I want to create the vector file from the outlet patch.how can i extract that in openfoam?
|
|
July 19, 2019, 08:36 |
|
#7 | |
Senior Member
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 8 |
Quote:
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. |
||
July 19, 2019, 09:03 |
|
#8 | |
New Member
Hardik Chauhan
Join Date: Apr 2019
Posts: 3
Rep Power: 7 |
Quote:
|
||
July 19, 2019, 09:18 |
|
#9 | |
Senior Member
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 8 |
Quote:
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 ); } } |
||
September 24, 2020, 12:08 |
|
#10 |
Member
Alex Jarosch
Join Date: Dec 2015
Location: Austria
Posts: 32
Rep Power: 10 |
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. |
|
|
|
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 |