Skip to content
Snippets Groups Projects
controlDict 2.51 KiB
Newer Older
  • Learn to ignore specific revisions
  • /*--------------------------------*- C++ -*----------------------------------*\
    | =========                 |                                                 |
    | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
    
    |  \\    /   O peration     | Version:  v2506                                 |
    
    |   \\  /    A nd           | Website:  www.openfoam.com                      |
    
    |    \\/     M anipulation  |                                                 |
    \*---------------------------------------------------------------------------*/
    FoamFile
    {
        version     2.0;
        format      ascii;
        class       dictionary;
        object      controlDict;
    }
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    
    
    application     moveDynamicMesh;
    
    
    startFrom       startTime;
    
    startTime       0;
    
    stopAt          endTime;
    
    
    
    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(),
    
                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(),
    
                );
    
                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;
            #};
        }
    }
    
    
    
    // ************************************************************************* //