diff --git a/src/dynamicFvMesh/Make/files b/src/dynamicFvMesh/Make/files index 9f5609fddd1a0e8252363c4afe72603e9f16c485..7f579610835e19fd6234d84bef01ebde4bf4020b 100644 --- a/src/dynamicFvMesh/Make/files +++ b/src/dynamicFvMesh/Make/files @@ -2,6 +2,7 @@ dynamicFvMesh/dynamicFvMesh.C dynamicFvMesh/dynamicFvMeshNew.C staticFvMesh/staticFvMesh.C dynamicMotionSolverFvMesh/dynamicMotionSolverFvMesh.C +dynamicMultiMotionSolverFvMesh/dynamicMultiMotionSolverFvMesh.C dynamicInkJetFvMesh/dynamicInkJetFvMesh.C dynamicRefineFvMesh/dynamicRefineFvMesh.C dynamicMotionSolverListFvMesh/dynamicMotionSolverListFvMesh.C diff --git a/src/dynamicFvMesh/dynamicMultiMotionSolverFvMesh/dynamicMultiMotionSolverFvMesh.C b/src/dynamicFvMesh/dynamicMultiMotionSolverFvMesh/dynamicMultiMotionSolverFvMesh.C new file mode 100644 index 0000000000000000000000000000000000000000..1309e0e99ed89198fd3278ef3aa0180441b37cb8 --- /dev/null +++ b/src/dynamicFvMesh/dynamicMultiMotionSolverFvMesh/dynamicMultiMotionSolverFvMesh.C @@ -0,0 +1,201 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 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 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "dynamicMultiMotionSolverFvMesh.H" +#include "addToRunTimeSelectionTable.H" +#include "volFields.H" +#include "boolList.H" +#include "syncTools.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(dynamicMultiMotionSolverFvMesh, 0); + addToRunTimeSelectionTable + ( + dynamicFvMesh, + dynamicMultiMotionSolverFvMesh, + IOobject + ); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::dynamicMultiMotionSolverFvMesh::dynamicMultiMotionSolverFvMesh +( + const IOobject& io +) +: + dynamicFvMesh(io) +{ + IOdictionary dynDict + ( + IOobject + ( + "dynamicMeshDict", + io.time().constant(), + *this, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE, + false + ) + ); + const dictionary& dynamicMeshCoeffs = dynDict.subDict(typeName + "Coeffs"); + + zoneIDs_.setSize(dynamicMeshCoeffs.size()); + motionPtr_.setSize(dynamicMeshCoeffs.size()); + pointIDs_.setSize(dynamicMeshCoeffs.size()); + label zoneI = 0; + + forAllConstIter(dictionary, dynamicMeshCoeffs, iter) + { + if (iter().isDict()) + { + const dictionary& subDict = iter().dict(); + + word zoneName(subDict.lookup("cellZone")); + + zoneIDs_[zoneI] = cellZones().findZoneID(zoneName); + + if (zoneIDs_[zoneI] == -1) + { + FatalIOErrorInFunction + ( + dynamicMeshCoeffs + ) << "Cannot find cellZone named " << zoneName + << ". Valid zones are " << cellZones().names() + << exit(FatalIOError); + } + + IOobject io(dynDict); + io.readOpt() = IOobject::NO_READ; + + motionPtr_.set + ( + zoneI, + motionSolver::New + ( + *this, + IOdictionary(io, subDict) + ) + ); + + // Collect points of cell zone. + const cellZone& cz = cellZones()[zoneIDs_[zoneI]]; + + boolList movePts(nPoints(), false); + + forAll(cz, i) + { + label cellI = cz[i]; + const cell& c = cells()[cellI]; + forAll(c, j) + { + const face& f = faces()[c[j]]; + forAll(f, k) + { + label pointI = f[k]; + movePts[pointI] = true; + } + } + } + + syncTools::syncPointList(*this, movePts, orEqOp<bool>(), false); + + DynamicList<label> ptIDs(nPoints()); + forAll(movePts, i) + { + if (movePts[i]) + { + ptIDs.append(i); + } + } + + pointIDs_[zoneI].transfer(ptIDs); + + Info<< "Applying motionSolver " << motionPtr_[zoneI].type() + << " to " + << returnReduce(pointIDs_[zoneI].size(), sumOp<label>()) + << " points of cellZone " << zoneName << endl; + + zoneI++; + } + } + zoneIDs_.setSize(zoneI); + motionPtr_.setSize(zoneI); + pointIDs_.setSize(zoneI); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::dynamicMultiMotionSolverFvMesh::~dynamicMultiMotionSolverFvMesh() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::dynamicMultiMotionSolverFvMesh::update() +{ + pointField transformedPts(points()); + + forAll(motionPtr_, zoneI) + { + tmp<pointField> tnewPoints(motionPtr_[zoneI].newPoints()); + const pointField& newPoints = tnewPoints(); + + const labelList& zonePoints = pointIDs_[zoneI]; + forAll(zonePoints, i) + { + label pointI = zonePoints[i]; + transformedPts[pointI] = newPoints[pointI]; + } + } + + fvMesh::movePoints(transformedPts); + + static bool hasWarned = false; + + if (foundObject<volVectorField>("U")) + { + const_cast<volVectorField&>(lookupObject<volVectorField>("U")) + .correctBoundaryConditions(); + } + else if (!hasWarned) + { + hasWarned = true; + + WarningInFunction + << "Did not find volVectorField U." + << " Not updating U boundary conditions." << endl; + } + + return true; +} + + +// ************************************************************************* // diff --git a/src/dynamicFvMesh/dynamicMultiMotionSolverFvMesh/dynamicMultiMotionSolverFvMesh.H b/src/dynamicFvMesh/dynamicMultiMotionSolverFvMesh/dynamicMultiMotionSolverFvMesh.H new file mode 100644 index 0000000000000000000000000000000000000000..d4906ed40d9d00f32a71d55098ec8d34b0d5ddc8 --- /dev/null +++ b/src/dynamicFvMesh/dynamicMultiMotionSolverFvMesh/dynamicMultiMotionSolverFvMesh.H @@ -0,0 +1,107 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 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 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 <http://www.gnu.org/licenses/>. + +Class + Foam::dynamicMultiMotionSolverFvMesh + +Description + Mesh motion described per cellZone. Individual motion solvers solve + over whole domain but are only applied per cellZone. + +SourceFiles + dynamicMultiMotionSolverFvMesh.C + +\*---------------------------------------------------------------------------*/ + +#ifndef dynamicMultiMotionSolverFvMesh_H +#define dynamicMultiMotionSolverFvMesh_H + +#include "dynamicFvMesh.H" +#include "motionSolver.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class dynamicMultiMotionSolverFvMesh Declaration +\*---------------------------------------------------------------------------*/ + +class dynamicMultiMotionSolverFvMesh +: + public dynamicFvMesh +{ + // Private data + + //- The motion control function + PtrList<motionSolver> motionPtr_; + + //- Specified cellZones + labelList zoneIDs_; + + //- Points to move per cellZone + labelListList pointIDs_; + + + // Private Member Functions + + //- Disallow default bitwise copy construct + dynamicMultiMotionSolverFvMesh(const dynamicMultiMotionSolverFvMesh&); + + //- Disallow default bitwise assignment + void operator=(const dynamicMultiMotionSolverFvMesh&); + + +public: + + //- Runtime type information + TypeName("dynamicMultiMotionSolverFvMesh"); + + + // Constructors + + //- Construct from IOobject + dynamicMultiMotionSolverFvMesh(const IOobject& io); + + + //- Destructor + ~dynamicMultiMotionSolverFvMesh(); + + + // Member Functions + + //- Update the mesh for both mesh motion and topology change + virtual bool update(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //