diff --git a/src/Allwmake b/src/Allwmake index 7a393240ea..a411ae3027 100755 --- a/src/Allwmake +++ b/src/Allwmake @@ -46,12 +46,13 @@ wmake $targetType dynamicMesh # Compile scotchDecomp, metisDecomp etc. parallel/Allwmake $targetType $* -wmake $targetType fvMeshMovers -wmake $targetType fvMeshTopoChangers -wmake $targetType fvMeshDistributors wmake $targetType conversion wmake $targetType sampling +wmake $targetType fvMeshMovers +fvMeshTopoChangers/Allwmake $targetType $* +wmake $targetType fvMeshDistributors + wmake $targetType ODE wmake $targetType randomProcesses diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index 8b2cc10812..f8af019a3e 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C @@ -866,7 +866,7 @@ const Foam::labelIOList& Foam::polyMesh::tetBasePtIs() const instance(), meshSubDir, *this, - IOobject::READ_IF_PRESENT, + IOobject::NO_READ, IOobject::NO_WRITE ), polyMeshTetDecomposition::findFaceBasePts(*this) diff --git a/src/dynamicMesh/motionSolvers/componentVelocity/componentVelocityMotionSolver.C b/src/dynamicMesh/motionSolvers/componentVelocity/componentVelocityMotionSolver.C index e999d84df6..72e195025d 100644 --- a/src/dynamicMesh/motionSolvers/componentVelocity/componentVelocityMotionSolver.C +++ b/src/dynamicMesh/motionSolvers/componentVelocity/componentVelocityMotionSolver.C @@ -119,7 +119,10 @@ void Foam::componentVelocityMotionSolver::mapMesh ( const polyMeshMap& map ) -{} +{ + pointMotionU_ == Zero; + pointMotionU_.correctBoundaryConditions(); +} void Foam::componentVelocityMotionSolver::distribute diff --git a/src/dynamicMesh/motionSolvers/velocity/velocityMotionSolver.C b/src/dynamicMesh/motionSolvers/velocity/velocityMotionSolver.C index 70381a29c0..f7d6196973 100644 --- a/src/dynamicMesh/motionSolvers/velocity/velocityMotionSolver.C +++ b/src/dynamicMesh/motionSolvers/velocity/velocityMotionSolver.C @@ -81,7 +81,10 @@ void Foam::velocityMotionSolver::topoChange(const polyTopoChangeMap& map) void Foam::velocityMotionSolver::mapMesh(const polyMeshMap& map) -{} +{ + pointMotionU_ == Zero; + pointMotionU_.correctBoundaryConditions(); +} void Foam::velocityMotionSolver::distribute(const polyDistributionMap&) diff --git a/src/dynamicMesh/motionSolvers/velocity/velocityMotionSolver.H b/src/dynamicMesh/motionSolvers/velocity/velocityMotionSolver.H index 1583e34583..eb786f49c4 100644 --- a/src/dynamicMesh/motionSolvers/velocity/velocityMotionSolver.H +++ b/src/dynamicMesh/motionSolvers/velocity/velocityMotionSolver.H @@ -109,7 +109,7 @@ public: //- Update local data for geometry changes virtual void movePoints(const pointField&); - //- Update local data for topology changes + //- Update corresponding to the given map virtual void topoChange(const polyTopoChangeMap&); //- Update from another mesh using the given map diff --git a/src/finiteVolume/fvMesh/fvMesh.C b/src/finiteVolume/fvMesh/fvMesh.C index f5127ba72f..e59e2046c4 100644 --- a/src/finiteVolume/fvMesh/fvMesh.C +++ b/src/finiteVolume/fvMesh/fvMesh.C @@ -286,45 +286,45 @@ Foam::fvMesh::fvMesh(const IOobject& io, const bool changers) topoChanger_.set(fvMeshTopoChanger::New(*this).ptr()); distributor_.set(fvMeshDistributor::New(*this).ptr()); mover_.set(fvMeshMover::New(*this).ptr()); - } - // Check the existence of the cell volumes and read if present - // and set the storage of V00 - if (fileHandler().isFile(time().timePath()/"V0")) - { - V0Ptr_ = new DimensionedField - ( - IOobject + // Check the existence of the cell volumes and read if present + // and set the storage of V00 + if (fileHandler().isFile(time().timePath()/"V0")) + { + V0Ptr_ = new DimensionedField ( - "V0", - time().timeName(), - *this, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ), - *this - ); + IOobject + ( + "V0", + time().timeName(), + *this, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ), + *this + ); - V00(); - } + V00(); + } - // Check the existence of the mesh fluxes and read if present - if (fileHandler().isFile(time().timePath()/"meshPhi")) - { - phiPtr_ = new surfaceScalarField - ( - IOobject + // Check the existence of the mesh fluxes and read if present + if (fileHandler().isFile(time().timePath()/"meshPhi")) + { + phiPtr_ = new surfaceScalarField ( - "meshPhi", - time().timeName(), - *this, - IOobject::MUST_READ, - IOobject::NO_WRITE, - true - ), - *this - ); + IOobject + ( + "meshPhi", + time().timeName(), + *this, + IOobject::MUST_READ, + IOobject::NO_WRITE, + true + ), + *this + ); + } } } diff --git a/src/functionObjects/field/layerAverage/layerAverage.C b/src/functionObjects/field/layerAverage/layerAverage.C index 4fc6310da8..51a98df1d9 100644 --- a/src/functionObjects/field/layerAverage/layerAverage.C +++ b/src/functionObjects/field/layerAverage/layerAverage.C @@ -440,13 +440,6 @@ bool Foam::functionObjects::layerAverage::write() } -void Foam::functionObjects::layerAverage::topoChange(const polyTopoChangeMap&) -{ - Info<< type() << " " << name() << ":" << nl; - calcLayers(); -} - - void Foam::functionObjects::layerAverage::movePoints(const polyMesh&) { Info<< type() << " " << name() << ":" << nl; @@ -454,4 +447,18 @@ void Foam::functionObjects::layerAverage::movePoints(const polyMesh&) } +void Foam::functionObjects::layerAverage::topoChange(const polyTopoChangeMap&) +{ + Info<< type() << " " << name() << ":" << nl; + calcLayers(); +} + + +void Foam::functionObjects::layerAverage::mapMesh(const polyMeshMap&) +{ + Info<< type() << " " << name() << ":" << nl; + calcLayers(); +} + + // ************************************************************************* // diff --git a/src/functionObjects/field/layerAverage/layerAverage.H b/src/functionObjects/field/layerAverage/layerAverage.H index 1c503f97f5..eff19e227d 100644 --- a/src/functionObjects/field/layerAverage/layerAverage.H +++ b/src/functionObjects/field/layerAverage/layerAverage.H @@ -201,11 +201,14 @@ public: //- Calculate and write the graphs virtual bool write(); + //- Update for mesh point-motion + virtual void movePoints(const polyMesh&); + //- Update topology using the given map virtual void topoChange(const polyTopoChangeMap&); - //- Update for mesh point-motion - virtual void movePoints(const polyMesh&); + //- Update from another mesh using the given map + virtual void mapMesh(const polyMeshMap&); // Member Operators diff --git a/src/functionObjects/field/streamlines/streamlines.C b/src/functionObjects/field/streamlines/streamlines.C index c6fd40fa0c..07253ab60a 100644 --- a/src/functionObjects/field/streamlines/streamlines.C +++ b/src/functionObjects/field/streamlines/streamlines.C @@ -585,6 +585,16 @@ bool Foam::functionObjects::streamlines::write() } +void Foam::functionObjects::streamlines::movePoints(const polyMesh& mesh) +{ + if (&mesh == &mesh_) + { + // Moving mesh affects the search tree + read(dict_); + } +} + + void Foam::functionObjects::streamlines::topoChange ( const polyTopoChangeMap& map @@ -597,13 +607,12 @@ void Foam::functionObjects::streamlines::topoChange } -void Foam::functionObjects::streamlines::movePoints(const polyMesh& mesh) +void Foam::functionObjects::streamlines::mapMesh +( + const polyMeshMap& map +) { - if (&mesh == &mesh_) - { - // Moving mesh affects the search tree - read(dict_); - } + read(dict_); } diff --git a/src/functionObjects/field/streamlines/streamlines.H b/src/functionObjects/field/streamlines/streamlines.H index 7635c230dd..20d1721a5b 100644 --- a/src/functionObjects/field/streamlines/streamlines.H +++ b/src/functionObjects/field/streamlines/streamlines.H @@ -238,11 +238,14 @@ public: //- Calculate and write the streamlines virtual bool write(); + //- Update for mesh point-motion + virtual void movePoints(const polyMesh&); + //- Update topology using the given map virtual void topoChange(const polyTopoChangeMap&); - //- Update for mesh point-motion - virtual void movePoints(const polyMesh&); + //- Update from another mesh using the given map + virtual void mapMesh(const polyMeshMap&); // Member Operators diff --git a/src/fvMeshTopoChangers/Allwmake b/src/fvMeshTopoChangers/Allwmake new file mode 100755 index 0000000000..8107681231 --- /dev/null +++ b/src/fvMeshTopoChangers/Allwmake @@ -0,0 +1,10 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory + +# Parse arguments for library compilation +. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments + +wmake $targetType +wmake $targetType meshToMesh + +#------------------------------------------------------------------------------ diff --git a/src/fvMeshTopoChangers/meshToMesh/Make/files b/src/fvMeshTopoChangers/meshToMesh/Make/files new file mode 100644 index 0000000000..1109f0bcb4 --- /dev/null +++ b/src/fvMeshTopoChangers/meshToMesh/Make/files @@ -0,0 +1,4 @@ +fvMeshTopoChangersMeshToMesh.C +meshToMeshAdjustTimeStep/meshToMeshAdjustTimeStepFunctionObject.C + +LIB = $(FOAM_LIBBIN)/libmeshToMeshTopoChanger diff --git a/src/fvMeshTopoChangers/meshToMesh/Make/options b/src/fvMeshTopoChangers/meshToMesh/Make/options new file mode 100644 index 0000000000..18c83d5bed --- /dev/null +++ b/src/fvMeshTopoChangers/meshToMesh/Make/options @@ -0,0 +1,13 @@ +EXE_INC = \ + -I$(LIB_SRC)/triSurface/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude + +LIB_LIBS = \ + -ltriSurface \ + -lmeshTools \ + -lsampling \ + -ldynamicMesh \ + -lfiniteVolume diff --git a/src/fvMeshTopoChangers/meshToMesh/MeshToMeshMapGeometricFields.H b/src/fvMeshTopoChangers/meshToMesh/MeshToMeshMapGeometricFields.H new file mode 100644 index 0000000000..e3eec2cb14 --- /dev/null +++ b/src/fvMeshTopoChangers/meshToMesh/MeshToMeshMapGeometricFields.H @@ -0,0 +1,289 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2022 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 . + +Class + Foam::MeshToMeshMapGeometricFields + +Description + Generic internal field mapper. For "real" mapping, add template + specialisations for mapping of internal fields depending on mesh + type. + +\*---------------------------------------------------------------------------*/ + +#ifndef MeshToMeshMapGeometricFields_H +#define MeshToMeshMapGeometricFields_H + +#include "polyMesh.H" +#include "meshToMesh.H" +#include "fvPatchFieldMapper.H" +#include "pointPatchFieldMapper.H" +#include "setSizeFieldMapper.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +template +void evaluateConstraintTypes(GeometricField& fld) +{ + typename GeometricField:: + Boundary& fldBf = fld.boundaryFieldRef(); + + if + ( + Pstream::defaultCommsType == Pstream::commsTypes::blocking + || Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking + ) + { + label nReq = Pstream::nRequests(); + + forAll(fldBf, patchi) + { + fvPatchField& tgtField = fldBf[patchi]; + + if + ( + tgtField.type() == tgtField.patch().patch().type() + && polyPatch::constraintType(tgtField.patch().patch().type()) + ) + { + tgtField.initEvaluate(Pstream::defaultCommsType); + } + } + + // Block for any outstanding requests + if + ( + Pstream::parRun() + && Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking + ) + { + Pstream::waitRequests(nReq); + } + + forAll(fldBf, patchi) + { + fvPatchField& tgtField = fldBf[patchi]; + + if + ( + tgtField.type() == tgtField.patch().patch().type() + && polyPatch::constraintType(tgtField.patch().patch().type()) + ) + { + tgtField.evaluate(Pstream::defaultCommsType); + } + } + } + else if (Pstream::defaultCommsType == Pstream::commsTypes::scheduled) + { + const lduSchedule& patchSchedule = + fld.mesh().globalData().patchSchedule(); + + forAll(patchSchedule, patchEvali) + { + label patchi = patchSchedule[patchEvali].patch; + fvPatchField& tgtField = fldBf[patchi]; + + if + ( + tgtField.type() == tgtField.patch().patch().type() + && polyPatch::constraintType(tgtField.patch().patch().type()) + ) + { + if (patchSchedule[patchEvali].init) + { + tgtField.initEvaluate(Pstream::commsTypes::scheduled); + } + else + { + tgtField.evaluate(Pstream::commsTypes::scheduled); + } + } + } + } +} + + +template +void MeshToMeshMapVolFields +( + const meshToMesh& mapper +) +{ + HashTable*> fields + ( + mapper.srcRegion().objectRegistry::template + lookupClass>() + ); + + // Deleted old time fields + for + ( + typename HashTable*>:: + iterator fieldIter = fields.begin(); + fieldIter != fields.end(); + ++fieldIter + ) + { + GeometricField& field = + const_cast&> + (*fieldIter()); + + field.clearOldTimes(); + } + + fields = + ( + mapper.srcRegion().objectRegistry::template + lookupClass>() + ); + + for + ( + typename HashTable*>:: + iterator fieldIter = fields.begin(); + fieldIter != fields.end(); + ++fieldIter + ) + { + GeometricField& field = + const_cast&> + (*fieldIter()); + + if (meshToMesh::debug) + { + Info<< "Mapping " << field.typeName << ' ' << field.name() + << endl; + } + + field.reset(mapper.mapSrcToTgt(field)); + evaluateConstraintTypes(field); + field.instance() = field.time().timeName(); + } +} + + +template +< + class Type, + template class PatchField, + class GeoMesh, + class PatchMapper +> +void NaNGeometricFields +( + const meshToMesh& mapper +) +{ + typedef GeometricField Gfield; + + //- Mapper for sizing only - does not do any actual mapping. + class patchFieldResizeMapper + : + public PatchMapper, + public setSizeFieldMapper + { + public: + + // Constructors + + //- Construct given size + patchFieldResizeMapper(const label size) + : + setSizeFieldMapper(size) + {} + }; + + HashTable fields + ( + mapper.srcRegion().objectRegistry::template lookupClass() + ); + + // Deleted old time fields + for + ( + typename HashTable:: + iterator fieldIter = fields.begin(); + fieldIter != fields.end(); + ++fieldIter + ) + { + Gfield& field = const_cast(*fieldIter()); + field.clearOldTimes(); + } + + fields = + mapper.srcRegion().objectRegistry::template lookupClass(); + + Type NaN; + + for (direction cmpt = 0; cmpt < pTraits::nComponents; cmpt++) + { + setComponent(NaN, cmpt) = std::numeric_limits::signaling_NaN(); + } + + for + ( + typename HashTable::iterator fieldIter = fields.begin(); + fieldIter != fields.end(); + ++fieldIter + ) + { + Gfield& field = const_cast(*fieldIter()); + + if (meshToMesh::debug) + { + Info<< "Setting to NaN " << field.typeName << ' ' << field.name() + << endl; + } + + const typename Gfield::Mesh& mesh = field.mesh(); + + field.primitiveFieldRef().setSize(GeoMesh::size(mesh)); + field.primitiveFieldRef() = NaN; + + forAll(mesh.boundary(), patchi) + { + typename Gfield::Patch& pf = field.boundaryFieldRef()[patchi]; + + pf.autoMap(patchFieldResizeMapper(pf.patch().size())); + pf == NaN; + } + + field.instance() = field.time().timeName(); + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/fvMeshTopoChangers/meshToMesh/fvMeshTopoChangersMeshToMesh.C b/src/fvMeshTopoChangers/meshToMesh/fvMeshTopoChangersMeshToMesh.C new file mode 100644 index 0000000000..3fc7d2b182 --- /dev/null +++ b/src/fvMeshTopoChangers/meshToMesh/fvMeshTopoChangersMeshToMesh.C @@ -0,0 +1,243 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2022 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 . + +\*---------------------------------------------------------------------------*/ + +#include "fvMeshTopoChangersMeshToMesh.H" +#include "polyTopoChangeMap.H" +#include "volFields.H" +#include "surfaceInterpolate.H" +#include "pointFields.H" +#include "meshToMeshAdjustTimeStepFunctionObject.H" +#include "meshToMesh.H" +#include "cellVolumeWeightMethod.H" +#include "MeshToMeshMapGeometricFields.H" +#include "polyMeshMap.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace fvMeshTopoChangers +{ + defineTypeNameAndDebug(meshToMesh, 0); + addToRunTimeSelectionTable(fvMeshTopoChanger, meshToMesh, fvMesh); +} +} + + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +void Foam::fvMeshTopoChangers::meshToMesh::readDict() +{ + const dictionary& meshToMeshDict(dict()); + + meshToMeshDict.lookup("times") >> times_; + + meshToMeshDict.lookup("timeDelta") >> timeDelta_; + + forAll(times_, i) + { + timeIndices_.insert(label(times_[i]/timeDelta_)); + } +} + + +Foam::word Foam::fvMeshTopoChangers::meshToMesh::Uname +( + const surfaceVectorField& Uf +) const +{ + const word UfName(Uf.member()); + + return + IOobject::groupName + ( + UfName.back() == 'f' + ? word(UfName(UfName.size() - 1)) + : word::null, + Uf.group() + ); +} + + +void Foam::fvMeshTopoChangers::meshToMesh::interpolateUfs() +{ + // Interpolate U to Uf + HashTable Ufs + ( + mesh().lookupClass() + ); + + forAllIter(HashTable, Ufs, iter) + { + surfaceVectorField& Uf = *iter(); + + const word Uname(this->Uname(Uf)); + + if (Uname != word::null) + { + Uf.reset + ( + fvc::interpolate + ( + mesh().lookupObject(Uname) + ) + ); + } + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fvMeshTopoChangers::meshToMesh::meshToMesh(fvMesh& mesh) +: + fvMeshTopoChanger(mesh), + timeIndex_(-1) +{ + // Read static part of dictionary + readDict(); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::fvMeshTopoChangers::meshToMesh::~meshToMesh() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::fvMeshTopoChangers::meshToMesh::update() +{ + if (timeIndex_ == -1) + { + const_cast(mesh().time()).functionObjects().append + ( + new functionObjects::meshToMeshAdjustTimeStepFunctionObject + ( + "meshToMeshAdjustTimeStep", + mesh().time(), + dict() + ) + ); + } + + // Only refine on the first call in a time-step + if (timeIndex_ != mesh().time().timeIndex()) + { + timeIndex_ = mesh().time().timeIndex(); + } + else + { + mesh().topoChanging(false); + + return false; + } + + bool hasChanged = false; + + const scalar userTime0 = + mesh().time().userTimeValue() + - mesh().time().timeToUserTime(mesh().time().deltaTValue()); + + if (timeIndices_.found((userTime0 + timeDelta_/2)/timeDelta_)) + { + const word meshDir = "meshToMesh_" + mesh().time().timeName(userTime0); + + Info << "Mapping to mesh " << meshDir << endl; + + hasChanged = true; + + fvMesh newMesh + ( + IOobject + ( + meshDir, + mesh().time().constant(), + mesh().time(), + IOobject::MUST_READ + ), + false + ); + + Foam::meshToMesh mapper + ( + mesh(), + newMesh, + cellVolumeWeightMethod::typeName + ); + + mesh().reset(newMesh); + + // Map all the volFields in the objectRegistry + #define mapVolFieldType(Type, nullArg) \ + MeshToMeshMapVolFields(mapper); + FOR_ALL_FIELD_TYPES(mapVolFieldType); + + // Set all the surfaceFields in the objectRegistry to NaN + #define NaNSurfaceFieldType(Type, nullArg) \ + NaNGeometricFields \ + (mapper); + FOR_ALL_FIELD_TYPES(NaNSurfaceFieldType); + + // Set all the pointFields in the objectRegistry to NaN + #define NaNPointFieldType(Type, nullArg) \ + NaNGeometricFields \ + (mapper); + FOR_ALL_FIELD_TYPES(NaNPointFieldType); + + // Interpolate U's to Uf's + interpolateUfs(); + + polyMeshMap map; + mesh().mapMesh(map); + } + + mesh().topoChanging(hasChanged); + + return hasChanged; +} + + +void Foam::fvMeshTopoChangers::meshToMesh::topoChange +( + const polyTopoChangeMap& map +) +{} + + +void Foam::fvMeshTopoChangers::meshToMesh::mapMesh(const polyMeshMap& map) +{} + + +void Foam::fvMeshTopoChangers::meshToMesh::distribute +( + const polyDistributionMap& map +) +{} + + +// ************************************************************************* // diff --git a/src/fvMeshTopoChangers/meshToMesh/fvMeshTopoChangersMeshToMesh.H b/src/fvMeshTopoChangers/meshToMesh/fvMeshTopoChangersMeshToMesh.H new file mode 100644 index 0000000000..3119e7bcea --- /dev/null +++ b/src/fvMeshTopoChangers/meshToMesh/fvMeshTopoChangersMeshToMesh.H @@ -0,0 +1,142 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2022 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 . + +Class + Foam::fvMeshTopoChangers::meshToMesh + +Description + fvMeshTopoChanger which maps to new mesh + +SourceFiles + fvMeshTopoChangersMeshToMesh.C + +\*---------------------------------------------------------------------------*/ + +#ifndef fvMeshTopoChangersMeshToMesh_H +#define fvMeshTopoChangersMeshToMesh_H + +#include "fvMeshTopoChanger.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace fvMeshTopoChangers +{ + +/*---------------------------------------------------------------------------*\ + Class fvMeshTopoChangers::meshToMesh Declaration +\*---------------------------------------------------------------------------*/ + +class meshToMesh +: + public fvMeshTopoChanger +{ + // Private Data + + //- List of mesh mapping times + scalarList times_; + + //- Time delta used for time -> index + scalar timeDelta_; + + //- Hash set of mesh mapping time indices + labelHashSet timeIndices_; + + //- The time index used for updating + label timeIndex_; + + + // Private Member Functions + + //- Read the parameters from dictionary + void readDict(); + + //- Find the U field name corresponding to Uf + word Uname(const surfaceVectorField& Uf) const; + + //- Interpolate U's to Uf's + void interpolateUfs(); + + +public: + + //- Runtime type information + TypeName("meshToMesh"); + + + // Constructors + + //- Construct from fvMesh + explicit meshToMesh(fvMesh& io); + + //- Disallow default bitwise copy construction + meshToMesh(const meshToMesh&) = delete; + + + //- Destructor + virtual ~meshToMesh(); + + + // Member Functions + + const scalarList& times() const + { + return times_; + } + + scalar timeDelta() const + { + return timeDelta_; + } + + //- Update the mesh for both mesh motion and topology change + virtual bool update(); + + //- Update corresponding to the given map + virtual void topoChange(const polyTopoChangeMap&); + + //- Update from another mesh using the given map + virtual void mapMesh(const polyMeshMap&); + + //- Update corresponding to the given distribution map + virtual void distribute(const polyDistributionMap&); + + + // Member Operators + + //- Disallow default bitwise assignment + void operator=(const meshToMesh&) = delete; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace fvMeshTopoChangers +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/fvMeshTopoChangers/meshToMesh/meshToMeshAdjustTimeStep/meshToMeshAdjustTimeStepFunctionObject.C b/src/fvMeshTopoChangers/meshToMesh/meshToMeshAdjustTimeStep/meshToMeshAdjustTimeStepFunctionObject.C new file mode 100644 index 0000000000..98ed4f5f83 --- /dev/null +++ b/src/fvMeshTopoChangers/meshToMesh/meshToMeshAdjustTimeStep/meshToMeshAdjustTimeStepFunctionObject.C @@ -0,0 +1,117 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2022 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 . + +\*---------------------------------------------------------------------------*/ + +#include "meshToMeshAdjustTimeStepFunctionObject.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + defineTypeNameAndDebug(meshToMeshAdjustTimeStepFunctionObject, 0); + + addToRunTimeSelectionTable + ( + functionObject, + meshToMeshAdjustTimeStepFunctionObject, + dictionary + ); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::meshToMeshAdjustTimeStepFunctionObject:: +meshToMeshAdjustTimeStepFunctionObject +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fvMeshFunctionObject(name, runTime, dict), + meshToMesh_ + ( + refCast(mesh_.topoChanger()) + ) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::meshToMeshAdjustTimeStepFunctionObject:: +~meshToMeshAdjustTimeStepFunctionObject() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionObjects::meshToMeshAdjustTimeStepFunctionObject::read +( + const dictionary& dict +) +{ + fvMeshFunctionObject::read(dict); + + return true; +} + + +Foam::scalar +Foam::functionObjects::meshToMeshAdjustTimeStepFunctionObject::timeToNextWrite() +{ + const scalarList& times = meshToMesh_.times(); + + if (time_.userTimeValue() + meshToMesh_.timeDelta() < times.last()) + { + forAll(times, i) + { + if (times[i] > time_.userTimeValue() + meshToMesh_.timeDelta()) + { + return time_.userTimeToTime(times[i] - time_.userTimeValue()); + } + } + } + + return vGreat; +} + + +bool Foam::functionObjects::meshToMeshAdjustTimeStepFunctionObject::execute() +{ + return true; +} + + +bool Foam::functionObjects::meshToMeshAdjustTimeStepFunctionObject::write() +{ + return true; +} + + +// ************************************************************************* // diff --git a/src/fvMeshTopoChangers/meshToMesh/meshToMeshAdjustTimeStep/meshToMeshAdjustTimeStepFunctionObject.H b/src/fvMeshTopoChangers/meshToMesh/meshToMeshAdjustTimeStep/meshToMeshAdjustTimeStepFunctionObject.H new file mode 100644 index 0000000000..6282bd8932 --- /dev/null +++ b/src/fvMeshTopoChangers/meshToMesh/meshToMeshAdjustTimeStep/meshToMeshAdjustTimeStepFunctionObject.H @@ -0,0 +1,126 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2022 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 . + +Class + Foam::functionObjects::meshToMeshAdjustTimeStepFunctionObject + +Description + Adjusts time-step for meshToMesh mapping. + +SourceFiles + meshToMeshAdjustTimeStepFunctionObject.C + +\*---------------------------------------------------------------------------*/ + +#ifndef functionObjects_meshToMeshAdjustTimeStepFunctionObject_H +#define functionObjects_meshToMeshAdjustTimeStepFunctionObject_H + +#include "fvMeshFunctionObject.H" +#include "fvMeshTopoChangersMeshToMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + +/*---------------------------------------------------------------------------*\ + Class meshToMeshAdjustTimeStepFunctionObject Declaration +\*---------------------------------------------------------------------------*/ + +class meshToMeshAdjustTimeStepFunctionObject +: + public fvMeshFunctionObject +{ + // Private Data + + //- Reference to the meshToMesh fvMeshTopoChanger + const fvMeshTopoChangers::meshToMesh& meshToMesh_; + + +public: + + //- Runtime type information + TypeName("meshToMeshAdjustTimeStep"); + + + // Constructors + + //- Construct from components + meshToMeshAdjustTimeStepFunctionObject + ( + const word& name, + const Time& runTime, + const dictionary& dict + ); + + //- Disallow default bitwise copy construction + meshToMeshAdjustTimeStepFunctionObject + ( + const meshToMeshAdjustTimeStepFunctionObject& + ) = delete; + + + // Destructor + virtual ~meshToMeshAdjustTimeStepFunctionObject(); + + + // Member Functions + + //- Read and reset the timeStep Function1 + virtual bool read(const dictionary&); + + //- Return the list of fields required + virtual wordList fields() const + { + return wordList::null(); + } + + //- Return the time to the next write + virtual scalar timeToNextWrite(); + + //- Do nothing + virtual bool execute(); + + //- Do nothing + virtual bool write(); + + + // Member Operators + + //- Disallow default bitwise assignment + void operator=(const meshToMeshAdjustTimeStepFunctionObject&) = delete; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionObjects +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/fvMotionSolver/Make/options b/src/fvMotionSolver/Make/options index 5ceecf8064..27bef84e11 100644 --- a/src/fvMotionSolver/Make/options +++ b/src/fvMotionSolver/Make/options @@ -1,4 +1,4 @@ -EXE_INC = \ +EXE_INC = -ggdb3 \ -I$(LIB_SRC)/triSurface/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ diff --git a/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C index 0c3982cc52..abcfbd8eeb 100644 --- a/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C @@ -258,4 +258,22 @@ void Foam::displacementComponentLaplacianFvMotionSolver::topoChange } +void Foam::displacementComponentLaplacianFvMotionSolver::mapMesh +( + const polyMeshMap& map +) +{ + componentDisplacementMotionSolver::mapMesh(map); + + // Update diffusivity. Note two stage to make sure old one is de-registered + // before creating/registering new one. + diffusivityPtr_.reset(nullptr); + diffusivityPtr_ = motionDiffusivity::New + ( + fvMesh_, + coeffDict().lookup("diffusivity") + ); +} + + // ************************************************************************* // diff --git a/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.H index fb8c40945f..174e1b3d06 100644 --- a/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.H +++ b/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.H @@ -121,9 +121,12 @@ public: //- Solve for motion virtual void solve(); - //- Update topology + //- Update corresponding to the given map virtual void topoChange(const polyTopoChangeMap&); + //- Update from another mesh using the given map + virtual void mapMesh(const polyMeshMap&); + // Member Operators diff --git a/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.C index e35aabc387..5afeca7b7e 100644 --- a/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.C @@ -149,4 +149,22 @@ void Foam::velocityComponentLaplacianFvMotionSolver::topoChange } +void Foam::velocityComponentLaplacianFvMotionSolver::mapMesh +( + const polyMeshMap& map +) +{ + componentVelocityMotionSolver::mapMesh(map); + + // Update diffusivity. Note two stage to make sure old one is de-registered + // before creating/registering new one. + diffusivityPtr_.reset(nullptr); + diffusivityPtr_ = motionDiffusivity::New + ( + fvMesh_, + coeffDict().lookup("diffusivity") + ); +} + + // ************************************************************************* // diff --git a/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.H index 3b26650f3b..84fdad8891 100644 --- a/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.H +++ b/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.H @@ -107,9 +107,12 @@ public: //- Solve for motion virtual void solve(); - //- Update topology + //- Update corresponding to the given map virtual void topoChange(const polyTopoChangeMap&); + //- Update from another mesh using the given map + virtual void mapMesh(const polyMeshMap&); + // Member Operators diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.C index a6e0f4caea..d375020c6e 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.C @@ -197,4 +197,22 @@ void Foam::displacementSBRStressFvMotionSolver::topoChange } +void Foam::displacementSBRStressFvMotionSolver::mapMesh +( + const polyMeshMap& map +) +{ + displacementMotionSolver::mapMesh(map); + + // Update diffusivity. Note two stage to make sure old one is de-registered + // before creating/registering new one. + diffusivityPtr_.reset(nullptr); + diffusivityPtr_ = motionDiffusivity::New + ( + fvMesh_, + coeffDict().lookup("diffusivity") + ); +} + + // ************************************************************************* // diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.H index 2ecbb659d7..13f2b6d5f7 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.H +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.H @@ -118,9 +118,12 @@ public: //- Solve for motion virtual void solve(); - //- Update topology + //- Update corresponding to the given map virtual void topoChange(const polyTopoChangeMap&); + //- Update from another mesh using the given map + virtual void mapMesh(const polyMeshMap&); + // Member Operators diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C index 80f2ebf116..ced44ca7ca 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C @@ -247,9 +247,16 @@ void Foam::displacementLaplacianFvMotionSolver::topoChange ) { displacementMotionSolver::topoChange(map); + diffusivityPtr_.clear(); +} - // Update diffusivity. Note two stage to make sure old one is de-registered - // before creating/registering new one. + +void Foam::displacementLaplacianFvMotionSolver::mapMesh +( + const polyMeshMap& map +) +{ + displacementMotionSolver::mapMesh(map); diffusivityPtr_.clear(); } diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.H index 7d227d6d1d..635f6f85eb 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.H +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.H @@ -123,9 +123,12 @@ public: //- Solve for motion virtual void solve(); - //- Update topology + //- Update corresponding to the given map virtual void topoChange(const polyTopoChangeMap&); + //- Update from another mesh using the given map + virtual void mapMesh(const polyMeshMap&); + // Member Operators diff --git a/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C index 6a0ee824b4..ba544b562d 100644 --- a/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C @@ -156,4 +156,22 @@ void Foam::velocityLaplacianFvMotionSolver::topoChange } +void Foam::velocityLaplacianFvMotionSolver::mapMesh +( + const polyMeshMap& map +) +{ + velocityMotionSolver::mapMesh(map); + + // Update diffusivity. Note two stage to make sure old one is de-registered + // before creating/registering new one. + diffusivityPtr_.reset(nullptr); + diffusivityPtr_ = motionDiffusivity::New + ( + fvMesh_, + coeffDict().lookup("diffusivity") + ); +} + + // ************************************************************************* // diff --git a/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.H index 94abfaf1cb..7706085725 100644 --- a/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.H +++ b/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.H @@ -112,9 +112,12 @@ public: //- Solve for motion virtual void solve(); - //- Update topology + //- Update corresponding to the given map virtual void topoChange(const polyTopoChangeMap&); + //- Update from another mesh using the given map + virtual void mapMesh(const polyMeshMap&); + // Member Operators diff --git a/src/sampling/probes/probes.C b/src/sampling/probes/probes.C index 343b8c3c1d..28057672a4 100644 --- a/src/sampling/probes/probes.C +++ b/src/sampling/probes/probes.C @@ -354,6 +354,17 @@ bool Foam::probes::write() } +void Foam::probes::movePoints(const polyMesh& mesh) +{ + DebugInfo<< "probes: movePoints" << endl; + + if (fixedLocations_ && &mesh == &mesh_) + { + findElements(mesh_); + } +} + + void Foam::probes::topoChange(const polyTopoChangeMap& map) { DebugInfo<< "probes: topoChange" << endl; @@ -433,14 +444,11 @@ void Foam::probes::topoChange(const polyTopoChangeMap& map) } -void Foam::probes::movePoints(const polyMesh& mesh) +void Foam::probes::mapMesh(const polyMeshMap& map) { - DebugInfo<< "probes: movePoints" << endl; + DebugInfo<< "probes: mapMesh" << endl; - if (fixedLocations_ && &mesh == &mesh_) - { - findElements(mesh_); - } + findElements(mesh_); } diff --git a/src/sampling/probes/probes.H b/src/sampling/probes/probes.H index 4dd0d0b271..2d834a3830 100644 --- a/src/sampling/probes/probes.H +++ b/src/sampling/probes/probes.H @@ -235,10 +235,13 @@ public: virtual bool write(); //- Update topology using the given map - virtual void topoChange(const polyTopoChangeMap&); + virtual void movePoints(const polyMesh&); //- Update topology using the given map - virtual void movePoints(const polyMesh&); + virtual void topoChange(const polyTopoChangeMap&); + + //- Update from another mesh using the given map + virtual void mapMesh(const polyMeshMap&); //- Update topology using the given map due to readUpdate virtual void readUpdate(const polyMesh::readUpdateState state) diff --git a/src/sampling/sampledSet/sampledSets/sampledSets.C b/src/sampling/sampledSet/sampledSets/sampledSets.C index ff961b4b06..6d8a0a4cb8 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSets.C +++ b/src/sampling/sampledSet/sampledSets/sampledSets.C @@ -283,6 +283,16 @@ void Foam::functionObjects::sampledSets::correct() } +void Foam::functionObjects::sampledSets::movePoints(const polyMesh& mesh) +{ + if (&mesh == &mesh_) + { + correct(); + } +} + + + void Foam::functionObjects::sampledSets::topoChange ( const polyTopoChangeMap& map @@ -295,12 +305,9 @@ void Foam::functionObjects::sampledSets::topoChange } -void Foam::functionObjects::sampledSets::movePoints(const polyMesh& mesh) +void Foam::functionObjects::sampledSets::mapMesh(const polyMeshMap& map) { - if (&mesh == &mesh_) - { - correct(); - } + correct(); } diff --git a/src/sampling/sampledSet/sampledSets/sampledSets.H b/src/sampling/sampledSet/sampledSets/sampledSets.H index 3dd1caaaad..0170c2848d 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSets.H +++ b/src/sampling/sampledSet/sampledSets/sampledSets.H @@ -181,11 +181,14 @@ public: //- Correct for mesh changes void correct(); + //- Update for mesh point-motion + virtual void movePoints(const polyMesh&); + //- Update topology using the given map virtual void topoChange(const polyTopoChangeMap&); - //- Update for mesh point-motion - virtual void movePoints(const polyMesh&); + //- Update from another mesh using the given map + virtual void mapMesh(const polyMeshMap&); //- Update topology using the given map due to readUpdate virtual void readUpdate(const polyMesh::readUpdateState state); diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C index 2d915cfc77..8c8cbca4fc 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C @@ -271,6 +271,15 @@ Foam::wordList Foam::functionObjects::sampledSurfaces::fields() const } +void Foam::functionObjects::sampledSurfaces::movePoints(const polyMesh& mesh) +{ + if (&mesh == &mesh_) + { + expire(); + } +} + + void Foam::functionObjects::sampledSurfaces::topoChange ( const polyTopoChangeMap& map @@ -285,12 +294,12 @@ void Foam::functionObjects::sampledSurfaces::topoChange } -void Foam::functionObjects::sampledSurfaces::movePoints(const polyMesh& mesh) +void Foam::functionObjects::sampledSurfaces::mapMesh +( + const polyMeshMap& map +) { - if (&mesh == &mesh_) - { - expire(); - } + expire(); } diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H index 3af159a8fd..aa5413db49 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H @@ -235,11 +235,14 @@ public: //- Sample and write virtual bool write(); + //- Update for mesh point-motion - expires the surfaces + virtual void movePoints(const polyMesh&); + //- Update topology using the given map - expires the surfaces virtual void topoChange(const polyTopoChangeMap&); - //- Update for mesh point-motion - expires the surfaces - virtual void movePoints(const polyMesh&); + //- Update from another mesh using the given map + virtual void mapMesh(const polyMeshMap&); //- Update topology using the given map due to readUpdate // - expires the surfaces diff --git a/tutorials/incompressible/pimpleFoam/laminar/movingCone/0/U b/tutorials/incompressible/pimpleFoam/laminar/movingCone/0/U index d444079a3b..4a34324300 100644 --- a/tutorials/incompressible/pimpleFoam/laminar/movingCone/0/U +++ b/tutorials/incompressible/pimpleFoam/laminar/movingCone/0/U @@ -19,6 +19,8 @@ internalField uniform (0 0 0); boundaryField { + #includeEtc "caseDicts/setConstraintTypes" + movingWall { type movingWallVelocity; @@ -45,16 +47,6 @@ boundaryField { type noSlip; } - - back - { - type wedge; - } - - front - { - type wedge; - } } // ************************************************************************* // diff --git a/tutorials/incompressible/pimpleFoam/laminar/movingCone/0/p b/tutorials/incompressible/pimpleFoam/laminar/movingCone/0/p index 21e7ed13cb..992415a721 100644 --- a/tutorials/incompressible/pimpleFoam/laminar/movingCone/0/p +++ b/tutorials/incompressible/pimpleFoam/laminar/movingCone/0/p @@ -19,6 +19,8 @@ internalField uniform 0; boundaryField { + #includeEtc "caseDicts/setConstraintTypes" + movingWall { type zeroGradient; @@ -44,16 +46,6 @@ boundaryField { type zeroGradient; } - - back - { - type wedge; - } - - front - { - type wedge; - } } // ************************************************************************* // diff --git a/tutorials/incompressible/pimpleFoam/laminar/movingCone/0/pointMotionUx b/tutorials/incompressible/pimpleFoam/laminar/movingCone/0/pointMotionUx index 23316be139..aeb7c388cb 100644 --- a/tutorials/incompressible/pimpleFoam/laminar/movingCone/0/pointMotionUx +++ b/tutorials/incompressible/pimpleFoam/laminar/movingCone/0/pointMotionUx @@ -9,7 +9,7 @@ FoamFile { format ascii; class pointScalarField; - object pointMotionU; + object pointMotionUx; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -19,37 +19,35 @@ internalField uniform 0; boundaryField { + #includeEtc "caseDicts/setConstraintTypes" + movingWall { type uniformFixedValue; uniformValue constant 1; } + farFieldMoving { type slip; } + fixedWall { type uniformFixedValue; uniformValue constant 0; } + left { type uniformFixedValue; uniformValue constant 0; } + farField { type slip; } - back - { - type wedge; - } - front - { - type wedge; - } } // ************************************************************************* // diff --git a/tutorials/incompressible/pimpleFoam/laminar/movingCone/Allclean b/tutorials/incompressible/pimpleFoam/laminar/movingCone/Allclean new file mode 100755 index 0000000000..15b463efe7 --- /dev/null +++ b/tutorials/incompressible/pimpleFoam/laminar/movingCone/Allclean @@ -0,0 +1,11 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory + +# Source tutorial clean functions +. $WM_PROJECT_DIR/bin/tools/CleanFunctions + +rm -rf constant/meshToMesh* + +cleanCase + +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/pimpleFoam/laminar/movingCone/Allrun b/tutorials/incompressible/pimpleFoam/laminar/movingCone/Allrun new file mode 100755 index 0000000000..2ad3c8bf84 --- /dev/null +++ b/tutorials/incompressible/pimpleFoam/laminar/movingCone/Allrun @@ -0,0 +1,23 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + +application=$(getApplication) + +runApplication -a blockMesh -dict blockMeshDict.2 +rm -rf constant/meshToMesh_0.0015 +mkdir constant/meshToMesh_0.0015 +mv constant/polyMesh constant/meshToMesh_0.0015 + +runApplication -a blockMesh -dict blockMeshDict.3 +rm -rf constant/meshToMesh_0.003 +mkdir constant/meshToMesh_0.003 +mv constant/polyMesh constant/meshToMesh_0.003 + +runApplication -a blockMesh -dict blockMeshDict.1 + +runApplication $application + +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/pimpleFoam/laminar/movingCone/constant/dynamicMeshDict b/tutorials/incompressible/pimpleFoam/laminar/movingCone/constant/dynamicMeshDict index d5c6ec7409..4cd753a097 100644 --- a/tutorials/incompressible/pimpleFoam/laminar/movingCone/constant/dynamicMeshDict +++ b/tutorials/incompressible/pimpleFoam/laminar/movingCone/constant/dynamicMeshDict @@ -27,4 +27,16 @@ mover } +topoChanger +{ + type meshToMesh; + + libs ("libmeshToMeshTopoChanger.so"); + + times (0.0015 0.003); + + timeDelta 1e-6; +} + + // ************************************************************************* // diff --git a/tutorials/incompressible/pimpleFoam/laminar/movingCone/system/blockMeshDict b/tutorials/incompressible/pimpleFoam/laminar/movingCone/system/blockMeshDict.1 similarity index 93% rename from tutorials/incompressible/pimpleFoam/laminar/movingCone/system/blockMeshDict rename to tutorials/incompressible/pimpleFoam/laminar/movingCone/system/blockMeshDict.1 index 07485265c8..6ef2c89643 100644 --- a/tutorials/incompressible/pimpleFoam/laminar/movingCone/system/blockMeshDict +++ b/tutorials/incompressible/pimpleFoam/laminar/movingCone/system/blockMeshDict.1 @@ -41,15 +41,20 @@ vertices blocks ( - hex (0 1 5 4 0 1 13 12) (15 15 1) simpleGrading (1 1 1) + hex (0 1 5 4 0 1 13 12) (8 15 1) simpleGrading (1 1 1) hex (2 3 7 6 2 3 15 14) (20 20 1) simpleGrading (2 0.25 1) - hex (4 5 9 8 12 13 17 16) (15 15 1) simpleGrading (1 1 1) + hex (4 5 9 8 12 13 17 16) (8 15 1) simpleGrading (1 1 1) hex (5 6 10 9 13 14 18 17) (50 15 1) simpleGrading (1 1 1) hex (6 7 11 10 14 15 19 18) (20 15 1) simpleGrading (2 1 1) ); boundary ( + internal + { + type internal; + faces (); + } movingWall { type wall; diff --git a/tutorials/incompressible/pimpleFoam/laminar/movingCone/system/blockMeshDict.2 b/tutorials/incompressible/pimpleFoam/laminar/movingCone/system/blockMeshDict.2 new file mode 100644 index 0000000000..c329f58207 --- /dev/null +++ b/tutorials/incompressible/pimpleFoam/laminar/movingCone/system/blockMeshDict.2 @@ -0,0 +1,139 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +convertToMeters 0.001; + +vertices +( + (-7.5 0 0) + (-5.5 0 0) + (-2 0 0) + (0 0 0) + (-7.5 0.75 -0.032745707) + (-5.5 0.75 -0.032745707) + (-2 2 -0.087321886) + (0 2 -0.087321886) + (-7.5 2.5 -0.10915236) + (-5.5 2.5 -0.10915236) + (-2 2.5 -0.10915236) + (0 2.5 -0.10915236) + (-7.5 0.75 0.032745707) + (-5.5 0.75 0.032745707) + (-2 2 0.087321886) + (0 2 0.087321886) + (-7.5 2.5 0.10915236) + (-5.5 2.5 0.10915236) + (-2 2.5 0.10915236) + (0 2.5 0.10915236) +); + +blocks +( + hex (0 1 5 4 0 1 13 12) (16 15 1) simpleGrading (1 1 1) + hex (2 3 7 6 2 3 15 14) (10 20 1) simpleGrading (2 0.25 1) + hex (4 5 9 8 12 13 17 16) (16 15 1) simpleGrading (1 1 1) + hex (5 6 10 9 13 14 18 17) (50 15 1) simpleGrading (1 1 1) + hex (6 7 11 10 14 15 19 18) (10 15 1) simpleGrading (2 1 1) +); + +boundary +( + internal + { + type internal; + faces (); + } + movingWall + { + type wall; + faces + ( + (1 5 13 1) + (5 6 14 13) + (2 2 14 6) + ); + } + farFieldMoving + { + type patch; + faces + ( + (9 17 18 10) + ); + } + fixedWall + { + type wall; + faces + ( + (3 7 15 3) + (7 11 19 15) + ); + } + axis + { + type empty; + faces + ( + (0 1 1 0) + (2 3 3 2) + ); + } + left + { + type patch; + faces + ( + (0 0 12 4) + (4 12 16 8) + ); + } + farField + { + type patch; + faces + ( + (8 16 17 9) + (10 18 19 11) + ); + } + back + { + type wedge; + faces + ( + (0 4 5 1) + (2 6 7 3) + (4 8 9 5) + (5 9 10 6) + (6 10 11 7) + ); + } + front + { + type wedge; + faces + ( + (0 1 13 12) + (2 3 15 14) + (12 13 17 16) + (13 14 18 17) + (14 15 19 18) + ); + } +); + + +// ************************************************************************* // diff --git a/tutorials/incompressible/pimpleFoam/laminar/movingCone/system/blockMeshDict.3 b/tutorials/incompressible/pimpleFoam/laminar/movingCone/system/blockMeshDict.3 new file mode 100644 index 0000000000..028340f6ca --- /dev/null +++ b/tutorials/incompressible/pimpleFoam/laminar/movingCone/system/blockMeshDict.3 @@ -0,0 +1,139 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +convertToMeters 0.001; + +vertices +( + (-7.5 0 0) + (-4 0 0) + (-0.5 0 0) + (0 0 0) + (-7.5 0.75 -0.032745707) + (-4 0.75 -0.032745707) + (-0.5 2 -0.087321886) + (0 2 -0.087321886) + (-7.5 2.5 -0.10915236) + (-4 2.5 -0.10915236) + (-0.5 2.5 -0.10915236) + (0 2.5 -0.10915236) + (-7.5 0.75 0.032745707) + (-4 0.75 0.032745707) + (-0.5 2 0.087321886) + (0 2 0.087321886) + (-7.5 2.5 0.10915236) + (-4 2.5 0.10915236) + (-0.5 2.5 0.10915236) + (0 2.5 0.10915236) +); + +blocks +( + hex (0 1 5 4 0 1 13 12) (25 15 1) simpleGrading (1 1 1) + hex (2 3 7 6 2 3 15 14) (5 20 1) simpleGrading (2 0.25 1) + hex (4 5 9 8 12 13 17 16) (25 15 1) simpleGrading (1 1 1) + hex (5 6 10 9 13 14 18 17) (50 15 1) simpleGrading (1 1 1) + hex (6 7 11 10 14 15 19 18) (5 15 1) simpleGrading (2 1 1) +); + +boundary +( + internal + { + type internal; + faces (); + } + movingWall + { + type wall; + faces + ( + (1 5 13 1) + (5 6 14 13) + (2 2 14 6) + ); + } + farFieldMoving + { + type patch; + faces + ( + (9 17 18 10) + ); + } + fixedWall + { + type wall; + faces + ( + (3 7 15 3) + (7 11 19 15) + ); + } + axis + { + type empty; + faces + ( + (0 1 1 0) + (2 3 3 2) + ); + } + left + { + type patch; + faces + ( + (0 0 12 4) + (4 12 16 8) + ); + } + farField + { + type patch; + faces + ( + (8 16 17 9) + (10 18 19 11) + ); + } + back + { + type wedge; + faces + ( + (0 4 5 1) + (2 6 7 3) + (4 8 9 5) + (5 9 10 6) + (6 10 11 7) + ); + } + front + { + type wedge; + faces + ( + (0 1 13 12) + (2 3 15 14) + (12 13 17 16) + (13 14 18 17) + (14 15 19 18) + ); + } +); + + +// ************************************************************************* // diff --git a/tutorials/incompressible/pimpleFoam/laminar/movingCone/system/controlDict b/tutorials/incompressible/pimpleFoam/laminar/movingCone/system/controlDict index ab3d8aa1fc..4672e63ecc 100644 --- a/tutorials/incompressible/pimpleFoam/laminar/movingCone/system/controlDict +++ b/tutorials/incompressible/pimpleFoam/laminar/movingCone/system/controlDict @@ -22,13 +22,13 @@ startTime 0; stopAt endTime; -endTime 0.003; +endTime 0.0034; deltaT 5e-06; -writeControl timeStep; +writeControl adjustableRunTime; -writeInterval 40; +writeInterval 1e-4; purgeWrite 0; @@ -44,9 +44,9 @@ timePrecision 6; runTimeModifiable true; -adjustTimeStep no; +adjustTimeStep yes; -maxCo 0.2; +maxCo 0.5; functions { diff --git a/tutorials/incompressible/pimpleFoam/laminar/movingCone/system/decomposeParDict b/tutorials/incompressible/pimpleFoam/laminar/movingCone/system/decomposeParDict new file mode 100644 index 0000000000..eeda159389 --- /dev/null +++ b/tutorials/incompressible/pimpleFoam/laminar/movingCone/system/decomposeParDict @@ -0,0 +1,42 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "system"; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 4; + +method hierarchical; + +simpleCoeffs +{ + n (2 1 1); +} + +hierarchicalCoeffs +{ + n (4 1 1); + order xyz; +} + +manualCoeffs +{ + dataFile ""; +} + +distributed no; + +roots ( ); + + +// ************************************************************************* // diff --git a/tutorials/incompressible/pimpleFoam/laminar/movingCone/system/fvSchemes b/tutorials/incompressible/pimpleFoam/laminar/movingCone/system/fvSchemes index 36abfcad84..def0708c4e 100644 --- a/tutorials/incompressible/pimpleFoam/laminar/movingCone/system/fvSchemes +++ b/tutorials/incompressible/pimpleFoam/laminar/movingCone/system/fvSchemes @@ -28,7 +28,7 @@ divSchemes { default none; - div(phi,U) Gauss linear; + div(phi,U) Gauss linearUpwind grad(U); div((nuEff*dev2(T(grad(U))))) Gauss linear; } diff --git a/tutorials/incompressible/pimpleFoam/laminar/movingCone/system/fvSolution b/tutorials/incompressible/pimpleFoam/laminar/movingCone/system/fvSolution index ceb1610b6d..5659dbb544 100644 --- a/tutorials/incompressible/pimpleFoam/laminar/movingCone/system/fvSolution +++ b/tutorials/incompressible/pimpleFoam/laminar/movingCone/system/fvSolution @@ -19,10 +19,11 @@ solvers p { solver GAMG; + smoother DIC; + cacheAgglomeration no; + tolerance 0; relTol 0.01; - smoother GaussSeidel; - cacheAgglomeration no; } pFinal @@ -41,16 +42,16 @@ solvers U { - solver smoothSolver; - smoother symGaussSeidel; - tolerance 1e-05; + solver PBiCGStab; + preconditioner DILU; + + tolerance 1e-6; relTol 0.1; } UFinal { $U; - tolerance 1e-05; relTol 0; }