CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums

auto reconstructPar

Register Blogs Community New Posts Updated Threads Search

Rate this Entry

auto reconstructPar

Posted March 22, 2016 at 01:33 by kkk
Updated March 22, 2016 at 04:56 by kkk

It is very troublesome to do reconstructPar after calculation of interFoam, pimpleFoam or other unsteady solvers.
So I created a codeStream script executing reconstructPar at each writeTime.
If you have some trouble of reconstructPar, please try this.

Just add follow to controlDict.

Code:
functions 
( 
    autoReconstructPar
    { 
        functionObjectLibs ("libutilityFunctionObjects.so"); 
        type coded; 
        redirectType autoReconstructPar;
        outputControl outputTime; 
        codeOptions
        #{

        #}; 
        code 
        #{
			IOdictionary autoReconstructParProperties
			(
			    IOobject
			    (
			        "autoReconstructParProperties",
			        mesh().time().constant(),
			        mesh(),
			        IOobject::MUST_READ_IF_MODIFIED,
			        IOobject::NO_WRITE
			    )
			);
			bool autoReconstructPar =autoReconstructParProperties.lookupOrDefault<Switch>("autoReconstructPar", false);
			bool backGroundExecution =autoReconstructParProperties.lookupOrDefault<Switch>("backGroundExecution", true);
			string reconstructParFields=autoReconstructParProperties.lookup("reconstructParFields");

			if (Pstream::parRun())
			{
				if (autoReconstructPar)
				{
					if (Pstream::master())
				    {
				        if (backGroundExecution)
				        {
				            Info<< "Execute reconstructPar on background." <<endl;
							system("reconstructPar -time " + mesh().time().timeName() +" -fields \'" + reconstructParFields +"\'>.rec.log&");
				        }
				        else
				        {
							system("reconstructPar -time " + mesh().time().timeName() +" -fields \'" + reconstructParFields +"\'");
				        }
				    }
				}
			}
        #}; 
    }
);
And put autoReconstructParProperties in constant.
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.1.x                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "constant";
    object      autoReconstructParProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

autoReconstructPar    true;

backGroundExecution       true;

reconstructParFields      "(p alpha1 U)";
Posted in OpenFOAM
Views 5038 Comments 0 Edit Tags Email Blog Entry
« Prev     Main     Next »
Total Comments 0

Comments

 

All times are GMT -4. The time now is 00:49.