diff --git a/applications/test/directMappedPatch/Make/files b/applications/test/directMappedPatch/Make/files new file mode 100644 index 0000000000..65f39a47b8 --- /dev/null +++ b/applications/test/directMappedPatch/Make/files @@ -0,0 +1,4 @@ + +testDirectMappedPatch.C + +EXE = $(FOAM_USER_APPBIN)/testDirectMappedPatch diff --git a/applications/test/directMappedPatch/Make/options b/applications/test/directMappedPatch/Make/options new file mode 100644 index 0000000000..d76bd10c8f --- /dev/null +++ b/applications/test/directMappedPatch/Make/options @@ -0,0 +1,6 @@ +EXE_INC = \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude + +EXE_LIBS = \ + -lfiniteVolume diff --git a/applications/test/directMappedPatch/testDirectMappedPatch.C b/applications/test/directMappedPatch/testDirectMappedPatch.C new file mode 100644 index 0000000000..dd27ff6955 --- /dev/null +++ b/applications/test/directMappedPatch/testDirectMappedPatch.C @@ -0,0 +1,127 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + testDirectMappedPatch + +Description + Test direct mapped b.c. by mapping face centres (mesh.C().boundaryField()). + +\*---------------------------------------------------------------------------*/ + + +#include "argList.H" +#include "fvMesh.H" +#include "volFields.H" +#include "meshTools.H" +#include "Time.H" +#include "OFstream.H" +#include "volFields.H" +#include "directMappedFixedValueFvPatchFields.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +// Main program: + +int main(int argc, char *argv[]) +{ +# include "addTimeOptions.H" +# include "setRootCase.H" +# include "createTime.H" +# include "createMesh.H" + + wordList patchFieldTypes + ( + mesh.boundaryMesh().size(), + calculatedFvPatchVectorField::typeName + ); + + forAll(mesh.boundaryMesh(), patchI) + { + if (isA(mesh.boundaryMesh()[patchI])) + { + patchFieldTypes[patchI] = + directMappedFixedValueFvPatchVectorField::typeName; + } + } + + Pout<< "patchFieldTypes:" << patchFieldTypes << endl; + + volVectorField cc + ( + IOobject + ( + "cc", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedVector("zero", dimLength, vector::zero), + patchFieldTypes + ); + + cc.internalField() = mesh.C().internalField(); + cc.boundaryField().updateCoeffs(); + + forAll(cc.boundaryField(), patchI) + { + if + ( + isA + ( + cc.boundaryField()[patchI] + ) + ) + { + Pout<< "Detected a directMapped patch:" << patchI << endl; + + OFstream str(mesh.boundaryMesh()[patchI].name() + ".obj"); + Pout<< "Writing mapped values to " << str.name() << endl; + + label vertI = 0; + const fvPatchVectorField& fvp = cc.boundaryField()[patchI]; + + forAll(fvp, i) + { + meshTools::writeOBJ(str, fvp.patch().Cf()[i]); + vertI++; + meshTools::writeOBJ(str, fvp[i]); + vertI++; + str << "l " << vertI-1 << ' ' << vertI << nl; + } + } + } + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index 706866bd2a..67b16d75ea 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C @@ -170,6 +170,13 @@ int main(int argc, char *argv[]) const dictionary& layerDict = meshDict.subDict("addLayersControls"); + const scalar mergeDist = getMergeDistance + ( + mesh, + readScalar(meshDict.lookup("mergeTolerance")) + ); + + // Debug // ~~~~~ @@ -192,8 +199,9 @@ int main(int argc, char *argv[]) IOobject ( "abc", // dummy name - mesh.time().constant(), // directory - "triSurface", // instance + //mesh.time().constant(), // instance + mesh.time().findInstance("triSurface", word::null),// instance + "triSurface", // local mesh.time(), // registry IOobject::MUST_READ, IOobject::NO_WRITE @@ -235,6 +243,33 @@ int main(int argc, char *argv[]) << mesh.time().cpuTimeIncrement() << " s" << nl << endl; + // Refinement engine + // ~~~~~~~~~~~~~~~~~ + + Info<< nl + << "Determining initial surface intersections" << nl + << "-----------------------------------------" << nl + << endl; + + // Main refinement engine + meshRefinement meshRefiner + ( + mesh, + mergeDist, // tolerance used in sorting coordinates + surfaces, // for surface intersection refinement + shells // for volume (inside/outside) refinement + ); + Info<< "Calculated surface intersections in = " + << mesh.time().cpuTimeIncrement() << " s" << nl << endl; + + // Some stats + meshRefiner.printMeshInfo(debug, "Initial mesh"); + + meshRefiner.write + ( + debug&meshRefinement::OBJINTERSECTIONS, + mesh.time().path()/mesh.time().timeName() + ); // Add all the surface regions as patches @@ -265,9 +300,8 @@ int main(int argc, char *argv[]) forAll(regNames, i) { - label patchI = meshRefinement::addPatch + label patchI = meshRefiner.addMeshedPatch ( - mesh, regNames[i], wallPolyPatch::typeName ); @@ -308,45 +342,10 @@ int main(int argc, char *argv[]) << exit(FatalError); } - const scalar mergeDist = getMergeDistance - ( - mesh, - readScalar(meshDict.lookup("mergeTolerance")) - ); - - // Mesh distribution engine (uses tolerance to reconstruct meshes) fvMeshDistribute distributor(mesh, mergeDist); - // Refinement engine - // ~~~~~~~~~~~~~~~~~ - - Info<< nl - << "Determining initial surface intersections" << nl - << "-----------------------------------------" << nl - << endl; - - // Main refinement engine - meshRefinement meshRefiner - ( - mesh, - mergeDist, // tolerance used in sorting coordinates - surfaces, // for surface intersection refinement - shells // for volume (inside/outside) refinement - ); - Info<< "Calculated surface intersections in = " - << mesh.time().cpuTimeIncrement() << " s" << nl << endl; - - // Some stats - meshRefiner.printMeshInfo(debug, "Initial mesh"); - - meshRefiner.write - ( - debug&meshRefinement::OBJINTERSECTIONS, - mesh.time().path()/mesh.time().timeName() - ); - @@ -403,11 +402,7 @@ int main(int argc, char *argv[]) if (wantLayers) { - autoLayerDriver layerDriver - ( - meshRefiner, - globalToPatch - ); + autoLayerDriver layerDriver(meshRefiner); // Layer addition parameters layerParameters layerParams(layerDict, mesh.boundaryMesh()); @@ -435,7 +430,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return 0; + return(0); } diff --git a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriver.C b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriver.C index 5bb4a0ee2d..9081ceb3ee 100644 --- a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriver.C +++ b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriver.C @@ -292,6 +292,40 @@ Foam::autoHexMeshDriver::autoHexMeshDriver meshRefinement::checkCoupledFaceZones(mesh_); + // Refinement engine + // ~~~~~~~~~~~~~~~~~ + + { + Info<< nl + << "Determining initial surface intersections" << nl + << "-----------------------------------------" << nl + << endl; + + // Main refinement engine + meshRefinerPtr_.reset + ( + new meshRefinement + ( + mesh, + mergeDist_, // tolerance used in sorting coordinates + surfaces(), + shells() + ) + ); + Info<< "Calculated surface intersections in = " + << mesh_.time().cpuTimeIncrement() << " s" << endl; + + // Some stats + meshRefinerPtr_().printMeshInfo(debug_, "Initial mesh"); + + meshRefinerPtr_().write + ( + debug_&meshRefinement::OBJINTERSECTIONS, + mesh_.time().path()/mesh_.time().timeName() + ); + } + + // Add all the surface regions as patches // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -319,9 +353,8 @@ Foam::autoHexMeshDriver::autoHexMeshDriver forAll(regNames, i) { - label patchI = meshRefinement::addPatch + label patchI = meshRefinerPtr_().addMeshedPatch ( - mesh, regNames[i], wallPolyPatch::typeName ); @@ -404,40 +437,6 @@ Foam::autoHexMeshDriver::autoHexMeshDriver // Mesh distribution engine (uses tolerance to reconstruct meshes) distributorPtr_.reset(new fvMeshDistribute(mesh_, mergeDist_)); } - - - // Refinement engine - // ~~~~~~~~~~~~~~~~~ - - { - Info<< nl - << "Determining initial surface intersections" << nl - << "-----------------------------------------" << nl - << endl; - - // Main refinement engine - meshRefinerPtr_.reset - ( - new meshRefinement - ( - mesh, - mergeDist_, // tolerance used in sorting coordinates - surfaces(), - shells() - ) - ); - Info<< "Calculated surface intersections in = " - << mesh_.time().cpuTimeIncrement() << " s" << endl; - - // Some stats - meshRefinerPtr_().printMeshInfo(debug_, "Initial mesh"); - - meshRefinerPtr_().write - ( - debug_&meshRefinement::OBJINTERSECTIONS, - mesh_.time().path()/mesh_.time().timeName() - ); - } } @@ -522,11 +521,7 @@ void Foam::autoHexMeshDriver::doMesh() const dictionary& shrinkDict = dict_.subDict("shrinkDict"); PtrList surfaceDicts(dict_.lookup("surfaces")); - autoLayerDriver layerDriver - ( - meshRefinerPtr_(), - globalToPatch_ - ); + autoLayerDriver layerDriver(meshRefinerPtr_()); // Get all the layer specific params layerParameters layerParams diff --git a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C index 01ab952c16..55e35269dd 100644 --- a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C +++ b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C @@ -75,7 +75,7 @@ Foam::label Foam::autoLayerDriver::mergePatchFacesUndo labelHashSet boundaryCells(mesh.nFaces()-mesh.nInternalFaces()); { - labelList patchIDs(meshRefinement::addedPatches(globalToPatch_)); + labelList patchIDs(meshRefiner_.meshedPatches()); const polyBoundaryMesh& patches = mesh.boundaryMesh(); @@ -2446,14 +2446,9 @@ void Foam::autoLayerDriver::getLayerCellsFaces // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::autoLayerDriver::autoLayerDriver -( - meshRefinement& meshRefiner, - const labelList& globalToPatch -) +Foam::autoLayerDriver::autoLayerDriver(meshRefinement& meshRefiner) : - meshRefiner_(meshRefiner), - globalToPatch_(globalToPatch) + meshRefiner_(meshRefiner) {} diff --git a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H index 164fd88ce0..1256957006 100644 --- a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H +++ b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H @@ -101,9 +101,6 @@ class autoLayerDriver //- Mesh+surface meshRefinement& meshRefiner_; - //- From surface region to patch - const labelList globalToPatch_; - // Private Member Functions @@ -509,11 +506,7 @@ public: // Constructors //- Construct from components - autoLayerDriver - ( - meshRefinement& meshRefiner, - const labelList& globalToPatch - ); + autoLayerDriver(meshRefinement& meshRefiner); // Member Functions diff --git a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoRefineDriver.C b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoRefineDriver.C index 9c4e0a17c5..d9c205bfca 100644 --- a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoRefineDriver.C +++ b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoRefineDriver.C @@ -680,7 +680,7 @@ void Foam::autoRefineDriver::mergePatchFaces ( Foam::cos(45*mathematicalConstant::pi/180.0), Foam::cos(45*mathematicalConstant::pi/180.0), - meshRefinement::addedPatches(globalToPatch_) + meshRefiner_.meshedPatches() ); if (debug) diff --git a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C index 011417c29e..f27ccdb9f3 100644 --- a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C +++ b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C @@ -830,35 +830,6 @@ Foam::scalarField Foam::autoSnapDriver::calcSnapDistance } -//// Invert globalToPatch_ to get the patches related to surfaces. -//Foam::labelList Foam::autoSnapDriver::getSurfacePatches() const -//{ -// // Set of patches originating from surface -// labelHashSet surfacePatchSet(globalToPatch_.size()); -// -// forAll(globalToPatch_, i) -// { -// if (globalToPatch_[i] != -1) -// { -// surfacePatchSet.insert(globalToPatch_[i]); -// } -// } -// -// const fvMesh& mesh = meshRefiner_.mesh(); -// -// DynamicList