diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C index f8b3fff3e9..de487f340e 100644 --- a/src/OpenFOAM/db/Time/Time.C +++ b/src/OpenFOAM/db/Time/Time.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -625,21 +625,25 @@ void Foam::Time::setDeltaT(const scalar deltaT) Foam::TimeState Foam::Time::subCycle(const label nSubCycles) { subCycling_ = true; + prevTimeState_.set(new TimeState(*this)); - TimeState ts = *this; setTime(*this - deltaT(), (timeIndex() - 1)*nSubCycles); deltaT_ /= nSubCycles; deltaT0_ /= nSubCycles; deltaTSave_ = deltaT0_; - return ts; + return prevTimeState(); } -void Foam::Time::endSubCycle(const TimeState& ts) +void Foam::Time::endSubCycle() { - subCycling_ = false; - TimeState::operator=(ts); + if (subCycling_) + { + subCycling_ = false; + TimeState::operator=(prevTimeState()); + prevTimeState_.clear(); + } } diff --git a/src/OpenFOAM/db/Time/Time.H b/src/OpenFOAM/db/Time/Time.H index 9f935091d8..694013ac17 100644 --- a/src/OpenFOAM/db/Time/Time.H +++ b/src/OpenFOAM/db/Time/Time.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -127,6 +127,9 @@ protected: //- Is the time currently being sub-cycled? bool subCycling_; + //- If time is being sub-cycled this is the previous TimeState + autoPtr prevTimeState_; + //- Time directory name format static fmtflags format_; @@ -347,6 +350,18 @@ public: return functionObjects_; } + //- Return true if time currently being sub-cycled, otherwise false + bool subCycling() const + { + return subCycling_; + } + + //- Return previous TimeState if time is being sub-cycled + const TimeState& prevTimeState() const + { + return prevTimeState_(); + } + // Check @@ -427,8 +442,8 @@ public: //- Set time to sub-cycle for the given number of steps virtual TimeState subCycle(const label nSubCycles); - //- Reset time after sub-cycling back to given TimeState - virtual void endSubCycle(const TimeState&); + //- Reset time after sub-cycling back to previous TimeState + virtual void endSubCycle(); //- Return non-const access to the list of function objects functionObjectList& functionObjects() diff --git a/src/OpenFOAM/db/Time/subCycleTime.C b/src/OpenFOAM/db/Time/subCycleTime.C index 344c881f9d..def50ab412 100644 --- a/src/OpenFOAM/db/Time/subCycleTime.C +++ b/src/OpenFOAM/db/Time/subCycleTime.C @@ -32,9 +32,10 @@ Foam::subCycleTime::subCycleTime(Time& t, const label nSubCycles) : time_(t), nSubCycles_(nSubCycles), - subCycleIndex_(0), - initialTimeState_(time_.subCycle(nSubCycles_)) -{} + subCycleIndex_(0) +{ + time_.subCycle(nSubCycles_); +} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // @@ -55,7 +56,7 @@ bool Foam::subCycleTime::end() const void Foam::subCycleTime::endSubCycle() { - time_.endSubCycle(initialTimeState_); + time_.endSubCycle(); } diff --git a/src/OpenFOAM/db/Time/subCycleTime.H b/src/OpenFOAM/db/Time/subCycleTime.H index 01082625fb..22dafe18cf 100644 --- a/src/OpenFOAM/db/Time/subCycleTime.H +++ b/src/OpenFOAM/db/Time/subCycleTime.H @@ -55,7 +55,6 @@ class subCycleTime label nSubCycles_; label subCycleIndex_; - TimeState initialTimeState_; public: diff --git a/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C b/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C index 3455b37804..bf72983e4a 100644 --- a/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C +++ b/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -34,6 +34,7 @@ License #include "fvcSurfaceIntegrate.H" #include "slicedSurfaceFields.H" #include "syncTools.H" + #include "fvm.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -107,7 +108,7 @@ void Foam::MULES::explicitSolve { psiIf = ( - mesh.V0()*rho.oldTime()*psi0/(deltaT*mesh.V()) + mesh.Vsc0()*rho.oldTime()*psi0/(deltaT*mesh.Vsc()) + Su.field() - psiIf )/(rho/deltaT - Sp.field()); @@ -325,7 +326,8 @@ void Foam::MULES::limiter const unallocLabelList& owner = mesh.owner(); const unallocLabelList& neighb = mesh.neighbour(); - const scalarField& V = mesh.V(); + tmp tVsc = mesh.Vsc(); + const scalarField& V = tVsc(); const scalar deltaT = mesh.time().deltaTValue(); const scalarField& phiBDIf = phiBD; @@ -452,14 +454,16 @@ void Foam::MULES::limiter if (mesh.moving()) { + tmp V0 = mesh.Vsc0(); + psiMaxn = V*((rho/deltaT - Sp)*psiMaxn - Su) - - (mesh.V0()/deltaT)*rho.oldTime()*psi0 + - (V0()/deltaT)*rho.oldTime()*psi0 + sumPhiBD; psiMinn = V*(Su - (rho/deltaT - Sp)*psiMinn) - + (mesh.V0()/deltaT)*rho.oldTime()*psi0 + + (V0/deltaT)*rho.oldTime()*psi0 - sumPhiBD; } else diff --git a/src/finiteVolume/fvMesh/fvMesh.H b/src/finiteVolume/fvMesh/fvMesh.H index 64e4d87f3e..8b75da3800 100644 --- a/src/finiteVolume/fvMesh/fvMesh.H +++ b/src/finiteVolume/fvMesh/fvMesh.H @@ -269,6 +269,12 @@ public: //- Return old-old-time cell volumes const DimensionedField& V00() const; + //- Return sub-cycle cell volumes + tmp > Vsc() const; + + //- Return sub-cycl old-time cell volumes + tmp > Vsc0() const; + //- Return cell face area vectors const surfaceVectorField& Sf() const; diff --git a/src/finiteVolume/fvMesh/fvMeshGeometry.C b/src/finiteVolume/fvMesh/fvMeshGeometry.C index 536b21c565..b7d0946f2a 100644 --- a/src/finiteVolume/fvMesh/fvMeshGeometry.C +++ b/src/finiteVolume/fvMesh/fvMeshGeometry.C @@ -285,6 +285,63 @@ const volScalarField::DimensionedInternalField& fvMesh::V00() const } +tmp fvMesh::Vsc() const +{ + if (moving() && time().subCycling()) + { + const TimeState& ts = time(); + const TimeState& ts0 = time().prevTimeState(); + + scalar tFrac = + ( + ts.value() - (ts0.value() - ts0.deltaTValue()) + )/ts0.deltaTValue(); + + if (tFrac < (1 - SMALL)) + { + return V0() + tFrac*(V() - V0()); + } + else + { + return V(); + } + } + else + { + return V(); + } +} + + +tmp fvMesh::Vsc0() const +{ + if (moving() && time().subCycling()) + { + const TimeState& ts = time(); + const TimeState& ts0 = time().prevTimeState(); + + scalar t0Frac = + ( + (ts.value() - ts.deltaTValue()) + - (ts0.value() - ts0.deltaTValue()) + )/ts0.deltaTValue(); + + if (t0Frac > SMALL) + { + return V0() + t0Frac*(V() - V0()); + } + else + { + return V0(); + } + } + else + { + return V0(); + } +} + + const surfaceVectorField& fvMesh::Sf() const { if (!SfPtr_) diff --git a/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/pointDisplacement b/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/pointDisplacement index a994b15b89..c808bc16bc 100644 --- a/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/pointDisplacement +++ b/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/pointDisplacement @@ -37,7 +37,8 @@ boundaryField centreOfMass (0.5 0.5 0.5); momentOfInertia (0.08622222 0.08622222 0.144); mass 9.6; - rhoInf 1; // for forces calculation + rhoInf 1; + report on; value uniform (0 0 0); } } diff --git a/tutorials/multiphase/interDyMFoam/ras/floatingObject/constant/polyMesh/boundary b/tutorials/multiphase/interDyMFoam/ras/floatingObject/constant/polyMesh/boundary index 62fd629b04..1543006b7a 100644 --- a/tutorials/multiphase/interDyMFoam/ras/floatingObject/constant/polyMesh/boundary +++ b/tutorials/multiphase/interDyMFoam/ras/floatingObject/constant/polyMesh/boundary @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 1.6.x | +| \\ / O peration | Version: dev | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ diff --git a/tutorials/multiphase/interDyMFoam/ras/floatingObject/system/controlDict b/tutorials/multiphase/interDyMFoam/ras/floatingObject/system/controlDict index 436dca3c27..b58fa81303 100644 --- a/tutorials/multiphase/interDyMFoam/ras/floatingObject/system/controlDict +++ b/tutorials/multiphase/interDyMFoam/ras/floatingObject/system/controlDict @@ -17,7 +17,7 @@ FoamFile application interDyMFoam; -startFrom startTime; +startFrom latestTime; startTime 0; @@ -29,7 +29,7 @@ deltaT 0.01; writeControl adjustableRunTime; -writeInterval 0.025; +writeInterval 0.1; purgeWrite 0; @@ -47,9 +47,9 @@ runTimeModifiable yes; adjustTimeStep yes; -maxCo 0.2; +maxCo 0.5; -maxDeltaT 0.025; +maxDeltaT 0.01; libs ( diff --git a/tutorials/multiphase/interDyMFoam/ras/floatingObject/system/fvSolution b/tutorials/multiphase/interDyMFoam/ras/floatingObject/system/fvSolution index 9edecbae82..55cffd160e 100644 --- a/tutorials/multiphase/interDyMFoam/ras/floatingObject/system/fvSolution +++ b/tutorials/multiphase/interDyMFoam/ras/floatingObject/system/fvSolution @@ -20,7 +20,7 @@ solvers cellDisplacement { solver GAMG; - tolerance 1e-08; + tolerance 1e-5; relTol 0; smoother GaussSeidel; cacheAgglomeration true; @@ -35,7 +35,7 @@ solvers preconditioner { preconditioner GAMG; - tolerance 1e-05; + tolerance 1e-5; relTol 0; smoother DICGaussSeidel; nPreSweeps 0; @@ -55,7 +55,7 @@ solvers p { solver GAMG; - tolerance 1e-08; + tolerance 1e-8; relTol 0.01; smoother DIC; nPreSweeps 0; @@ -73,7 +73,7 @@ solvers preconditioner { preconditioner GAMG; - tolerance 2e-09; + tolerance 1e-8; relTol 0; nVcycles 2; smoother DICGaussSeidel; @@ -86,7 +86,7 @@ solvers mergeLevels 1; } - tolerance 2e-09; + tolerance 1e-8; relTol 0; maxIter 20; } @@ -95,18 +95,18 @@ solvers { solver smoothSolver; smoother GaussSeidel; - tolerance 1e-06; + tolerance 1e-6; relTol 0; nSweeps 1; } - "(k|epsilon|R|nuTilda)" + "(k|epsilon|omega|R|nuTilda)" { - $U; - tolerance 1e-08; + solver PBiCG; + preconditioner DILU; + tolerance 1e-8; relTol 0; } - } PISO @@ -115,14 +115,14 @@ PISO nCorrectors 2; nNonOrthogonalCorrectors 0; nAlphaCorr 1; - nAlphaSubCycles 1; - cAlpha 1.5; + nAlphaSubCycles 3; + cAlpha 1; correctPhi yes; } relaxationFactors { - U 1; + "(U|k|epsilon|omega|R|nuTilda)" 1; }