diff --git a/src/finiteArea/interpolation/volSurfaceMapping/volSurfaceMapping.C b/src/finiteArea/interpolation/volSurfaceMapping/volSurfaceMapping.C index e812353649570f35381c5241a26ce3bd99fe2657..01bc10a050b376ff64f7a7da10ff64b58356d8dd 100644 --- a/src/finiteArea/interpolation/volSurfaceMapping/volSurfaceMapping.C +++ b/src/finiteArea/interpolation/volSurfaceMapping/volSurfaceMapping.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 Wikki Ltd - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -65,6 +65,36 @@ Foam::tmp<Foam::Field<Type>> Foam::volSurfaceMapping::mapToSurface } +template<class Type> +Foam::tmp<Foam::Field<Type>> Foam::volSurfaceMapping::mapToSurface +( + const Field<Type>& f +) const +{ + const labelList& faceLabels = mesh_.faceLabels(); + + auto tresult = tmp<Field<Type>>::New(faceLabels.size(), Zero); + auto& result = tresult.ref(); + + const polyMesh& pMesh = mesh_(); + const polyBoundaryMesh& bm = pMesh.boundaryMesh(); + label patchID, faceID; + + forAll(faceLabels, i) + { + if (faceLabels[i] < pMesh.nFaces()) + { + patchID = bm.whichPatch(faceLabels[i]); + faceID = bm[patchID].whichFace(faceLabels[i]); + + result[i] = f[faceID]; + } + } + + return tresult; +} + + template<class Type> Foam::tmp<Foam::Field<Type>> Foam::volSurfaceMapping::mapInternalToSurface ( @@ -151,6 +181,19 @@ void Foam::volSurfaceMapping::mapToField const GeometricField<Type, faPatchField, areaMesh>& af, Field<Type>& f ) const +{ + const Field<Type>& afi = af.internalField(); + + mapToField(afi, f); +} + + +template<class Type> +void Foam::volSurfaceMapping::mapToField +( + const Field<Type>& af, + Field<Type>& f +) const { const labelList& faceLabels = mesh_.faceLabels(); @@ -158,15 +201,13 @@ void Foam::volSurfaceMapping::mapToField const polyBoundaryMesh& bm = pMesh.boundaryMesh(); label patchID, faceID; - const Field<Type>& afi = af.internalField(); - forAll(faceLabels, i) { if (faceLabels[i] < pMesh.nFaces()) { patchID = bm.whichPatch(faceLabels[i]); faceID = bm[patchID].whichFace(faceLabels[i]); - f[faceID] = afi[i]; + f[faceID] = af[i]; } } } diff --git a/src/finiteArea/interpolation/volSurfaceMapping/volSurfaceMapping.H b/src/finiteArea/interpolation/volSurfaceMapping/volSurfaceMapping.H index 5b428f099c19df902ad6e9ba5fe28e0f9ea5e6f6..f5908f04a41db680ac01ded0feb144c2fc18e6b0 100644 --- a/src/finiteArea/interpolation/volSurfaceMapping/volSurfaceMapping.H +++ b/src/finiteArea/interpolation/volSurfaceMapping/volSurfaceMapping.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 Wikki Ltd - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,6 +42,7 @@ SourceFiles #define volSurfaceMapping_H #include "faMesh.H" +#include "volMesh.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -85,7 +86,7 @@ public: // Member Functions - //- Map droplet cloud sources to surface + //- Map Boundary field to surface template<class Type> tmp<Field<Type>> mapToSurface ( @@ -93,6 +94,9 @@ public: GeometricField<Type, fvPatchField, volMesh>::Boundary& df ) const; + //- Map vol Field to surface Field + template<class Type> + tmp<Field<Type>> mapToSurface(const Field<Type>& f) const; //- Map patch internal field to surface template<class Type> @@ -118,14 +122,23 @@ public: typename GeometricField<Type, fvPatchField, volMesh>::Boundary& bf ) const; - //- Map surface field to field assumes Field - //- faces in the same order as Boundary + //- Map surface field to field + // Assumes Field faces in the same order as Boundary template<class Type> void mapToField ( const GeometricField<Type, faPatchField, areaMesh>& af, Field<Type>& f ) const; + + //- Map surface field to volume field + // Assumes Field faces in the same order as Boundary + template<class Type> + void mapToField + ( + const Field<Type>& af, + Field<Type>& f + ) const; };