ENH: FieldMapper: extend with unmapped checking flag

This commit is contained in:
mattijs
2013-09-12 15:37:53 +01:00
parent f35433bdea
commit 5ac31aabc8
28 changed files with 754 additions and 402 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -88,6 +88,12 @@ public:
return true;
}
//- Are there unmapped values
bool hasUnmapped() const
{
return false;
}
const labelUList& directAddressing() const
{
return directAddressing_;
@ -128,6 +134,12 @@ public:
return true;
}
//- Are there unmapped values
bool hasUnmapped() const
{
return false;
}
const labelUList& directAddressing() const
{
return directAddressing_;
@ -165,6 +177,12 @@ public:
return false;
}
//- Are there unmapped values
bool hasUnmapped() const
{
return false;
}
const labelListList& addressing() const
{
return addressing_;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -40,83 +40,25 @@ Foam::fvFieldDecomposer::decomposeField
const bool allowUnknownPatchFields
) const
{
// Create and map the internal field values
Field<Type> internalField(field.internalField(), cellAddressing_);
// Create and map the patch field values
// 1. Create the complete field with dummy patch fields
PtrList<fvPatchField<Type> > patchFields(boundaryAddressing_.size());
forAll(boundaryAddressing_, patchi)
{
if (patchFieldDecomposerPtrs_[patchi])
{
patchFields.set
patchFields.set
(
patchi,
fvPatchField<Type>::New
(
patchi,
fvPatchField<Type>::New
(
field.boundaryField()[boundaryAddressing_[patchi]],
procMesh_.boundary()[patchi],
DimensionedField<Type, volMesh>::null(),
*patchFieldDecomposerPtrs_[patchi]
)
);
}
else if (isA<processorCyclicFvPatch>(procMesh_.boundary()[patchi]))
{
patchFields.set
(
patchi,
new processorCyclicFvPatchField<Type>
(
procMesh_.boundary()[patchi],
DimensionedField<Type, volMesh>::null(),
Field<Type>
(
field.internalField(),
*processorVolPatchFieldDecomposerPtrs_[patchi]
)
)
);
}
else if (isA<processorFvPatch>(procMesh_.boundary()[patchi]))
{
patchFields.set
(
patchi,
new processorFvPatchField<Type>
(
procMesh_.boundary()[patchi],
DimensionedField<Type, volMesh>::null(),
Field<Type>
(
field.internalField(),
*processorVolPatchFieldDecomposerPtrs_[patchi]
)
)
);
}
else if (allowUnknownPatchFields)
{
patchFields.set
(
patchi,
new emptyFvPatchField<Type>
(
procMesh_.boundary()[patchi],
DimensionedField<Type, volMesh>::null()
)
);
}
else
{
FatalErrorIn("fvFieldDecomposer::decomposeField()")
<< "Unknown type." << abort(FatalError);
}
calculatedFvPatchField<Type>::typeName,
procMesh_.boundary()[patchi],
DimensionedField<Type, volMesh>::null()
)
);
}
// Create the field for the processor
return tmp<GeometricField<Type, fvPatchField, volMesh> >
tmp<GeometricField<Type, fvPatchField, volMesh> > tresF
(
new GeometricField<Type, fvPatchField, volMesh>
(
@ -130,10 +72,90 @@ Foam::fvFieldDecomposer::decomposeField
),
procMesh_,
field.dimensions(),
internalField,
Field<Type>(field.internalField(), cellAddressing_),
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 (patchFieldDecomposerPtrs_[patchi])
{
bf.set
(
patchi,
fvPatchField<Type>::New
(
field.boundaryField()[boundaryAddressing_[patchi]],
procMesh_.boundary()[patchi],
resF.dimensionedInternalField(),
*patchFieldDecomposerPtrs_[patchi]
)
);
}
else if (isA<processorCyclicFvPatch>(procMesh_.boundary()[patchi]))
{
bf.set
(
patchi,
new processorCyclicFvPatchField<Type>
(
procMesh_.boundary()[patchi],
resF.dimensionedInternalField(),
Field<Type>
(
field.internalField(),
*processorVolPatchFieldDecomposerPtrs_[patchi]
)
)
);
}
else if (isA<processorFvPatch>(procMesh_.boundary()[patchi]))
{
bf.set
(
patchi,
new processorFvPatchField<Type>
(
procMesh_.boundary()[patchi],
resF.dimensionedInternalField(),
Field<Type>
(
field.internalField(),
*processorVolPatchFieldDecomposerPtrs_[patchi]
)
)
);
}
else if (allowUnknownPatchFields)
{
bf.set
(
patchi,
new emptyFvPatchField<Type>
(
procMesh_.boundary()[patchi],
resF.dimensionedInternalField()
)
);
}
else
{
FatalErrorIn("fvFieldDecomposer::decomposeField()")
<< "Unknown type." << abort(FatalError);
}
}
// Create the field for the processor
return tresF;
}
@ -188,34 +210,76 @@ Foam::fvFieldDecomposer::decomposeField
}
}
// Create and map the patch field values
// 1. Create the complete field with dummy patch fields
PtrList<fvsPatchField<Type> > patchFields(boundaryAddressing_.size());
forAll(boundaryAddressing_, patchi)
{
patchFields.set
(
patchi,
fvsPatchField<Type>::New
(
calculatedFvsPatchField<Type>::typeName,
procMesh_.boundary()[patchi],
DimensionedField<Type, surfaceMesh>::null()
)
);
}
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tresF
(
new GeometricField<Type, fvsPatchField, surfaceMesh>
(
IOobject
(
field.name(),
procMesh_.time().timeName(),
procMesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
procMesh_,
field.dimensions(),
Field<Type>(field.internalField(), mapAddr),
patchFields
)
);
GeometricField<Type, fvsPatchField, surfaceMesh>& resF = tresF();
// 2. Change the fvsPatchFields to the correct type using a mapper
// constructor (with reference to the now correct internal field)
typename GeometricField<Type, fvsPatchField, surfaceMesh>::
GeometricBoundaryField& bf = resF.boundaryField();
forAll(boundaryAddressing_, patchi)
{
if (patchFieldDecomposerPtrs_[patchi])
{
patchFields.set
bf.set
(
patchi,
fvsPatchField<Type>::New
(
field.boundaryField()[boundaryAddressing_[patchi]],
procMesh_.boundary()[patchi],
DimensionedField<Type, surfaceMesh>::null(),
resF.dimensionedInternalField(),
*patchFieldDecomposerPtrs_[patchi]
)
);
}
else if (isA<processorCyclicFvPatch>(procMesh_.boundary()[patchi]))
{
patchFields.set
bf.set
(
patchi,
new processorCyclicFvsPatchField<Type>
(
procMesh_.boundary()[patchi],
DimensionedField<Type, surfaceMesh>::null(),
resF.dimensionedInternalField(),
Field<Type>
(
allFaceField,
@ -226,13 +290,13 @@ Foam::fvFieldDecomposer::decomposeField
}
else if (isA<processorFvPatch>(procMesh_.boundary()[patchi]))
{
patchFields.set
bf.set
(
patchi,
new processorFvsPatchField<Type>
(
procMesh_.boundary()[patchi],
DimensionedField<Type, surfaceMesh>::null(),
resF.dimensionedInternalField(),
Field<Type>
(
allFaceField,
@ -249,24 +313,7 @@ Foam::fvFieldDecomposer::decomposeField
}
// Create the field for the processor
return tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
(
new GeometricField<Type, fvsPatchField, surfaceMesh>
(
IOobject
(
field.name(),
procMesh_.time().timeName(),
procMesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
procMesh_,
field.dimensions(),
internalField,
patchFields
)
);
return tresF;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -116,6 +116,11 @@ public:
return true;
}
bool hasUnmapped() const
{
return false;
}
const labelUList& directAddressing() const
{
return labelUList::null();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -112,6 +112,11 @@ public:
return true;
}
bool hasUnmapped() const
{
return false;
}
const labelUList& directAddressing() const
{
return labelUList::null();