diff --git a/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C b/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C index 2a9bd02286..7c5e4baf77 100644 --- a/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C +++ b/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C @@ -60,7 +60,7 @@ void subsetVolFields Info<< "Subsetting field " << fieldName << endl; - GeometricField volField + GeometricField fld ( IOobject ( @@ -73,7 +73,7 @@ void subsetVolFields baseMesh ); - subFields.set(i, subsetter.interpolate(volField)); + subFields.set(i, subsetter.interpolate(fld)); } } @@ -94,7 +94,7 @@ void subsetSurfaceFields Info<< "Subsetting field " << fieldName << endl; - GeometricField volField + GeometricField fld ( IOobject ( @@ -107,7 +107,42 @@ void subsetSurfaceFields baseMesh ); - subFields.set(i, subsetter.interpolate(volField)); + subFields.set(i, subsetter.interpolate(fld)); + } +} + + +template +void subsetPointFields +( + const fvMeshSubset& subsetter, + const pointMesh& pMesh, + const wordList& fieldNames, + PtrList >& subFields +) +{ + const fvMesh& baseMesh = subsetter.baseMesh(); + + forAll(fieldNames, i) + { + const word& fieldName = fieldNames[i]; + + Info<< "Subsetting field " << fieldName << endl; + + GeometricField fld + ( + IOobject + ( + fieldName, + baseMesh.time().timeName(), + baseMesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ), + pMesh + ); + + subFields.set(i, subsetter.interpolate(fld)); } } @@ -163,7 +198,9 @@ int main(int argc, char *argv[]) IOobjectList objects(mesh, runTime.timeName()); - // Read vol fields and subset. + + // Read vol fields and subset + // ~~~~~~~~~~~~~~~~~~~~~~~~~~ wordList scalarNames(objects.names(volScalarField::typeName)); PtrList scalarFlds(scalarNames.size()); @@ -191,7 +228,9 @@ int main(int argc, char *argv[]) PtrList tensorFlds(tensorNames.size()); subsetVolFields(subsetter, tensorNames, tensorFlds); - // Read surface fields and subset. + + // Read surface fields and subset + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ wordList surfScalarNames(objects.names(surfaceScalarField::typeName)); PtrList surfScalarFlds(surfScalarNames.size()); @@ -231,6 +270,59 @@ int main(int argc, char *argv[]) subsetSurfaceFields(subsetter, surfTensorNames, surfTensorFlds); + // Read point fields and subset + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + pointMesh pMesh(mesh); + + wordList pointScalarNames(objects.names(pointScalarField::typeName)); + PtrList pointScalarFlds(pointScalarNames.size()); + subsetPointFields(subsetter, pMesh, pointScalarNames, pointScalarFlds); + + wordList pointVectorNames(objects.names(pointVectorField::typeName)); + PtrList pointVectorFlds(pointVectorNames.size()); + subsetPointFields(subsetter, pMesh, pointVectorNames, pointVectorFlds); + + wordList pointSphericalTensorNames + ( + objects.names(pointSphericalTensorField::typeName) + ); + PtrList pointSphericalTensorFlds + ( + pointSphericalTensorNames.size() + ); + subsetPointFields + ( + subsetter, + pMesh, + pointSphericalTensorNames, + pointSphericalTensorFlds + ); + + wordList pointSymmTensorNames + ( + objects.names(pointSymmTensorField::typeName) + ); + PtrList pointSymmTensorFlds + ( + pointSymmTensorNames.size() + ); + subsetPointFields + ( + subsetter, + pMesh, + pointSymmTensorNames, + pointSymmTensorFlds + ); + + wordList pointTensorNames(objects.names(pointTensorField::typeName)); + PtrList pointTensorFlds(pointTensorNames.size()); + subsetPointFields(subsetter, pMesh, pointTensorNames, pointTensorFlds); + + + + // Write mesh and fields to new time + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ runTime++; @@ -252,6 +344,18 @@ int main(int argc, char *argv[]) vectorFlds[i].write(); } + forAll(sphericalTensorFlds, i) + { + sphericalTensorFlds[i].rename(sphericalTensorNames[i]); + + sphericalTensorFlds[i].write(); + } + forAll(symmTensorFlds, i) + { + symmTensorFlds[i].rename(symmTensorNames[i]); + + symmTensorFlds[i].write(); + } forAll(tensorFlds, i) { tensorFlds[i].rename(tensorNames[i]); @@ -272,6 +376,18 @@ int main(int argc, char *argv[]) surfVectorFlds[i].write(); } + forAll(surfSphericalTensorFlds, i) + { + surfSphericalTensorFlds[i].rename(surfSphericalTensorNames[i]); + + surfSphericalTensorFlds[i].write(); + } + forAll(surfSymmTensorFlds, i) + { + surfSymmTensorFlds[i].rename(surfSymmTensorNames[i]); + + surfSymmTensorFlds[i].write(); + } forAll(surfTensorNames, i) { surfTensorFlds[i].rename(surfTensorNames[i]); @@ -279,6 +395,39 @@ int main(int argc, char *argv[]) surfTensorFlds[i].write(); } + // Point ones + forAll(pointScalarFlds, i) + { + pointScalarFlds[i].rename(pointScalarNames[i]); + + pointScalarFlds[i].write(); + } + forAll(pointVectorFlds, i) + { + pointVectorFlds[i].rename(pointVectorNames[i]); + + pointVectorFlds[i].write(); + } + forAll(pointSphericalTensorFlds, i) + { + pointSphericalTensorFlds[i].rename(pointSphericalTensorNames[i]); + + pointSphericalTensorFlds[i].write(); + } + forAll(pointSymmTensorFlds, i) + { + pointSymmTensorFlds[i].rename(pointSymmTensorNames[i]); + + pointSymmTensorFlds[i].write(); + } + forAll(pointTensorNames, i) + { + pointTensorFlds[i].rename(pointTensorNames[i]); + + pointTensorFlds[i].write(); + } + + Info << nl << "End" << endl; return 0; diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C index 85efbfaa10..c9d7409a02 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C @@ -469,7 +469,6 @@ int main(int argc, char *argv[]) // Construct pointMesh only if nessecary since constructs edge // addressing (expensive on polyhedral meshes) - autoPtr pMeshPtr(NULL); if (noPointValues) { Info<< " pointScalarFields : switched off" @@ -477,10 +476,6 @@ int main(int argc, char *argv[]) Info<< " pointVectorFields : switched off" << " (\"-noPointValues\" option)\n"; } - else - { - pMeshPtr.reset(new pointMesh(mesh)); - } PtrList psf; PtrList pvf; @@ -488,21 +483,56 @@ int main(int argc, char *argv[]) PtrList pSymmtf; PtrList ptf; - if (pMeshPtr.valid()) + if (!noPointValues) { - readFields(pMeshPtr(), objects, selectedFields, psf); + readFields + ( + vMesh, + vMesh.basePointMesh(), + objects, + selectedFields, + psf + ); print(" pointScalarFields :", Info, psf); - readFields(pMeshPtr(), objects, selectedFields, pvf); + readFields + ( + vMesh, + vMesh.basePointMesh(), + objects, + selectedFields, + pvf + ); print(" pointVectorFields :", Info, pvf); - readFields(pMeshPtr(), objects, selectedFields, pSpheretf); + readFields + ( + vMesh, + vMesh.basePointMesh(), + objects, + selectedFields, + pSpheretf + ); print(" pointSphericalTensorFields :", Info, pSpheretf); - readFields(pMeshPtr(), objects, selectedFields, pSymmtf); + readFields + ( + vMesh, + vMesh.basePointMesh(), + objects, + selectedFields, + pSymmtf + ); print(" pointSymmTensorFields :", Info, pSymmtf); - readFields(pMeshPtr(), objects, selectedFields, ptf); + readFields + ( + vMesh, + vMesh.basePointMesh(), + objects, + selectedFields, + ptf + ); print(" pointTensorFields :", Info, ptf); } Info<< endl; @@ -550,7 +580,7 @@ int main(int argc, char *argv[]) writer.write(vSymmtf); writer.write(vtf); - if (pMeshPtr.valid()) + if (!noPointValues) { writeFuns::writePointDataHeader ( @@ -567,7 +597,7 @@ int main(int argc, char *argv[]) writer.write(ptf); // Interpolated volFields - volPointInterpolation pInterp(mesh, pMeshPtr()); + volPointInterpolation pInterp(mesh, vMesh.pMesh()); writer.write(pInterp, vsf); writer.write(pInterp, vvf); writer.write(pInterp, vSpheretf); @@ -705,7 +735,7 @@ int main(int argc, char *argv[]) writer.write(vSymmtf); writer.write(vtf); - if (pMeshPtr.valid()) + if (!noPointValues) { writeFuns::writePointDataHeader ( @@ -785,7 +815,7 @@ int main(int argc, char *argv[]) writer.write(vSymmtf); writer.write(vtf); - if (pMeshPtr.valid()) + if (!noPointValues) { writeFuns::writePointDataHeader ( diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/readFields.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/readFields.C index 60d09309c3..975124046f 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/readFields.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/readFields.C @@ -34,50 +34,6 @@ namespace Foam // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // -//template -template -void readFields -( - const typename GeoField::Mesh& mesh, - const IOobjectList& objects, - const HashSet& selectedFields, - PtrList& fields -) -{ - // Search list of objects for volScalarFields - IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName)); - - // Construct the vol scalar fields - fields.setSize(fieldObjects.size()); - label nFields = 0; - - for - ( - IOobjectList::iterator iter = fieldObjects.begin(); - iter != fieldObjects.end(); - ++iter - ) - { - if (!selectedFields.size() || selectedFields.found(iter()->name())) - { - fields.set - ( - nFields, - new GeoField - ( - *iter(), - mesh - ) - ); - - nFields++; - } - } - - fields.setSize(nFields); -} - - template void readFields ( diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/readFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/readFields.H index 577bdf32f0..db98dd948e 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/readFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/readFields.H @@ -45,16 +45,6 @@ SourceFiles namespace Foam { -// Read the fields and put on the pointer list -template -void readFields -( - const typename GeoField::Mesh& mesh, - const IOobjectList& objects, - const HashSet& selectedFields, - PtrList& fields -); - // Read the fields and optionally subset and put on the pointer list template void readFields diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkMesh.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkMesh.C index c96cfd4f67..aecd725ddc 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkMesh.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkMesh.C @@ -45,8 +45,7 @@ Foam::vtkMesh::vtkMesh : baseMesh_(baseMesh), subsetter_(baseMesh), - setName_(setName), - topoPtr_(NULL) + setName_(setName) { if (setName.size() > 0) { @@ -59,14 +58,6 @@ Foam::vtkMesh::vtkMesh } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::vtkMesh::~vtkMesh() -{ - deleteDemandDrivenData(topoPtr_); -} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::polyMesh::readUpdateState Foam::vtkMesh::readUpdate() @@ -78,11 +69,11 @@ Foam::polyMesh::readUpdateState Foam::vtkMesh::readUpdate() // Note: since fvMeshSubset has no movePoints() functionality reconstruct // the subset even if only movement. - deleteDemandDrivenData(topoPtr_); + topoPtr_.clear(); if (setName_.size() > 0) { - Pout<< "Subsetting mesh based on cellSet " << setName_ << endl; + Info<< "Subsetting mesh based on cellSet " << setName_ << endl; // Read cellSet using whole mesh cellSet currentSet(baseMesh_, setName_); diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkMesh.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkMesh.H index b1ceec83dd..8d4ad36ab4 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkMesh.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkMesh.H @@ -39,6 +39,7 @@ SourceFiles #include "vtkTopo.H" #include "fvMeshSubset.H" +#include "pointMesh.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -59,14 +60,17 @@ class vtkMesh //- Reference to mesh fvMesh& baseMesh_; - //- Subsetting engine + //- Demand driven pointMesh + mutable autoPtr pointMeshPtr_; + + //- Subsetting engine + sub-fvMesh fvMeshSubset subsetter_; //- Current cellSet (or empty) const word setName_; //- Current decomposition of topology - mutable vtkTopo* topoPtr_; + mutable autoPtr topoPtr_; @@ -87,11 +91,6 @@ public: vtkMesh(fvMesh& baseMesh, const word& setName = ""); - // Destructor - - ~vtkMesh(); - - // Member Functions // Access @@ -102,6 +101,15 @@ public: return baseMesh_; } + const pointMesh& basePointMesh() const + { + if (!pointMeshPtr_.valid()) + { + pointMeshPtr_.reset(new pointMesh(baseMesh_)); + } + return pointMeshPtr_(); + } + const fvMeshSubset& subsetter() const { return subsetter_; @@ -116,11 +124,11 @@ public: //- topology const vtkTopo& topo() const { - if (!topoPtr_) + if (!topoPtr_.valid()) { - topoPtr_ = new vtkTopo(mesh()); + topoPtr_.reset(new vtkTopo(mesh())); } - return *topoPtr_; + return topoPtr_(); } //- Access either mesh or submesh @@ -136,6 +144,19 @@ public: } } + //- Access either pointMesh of base or pointMesh of subset + const pointMesh& pMesh() const + { + if (useSubMesh()) + { + return subsetter_.subPointMesh(); + } + else + { + return basePointMesh(); + } + } + //- Number of field cells label nFieldCells() const { @@ -145,7 +166,7 @@ public: //- Number of field points label nFieldPoints() const { - return mesh().nPoints() + topo().addPointCellLabels().size(); + return pMesh().size() + topo().addPointCellLabels().size(); } @@ -171,7 +192,6 @@ public: return fld; } } - }; diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkTopo.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkTopo.H index b45a5f3d2e..6867eac71c 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkTopo.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkTopo.H @@ -81,14 +81,17 @@ public: // Public static data // this must be consistent with the enumeration in "vtkCell.H" - static const label VTK_TRIANGLE = 5; - static const label VTK_POLYGON = 7; - static const label VTK_QUAD = 9; + enum vtkTypes + { + VTK_TRIANGLE = 5, + VTK_POLYGON = 7, + VTK_QUAD = 9, - static const label VTK_TETRA = 10; - static const label VTK_PYRAMID = 14; - static const label VTK_WEDGE = 13; - static const label VTK_HEXAHEDRON = 12; + VTK_TETRA = 10, + VTK_PYRAMID = 14, + VTK_WEDGE = 13, + VTK_HEXAHEDRON = 12, + }; // Constructors diff --git a/src/OpenFOAM/fields/pointPatchFields/basic/basicSymmetry/basicSymmetryPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/basic/basicSymmetry/basicSymmetryPointPatchField.C index 1dec091e8a..fe04cb0454 100644 --- a/src/OpenFOAM/fields/pointPatchFields/basic/basicSymmetry/basicSymmetryPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/basic/basicSymmetry/basicSymmetryPointPatchField.C @@ -66,7 +66,7 @@ basicSymmetryPointPatchField::basicSymmetryPointPatchField const pointPatchFieldMapper& ) : - pointPatchField(ptf, iF) + pointPatchField(p, iF) {} diff --git a/src/OpenFOAM/fields/pointPatchFields/basic/calculated/calculatedPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/basic/calculated/calculatedPointPatchField.C index f3367bd57e..b57ae68f80 100644 --- a/src/OpenFOAM/fields/pointPatchFields/basic/calculated/calculatedPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/basic/calculated/calculatedPointPatchField.C @@ -72,7 +72,7 @@ calculatedPointPatchField::calculatedPointPatchField const pointPatchFieldMapper& ) : - pointPatchField(ptf, iF) + pointPatchField(p, iF) {} diff --git a/src/OpenFOAM/fields/pointPatchFields/basic/coupled/coupledPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/basic/coupled/coupledPointPatchField.C index 80fa72bdeb..6d2a1250d1 100644 --- a/src/OpenFOAM/fields/pointPatchFields/basic/coupled/coupledPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/basic/coupled/coupledPointPatchField.C @@ -65,7 +65,7 @@ coupledPointPatchField::coupledPointPatchField const pointPatchFieldMapper& ) : - pointPatchField(ptf, iF) + pointPatchField(p, iF) {} diff --git a/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.C index 261c42e5d6..5d95ea2964 100644 --- a/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.C @@ -114,7 +114,7 @@ valuePointPatchField::valuePointPatchField const pointPatchFieldMapper& mapper ) : - pointPatchField(ptf, iF), + pointPatchField(p, iF), Field(ptf, mapper) {} diff --git a/src/OpenFOAM/fields/pointPatchFields/basic/zeroGradient/zeroGradientPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/basic/zeroGradient/zeroGradientPointPatchField.C index e71bcfe693..7e84b13134 100644 --- a/src/OpenFOAM/fields/pointPatchFields/basic/zeroGradient/zeroGradientPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/basic/zeroGradient/zeroGradientPointPatchField.C @@ -65,7 +65,7 @@ zeroGradientPointPatchField::zeroGradientPointPatchField const pointPatchFieldMapper& ) : - pointPatchField(ptf, iF) + pointPatchField(p, iF) {} diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/cyclic/cyclicPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/constraint/cyclic/cyclicPointPatchField.C index fc1dcc205a..32a68dd977 100644 --- a/src/OpenFOAM/fields/pointPatchFields/constraint/cyclic/cyclicPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/cyclic/cyclicPointPatchField.C @@ -81,10 +81,10 @@ cyclicPointPatchField::cyclicPointPatchField const cyclicPointPatchField& ptf, const pointPatch& p, const DimensionedField& iF, - const pointPatchFieldMapper& + const pointPatchFieldMapper& mapper ) : - coupledPointPatchField(ptf, iF), + coupledPointPatchField(ptf, p, iF, mapper), cyclicPatch_(refCast(p)) { if (!isType(this->patch())) diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/empty/emptyPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/constraint/empty/emptyPointPatchField.C index a99e9255a7..e467baf941 100644 --- a/src/OpenFOAM/fields/pointPatchFields/constraint/empty/emptyPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/empty/emptyPointPatchField.C @@ -81,7 +81,7 @@ emptyPointPatchField::emptyPointPatchField const pointPatchFieldMapper& ) : - pointPatchField(ptf, iF) + pointPatchField(p, iF) { if (!isType(this->patch())) { diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/processor/processorPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/constraint/processor/processorPointPatchField.C index 525e9b4179..831b023b97 100644 --- a/src/OpenFOAM/fields/pointPatchFields/constraint/processor/processorPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/processor/processorPointPatchField.C @@ -66,10 +66,10 @@ processorPointPatchField::processorPointPatchField const processorPointPatchField& ptf, const pointPatch& p, const DimensionedField& iF, - const pointPatchFieldMapper& + const pointPatchFieldMapper& mapper ) : - coupledPointPatchField(ptf, iF), + coupledPointPatchField(ptf, p, iF, mapper), procPatch_(refCast(ptf.patch())) {} diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/symmetry/symmetryPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/constraint/symmetry/symmetryPointPatchField.C index 885a06a7c7..62eb09b596 100644 --- a/src/OpenFOAM/fields/pointPatchFields/constraint/symmetry/symmetryPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/symmetry/symmetryPointPatchField.C @@ -78,10 +78,10 @@ symmetryPointPatchField::symmetryPointPatchField const symmetryPointPatchField& ptf, const pointPatch& p, const DimensionedField& iF, - const pointPatchFieldMapper& + const pointPatchFieldMapper& mapper ) : - basicSymmetryPointPatchField(ptf, iF) + basicSymmetryPointPatchField(ptf, p, iF, mapper) { if (!isType(this->patch())) { diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/wedge/wedgePointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/constraint/wedge/wedgePointPatchField.C index 33f136da20..2c0b4f721f 100644 --- a/src/OpenFOAM/fields/pointPatchFields/constraint/wedge/wedgePointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/wedge/wedgePointPatchField.C @@ -82,7 +82,7 @@ wedgePointPatchField::wedgePointPatchField const pointPatchFieldMapper& ) : - pointPatchField(ptf, iF) + pointPatchField(p, iF) { if (!isType(this->patch())) { diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/global/globalPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/derived/global/globalPointPatchField.C index eed5b1d0f4..2dfe6378f9 100644 --- a/src/OpenFOAM/fields/pointPatchFields/derived/global/globalPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/derived/global/globalPointPatchField.C @@ -82,10 +82,10 @@ globalPointPatchField::globalPointPatchField const globalPointPatchField& ptf, const pointPatch& p, const DimensionedField& iF, - const pointPatchFieldMapper& + const pointPatchFieldMapper& mapper ) : - coupledPointPatchField(ptf, iF), + coupledPointPatchField(ptf, p, iF, mapper), globalPointPatch_(refCast(ptf.patch())) { if (!isType(this->patch())) diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/slip/slipPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/derived/slip/slipPointPatchField.C index ae1014dcea..b32cf3e5fe 100644 --- a/src/OpenFOAM/fields/pointPatchFields/derived/slip/slipPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/derived/slip/slipPointPatchField.C @@ -62,10 +62,10 @@ slipPointPatchField::slipPointPatchField const slipPointPatchField& ptf, const pointPatch& p, const DimensionedField& iF, - const pointPatchFieldMapper& + const pointPatchFieldMapper& mapper ) : - basicSymmetryPointPatchField(ptf, iF) + basicSymmetryPointPatchField(ptf, p, iF, mapper) {} diff --git a/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.C b/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.C index 26fb6ebbe9..9947aabbe8 100644 --- a/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.C +++ b/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.C @@ -48,7 +48,7 @@ namespace Foam bool Foam::fvMeshSubset::checkCellSubset() const { - if (!fvMeshSubsetPtr_) + if (!fvMeshSubsetPtr_.valid()) { FatalErrorIn("bool fvMeshSubset::checkCellSubset() const") << "Mesh subset not set. Please set the cell map using " @@ -267,7 +267,7 @@ void Foam::fvMeshSubset::subsetZones() pz.name(), subset(baseMesh().nPoints(), pz, pointMap()), i, - fvMeshSubsetPtr_->pointZones() + fvMeshSubsetPtr_().pointZones() ); } @@ -315,7 +315,7 @@ void Foam::fvMeshSubset::subsetZones() subAddressing, subFlipStatus, i, - fvMeshSubsetPtr_->faceZones() + fvMeshSubsetPtr_().faceZones() ); } @@ -333,13 +333,13 @@ void Foam::fvMeshSubset::subsetZones() cz.name(), subset(baseMesh().nCells(), cz, cellMap()), i, - fvMeshSubsetPtr_->cellZones() + fvMeshSubsetPtr_().cellZones() ); } // Add the zones - fvMeshSubsetPtr_->addZones(pZonePtrs, fZonePtrs, cZonePtrs); + fvMeshSubsetPtr_().addZones(pZonePtrs, fZonePtrs, cZonePtrs); } @@ -357,14 +357,6 @@ Foam::fvMeshSubset::fvMeshSubset(const fvMesh& baseMesh) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::fvMeshSubset::~fvMeshSubset() -{ - deleteDemandDrivenData(fvMeshSubsetPtr_); -} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::fvMeshSubset::setCellSubset @@ -671,20 +663,24 @@ void Foam::fvMeshSubset::setCellSubset // Make a new mesh - fvMeshSubsetPtr_ = new fvMesh + fvMeshSubsetPtr_.reset ( - IOobject + new fvMesh ( - baseMesh().name() + "SubSet", - baseMesh().time().timeName(), - baseMesh().time(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - newPoints, - newFaces, - newCells + IOobject + ( + baseMesh().name() + "SubSet", + baseMesh().time().timeName(), + baseMesh().time(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + newPoints, + newFaces, + newCells + ) ); + pointMeshSubsetPtr_.clear(); // Add old patches @@ -700,7 +696,7 @@ void Foam::fvMeshSubset::setCellSubset // Patch still exists. Add it newBoundary[nNewPatches] = oldPatches[patchI].clone ( - fvMeshSubsetPtr_->boundaryMesh(), + fvMeshSubsetPtr_().boundaryMesh(), nNewPatches, boundaryPatchSizes[patchI], patchStart @@ -723,7 +719,7 @@ void Foam::fvMeshSubset::setCellSubset boundaryPatchSizes[oldInternalPatchID], patchStart, nNewPatches, - fvMeshSubsetPtr_->boundaryMesh() + fvMeshSubsetPtr_().boundaryMesh() ); // The index for the first patch is -1 as it originates from @@ -738,7 +734,7 @@ void Foam::fvMeshSubset::setCellSubset patchMap_.setSize(nNewPatches); // Add the fvPatches - fvMeshSubsetPtr_->addFvPatches(newBoundary); + fvMeshSubsetPtr_().addFvPatches(newBoundary); // Subset and add any zones subsetZones(); @@ -1166,22 +1162,25 @@ void Foam::fvMeshSubset::setLargeCellSubset // not proper but cannot be avoided since otherwise surfaceInterpolation // cannot find its fvSchemes (it will try to read e.g. // system/region0SubSet/fvSchemes) - fvMeshSubsetPtr_ = new fvMesh + fvMeshSubsetPtr_.reset ( - IOobject + new fvMesh ( - baseMesh().name(), - baseMesh().time().timeName(), - baseMesh().time(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - newPoints, - newFaces, - newCells, - syncPar // parallel synchronisation + IOobject + ( + baseMesh().name(), + baseMesh().time().timeName(), + baseMesh().time(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + newPoints, + newFaces, + newCells, + syncPar // parallel synchronisation + ) ); - + pointMeshSubsetPtr_.clear(); // Add old patches List newBoundary(nbSize); @@ -1251,7 +1250,7 @@ void Foam::fvMeshSubset::setLargeCellSubset // Clone (even if 0 size) newBoundary[nNewPatches] = oldPatches[oldPatchI].clone ( - fvMeshSubsetPtr_->boundaryMesh(), + fvMeshSubsetPtr_().boundaryMesh(), nNewPatches, newSize, patchStart @@ -1282,7 +1281,7 @@ void Foam::fvMeshSubset::setLargeCellSubset boundaryPatchSizes[oldInternalPatchID], patchStart, nNewPatches, - fvMeshSubsetPtr_->boundaryMesh() + fvMeshSubsetPtr_().boundaryMesh() ); //Pout<< " oldInternalFaces : " @@ -1310,7 +1309,7 @@ void Foam::fvMeshSubset::setLargeCellSubset // Patch still exists. Add it newBoundary[nNewPatches] = oldPatches[oldPatchI].clone ( - fvMeshSubsetPtr_->boundaryMesh(), + fvMeshSubsetPtr_().boundaryMesh(), nNewPatches, newSize, patchStart @@ -1331,7 +1330,7 @@ void Foam::fvMeshSubset::setLargeCellSubset // Add the fvPatches - fvMeshSubsetPtr_->addFvPatches(newBoundary); + fvMeshSubsetPtr_().addFvPatches(newBoundary); // Subset and add any zones subsetZones(); @@ -1359,7 +1358,7 @@ const fvMesh& Foam::fvMeshSubset::subMesh() const { checkCellSubset(); - return *fvMeshSubsetPtr_; + return fvMeshSubsetPtr_(); } @@ -1367,7 +1366,27 @@ fvMesh& Foam::fvMeshSubset::subMesh() { checkCellSubset(); - return *fvMeshSubsetPtr_; + return fvMeshSubsetPtr_(); +} + + +const pointMesh& Foam::fvMeshSubset::subPointMesh() const +{ + if (!pointMeshSubsetPtr_.valid()) + { + pointMeshSubsetPtr_.reset(new pointMesh(subMesh())); + } + return pointMeshSubsetPtr_(); +} + + +pointMesh& Foam::fvMeshSubset::subPointMesh() +{ + if (!pointMeshSubsetPtr_.valid()) + { + pointMeshSubsetPtr_.reset(new pointMesh(subMesh())); + } + return pointMeshSubsetPtr_(); } diff --git a/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.H b/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.H index d5c55900da..e8428aea07 100644 --- a/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.H +++ b/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.H @@ -56,11 +56,11 @@ SourceFiles #define fvMeshSubset_H #include "fvMesh.H" +#include "pointMesh.H" #include "fvPatchFieldMapper.H" +#include "pointPatchFieldMapper.H" #include "GeometricField.H" -#include "emptyFvPatchFields.H" #include "labelHashSet.H" -#include "SubField.H" #include "surfaceMesh.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -119,6 +119,48 @@ public: }; + //- Patch-field subset interpolation class + class pointPatchFieldSubset + : + public pointPatchFieldMapper + { + const labelList& directAddressing_; + + public: + + // Constructors + + //- Construct given addressing + pointPatchFieldSubset(const labelList& directAddressing) + : + directAddressing_(directAddressing) + {} + + // Destructor + + virtual ~pointPatchFieldSubset() + {} + + + // Member Functions + + label size() const + { + return directAddressing_.size(); + } + + bool direct() const + { + return true; + } + + const unallocLabelList& directAddressing() const + { + return directAddressing_; + } + }; + + private: // Private data @@ -127,7 +169,9 @@ private: const fvMesh& baseMesh_; //- Subset mesh pointer - fvMesh* fvMeshSubsetPtr_; + autoPtr fvMeshSubsetPtr_; + + mutable autoPtr pointMeshSubsetPtr_; //- Point mapping array labelList pointMap_; @@ -185,11 +229,6 @@ public: explicit fvMeshSubset(const fvMesh&); - // Destructor - - ~fvMeshSubset(); - - // Member Functions // Edit @@ -236,8 +275,14 @@ public: //- Return reference to subset mesh const fvMesh& subMesh() const; + fvMesh& subMesh(); + //- Return reference to demand-driven subset pointMesh + const pointMesh& subPointMesh() const; + + pointMesh& subPointMesh(); + //- Return point map const labelList& pointMap() const; @@ -275,7 +320,7 @@ public: //- Map surface field template static tmp > - interpolate + interpolate ( const GeometricField&, const fvMesh& sMesh, @@ -289,6 +334,25 @@ public: ( const GeometricField& ) const; + + //- Map point field + template + static tmp > + interpolate + ( + const GeometricField&, + const pointMesh& sMesh, + const objectRegistry& reg, + const labelList& patchMap, + const labelList& pointMap + ); + + template + tmp > + interpolate + ( + const GeometricField& + ) const; }; diff --git a/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubsetInterpolate.C b/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubsetInterpolate.C index 40045e89c0..3b59b7b6b9 100644 --- a/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubsetInterpolate.C +++ b/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubsetInterpolate.C @@ -26,6 +26,8 @@ License #include "fvMeshSubset.H" #include "emptyFvsPatchField.H" +#include "emptyPointPatchField.H" +#include "emptyFvPatchFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -134,6 +136,23 @@ tmp > fvMeshSubset::interpolate } +template +tmp > fvMeshSubset::interpolate +( + const GeometricField& vf +) const +{ + return interpolate + ( + vf, + subMesh(), + patchMap(), + cellMap(), + faceMap() + ); +} + + template tmp > fvMeshSubset::interpolate ( @@ -258,23 +277,6 @@ tmp > fvMeshSubset::interpolate } -template -tmp > fvMeshSubset::interpolate -( - const GeometricField& vf -) const -{ - return interpolate - ( - vf, - subMesh(), - patchMap(), - cellMap(), - faceMap() - ); -} - - template tmp > fvMeshSubset::interpolate ( @@ -291,6 +293,130 @@ tmp > fvMeshSubset::interpolate } +template +tmp > +fvMeshSubset::interpolate +( + const GeometricField& vf, + const pointMesh& sMesh, + const objectRegistry& reg, + const labelList& patchMap, + const labelList& pointMap +) +{ + // Create and map the internal-field values + Field internalField(vf.internalField(), pointMap); + + // Create and map the patch field values + PtrList > patchFields(patchMap.size()); + + forAll (patchFields, patchI) + { + // Set the first one by hand as it corresponds to the + // exposed internal faces. Additional interpolation can be put here + // as necessary. + if (patchMap[patchI] == -1) + { + patchFields.set + ( + patchI, + new emptyPointPatchField + ( + sMesh.boundary()[patchI], + DimensionedField::null() + ) + ); + } + else + { + // Construct addressing + const pointPatch& basePatch = + vf.mesh().boundary()[patchMap[patchI]]; + + const labelList& meshPoints = basePatch.meshPoints(); + + // Make addressing from mesh to patch point + Map