From b1c25026e696f0f8e7936c94a6ff854dfef19c3d Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Tue, 19 Aug 2014 15:42:49 +0100 Subject: [PATCH] Added new solver potentialDyMFoam --- .../solvers/basic/potentialDyMFoam/Make/files | 3 + .../basic/potentialDyMFoam/Make/options | 14 ++ .../basic/potentialDyMFoam/correctPhi.H | 57 +++++++ .../basic/potentialDyMFoam/createFields.H | 50 ++++++ .../basic/potentialDyMFoam/potentialDyMFoam.C | 145 ++++++++++++++++++ .../basic/potentialFoam/potentialFoam.C | 5 +- 6 files changed, 271 insertions(+), 3 deletions(-) create mode 100644 applications/solvers/basic/potentialDyMFoam/Make/files create mode 100644 applications/solvers/basic/potentialDyMFoam/Make/options create mode 100644 applications/solvers/basic/potentialDyMFoam/correctPhi.H create mode 100644 applications/solvers/basic/potentialDyMFoam/createFields.H create mode 100644 applications/solvers/basic/potentialDyMFoam/potentialDyMFoam.C diff --git a/applications/solvers/basic/potentialDyMFoam/Make/files b/applications/solvers/basic/potentialDyMFoam/Make/files new file mode 100644 index 000000000..2cc44fbe6 --- /dev/null +++ b/applications/solvers/basic/potentialDyMFoam/Make/files @@ -0,0 +1,3 @@ +potentialDyMFoam.C + +EXE = $(FOAM_APPBIN)/potentialDyMFoam diff --git a/applications/solvers/basic/potentialDyMFoam/Make/options b/applications/solvers/basic/potentialDyMFoam/Make/options new file mode 100644 index 000000000..c5d3bb76c --- /dev/null +++ b/applications/solvers/basic/potentialDyMFoam/Make/options @@ -0,0 +1,14 @@ +EXE_INC = \ + -I$(LIB_SRC)/dynamicMesh/dynamicFvMesh/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude + +EXE_LIBS = \ + -ldynamicFvMesh \ + -ldynamicMesh \ + -lengine \ + -lmeshTools \ + -lfiniteVolume \ + -llduSolvers \ + -L$(MESQUITE_LIB_DIR) -lmesquite diff --git a/applications/solvers/basic/potentialDyMFoam/correctPhi.H b/applications/solvers/basic/potentialDyMFoam/correctPhi.H new file mode 100644 index 000000000..9a32c5ecc --- /dev/null +++ b/applications/solvers/basic/potentialDyMFoam/correctPhi.H @@ -0,0 +1,57 @@ +{ + wordList pcorrTypes(p.boundaryField().types()); + + for (label i=0; i. + +Application + potentialDyMFoam + +Description + Transient solver for potential flow with dynamic mesh. + +Author + Hrvoje Jasak, Wikki Ltd. All rights reserved. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "dynamicFvMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + argList::validOptions.insert("resetU", ""); + argList::validOptions.insert("writep", ""); + +# include "setRootCase.H" +# include "createTime.H" +# include "createDynamicFvMesh.H" +# include "createFields.H" +# include "initTotalVolume.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.loop()) + { +# include "readPISOControls.H" +# include "checkTotalVolume.H" + + runTime++; + + Info<< "Time = " << runTime.timeName() << nl << endl; + + bool meshChanged = mesh.update(); + reduce(meshChanged, orOp()); + + p.internalField() = 0; + + if (args.optionFound("resetU")) + { + U.internalField() = vector::zero; + } + +# include "volContinuity.H" + + // Solve potential flow equations + adjustPhi(phi, U, p); + + for (int nonOrth = 0; nonOrth <= nNonOrthCorr; nonOrth++) + { + p.storePrevIter(); + + fvScalarMatrix pEqn + ( + fvm::laplacian + ( + dimensionedScalar + ( + "1", + dimTime/p.dimensions()*dimensionSet(0, 2, -2, 0, 0), + 1 + ), + p + ) + == + fvc::div(phi) + ); + + pEqn.setReference(pRefCell, pRefValue); + pEqn.solve(); + + if (nonOrth == nNonOrthCorr) + { + phi -= pEqn.flux(); + } + else + { + p.relax(); + } + } + + Info<< "continuity error = " + << mag(fvc::div(phi))().weightedAverage(mesh.V()).value() + << endl; + + U = fvc::reconstruct(phi); + U.correctBoundaryConditions(); + + Info<< "Interpolated U error = " + << (sqrt(sum(sqr((fvc::interpolate(U) & mesh.Sf()) - phi))) + /sum(mesh.magSf())).value() + << endl; + + // Calculate velocity magnitude + { + volScalarField magU = mag(U); + + Info<< "mag(U): max: " << gMax(magU.internalField()) + << " min: " << gMin(magU.internalField()) << endl; + } + + runTime.write(); + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "End\n" << endl; + + return(0); +} + + +// ************************************************************************* // diff --git a/applications/solvers/basic/potentialFoam/potentialFoam.C b/applications/solvers/basic/potentialFoam/potentialFoam.C index 367f8aa51..46a8965ff 100644 --- a/applications/solvers/basic/potentialFoam/potentialFoam.C +++ b/applications/solvers/basic/potentialFoam/potentialFoam.C @@ -32,7 +32,6 @@ Description #include "fvCFD.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) @@ -53,7 +52,7 @@ int main(int argc, char *argv[]) adjustPhi(phi, U, p); - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + for (int nonOrth = 0; nonOrth <= nNonOrthCorr; nonOrth++) { p.storePrevIter(); @@ -102,7 +101,7 @@ int main(int argc, char *argv[]) { volScalarField magU = mag(U); - Info << "mag(U): max: " << gMax(magU.internalField()) + Info<< "mag(U): max: " << gMax(magU.internalField()) << " min: " << gMin(magU.internalField()) << endl; }