Newer
Older
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application moveDynamicMesh;
startFrom startTime;
startTime 0;
stopAt endTime;
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().thisDb()
auto* ptr =
io.db().getObjectPtr<uniformDimensionedScalarField>(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().thisDb()
);
auto& val =
io.db().lookupObjectRef<uniformDimensionedScalarField>
(
io.name()
);
// Ramp a bit
val.value() = min(0.99, val.value()+0.01);
Info<< "Set relaxation factor to " << val << endl;
#};
}
}
// ************************************************************************* //