/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . Application snappyHexMesh Description Automatic split hex mesher. Refines and snaps to surface. \*---------------------------------------------------------------------------*/ #include "argList.H" #include "Time.H" #include "fvMesh.H" #include "autoRefineDriver.H" #include "autoSnapDriver.H" #include "autoLayerDriver.H" #include "searchableSurfaces.H" #include "refinementSurfaces.H" #include "refinementFeatures.H" #include "shellSurfaces.H" #include "decompositionMethod.H" #include "noDecomp.H" #include "fvMeshDistribute.H" #include "wallPolyPatch.H" #include "refinementParameters.H" #include "snapParameters.H" #include "layerParameters.H" #include "faceSet.H" #include "motionSmoother.H" using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Check writing tolerance before doing any serious work scalar getMergeDistance(const polyMesh& mesh, const scalar mergeTol) { const boundBox& meshBb = mesh.bounds(); scalar mergeDist = mergeTol * meshBb.mag(); Info<< nl << "Overall mesh bounding box : " << meshBb << nl << "Relative tolerance : " << mergeTol << nl << "Absolute matching distance : " << mergeDist << nl << endl; // check writing tolerance if (mesh.time().writeFormat() == IOstream::ASCII) { const scalar writeTol = std::pow ( scalar(10.0), -scalar(IOstream::defaultPrecision()) ); if (mergeTol < writeTol) { FatalErrorIn("getMergeDistance(const polyMesh&, const dictionary&)") << "Your current settings specify ASCII writing with " << IOstream::defaultPrecision() << " digits precision." << nl << "Your merging tolerance (" << mergeTol << ") is finer than this." << nl << "Change to binary writeFormat, " << "or increase the writePrecision" << endl << "or adjust the merge tolerance (mergeTol)." << exit(FatalError); } } return mergeDist; } // Write mesh and additional information void writeMesh ( const string& msg, const meshRefinement& meshRefiner, const label debug ) { const fvMesh& mesh = meshRefiner.mesh(); meshRefiner.printMeshInfo(debug, msg); Info<< "Writing mesh to time " << meshRefiner.timeName() << endl; meshRefiner.write(meshRefinement::MESH|meshRefinement::SCALARLEVELS, ""); if (debug & meshRefinement::OBJINTERSECTIONS) { meshRefiner.write ( meshRefinement::OBJINTERSECTIONS, mesh.time().path()/meshRefiner.timeName() ); } Info<< "Wrote mesh in = " << mesh.time().cpuTimeIncrement() << " s." << endl; } int main(int argc, char *argv[]) { # include "addOverwriteOption.H" # include "setRootCase.H" # include "createTime.H" runTime.functionObjects().off(); # include "createMesh.H" Info<< "Read mesh in = " << runTime.cpuTimeIncrement() << " s" << endl; const bool overwrite = args.optionFound("overwrite"); // Check patches and faceZones are synchronised mesh.boundaryMesh().checkParallelSync(true); meshRefinement::checkCoupledFaceZones(mesh); // Read meshing dictionary IOdictionary meshDict ( IOobject ( "snappyHexMeshDict", runTime.system(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE ) ); // all surface geometry const dictionary& geometryDict = meshDict.subDict("geometry"); // refinement parameters const dictionary& refineDict = meshDict.subDict("castellatedMeshControls"); // mesh motion and mesh quality parameters const dictionary& motionDict = meshDict.subDict("meshQualityControls"); // snap-to-surface parameters const dictionary& snapDict = meshDict.subDict("snapControls"); // layer addition parameters const dictionary& layerDict = meshDict.subDict("addLayersControls"); // absolute merge distance const scalar mergeDist = getMergeDistance ( mesh, readScalar(meshDict.lookup("mergeTolerance")) ); // Read decomposePar dictionary dictionary decomposeDict; { if (Pstream::parRun()) { decomposeDict = IOdictionary ( IOobject ( "decomposeParDict", runTime.system(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE ) ); } else { decomposeDict.add("method", "none"); decomposeDict.add("numberOfSubdomains", 1); } } // Debug // ~~~~~ const label debug = meshDict.lookupOrDefault