Example #1
0
int main(int argc, char *argv[])
{
#   include "setRootCase.H"
#   include "createTime.H"
//#   include "createMesh.H"
#   include "createDynamicFvMesh.H" // Martin R. Du, Apr 11, 2011
#   include "readGravitationalAcceleration.H"
#   include "readPISOControls.H"
#   include "initContinuityErrs.H"
#   include "createFields.H"
#   include "readTimeControls.H"
#   include "correctPhi.H"
#   include "CourantNo.H"
#   include "setInitialDeltaT.H"

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

    Info<< "\nStarting time loop\n" << endl;

    while (runTime.run())
    {
//#       include "readPISOControls.H"
//#       include "readTimeControls.H"
#       include "readControls.H"
#       include "CourantNo.H"

        // Make the fluxes absolute
        fvc::makeAbsolute(phi, U); // Martin R. Du, Apr 11, 2011

#       include "setDeltaT.H"

        runTime++;

        Info<< "Time = " << runTime.timeName() << nl << endl;

        scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime(); // Martin R. Du, Apr 11, 2011

// Martin R. Du, Apr 11, 2011
////////////////////////////////////////////////////////////////////////////////
        // Do any mesh changes
        mesh.update();

        if (mesh.changing())
        {
            Info<< "Execution time for mesh.update() = "
                << runTime.elapsedCpuTime() - timeBeforeMeshUpdate
                << " s" << endl;
        }

        volScalarField gh("gh", g & mesh.C());
        surfaceScalarField ghf("ghf", g & mesh.Cf());

        if (mesh.changing() && correctPhi)
        {
#           include "correctPhi.H"
        }

//#       include "fEqn.H"

        // Make the fluxes relative to the mesh motion
        fvc::makeRelative(phi, U);

        if (mesh.changing() && checkMeshCourantNo)
        {
#           include "meshCourantNo.H"
        }
////////////////////////////////////////////////////////////////////////////////

        // --- Outer-corrector loop
        for (int oCorr=0; oCorr<nOuterCorr; oCorr++)
        {
        #include "alphaEqnSubCycle.H"

             solve(fvm::ddt(rho) + fvc::div(rhoPhi));

        #include "UEqn.H"

       // --- PISO loop
          for (int corr=0; corr<nCorr; corr++)
          {
           #include "pEqn.H"
          }
         }
		// Correct stress
        visco.correct();

        #include "continuityErrs.H"

//        p = pd + rho*gh;
/*
        if (pd.needReference())
        {
            p += dimensionedScalar
            (
                "p",
                p.dimensions(),
                pRefValue - getRefCellValue(p, pdRefCell)
            );
        }
*/
		strainRate = 
			alpha*Foam::sqrt(2.0)*mag
			(
				symm(fvc::grad(U))
			) 
		   + 
			(scalar(1) - alpha)*Foam::sqrt(2.0)*mag
			(
				symm(fvc::grad(U))
			);

        runTime.write();

        Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;
    }

    Info<< "End\n" << endl;

    return(0);
}
Example #2
0
int main(int argc, char *argv[])
{
	#include "setRootCase.H"
	#include "createTime.H"
	#include "createDynamicFvMesh.H"
	#include "readEnvironmentalProperties.H"
	#include "readPISOControls.H"
	
	#include "initContinuityErrs.H"
	#include "createFields.H"
	#include "readTimeControls.H"
	#include "correctPhi.H"
	#include "CourantNo.H"
	#include "setInitialDeltaT.H"
	#include "initializeForceBalance.H"
	// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
	
	bool firstTimeStep 			= true;
	static vector CgCenter0		= vector(0,0,0);
	scalar myTimeStep			= 0;
	/*
	* Open an output stream, to write the position of the COG into a file.
	* This should be able to be disabled in the future.
	*/
	OFstream of(runTime.path()/"cog.dat");
	of << "# time" << tab << "CgCenter" << tab << "rotationCenter" << tab << "thetaAccel" << tab << "accelMass" << endl;
	OFstream angles(runTime.path()/"angles.dat");
	angles << "# time" << tab << "thetaDiste" << endl;

	Info<< "\nStarting time loop\n" << endl;

	while (runTime.run())
	{
		#include "readForceBalanceControls.H"
		#include "readControls.H"
		#include "CourantNo.H"

        // Make the fluxes absolute
		fvc::makeAbsolute(phi, U);

		#include "setDeltaT.H"
		runTime++;

		Info<< "Time = " << runTime.timeName() << nl << endl;

		scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
		Info<< "Balance"<< endl;
		# include "krafter.H"
        // Does mesh change?
		//#include "krafter.H"
		//runTime.write();
		//return(0);

		mesh.update();
		//runTime.write();
		//return(0);
		//bool meshChanged = mesh.update();
		
		//if(mesh.moving() || meshChanged)
		if (mesh.changing())
		{
			Info<< "Execution time for mesh.update() = "
				<< runTime.elapsedCpuTime() - timeBeforeMeshUpdate
				<< " s" << endl;
		}

		volScalarField gh("gh", g & mesh.C());
		surfaceScalarField ghf("ghf", g & mesh.Cf());

		if (mesh.changing() && correctPhi)
		{
			#include "correctPhi.H"
		}

		// Make the fluxes relative to the mesh motion
		fvc::makeRelative(phi, U); 

		if (mesh.changing() && checkMeshCourantNo)
		{
			#include "meshCourantNo.H"
		}

		twoPhaseProperties.correct();

		#include "gammaEqnSubCycle.H"
		#include "UEqn.H"
		Info << " ueqn... " << endl;

        // --- PISO loop
		for (int corr=0; corr<nCorr; corr++)
		{
			#include "pEqn.H"
		}

		p = pd + rho*gh;

		if (pd.needReference())
		{
			p += dimensionedScalar
				(
				"p",
				p.dimensions(),
				pRefValue - pRefProbe->sample<scalar>("p")()[0]
			);
		}
		turbulence->correct();

		//this gravity maybe commented, not sure how well it works!
		#include"pEqnGravity.H"
		#include "continuityErrs.H"
		runTime.write();

		Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
			<< "  ClockTime = " << runTime.elapsedClockTime() << " s"
			<< nl << endl;
		
		firstTimeStep = false;
		myTimeStep++;
	}
	Info<< "End\n" << endl;
	return(0);
}
Example #3
0
int main(int argc, char *argv[])
{
#   include "setRootCase.H"
#   include "createTime.H"
#   include "createDynamicFvMesh.H"
#   include "readGravitationalAcceleration.H"
#   include "readPIMPLEControls.H"
#   include "initContinuityErrs.H"
#   include "createFields.H"
#   include "readTimeControls.H"
#   include "correctPhi.H"
#   include "CourantNo.H"
#   include "setInitialDeltaT.H"

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

    Info<< "\nStarting time loop\n" << endl;

    while (runTime.run())
    {
#       include "readControls.H"
#       include "CourantNo.H"

        // Make the fluxes absolute
        fvc::makeAbsolute(phi, U);

#       include "setDeltaT.H"

        runTime++;

        Info<< "Time = " << runTime.timeName() << nl << endl;

        bool meshChanged = mesh.update();
        reduce(meshChanged, orOp<bool>());

#       include "volContinuity.H"

        volScalarField gh("gh", g & mesh.C());
        surfaceScalarField ghf("ghf", g & mesh.Cf());

        if (correctPhi && meshChanged)
        {
#           include "correctPhi.H"
        }

        // Make the fluxes relative to the mesh motion
        fvc::makeRelative(phi, U);

        if (checkMeshCourantNo)
        {
#           include "meshCourantNo.H"
        }

        // Pressure-velocity corrector
        int oCorr = 0;
        do
        {
            twoPhaseProperties.correct();

#           include "alphaEqnSubCycle.H"

#           include "UEqn.H"

            // --- PISO loop
            for (int corr = 0; corr < nCorr; corr++)
            {
                    #           include "pEqn.H"
            }

            p = pd + rho*gh;

            if (pd.needReference())
            {
                p += dimensionedScalar
                (
                    "p",
                    p.dimensions(),
                    pRefValue - getRefCellValue(p, pdRefCell)
                );
            }

            turbulence->correct();
        } while (++oCorr < nOuterCorr);

        runTime.write();
        // Write Porous Variables
        if( activePorosity && runTime.outputTime() ) 
        {
            porosity.write();
            porosityIndex.write();
        }

        Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;
    }

    Info<< "End\n" << endl;

    return 0;
}