|
[Sponsors] |
How to edit OpenFOAM files at runtime without crashing the simulations? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 30, 2023, 22:19 |
How to edit OpenFOAM files at runtime without crashing the simulations?
|
#1 |
Senior Member
ONESP-RO
Join Date: Feb 2021
Location: Somwhere on Planet Earth
Posts: 127
Rep Power: 5 |
Hello,
In my system/controlDict file I set: Code:
runTimeModifiable true; Problem: Sometimes I am lucky enough that the simulations do not crash when I save the modifications of the files but in most cases, the simulation crashes. I think this happens because while the text editor writes to the disk, the solver tries to re-read the file which leads to the crash of the simulation. Question Is there any reliable solution to this issue so I could modify simulation files at runtime without the risk of crashing when I save the file using the text editor? P.S: I am using OpenFOAM v2212 |
|
July 1, 2023, 05:07 |
|
#2 |
Senior Member
Join Date: Oct 2017
Posts: 133
Rep Power: 9 |
In my experience, crashes of this kind have to do with making a mistake yourself (e.g. forgetting a semicolon). Could you please show an error message?
|
|
July 1, 2023, 23:15 |
|
#3 | |
Senior Member
ONESP-RO
Join Date: Feb 2021
Location: Somwhere on Planet Earth
Posts: 127
Rep Power: 5 |
Quote:
No. There are no mistakes while editing files. This happened to me hundreds of times. When I re-run the simulation it works fine (this demonstrates that there are no mistakes in the files). |
||
July 2, 2023, 06:02 |
|
#4 |
Senior Member
Yann
Join Date: Apr 2012
Location: France
Posts: 1,238
Rep Power: 29 |
What is your work environment? (OS, running simulations locally or remotely, etc...)
I've edited countless of controlDict/fvSchemes/fvSolution files at runtime for the past 10 years, using multiple OpenFOAM versions on multiple systems, and from my experience it's quite reliable (actually I don't remember facing any crash, except the ones due to typos) Yann |
|
July 2, 2023, 16:32 |
|
#5 | |
Senior Member
ONESP-RO
Join Date: Feb 2021
Location: Somwhere on Planet Earth
Posts: 127
Rep Power: 5 |
Quote:
Code:
From virtual bool Foam::regIOobject::readIfModified() in file db/regIOobject/regIOobjectRead.C at line 271 Re-reading object controlDict from file "/home/feelTheFearAndDoItAnyway/scratch/squareCylinder/piso/system/controlDict" --> FOAM Warning : From bool Foam::IOobject::readHeader(Foam::dictionary&, Foam::Istream&) in file db/IOobject/IOobjectReadHeader.C at line 116 Reading "/home/feelTheFearAndDoItAnyway/scratch/squareCylinder/piso/system/controlDict" at line 1 First token could not be read or is not 'FoamFile' Check header is of the form: /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 2112 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; arch "LSB;label=32;scalar=64"; class dictionary; location "system"; object controlDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // [0] --> FOAM FATAL IO ERROR: (openfoam-2112) [0] problem while reading header for object controlDict [0] [0] file: system/controlDict at line 1. [0] [0] From virtual Foam::autoPtr<Foam::ISstream> Foam::fileOperations::uncollatedFileOperation::readStream(Foam::regIOobject&, const Foam::fileName&, const Foam::word&, bool) const [0] in file global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.C at line 563. [0] FOAM parallel run exiting [0] -------------------------------------------------------------------------- MPI_ABORT was invoked on rank 0 in communicator MPI_COMM_WORLD with errorcode 1. NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes. You may or may not see output from other processes, depending on exactly when Open MPI kills them. -------------------------------------------------------------------------- In: PMI_Abort(1, N/A) srun: Job step aborted: Waiting up to 32 seconds for job step to finish. slurmstepd: error: *** STEP 6296119.0 ON ngm552 CANCELLED AT 2023-07-02T12:23:16 *** srun: error: ngm555: tasks 11-15: Killed srun: Terminating StepId=6296119.0 srun: error: ngm552: tasks 0-10: Killed ---- END ---- |
||
July 3, 2023, 10:04 |
|
#6 |
Senior Member
ONESP-RO
Join Date: Feb 2021
Location: Somwhere on Planet Earth
Posts: 127
Rep Power: 5 |
I have finally solved the issue!
It turned out that Vim saves the changes directly to the file so the file goes through a period of time where it is in inconsistent state and when OpenFOAM attempts to read the file during this period, it may not find what it expects and hence fail. The solution is to told Vim to use an "atomic" save method (saves to a temporary file then replaces the old one) by adding this command in ~/.vimrc: Code:
:set backupcopy=yes |
|
July 3, 2023, 10:59 |
|
#7 |
Senior Member
Yann
Join Date: Apr 2012
Location: France
Posts: 1,238
Rep Power: 29 |
Thanks for your feedback, it's definitely good to know!
Yann |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How To View OpenFOAM files from WSL Bash Environment | ajcib | Main CFD Forum | 0 | February 11, 2022 17:42 |
Planning a (EPYC?) workstation for thermal/reacting simulations (OpenFOAM) | hsnyder | Hardware | 14 | October 30, 2020 11:13 |
OpenFOAM v3.0+ ?? | SBusch | OpenFOAM | 22 | December 26, 2016 15:24 |
OpenFOAM v3.0.1 Training, London, Houston, Berlin, Jan-Mar 2016 | cfd.direct | OpenFOAM Announcements from Other Sources | 0 | January 5, 2016 04:18 |
OpenFOAM15 paraFoam bug | koen | OpenFOAM Bugs | 19 | June 30, 2009 11:46 |