/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: v2312 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; object controlDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // libs (blockMesh); DebugSwitches { //project 1; //searchableExtrudedCircle 1; //projectCurve 1; solution 1; } application simpleFoam; startFrom startTime; startTime 0; stopAt endTime; endTime 100; deltaT 1; writeControl timeStep; writeInterval 10; purgeWrite 0; writeFormat ascii; writePrecision 6; writeCompression off; timeFormat general; timePrecision 6; runTimeModifiable true; functions { relaxationFactor { // Convoluted example - control relaxation factor libs (utilityFunctionObjects); type coded; name relaxationFactor; codeRead #{ const IOobject io ( "banana", mesh().time().constant(), mesh() ); auto* ptr = const_cast(io.db()). findObject(io.name()); if (!ptr) { Info<< "Registering relaxation factor " << io.name() << endl; ptr = new uniformDimensionedScalarField ( io, dimless, 0.80 ); ptr->store(); } #}; codeExecute #{ const IOobject io ( "banana", mesh().time().constant(), mesh() ); auto& val = io.db().lookupObjectRef ( io.name() ); // Ramp a bit val.value() = min(0.99, val.value()+0.01); Info<< "Set relaxation factor to " << val << endl; #}; } } // ************************************************************************* //