diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.C index 5bec567310..a2940ef12b 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.C +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.C @@ -208,6 +208,9 @@ void Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::updateCoeffs() patch().patch() ); const polyMesh& nbrMesh = mpp.sampleMesh(); + // Force recalculation of mapping and schedule + const mapDistribute& distMap = mpp.map(); + (void)distMap.schedule(); tmp intFld = patchInternalField(); @@ -217,7 +220,6 @@ void Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::updateCoeffs() // to be updated the first time round the iteration (i.e. when // switching regions) but unfortunately we don't have this information. - const mapDistribute& distMap = mpp.map(); const fvPatch& nbrPatch = refCast ( nbrMesh diff --git a/applications/solvers/incompressible/pimpleDyMFoam/Make/options b/applications/solvers/incompressible/pimpleDyMFoam/Make/options index e14eec2585..40023adad7 100644 --- a/applications/solvers/incompressible/pimpleDyMFoam/Make/options +++ b/applications/solvers/incompressible/pimpleDyMFoam/Make/options @@ -9,6 +9,7 @@ EXE_INC = \ EXE_LIBS = \ -ldynamicFvMesh \ + -ltopoChangerFvMesh \ -ldynamicMesh \ -lmeshTools \ -lincompressibleTransportModels \ diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/Make/options b/applications/solvers/multiphase/compressibleInterDyMFoam/Make/options index af146aaa38..75094c8b16 100644 --- a/applications/solvers/multiphase/compressibleInterDyMFoam/Make/options +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/Make/options @@ -16,5 +16,6 @@ EXE_LIBS = \ -lfiniteVolume \ -ldynamicMesh \ -lmeshTools \ - -ldynamicFvMesh + -ldynamicFvMesh \ + -ltopoChangerFvMesh diff --git a/applications/solvers/multiphase/interDyMFoam/Make/options b/applications/solvers/multiphase/interDyMFoam/Make/options index b9aa770576..6bbea18fd6 100644 --- a/applications/solvers/multiphase/interDyMFoam/Make/options +++ b/applications/solvers/multiphase/interDyMFoam/Make/options @@ -17,4 +17,5 @@ EXE_LIBS = \ -lfiniteVolume \ -ldynamicMesh \ -lmeshTools \ - -ldynamicFvMesh + -ldynamicFvMesh \ + -ltopoChangerFvMesh diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index 6f086523dd..9a0825ac91 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C @@ -203,8 +203,8 @@ int main(int argc, char *argv[]) IOobject ( "abc", // dummy name - //mesh.time().constant(), // instance - mesh.time().findInstance("triSurface", word::null),// instance + mesh.time().constant(), // instance + //mesh.time().findInstance("triSurface", word::null),// instance "triSurface", // local mesh.time(), // registry IOobject::MUST_READ, diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C index cc2c8e710d..fa9b3e6a91 100644 --- a/src/OpenFOAM/db/Time/Time.C +++ b/src/OpenFOAM/db/Time/Time.C @@ -638,10 +638,10 @@ Foam::Time& Foam::Time::operator+=(const scalar deltaT) Foam::Time& Foam::Time::operator++() { - readModifiedObjects(); - if (!subCycling_) { + readModifiedObjects(); + if (timeIndex_ == startTimeIndex_) { functionObjects_.start(); diff --git a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriver.C b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriver.C index 3c2221f8d0..1612a23dea 100644 --- a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriver.C +++ b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoHexMeshDriver.C @@ -225,7 +225,9 @@ Foam::autoHexMeshDriver::autoHexMeshDriver IOobject ( "abc", // dummy name - mesh_.time().findInstance("triSurface", word::null),// inst + //mesh_.time().findInstance("triSurface", word::null), + // instance + mesh_.time().constant(), // instance "triSurface", // local mesh_.time(), // registry IOobject::MUST_READ, diff --git a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoRefineDriver.C b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoRefineDriver.C index 0ac24a5574..a9b31b9bd1 100644 --- a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoRefineDriver.C +++ b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoRefineDriver.C @@ -78,8 +78,9 @@ Foam::label Foam::autoRefineDriver::readFeatureEdges IOobject ( featFileName, // name - mesh.time().findInstance("triSurface", featFileName), - // instance + //mesh.time().findInstance("triSurface", featFileName), + // // instance + mesh.time().constant(), // instance "triSurface", // local mesh.time(), // registry IOobject::MUST_READ, diff --git a/src/dynamicMesh/Make/files b/src/dynamicMesh/Make/files index 2343124597..e59bbe3800 100644 --- a/src/dynamicMesh/Make/files +++ b/src/dynamicMesh/Make/files @@ -16,16 +16,13 @@ $(enrichedPatch)/enrichedPatchPointPoints.C $(enrichedPatch)/enrichedPatchCutFaces.C $(enrichedPatch)/enrichedPatchMasterPoints.C -/* polyTopoChange/polyTopoChange/polyTopoChange.C */ -polyTopoChange/polyTopoChange/topoAction/topoActions.C polyMeshModifier = polyTopoChange/polyMeshModifier $(polyMeshModifier)/polyMeshModifier.C $(polyMeshModifier)/newPolyMeshModifier.C +polyTopoChange/polyTopoChange/topoAction/topoActions.C polyTopoChange/polyTopoChanger/polyTopoChanger.C -/* polyTopoChange/polyTopoChanger/polyTopoChangerChangeMesh.C */ - polyTopoChange/polyTopoChange/polyTopoChange.C polyTopoChange/polyTopoChange/addPatchCellLayer.C polyTopoChange/polyTopoChange/edgeCollapser.C diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C index af4a37bead..926f2f4913 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C @@ -350,6 +350,18 @@ void Foam::hexRef8::modFace // Bit complex way to determine the unrefined edge length. Foam::scalar Foam::hexRef8::getLevel0EdgeLength() const { + if (cellLevel_.size() != mesh_.nCells()) + { + FatalErrorIn + ( + "hexRef8::getLevel0EdgeLength() const" + ) << "Number of cells in mesh:" << mesh_.nCells() + << " does not equal size of cellLevel:" << cellLevel_.size() + << endl + << "This might be because of a restart with inconsistent cellLevel." + << abort(FatalError); + } + // Determine minimum edge length per refinement level // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/src/finiteVolume/fields/fvPatchFields/derived/directMappedFixedValue/directMappedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/directMappedFixedValue/directMappedFixedValueFvPatchField.C index d85e393fd8..e62987148d 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/directMappedFixedValue/directMappedFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/directMappedFixedValue/directMappedFixedValueFvPatchField.C @@ -114,12 +114,12 @@ directMappedFixedValueFvPatchField::directMappedFixedValueFvPatchField << exit(FatalError); } - // Force calculation of schedule (uses parallel comms) - const directMappedPatchBase& mpp = refCast - ( - this->patch().patch() - ); - (void)mpp.map().schedule(); + //// Force calculation of schedule (uses parallel comms) + //const directMappedPatchBase& mpp = refCast + //( + // this->patch().patch() + //); + //(void)mpp.map().schedule(); } @@ -166,6 +166,10 @@ void directMappedFixedValueFvPatchField::updateCoeffs() directMappedFixedValueFvPatchField::patch().patch() ); const mapDistribute& distMap = mpp.map(); + + // Force recalculation of schedule + (void)distMap.schedule(); + const fvMesh& nbrMesh = refCast(mpp.sampleMesh()); const word& fldName = this->dimensionedInternalField().name(); diff --git a/src/topoChangerFvMesh/Make/files b/src/topoChangerFvMesh/Make/files index 838500fd8b..1788317304 100644 --- a/src/topoChangerFvMesh/Make/files +++ b/src/topoChangerFvMesh/Make/files @@ -1,4 +1,5 @@ topoChangerFvMesh/topoChangerFvMesh.C +rawTopoChangerFvMesh/rawTopoChangerFvMesh.C /* linearValveFvMesh/linearValveFvMesh.C diff --git a/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.C b/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.C new file mode 100644 index 0000000000..ccfb392b2e --- /dev/null +++ b/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.C @@ -0,0 +1,180 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +\*---------------------------------------------------------------------------*/ + +#include "rawTopoChangerFvMesh.H" +#include "mapPolyMesh.H" +#include "addToRunTimeSelectionTable.H" +#include "volFields.H" +#include "linear.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(rawTopoChangerFvMesh, 0); + addToRunTimeSelectionTable + ( + topoChangerFvMesh, + rawTopoChangerFvMesh, + IOobject + ); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// Construct from components +Foam::rawTopoChangerFvMesh::rawTopoChangerFvMesh(const IOobject& io) +: + topoChangerFvMesh(io) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::rawTopoChangerFvMesh::~rawTopoChangerFvMesh() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::rawTopoChangerFvMesh::update() +{ + // Do mesh changes (use inflation - put new points in topoChangeMap) + Info<< "rawTopoChangerFvMesh : Checking for topology changes..." + << endl; + autoPtr topoChangeMap = topoChanger_.changeMesh(true); + + bool hasChanged = topoChangeMap.valid(); + + if (hasChanged) + { + Info<< "rawTopoChangerFvMesh : Done topology changes..." + << endl; + + // Temporary: fix fields on patch faces created out of nothing + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + // Two situations: + // - internal faces inflated out of nothing + // - patch faces created out of previously internal faces + + // Is face mapped in any way + PackedList<1> mappedFace(nFaces()); + + const label nOldInternal = topoChangeMap().oldPatchStarts()[0]; + + const labelList& faceMap = topoChangeMap().faceMap(); + for (label faceI = 0; faceI < nInternalFaces(); faceI++) + { + if (faceMap[faceI] >= 0) + { + mappedFace[faceI] = 1; + } + } + for (label faceI = nInternalFaces(); faceI < nFaces(); faceI++) + { + if (faceMap[faceI] >= 0 && faceMap[faceI] >= nOldInternal) + { + mappedFace[faceI] = 1; + } + } + + const List& fromFaces = topoChangeMap().facesFromFacesMap(); + + forAll(fromFaces, i) + { + mappedFace[fromFaces[i].index()] = 1; + } + + const List& fromEdges = topoChangeMap().facesFromEdgesMap(); + + forAll(fromEdges, i) + { + mappedFace[fromEdges[i].index()] = 1; + } + + const List& fromPts = topoChangeMap().facesFromPointsMap(); + + forAll(fromPts, i) + { + mappedFace[fromPts[i].index()] = 1; + } + + // Set unmapped faces to zero + Info<< "rawTopoChangerFvMesh : zeroing unmapped boundary values." + << endl; + zeroUnmappedValues(mappedFace); + zeroUnmappedValues(mappedFace); + zeroUnmappedValues(mappedFace); + zeroUnmappedValues(mappedFace); + zeroUnmappedValues(mappedFace); + + // Special handling for phi: set unmapped faces to recreated phi + Info<< "rawTopoChangerFvMesh :" + << " recreating phi for unmapped boundary values." << endl; + const volVectorField& U = lookupObject("U"); + surfaceScalarField& phi = const_cast + ( + lookupObject("phi") + ); + setUnmappedValues + ( + phi, + mappedFace, + (linearInterpolate(U) & Sf())() + ); + + + if (topoChangeMap().hasMotionPoints()) + { + pointField newPoints = topoChangeMap().preMotionPoints(); + + // Give the meshModifiers opportunity to modify points + Info<< "rawTopoChangerFvMesh :" + << " calling modifyMotionPoints." << endl; + topoChanger_.modifyMotionPoints(newPoints); + + // Actually move points + Info<< "rawTopoChangerFvMesh :" + << " calling movePoints." << endl; + + movePoints(newPoints); + } + } + else + { + //Pout<< "rawTopoChangerFvMesh :" + // << " no topology changes..." << endl; + } + + changing(hasChanged); + + return hasChanged; +} + + +// ************************************************************************* // diff --git a/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.H b/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.H new file mode 100644 index 0000000000..612829c3c8 --- /dev/null +++ b/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.H @@ -0,0 +1,117 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 + +Class + Foam::rawTopoChangerFvMesh + +Description + topoChangerFvMesh without any added functionality. + + Note: run without FOAM_SETNAN. Temporary has unitialised patch + data when faces get created out of nothing. + +SourceFiles + rawTopoChangerFvMesh.C + +\*---------------------------------------------------------------------------*/ + +#ifndef rawTopoChangerFvMesh_H +#define rawTopoChangerFvMesh_H + +#include "topoChangerFvMesh.H" +#include "PackedList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes + +/*---------------------------------------------------------------------------*\ + Class rawTopoChangerFvMesh Declaration +\*---------------------------------------------------------------------------*/ + +class rawTopoChangerFvMesh +: + public topoChangerFvMesh +{ + // Private Member Functions + + //- Set unmapped values + template class PatchField, class GeoMesh> + static void setUnmappedValues + ( + GeometricField& fld, + const PackedList<1>& mappedFace, + const GeometricField& baseFld + ); + + template class PatchField, class GeoMesh> + void zeroUnmappedValues(const PackedList<1>&) const; + + //- Disallow default bitwise copy construct + rawTopoChangerFvMesh(const rawTopoChangerFvMesh&); + + //- Disallow default bitwise assignment + void operator=(const rawTopoChangerFvMesh&); + +public: + + //- Runtime type information + TypeName("rawTopoChangerFvMesh"); + + + // Constructors + + //- Construct from database + explicit rawTopoChangerFvMesh(const IOobject& io); + + // Destructor + + virtual ~rawTopoChangerFvMesh(); + + + // Member Functions + + //- Update the mesh for both mesh motion and topology change + virtual bool update(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "rawTopoChangerFvMeshTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMeshTemplates.C b/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMeshTemplates.C new file mode 100644 index 0000000000..0be0306186 --- /dev/null +++ b/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMeshTemplates.C @@ -0,0 +1,107 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 + +\*---------------------------------------------------------------------------*/ + +#include "rawTopoChangerFvMesh.H" +#include "Time.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template class PatchField, class GeoMesh> +void Foam::rawTopoChangerFvMesh::setUnmappedValues +( + GeometricField& fld, + const PackedList<1>& mappedFace, + const GeometricField& baseFld +) +{ + //Pout<< "Checking field " << fld.name() << endl; + + forAll(fld.boundaryField(), patchI) + { + PatchField& fvp = const_cast&> + ( + fld.boundaryField()[patchI] + ); + + label start = fvp.patch().patch().start(); + forAll(fvp, i) + { + if (!mappedFace[start+i]) + { + //Pout<< "** Resetting unassigned value on patch " + // << fvp.patch().name() + // << " localface:" << i + // << " to:" << baseFld.boundaryField()[patchI][i] << endl; + fvp[i] = baseFld.boundaryField()[patchI][i]; + } + } + } +} + + +template class PatchField, class GeoMesh> +void Foam::rawTopoChangerFvMesh::zeroUnmappedValues +( + const PackedList<1>& mappedFace +) const +{ + typedef GeometricField FieldType; + + const wordList fldNames(names(FieldType::typeName)); + + forAll(fldNames, i) + { + //Pout<< "Checking field " << fldNames[i] << endl; + + FieldType& fld = const_cast + ( + lookupObject(fldNames[i]) + ); + + setUnmappedValues + ( + fld, + mappedFace, + FieldType + ( + IOobject + ( + "zero", + time().timeName(), + *this, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + *this, + dimensioned("0", fld.dimensions(), pTraits::zero) + ) + ); + } +} + + +// ************************************************************************* //