diff --git a/applications/solvers/incompressible/icoDyMFoam/Make/options b/applications/solvers/incompressible/icoDyMFoam/Make/options index 460426a5b..c603cef83 100644 --- a/applications/solvers/incompressible/icoDyMFoam/Make/options +++ b/applications/solvers/incompressible/icoDyMFoam/Make/options @@ -1,6 +1,6 @@ EXE_INC = \ - -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ - -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/dynamicFvMesh/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/dynamicMesh/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude diff --git a/src/dynamicMesh/meshMotion/Allwmake b/src/dynamicMesh/meshMotion/Allwmake index adbd2f347..29aa3df33 100755 --- a/src/dynamicMesh/meshMotion/Allwmake +++ b/src/dynamicMesh/meshMotion/Allwmake @@ -5,6 +5,7 @@ set -x # Make meshMotion solvers wmake libso fvMotionSolver wmake libso RBFMotionSolver +wmake libso mesquiteMotionSolver (cd tetDecompositionMotionSolver ; ./Allwmake) # ----------------------------------------------------------------- end-of-file diff --git a/src/dynamicMesh/meshMotion/AllwmakeLnInclude b/src/dynamicMesh/meshMotion/AllwmakeLnInclude index 7881b2a92..445bd7a59 100755 --- a/src/dynamicMesh/meshMotion/AllwmakeLnInclude +++ b/src/dynamicMesh/meshMotion/AllwmakeLnInclude @@ -4,3 +4,4 @@ set -x wmakeLnInclude fvMotionSolver wmakeLnInclude RBFMotionSolver +wmakeLnInclude mesquiteMotionSolver diff --git a/src/dynamicMesh/meshMotion/mesquiteMotionSolver/Make/files b/src/dynamicMesh/meshMotion/mesquiteMotionSolver/Make/files new file mode 100644 index 000000000..4950d82d8 --- /dev/null +++ b/src/dynamicMesh/meshMotion/mesquiteMotionSolver/Make/files @@ -0,0 +1,3 @@ +mesquiteMotionSolver.C + +LIB = $(FOAM_LIBBIN)/libmesquiteMotionSolver diff --git a/src/dynamicMesh/meshMotion/mesquiteMotionSolver/Make/options b/src/dynamicMesh/meshMotion/mesquiteMotionSolver/Make/options new file mode 100644 index 000000000..fcd2872f5 --- /dev/null +++ b/src/dynamicMesh/meshMotion/mesquiteMotionSolver/Make/options @@ -0,0 +1,9 @@ +EXE_INC = \ + -I$(WM_THIRD_PARTY_DIR)/mesquite-2.1.2/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/dynamicMesh/lnInclude \ + +LIB_LIBS = \ + -lmeshTools \ + -ldynamicMesh \ + -lmesquite diff --git a/src/dynamicMesh/meshMotion/mesquiteMotionSolver/mesquiteMotionSolver.C b/src/dynamicMesh/meshMotion/mesquiteMotionSolver/mesquiteMotionSolver.C new file mode 100644 index 000000000..f8a13b105 --- /dev/null +++ b/src/dynamicMesh/meshMotion/mesquiteMotionSolver/mesquiteMotionSolver.C @@ -0,0 +1,2011 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright held by original author + \\/ 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 + +\*---------------------------------------------------------------------------*/ + +#include "mesquiteMotionSolver.H" +#include "Random.H" +#include "IOmanip.H" +#include "globalMeshData.H" +#include "processorPolyPatch.H" +#include "addToRunTimeSelectionTable.H" +#include "polyMesh.H" + +#include "DimensionedField.H" +#include "pointPatchField.H" +#include "pointMesh.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(mesquiteMotionSolver, 0); + addToRunTimeSelectionTable + ( + motionSolver, + mesquiteMotionSolver, + dictionary + ); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +mesquiteMotionSolver::mesquiteMotionSolver +( + const polyMesh& mesh +) +: + motionSolver(mesh), + Mesh_(mesh), + twoDMesh_(mesh.nGeometricD() == 2 ? true : false), + nPoints_(mesh.nPoints()), + nCells_(mesh.nCells()), + nAuxPoints_(0), + nAuxCells_(0), + surfaceSmoothing_(false), + volumeCorrection_(false), + volCorrTolerance_(1e-20), + volCorrMaxIter_(100), + tolerance_(1e-4), + nSweeps_(1), + surfInterval_(1), + relax_(1.0), + vtxCoords_(NULL), + cellToNode_(NULL), + fixFlags_(NULL), + refPoints_ + ( + IOobject + ( + "refPoints", + mesh.time().timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + mesh.points() + ), + oldVolume_(0.0) +{ + // Read options from the dictionary + readOptions(); + + // Initialize connectivity arrays for Mesquite + initArrays(); +} + +mesquiteMotionSolver::mesquiteMotionSolver +( + const polyMesh& mesh, + Istream& msData +) +: + motionSolver(mesh), + Mesh_(mesh), + twoDMesh_(mesh.nGeometricD() == 2 ? true : false), + nPoints_(mesh.nPoints()), + nCells_(mesh.nCells()), + nAuxPoints_(0), + nAuxCells_(0), + surfaceSmoothing_(false), + volumeCorrection_(false), + volCorrTolerance_(1e-20), + volCorrMaxIter_(100), + tolerance_(1e-4), + nSweeps_(1), + surfInterval_(1), + relax_(1.0), + vtxCoords_(NULL), + cellToNode_(NULL), + fixFlags_(NULL), + refPoints_ + ( + IOobject + ( + "refPoints", + mesh.time().timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + mesh.points() + ), + oldVolume_(0.0) +{ + // Read options from the dictionary + readOptions(); + + // Initialize connectivity arrays for Mesquite + initArrays(); +} + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +mesquiteMotionSolver::~mesquiteMotionSolver() +{ + clearOut(); +} + +// Clear out addressing +void mesquiteMotionSolver::clearOut() +{ + // Delete memory pointers + delete [] vtxCoords_; + delete [] cellToNode_; + delete [] fixFlags_; + + // Reset to NULL + vtxCoords_ = NULL; + cellToNode_ = NULL; + fixFlags_ = NULL; +} + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +// Read options from the dictionary +void mesquiteMotionSolver::readOptions() +{ + // Fetch the sub-dictionary + const dictionary& optionsDict = subDict("mesquiteOptions"); + + // Check if any slip patches are specified + if (optionsDict.found("slipPatches") || twoDMesh_) + { + labelHashSet slipPatchIDs; + + // For 2D meshes, add all patches + if (twoDMesh_) + { + forAll(mesh().boundaryMesh(), patchI) + { + slipPatchIDs.insert(patchI); + } + + surfaceSmoothing_ = true; + } + else + { + wordList slipPatches = optionsDict.subDict("slipPatches").toc(); + + forAll(slipPatches, wordI) + { + word& patchName = slipPatches[wordI]; + + slipPatchIDs.insert + ( + mesh().boundaryMesh().findPatchID(patchName) + ); + + surfaceSmoothing_ = true; + } + } + + // Check if a tolerance has been specified + if (optionsDict.found("tolerance")) + { + tolerance_ = readScalar(optionsDict.lookup("tolerance")); + } + + // Check if volume correction is enabled + if (optionsDict.found("volumeCorrection")) + { + volumeCorrection_ = + ( + readBool(optionsDict.lookup("volumeCorrection")) + ); + } + + // Check if volume correction tolerance is specified + if (optionsDict.found("volCorrTolerance")) + { + volCorrTolerance_ = + ( + readScalar(optionsDict.lookup("volCorrTolerance")) + ); + } + + // Check if volume correction maxIter is specified + if (optionsDict.found("volCorrMaxIter")) + { + volCorrMaxIter_ = readLabel(optionsDict.lookup("volCorrMaxIter")); + } + + // Check if multiple sweeps have been requested + if (optionsDict.found("nSweeps")) + { + nSweeps_ = readLabel(optionsDict.lookup("nSweeps")); + } + + // Check if a surface smoothing interval has been specified + if (optionsDict.found("surfInterval")) + { + surfInterval_ = readLabel(optionsDict.lookup("surfInterval")); + } + + // Check if a relaxation factor is specified + if (optionsDict.found("relaxationFactor")) + { + relax_ = readScalar(optionsDict.lookup("relaxationFactor")); + } + + // Check if coupled patches exist. + if (optionsDict.found("coupledPatches")) + { + const dictionary& coupledPatches = + ( + optionsDict.subDict("coupledPatches") + ); + + const polyBoundaryMesh& boundary = mesh().boundaryMesh(); + + // Determine master and slave patches + forAllConstIter(dictionary, coupledPatches, dIter) + { + const dictionary& dictI = dIter().dict(); + + // Lookup the master / slave patches + word masterPatch = dictI.lookup("master"); + word slavePatch = dictI.lookup("slave"); + + // Determine patch indices + label mPatch = boundary.findPatchID(masterPatch); + label sPatch = boundary.findPatchID(slavePatch); + + if (mPatch == -1 && sPatch == -1) + { + continue; + } + + // Add to the patch-list, if the entry hasn't been found. + if (!slipPatchIDs.found(sPatch) && (sPatch != -1)) + { + slipPatchIDs.insert(sPatch); + } + + // Add to the list if entries are legitimate + if + ( + mPatch != sPatch && + boundary[mPatch].size() == boundary[sPatch].size() + ) + { + patchCoupling_.insert(mPatch, sPatch); + } + else + { + FatalErrorIn("void mesquiteMotionSolver::readOptions()") + << " Coupled patches are wrongly specified." << nl + << " Master: " << mPatch << ":" << masterPatch << nl + << " Slave: " << sPatch << ":" << slavePatch << nl + << abort(FatalError); + } + } + } + + // Extract the final slip-patch list + pIDs_ = slipPatchIDs.toc(); + } + + if (twoDMesh_) + { + return; + } + + // The following applies only to 3D meshes + Mesquite::MsqError err; + + // Add existing metrics to the hash-table + qMetricTable_.insert + ( + "AspectRatioGamma", + autoPtr + ( + new Mesquite::AspectRatioGammaQualityMetric + ) + ); + + qMetricTable_.insert + ( + "ConditionNumber", + autoPtr + ( + new Mesquite::ConditionNumberQualityMetric + ) + ); + + qMetricTable_.insert + ( + "InverseMeanRatio", + autoPtr + ( + new Mesquite::IdealWeightInverseMeanRatio + ) + ); + + qMetricTable_.insert + ( + "MeanRatio", + autoPtr + ( + new Mesquite::IdealWeightMeanRatio + ) + ); + + qMetricTable_.insert + ( + "VertexConditionNumber", + autoPtr + ( + new Mesquite::VertexConditionNumberQualityMetric + ) + ); + + // Read the optimization metric + qMetric_ = word(optionsDict.lookup("optMetric")); + + if (!qMetricTable_.found(qMetric_)) + { + FatalErrorIn("void mesquiteMotionSolver::readOptions()") + << "Unrecognized quality metric: " << qMetric_ << nl + << "Available metrics are: " << nl << qMetricTable_.toc() + << abort(FatalError); + } + else + { + Info << "Selecting quality metric: " << qMetric_ << endl; + } + + // Define the objective function table, + // and add existing possibilities + HashTable