|
[Sponsors] |
Force solver to stop if dictionary is not found in functionObject |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
February 24, 2022, 06:46 |
Force solver to stop if dictionary is not found in functionObject
|
#1 |
New Member
Join Date: Feb 2022
Posts: 25
Rep Power: 4 |
Hello,
I am trying to create a solver as a functionObject (FO) utility in OF2106. As such, I am trying to read values from a IOdictionary in the constant directory. I have modified the public inheritance of the FO to inherit publicly form the IOdictionary class. Code:
class myFOSolver : public fvMeshFunctionObject, public IOdictionary { With "standard" initialization: Code:
IOdictionary ( IOobject ( "myPropertiesDict", mesh_.time().constant(), mesh_, IOobject::MUST_READ, IOobject::NO_WRITE ) ); I created a function to initialize the dictionary as: Code:
Foam::IOdictionary Foam::functionObjects::myFOSolver::init() { bool checkDict ( IOobject ( "myPropertiesDict", mesh_.time().constant(), mesh_, IOobject::MUST_READ, IOobject::NO_WRITE, false ).typeHeaderOk<IOdictionary>() ); if (!checkDict) { FatalErrorInFunction << "Dictionary does not exist in " << mesh_.time().constant() << "directory " << nl << nl << abort(FatalError); } IOdictionary dict ( IOobject ( "myPropertiesDict", mesh_.time().constant(), mesh_, IOobject::MUST_READ, IOobject::NO_WRITE ) ); return dict; } I just get the following: Code:
Starting time loop --> FOAM Warning : cannot find file "/home/bananaTrick/Desktop/myCase/constant/myPropertiesDict Last edited by theBananaTrick; February 24, 2022 at 13:30. |
|
February 24, 2022, 15:34 |
|
#2 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,695
Rep Power: 40 |
What it actually does is surrounding the construction in a try/catch block and discards the function object out of the list is there was a problem. You can customise that for all function objects or individual ones in the functions specification.
https://www.openfoam.com/documentati...t.html#details you have the choice of default/warn/error/strict. So many options because everyone has a different situation, or some function objects might be critical but others just "nice to have" |
|
February 24, 2022, 15:42 |
|
#3 |
New Member
Join Date: Feb 2022
Posts: 25
Rep Power: 4 |
Thank you for the help!
With this, I also cleared several lines of code |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[RapidCFD] Discussion thread on how to install and use RapidCFD | newoscar | OpenFOAM Community Contributions | 88 | May 17, 2024 09:39 |
Running UDF with Supercomputer | roi247 | FLUENT | 4 | October 15, 2015 13:41 |
injection problem | Mark New | FLUENT | 0 | August 4, 2013 01:30 |
Regarding FoamX running Kindly help out | hariya03 | OpenFOAM Pre-Processing | 0 | April 18, 2008 04:26 |
Problem with rhoSimpleFoam | matteo_gautero | OpenFOAM Running, Solving & CFD | 0 | February 28, 2008 06:51 |