adaptive mesh refinement with a moving mesh using
play

Adaptive Mesh Refinement With a Moving Mesh using sprayDyMFoam - PowerPoint PPT Presentation

Adaptive Mesh Refinement With a Moving Mesh using sprayDyMFoam Andreas Nygren Chalmers University of Technology Division of Combustion 8-9th of December OpenFoam Course Andreas Nygren OpenFoam Course - December 8-9 2015 Introduction


  1. Adaptive Mesh Refinement With a Moving Mesh using sprayDyMFoam Andreas Nygren Chalmers University of Technology Division of Combustion 8-9th of December OpenFoam Course Andreas Nygren OpenFoam Course - December 8-9 2015

  2. Introduction Motivation • To properly resolve the physics, fine meshes are needed in regions of interest. • It is computationally expensive to make the whole mesh very fine. • For automotive applications moving meshes are used to model piston movement. Andreas Nygren OpenFoam Course - December 8-9 2015

  3. Introduction Learning Outcomes Today you will learn how to: • How to combine the dynamicRefineFvMesh class with thedynamicMotionSolverFvMesh class • Modify sprayDyMFoam to calculate and output the gradient of the velocity field to be used as basis for the adaptive mesh refinement. • How to set-up a case with mesh motion and on-line adaptive mesh refinement. Andreas Nygren OpenFoam Course - December 8-9 2015

  4. Introduction Dynamic Mesh Libraries in OpenFOAM topoChangerFvMesh dynamicFvMesh • linearValveFvMesh • dynamicMotionSolverFvMesh • linearValveLayersFvMesh • dynamicRefineFvMesh • mixerFvMesh • solidBodyMotionFvMesh • movingConeTopoFvMesh • dynamicInkJetFvMesh • rawTopoChangerFvMesh Andreas Nygren OpenFoam Course - December 8-9 2015

  5. Introduction Dynamic Mesh Libraries in OpenFOAM topoChangerFvMesh dynamicFvMesh • linearValveFvMesh • dynamicMotionSolverFvMesh • linearValveLayersFvMesh • dynamicRefineFvMesh • mixerFvMesh • solidBodyMotionFvMesh • movingConeTopoFvMesh • dynamicInkJetFvMesh • rawTopoChangerFvMesh Focus on simple mesh motion with mesh refinement! Andreas Nygren OpenFoam Course - December 8-9 2015

  6. Mesh Refinement with Motion First off! • Combine dynamicRefineFvMesh and dynamicMotionSolverFvMesh • Create a library for both mesh motion and refinement Andreas Nygren OpenFoam Course - December 8-9 2015

  7. Mesh Refinement with Motion Copy and rename Start by copying dynamicRefineFvMesh to your own folder OF30x mkdir -p $FOAM_RUN/../src/motionRefinementFvMesh/ cd $FOAM_RUN/../src/motionRefinementFvMesh/ cp -r $FOAM_SRC/dynamicFvMesh/dynamicRefineFvMesh . mv dynamicRefineFvMesh dynamicMotionSolverRefineFvMesh cd dynamicMotionSolverRefineFvMesh mv dynamicRefineFvMesh.C dynamicMotionSolverRefineFvMesh.C mv dynamicRefineFvMesh.H dynamicMotionSolverRefineFvMesh.H Andreas Nygren OpenFoam Course - December 8-9 2015

  8. Mesh Refinement with Motion Renaming Inside Files • Function calls and includes etc need to be renamed to the new class name • Use the sed command! sed command sed -i s/dynamicRefineFvMesh/dynamicMotionSolverRefineFvMesh/g dynamicMotionSolverRefineFvMesh.C sed -i s/dynamicRefineFvMesh/dynamicMotionSolverRefineFvMesh/g dynamicMotionSolverRefineFvMesh.H • A Convenient and safe way to change the name Andreas Nygren OpenFoam Course - December 8-9 2015

  9. Mesh Refinement with Motion Edit dynamicMotionSolverRefineFvMesh.H Class Declaration for motionSolver namespace Foam { // Add Class Declaration for the Motion Solver Class class motionSolver; Declare a pointer to the motionSolver class dynamicMotionSolverRefineFvMesh : public dynamicFvMesh { //Add declaration for pointer to Motion Solver autoPtr<motionSolver> motionPtr_; protected: Andreas Nygren OpenFoam Course - December 8-9 2015

  10. Mesh Refinement with Motion Edit dynamicMotionSolverRefineFvMesh.C Includes for the Motion Solver #include "dynamicMotionSolverRefineFvMesh.H" #include "addToRunTimeSelectionTable.H" #include "surfaceInterpolate.H" #include "volFields.H" #include "polyTopoChange.H" #include "surfaceFields.H" #include "syncTools.H" #include "pointFields.H" #include "sigFpe.H" #include "cellSet.H" // Add the Following Includes to the Header: #include "motionSolver.H" #include "mapPolyMesh.H" #include "pointField.H" Andreas Nygren OpenFoam Course - December 8-9 2015

  11. Mesh Refinement with Motion Edit dynamicMotionSolverRefineFvMesh.C Pointer to the motionSolver object in the Constructor dynamicFvMesh(io), //define a pointer to the motionSolver Object in the Constructor: motionPtr_(motionSolver::New(*this)), meshCutter_(*this), dumpLevel_(false), nRefinementIterations_(0), protectedCell_(nCells(), 0) function call to move points bool Foam::dynamicMotionSolverRefineFvMesh::update() { // Add a function call to the motionSolver // to move points before refinement. dynamicFvMesh::movePoints(motionPtr_->newPoints()); Andreas Nygren OpenFoam Course - December 8-9 2015

  12. Mesh Refinement with Motion Create a Make folder Copy the Make folder from dynamicFvMesh cd .. cp -r $FOAM_SRC/dynamicFvMesh/Make . Edit Make/files dynamicMotionSolverRefineFvMesh/dynamicMotionSolverRefineFvMesh.C LIB = $(FOAM_USER_LIBBIN)/libmotionRefinementFvMesh Andreas Nygren OpenFoam Course - December 8-9 2015

  13. Mesh Refinement with Motion Make/options link with dynamicFvMesh EXE_INC = \ -I$(LIB_SRC)/triSurface/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude LIB_LIBS = \ -ltriSurface \ -lmeshTools \ -ldynamicMesh \ -ldynamicFvMesh \ -lfiniteVolume Andreas Nygren OpenFoam Course - December 8-9 2015

  14. Mesh Refinement with Motion Clean and Compile! Make wclean wmake Andreas Nygren OpenFoam Course - December 8-9 2015

  15. Mesh Refinement Based on a Gradient • It is known that the mesh should be refined where the gradient of a field is high. • We can base our mesh refinement on the gradient of a field rather than the field itself. • We just need to calculate the gradient of the field every time step • An easy way of doing this is to just modify the solver Andreas Nygren OpenFoam Course - December 8-9 2015

  16. Mesh Refinement Based on a Gradient Copying The Files Copy and rename sprayDyMFoam mkdir -p $FOAM_RUN/../applications/solvers/mySprayDyMFoam cd $FOAM_RUN/../applications/solvers/mySprayDyMFoam cp $FOAM_SOLVERS/lagrangian/sprayFoam/createClouds.H . cp $FOAM_SOLVERS/lagrangian/sprayFoam/createFields.H . cp $FOAM_SOLVERS/lagrangian/sprayFoam/rhoEqn.H . cp $FOAM_SOLVERS/lagrangian/sprayFoam/UEqn.H . cp $FOAM_SOLVERS/lagrangian/sprayFoam/sprayDyMFoam/pEqn.H . cp $FOAM_SOLVERS/lagrangian/sprayFoam/sprayDyMFoam/sprayDyMFoam.C . cp -r $FOAM_SOLVERS/lagrangian/sprayFoam/sprayDyMFoam/Make . mv sprayDyMFoam.C mySprayDyMFoam.C Andreas Nygren OpenFoam Course - December 8-9 2015

  17. Mesh Refinement Based on a Gradient Initialize The Gradient Field Add to createFields.H // Initialize After U! volScalarField UGrad ( IOobject ( "UGrad", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), mag(fvc::grad(U)) ); Andreas Nygren OpenFoam Course - December 8-9 2015

  18. Mesh Refinement Based on a Gradient Modify the Solver Add gradient calculation // Store momentum to set rhoUf for introduced faces. volVectorField rhoU("rhoU", rho*U); // Add the calculation of the velocity // gradient before the mesh changes UGrad = mag(fvc::grad(U)); // Do any mesh changes mesh.update(); Andreas Nygren OpenFoam Course - December 8-9 2015

  19. Mesh Refinement Based on a Gradient Create Make/files, Make/options and compile Make/files - Change Name mySprayDyMFoam.C EXE = $(FOAM_USER_APPBIN)/mySprayDyMFoam Make/options - Change the Path to Two Folders -I$(FOAM_SOLVERS)/lagrangian/reactingParcelFoam \ -I$(FOAM_SOLVERS)/compressible/rhoPimpleFoam/rhoPimpleDyMFoam \ Clean and Compile! wclean wmake Andreas Nygren OpenFoam Course - December 8-9 2015

  20. Case Set-Up Aachen-Bomb case • Static Spray combustion chamber • sprayFoam tutorial case • We can modify it to run with dynamicMotionSolver- RefineFvMesh Andreas Nygren OpenFoam Course - December 8-9 2015

  21. Case Set-Up • Download the aachenBombMotionRefine case. • It has been modified so that the spray chamber will shrink during run-time. • It serve to illustrate the simultaneous mesh motion and refinement. • This is not a ”real spray simulation”. The mesh is to coarse. • We will now go through the modifications and then run the case. Andreas Nygren OpenFoam Course - December 8-9 2015

  22. Case Set-Up Add patches for movingWall patches ( wall walls ( (2 6 5 1) wall movingWall (0 4 7 3) ( (0 1 5 4) (0 1 2 3) ) (7 6 2 3) ) ); wall fixedWall ( (4 5 6 7) ) Andreas Nygren OpenFoam Course - December 8-9 2015

  23. Case Set-Up Modify inital files to correspond to new patches boundaryField { walls { type zeroGradient; } fixedWall { type zeroGradient; } movingWall { type zeroGradient; } } Andreas Nygren OpenFoam Course - December 8-9 2015

  24. Case Set-Up Moving Wall velocity for U movingWall { type movingWallVelocity; value uniform (0 0 0); } Andreas Nygren OpenFoam Course - December 8-9 2015

  25. Case Set-Up pointMotion dimensions [ 0 1 -1 0 0 0 0 ]; internalField uniform 0; boundaryField { movingWall { type uniformFixedValue; uniformValue 1; • Special Inital File value uniform 1; } • Prescribe velocity for mesh walls { points at movingWall type slip; } fixedWall { type uniformFixedValue; uniformValue 0; value uniform 0; } } Andreas Nygren OpenFoam Course - December 8-9 2015

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend