/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |				
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  9                                   	
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    format      ascii;
    class       dictionary;
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application     pimpleFoam;

startFrom       startTime;
//startFrom       latestTime;

startTime       0;

stopAt          endTime;

///////////////////////////////////////////////////////

//For flow field solution

endTime         100;
deltaT          0.001;
//deltaT          0.01;
//deltaT          0.02;
//deltaT          0.05;

writeControl    adjustableRunTime;
writeInterval   0.05;

///////////////////////////////////////////////////////

purgeWrite      0;

writeFormat     ascii;

writePrecision  8;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable yes;

adjustTimeStep  yes;

maxCo           2;
maxDeltaT       0.1;

// ************************************************************************* //

functions
{

///////////////////////////////////////////////////////////////////////////
    inMassFlow
    {
        type            surfaceFieldValue;
        functionObjectLibs ("libfieldFunctionObjects.so");
        enabled         true;

		//writeControl     outputTime;
		writeControl   timeStep;
		writeInterval  1;

        log             true;

        writeFields     false;

        regionType      patch;
        name      		in;

		operation       sum;
        fields
        (
            phi
        );
    }
///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////
    outMassFlow
    {
        type            surfaceFieldValue;
        functionObjectLibs ("libfieldFunctionObjects.so");
        enabled         true;

		//writeControl     outputTime;

		writeControl   timeStep;
		writeInterval  1;

        log             yes;

        writeFields     false;

		//writeFields     true;
		//surfaceFormat   raw;

        regionType          patch;
        name      out;

		operation       sum;
        fields
        (
            phi
        );
    }
///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////

forces_object
{
	type forces;
	functionObjectLibs ("libforces.so");

	//writeControl outputTime;
	writeControl   timeStep;
	writeInterval  1;

	//// Patches to sample
	//patches ("body1" "body2" "body3");
	patches ("cylinder");

	//// Name of fields
	pName p;
	Uname U;

	//// Density
	rho rhoInf;
	rhoInf 1.;

	//// Centre of rotation
	CofR (0 0 0);
}

///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////

forceCoeffs_object
{
	// rhoInf - reference density
	// CofR - Centre of rotation
	// dragDir - Direction of drag coefficient
	// liftDir - Direction of lift coefficient
	// pitchAxis - Pitching moment axis
	// magUinf - free stream velocity magnitude
	// lRef - reference length
	// Aref - reference area
	type forceCoeffs;
	functionObjectLibs ("libforces.so");
	//patches ("body1" "body2" "body3");
	patches (cylinder);

	pName p;
	Uname U;
	rho rhoInf;
	rhoInf 1.0;

	//// Dump to file
	log true;

	CofR (0.0 0 0);
	liftDir (0 1 0);
	dragDir (1 0 0);
	pitchAxis (0 0 1);
	magUInf 1.0;
	lRef 1;           // reference lenght for moments!!!
	Aref 2.0;         // reference area 1 for 2d

        writeControl   timeStep;
        writeInterval  1;
}

///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////

minmaxdomain_scalar
{
    type            volFieldValue;
    libs            ("libfieldFunctionObjects.so");

    enabled         true;   //true or false
    log             true;   //write to screen
    
    //writeControl    writeTime;
    writeControl    timeStep;
    writeInterval   1;

    writeFields     false;  //write solution to field value - Not needed when only reporting value to screen

    writeLocation   true;   //write location in the output file

    //mode component;

    regionType      all;

    operation       none;

    fields
    (
        p
    );
}

minmaxdomain_vector
{
    type            volFieldValue;
    libs            ("libfieldFunctionObjects.so");

    enabled         true;   //true or false
    log             true;   //write to screen
    
    //writeControl    writeTime;
    writeControl    timeStep;
    writeInterval   1;

    writeFields     false;  //write solution to field value - Not needed when only reporting value to screen

    writeLocation   true;   //write location in the output file

    //mode component;

    regionType      all;

    operation       none;

    fields
    (
        U
    );
}

mindomain_scalar
{
    $minmaxdomain_scalar
    operation       min;
}

mindomain_vector
{
    $minmaxdomain_vector
    operation       minMag;
}

maxdomain_scalar
{
    $minmaxdomain_scalar
    operation       max;
}

maxdomain_vector
{
    $minmaxdomain_vector
    operation       maxMag;
}

///////////////////////////////////////////////////////////////////////////

};
