/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2011-2026 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 "fvMeshSubset.H" #include "surfaceFields.H" #include "internalFvsPatchField.H" #include "internalPointPatchField.H" #include "internalFvPatchFields.H" #include "forwardFieldMapper.H" #include "flipOp.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template Foam::tmp> Foam::fvMeshSubset::interpolate ( const VolField& vf, const fvMesh& sMesh, const labelList& patchMap, const labelList& cellMap, const labelList& faceMap ) { // 1. Create the complete field with dummy patch fields PtrField> 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 internalFvPatchField ( sMesh.boundary()[patchi], DimensionedField::null() ) ); } else { patchFields.set ( patchi, fvPatchField::New ( calculatedFvPatchField::typeName, sMesh.boundary()[patchi], DimensionedField::null() ) ); } } tmp> tresF ( new VolField ( IOobject ( "subset"+vf.name(), sMesh.time().name(), sMesh, IOobject::NO_READ, IOobject::NO_WRITE, false ), sMesh, vf.dimensions(), Field(vf.primitiveField(), cellMap), patchFields ) ); VolField& resF = tresF.ref(); // 2. Change the fvPatchFields to the correct type using a mapper // constructor (with reference to the now correct internal field) typename VolField::BoundaryField& bf = resF.boundaryFieldRef(); forAll(bf, patchi) { if (patchMap[patchi] != -1) { // Construct addressing const fvPatch& subPatch = sMesh.boundary()[patchi]; const fvPatch& basePatch = vf.mesh().boundary()[patchMap[patchi]]; const label baseStart = basePatch.start(); const label baseSize = basePatch.size(); labelList directAddressing(subPatch.size()); forAll(directAddressing, i) { const label baseFacei = faceMap[subPatch.start() + i]; if (baseFacei >= baseStart && baseFacei < baseStart+baseSize) { directAddressing[i] = baseFacei-baseStart; } else { // Mapped from internal face. Do what? Leave up to // fvPatchField directAddressing[i] = -1; } } bf.set ( patchi, fvPatchField::New ( vf.boundaryField()[patchMap[patchi]], subPatch, resF(), forwardFieldMapper(directAddressing) ) ); } } return tresF; } template Foam::tmp> Foam::fvMeshSubset::interpolate ( const VolField& vf ) const { return interpolate ( vf, subMesh(), patchMap(), cellMap(), faceMap() ); } template Foam::tmp> Foam::fvMeshSubset::interpolate ( const SurfaceField& sf, const fvMesh& sMesh, const labelList& patchMap, const labelList& cellMap, const labelList& faceMap ) { const bool negateIfFlipped = isFlux(sf); // 1. Create the complete field with dummy patch fields PtrField> 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 internalFvsPatchField ( sMesh.boundary()[patchi], DimensionedField::null() ) ); } else { patchFields.set ( patchi, fvsPatchField::New ( calculatedFvsPatchField::typeName, sMesh.boundary()[patchi], DimensionedField::null() ) ); } } // Create the complete field from the pieces tmp> tresF ( new SurfaceField ( IOobject ( "subset"+sf.name(), sMesh.time().name(), sMesh, IOobject::NO_READ, IOobject::NO_WRITE, false ), sMesh, sf.dimensions(), Field ( sf.primitiveField(), SubList