ENH: fvPatchField: move mapping of exposed faces to fvPatchField.

This commit is contained in:
mattijs
2013-09-05 13:39:58 +01:00
parent c40460644f
commit 713cb576d0
2 changed files with 99 additions and 40 deletions

View File

@ -79,7 +79,49 @@ Foam::fvPatchField<Type>::fvPatchField
updated_(false), updated_(false),
manipulatedMatrix_(false), manipulatedMatrix_(false),
patchType_(ptf.patchType_) patchType_(ptf.patchType_)
{} {
// For unmapped faces set to internal field value (zero-gradient)
if (&iF && iF.size())
{
Field<Type>& f = *this;
if
(
mapper.direct()
&& &mapper.directAddressing()
&& mapper.directAddressing().size()
)
{
Field<Type> pif(this->patchInternalField());
const labelList& mapAddressing = mapper.directAddressing();
forAll(mapAddressing, i)
{
if (mapAddressing[i] < 0)
{
f[i] = pif[i];
}
}
}
else if (!mapper.direct() && mapper.addressing().size())
{
Field<Type> pif(this->patchInternalField());
const labelListList& mapAddressing = mapper.addressing();
forAll(mapAddressing, i)
{
const labelList& localAddrs = mapAddressing[i];
if (!localAddrs.size())
{
f[i] = pif[i];
}
}
}
}
}
template<class Type> template<class Type>

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -45,10 +45,7 @@ tmp<GeometricField<Type, fvPatchField, volMesh> > fvMeshSubset::interpolate
const labelList& faceMap const labelList& faceMap
) )
{ {
// Create and map the internal-field values // 1. Create the complete field with dummy patch fields
Field<Type> internalField(vf.internalField(), cellMap);
// Create and map the patch field values
PtrList<fvPatchField<Type> > patchFields(patchMap.size()); PtrList<fvPatchField<Type> > patchFields(patchMap.size());
forAll(patchFields, patchI) forAll(patchFields, patchI)
@ -69,6 +66,49 @@ tmp<GeometricField<Type, fvPatchField, volMesh> > fvMeshSubset::interpolate
); );
} }
else else
{
patchFields.set
(
patchI,
new calculatedFvPatchField<Type>
(
sMesh.boundary()[patchI],
DimensionedField<Type, volMesh>::null()
)
);
}
}
tmp<GeometricField<Type, fvPatchField, volMesh> > tresF
(
new GeometricField<Type, fvPatchField, volMesh>
(
IOobject
(
"subset"+vf.name(),
sMesh.time().timeName(),
sMesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
sMesh,
vf.dimensions(),
Field<Type>(vf.internalField(), cellMap),
patchFields
)
);
GeometricField<Type, fvPatchField, volMesh>& resF = tresF();
// 2. Change the fvPatchFields to the correct type using a mapper
// constructor (with reference to the now correct internal field)
typename GeometricField<Type, fvPatchField, volMesh>::
GeometricBoundaryField& bf = resF.boundaryField();
forAll(bf, patchI)
{
if (patchMap[patchI] != -1)
{ {
// Construct addressing // Construct addressing
const fvPatch& subPatch = sMesh.boundary()[patchI]; const fvPatch& subPatch = sMesh.boundary()[patchI];
@ -88,49 +128,26 @@ tmp<GeometricField<Type, fvPatchField, volMesh> > fvMeshSubset::interpolate
} }
else else
{ {
// Mapped from internal face. Do what? Map from element // Mapped from internal face. Do what? Leave up to
// 0 for now. // fvPatchField
directAddressing[i] = 0; directAddressing[i] = -1;
} }
} }
patchFields.set bf.set
( (
patchI, patchI,
fvPatchField<Type>::New fvPatchField<Type>::New
( (
vf.boundaryField()[patchMap[patchI]], vf.boundaryField()[patchMap[patchI]],
sMesh.boundary()[patchI], subPatch,
DimensionedField<Type, volMesh>::null(), resF.dimensionedInternalField(),
patchFieldSubset(directAddressing) patchFieldSubset(directAddressing)
) )
); );
// What to do with exposed internal faces if put into this patch?
} }
} }
// Create the complete field from the pieces
tmp<GeometricField<Type, fvPatchField, volMesh> > tresF
(
new GeometricField<Type, fvPatchField, volMesh>
(
IOobject
(
"subset"+vf.name(),
sMesh.time().timeName(),
sMesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
sMesh,
vf.dimensions(),
internalField,
patchFields
)
);
return tresF; return tresF;
} }
@ -212,9 +229,9 @@ tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > fvMeshSubset::interpolate
} }
else else
{ {
// Mapped from internal face. Do what? Map from element // Mapped from internal face. Do what? Leave up to
// 0 for now. // patchField
directAddressing[i] = 0; directAddressing[i] = -1;
} }
} }
@ -344,8 +361,8 @@ fvMeshSubset::interpolate
const pointPatch& subPatch = sMesh.boundary()[patchI]; const pointPatch& subPatch = sMesh.boundary()[patchI];
const labelList& subMeshPoints = subPatch.meshPoints(); const labelList& subMeshPoints = subPatch.meshPoints();
// If mapped from outside patch use point 0 for lack of better. // If mapped from outside patch leave handling up to patchField
labelList directAddressing(subPatch.size(), 0); labelList directAddressing(subPatch.size(), -1);
forAll(subMeshPoints, localI) forAll(subMeshPoints, localI)
{ {