|
[Sponsors] |
Restarting simulations in openfoam with updated boundary conditions |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 11, 2013, 07:24 |
Restarting simulations in openfoam with updated boundary conditions
|
#1 |
New Member
Mahesh
Join Date: Dec 2010
Posts: 9
Rep Power: 15 |
Hi All,
Suppose I have run a simulation to 2000 iterations with a set of BC's and want to run another 2000 iterations with changed BC's or a new mass flow rate. The iteration should start from 2001 and should use the flow field already developed. Could you let me know how to do this? Thanks, Mahesh |
|
March 11, 2013, 10:48 |
|
#2 |
Senior Member
Vieri Abolaffio
Join Date: Jul 2010
Location: Always on the move.
Posts: 308
Rep Power: 17 |
any reason why you can't simply edit the approriate file (U, p, etc...) in the 2000 directory?
|
|
March 12, 2013, 12:18 |
|
#3 |
New Member
Mahesh
Join Date: Dec 2010
Posts: 9
Rep Power: 15 |
U or any file at 2000th iteration is a binary file and will contain the values at each node. So it is not possble to edit these files.
Last edited by maheshraj; March 13, 2013 at 09:08. |
|
March 13, 2013, 19:39 |
|
#4 |
Senior Member
|
I think you can do it using the changeDictionary utility.
__________________
--- Julien de Charentenay |
|
March 14, 2013, 03:45 |
|
#5 | |
Senior Member
Pablo Higuera
Join Date: Jan 2011
Location: Auckland
Posts: 627
Rep Power: 19 |
Quote:
Clone your constant and system folders, along with your 2000 folder. Then change writeFormat on controlDict from binary to ascii. Finally run foamFormatConvert. Then you can change whatever you want. If you proceed in the inverse way you will end up with your new case in binary format again. |
||
March 14, 2013, 13:05 |
|
#6 |
Senior Member
Vieri Abolaffio
Join Date: Jul 2010
Location: Always on the move.
Posts: 308
Rep Power: 17 |
sorry, i usually keep my writeFormat in ascii, mor ease of modification and readability.
|
|
March 14, 2013, 14:36 |
|
#7 |
Senior Member
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28 |
I would use mapFields have the target mesh equipped with new boundary conditions (and specified at cutting patches)
|
|
January 24, 2014, 10:04 |
|
#8 |
Member
Tobias Adam
Join Date: Oct 2013
Location: Siegen
Posts: 55
Rep Power: 13 |
can anyone show me an example for the Mapfieldsdict?
I don know how to create this properly. When I map the fields, I always get the old boundary conditions of the source case. best regards Tobi |
|
January 25, 2014, 01:44 |
|
#9 |
Senior Member
|
Hi Tobi,
You may want to use the -sourceRegion/-targetRegion options of mapFields, which may be able to limit itself to the internalField (untested, and I would love to hear if it works). But, as mentioned previously you may as well just modify the boundary conditions in the file 2000. My understanding from reading the file is that parts of it are binary but not all and you are likely to be able to edit the boundary condition definition. Below is an extract of one of my file: Code:
ÁÀìLÍèýÁÀÑT¾» w‘@M%Þ“/ÁÀŸ0Ì|E-ÁÀ¿¯•Ì¡@K'ç2Œ¹ÀÀ“Un¥~;ÁÀv©NL¾ÀŸrgk ã–@^) 3ÇáÀÀŽÏrÐùIÁÀûN§êwÈ”@(<VÎ^MÁÀä&•#ÂBÁÀŒ|Î-³—@yÃÅÀÀðûÁ{ÓÀÀüJj\ X”@N<ÿ9üëÀÀ&¶mðÀÀ); boundaryField { minX { type zeroGradient; } maxX { type zeroGradient; }
__________________
--- Julien de Charentenay |
|
January 26, 2014, 14:50 |
|
#10 |
Member
Ripudaman Manchanda
Join Date: May 2013
Posts: 55
Rep Power: 13 |
Does anyone have any idea how to automatize this?
Say I have to run 5 such instances successively where I change the boundary conditions 5 times. Adding to the complexity, the number of time steps the solution will require to converge will be different for each case (I have modified my solver file to incorporate that). Is there anyway I could access the latestTime from outside Openfoam? |
|
January 28, 2014, 07:38 |
|
#11 |
Senior Member
|
It depends on your preferred environment, script and/or programming language.
Do recover the latest time, you can just loop through the directories that are numerical values and select the highest one. It should be the latest one. This is a way to do it in ruby (Note: it assumes that time directories are integer, not float. In other words, it works for steady-state simulations): Code:
times = [] Dir.foreach(".") { |f| times.push(f.to_f) if ((File.directory?(f)) and (f =~ /\d+/)) } latestTime = times.max()
__________________
--- Julien de Charentenay Last edited by julien.decharentenay; January 28, 2014 at 07:38. Reason: Add ")" to code expression |
|
May 1, 2017, 16:56 |
Editing the phi field to restart a simulation
|
#12 | |
New Member
Jorge Rivas Ordenes
Join Date: Dec 2016
Location: Chile
Posts: 12
Rep Power: 9 |
Hi everyone! Hope i am not boring anyone posting in this "old" thread, but i have a question related to some topics that have been spoken here:
Quote:
To restart the simulation from the 5000 seconds i have already edit the U, p, k and nut files but i am still struggling with the edition of the phi and phi_0 files. Related to this last issue, my questions are:
|
||
May 1, 2017, 17:28 |
|
#14 |
Senior Member
Yuehan
Join Date: Nov 2012
Posts: 142
Rep Power: 14 |
If the mesh is the same, use changeDictionary utility.
|
|
May 1, 2017, 17:36 |
|
#16 |
New Member
Jorge Rivas Ordenes
Join Date: Dec 2016
Location: Chile
Posts: 12
Rep Power: 9 |
||
April 7, 2020, 16:03 |
|
#17 |
New Member
Join Date: Mar 2020
Location: Paris
Posts: 5
Rep Power: 6 |
Hi all,
I know that this conversation is quite old, but my issue is relative to this topic. I have already run a simulation and I have a serious issue of wave reflection to the outlet boundary, so I would like to take the last path before the wave reflexion and try to change the outlet. For this, initially I tried to use the changeDictionaryDict where I take always the same error: --> FOAM FATAL IO ERROR: keyword sampleMode is undefined in dictionary ".inlet" file: .inlet from line 23 to line 25. From function const Foam::entry& Foam::dictionary::lookupEntry(const Foam::word&, bool, bool) const in file db/dictionary/dictionary.C at line 551. FOAM exiting After, I tried with the MapFields utility by changing the boudary condition in the target and by taking the latestTime information of the source. I take exactly the same error in the execution of mapFields too. Does someone have met a relative error in the past and could explain to me? Thank you in advance Georgia |
|
April 14, 2020, 13:33 |
|
#18 |
Member
Gui Miotto
Join Date: Feb 2020
Posts: 30
Rep Power: 6 |
Hi everyone,
I recently had to go through this problem and I'll share here the solution I've adopted. First of all:
Code:
#!/bin/bash ### BEGIN FUNCTION DEFINITIONS delete_old_files() { echo "Removing old files." rm -r -v dynamicCode rm -r -v postProcessing ls -1 | grep -E "processors?[0-9]*" | xargs -d"\n" rm -r -v foamListTimes -rm # Deletes all time directories except t=0 local ZERODIR=$(foamListTimes -withZero | head -n 1) rm ${ZERODIR}/alpha.water rm ${ZERODIR}/p_rgh } close_valve() { local LATEST_TIME=$(foamListTimes -withZero -latestTime | tail -n 1) echo "Closing valve at" $LATEST_TIME # Patch type (not sure if this is really necessary) foamDictionary constant/polyMesh/boundary \ -entry entry0.pres_inlet.type -set "wall" || exit 1 # pressure foamDictionary ${LATEST_TIME}/p_rgh -entry boundaryField.pres_inlet \ -set "{type fixedFluxPressure; value uniform 0;}" || exit 1 # velocity foamDictionary ${LATEST_TIME}/U -entry boundaryField.pres_inlet \ -set "{type noSlip;}" || exit 1 # alpha foamDictionary ${LATEST_TIME}/alpha.water -entry boundaryField.pres_inlet \ -set "{type zeroGradient;}" || exit 1 } open_valve() # Expects one argument: The inlet pressure in Pascal { local LATEST_TIME=$(foamListTimes -withZero -latestTime | tail -n 1) echo "Opening valve at" $LATEST_TIME # Patch type (not sure if this is really necessary) foamDictionary constant/polyMesh/boundary \ -entry entry0.pres_inlet.type -set "patch" || exit 1 # pressure foamDictionary ${LATEST_TIME}/p_rgh -entry boundaryField.pres_inlet \ -set "{type totalPressure; p0 uniform ${1};}" || exit 1 # velocity foamDictionary ${LATEST_TIME}/U -entry boundaryField.pres_inlet \ -set "{type pressureInletOutletVelocity; value uniform (0 0 0);}" || exit 1 # alpha foamDictionary ${LATEST_TIME}/alpha.water -entry boundaryField.pres_inlet \ -set "{type inletOutlet; inletValue uniform 1; value uniform 0;}" || exit 1 } simulate_until() # Expects one argument: endTime in seconds { foamDictionary system/controlDict -entry endTime -set ${1} || exit 1 if [[ $(foamListTimes) = "" ]]; then echo "Simulating for the first time." echo "setFields and decomposePar including geometry will be executed" setFields || exit 1 decomposePar || exit 1 else echo "Simulation already in progress." echo "Decomposing fields only." decomposePar -latestTime -fields || exit 1 fi mpirun -np 12 interFoam -parallel || exit 1 reconstructPar -newTimes || exit 1 } ### END FUNCTION DEFINITIONS ### USAGE EXAMPLE delete_old_files open_valve "4000" simulate_until "2E-6" close_valve simulate_until "4E-6" open_valve "8000" simulate_until "6E-6" close_valve simulate_until "8E-6"
Code:
startFrom latestTime; Cheers |
|
October 9, 2020, 06:48 |
|
#19 |
Member
Kristjan
Join Date: Apr 2017
Location: Slovenia
Posts: 36
Rep Power: 9 |
This is a nice solution!
Any ideas on how to set the 'value' entry when switching from 'zeroGradient' to something else? externalWallHeatFluxTemperature in my case. Zero gradient doesn't have a value entry because it uses neighboring cell values. I'd like to use those rather than a uniform field. Temperature in my case. PS. It just occurred to me that externalWallHeatFluxTemperature is a mixed type BC so I can have it work like zeroGradient by using HTC=0. It's gonna look illogical but it'll work. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
mesh file for flow over a circular cylinder | Ardalan | Main CFD Forum | 7 | December 15, 2020 14:06 |
[Commercial meshers] exporting boundary conditions with pointwise -> openFoam | ebah6 | OpenFOAM Meshing & Mesh Conversion | 2 | September 16, 2012 17:57 |
CFX13 Post Periodic interface | EtaEta | CFX | 7 | December 8, 2011 18:15 |
OpenFOAM class to represent initial boundary conditions | sanatan | OpenFOAM Programming & Development | 1 | March 20, 2011 10:16 |
Please help with flow around car modelling! | Tudor Miron | CFX | 17 | March 19, 2004 20:23 |