Field: Replaced autoMap with support in the map functions for mapping to self

Avoids clutter in the interface and code duplication.
This commit is contained in:
Henry Weller
2019-05-02 19:05:42 +01:00
parent 687d56fbf1
commit 76a8f398aa
51 changed files with 78 additions and 165 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -129,13 +129,6 @@ public:
const scalarListList& weights
);
//- Construct by mapping from the given field
inline DynamicField
(
const UList<T>& mapF,
const FieldMapper& map
);
//- Construct copy
inline DynamicField(const DynamicField<T, SizeInc, SizeMult, SizeDiv>&);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -94,19 +94,6 @@ inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
{}
//- Construct by mapping from the given field
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
(
const UList<T>& mapF,
const FieldMapper& map
)
:
Field<T>(mapF, map),
capacity_(Field<T>::size())
{}
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
(

View File

@ -23,7 +23,7 @@ License
\*---------------------------------------------------------------------------*/
#include "FieldMapper.H"
#include "Field.H"
#include "FieldM.H"
#include "dictionary.H"
#include "contiguous.H"
@ -374,69 +374,6 @@ void Foam::Field<Type>::map
}
template<class Type>
void Foam::Field<Type>::autoMap
(
const FieldMapper& mapper
)
{
if (mapper.distributed())
{
// Fetch remote parts of *this
const mapDistributeBase& distMap = mapper.distributeMap();
Field<Type> fCpy(*this);
// Moved flux "flip" functionality to higher level
// if (applyFlip)
// {
// distMap.distribute(fCpy);
// }
// else
{
distMap.distribute(fCpy, noOp());
}
if
(
(mapper.direct()
&& notNull(mapper.directAddressing()))
|| !mapper.direct()
)
{
mapper(*this, fCpy);
}
else if (mapper.direct() && isNull(mapper.directAddressing()))
{
// Special case, no local mapper. Assume ordering already correct
// from distribution. Note: this behaviour is different compared
// to local mapper.
this->transfer(fCpy);
this->setSize(mapper.size());
}
}
else
{
if
(
(
mapper.direct()
&& notNull(mapper.directAddressing())
&& mapper.directAddressing().size()
)
|| (!mapper.direct() && mapper.addressing().size())
)
{
Field<Type> fCpy(*this);
mapper(*this, fCpy);
}
else
{
this->setSize(mapper.size());
}
}
}
template<class Type>
void Foam::Field<Type>::rmap
(

View File

@ -30,7 +30,6 @@ Description
SourceFiles
FieldFunctions.H
FieldFunctionsM.H
FieldMapper.H
FieldM.H
Field.C
FieldFunctions.C
@ -70,7 +69,6 @@ Ostream& operator<<(Ostream&, const Field<Type>&);
template<class Type>
Ostream& operator<<(Ostream&, const tmp<Field<Type>>&);
class FieldMapper;
class dictionary;
/*---------------------------------------------------------------------------*\
@ -233,9 +231,6 @@ public:
const scalarListList& weights
);
//- Map from self
void autoMap(const FieldMapper& map);
//- 1 to 1 reverse-map from the given field
void rmap
(

View File

@ -23,7 +23,6 @@ License
\*---------------------------------------------------------------------------*/
#include "Field.H"
#include "FieldMapper.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

View File

@ -32,6 +32,7 @@ Description
#ifndef FieldMapper_H
#define FieldMapper_H
#include "Field.H"
#include "mapDistributeBase.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -124,7 +124,7 @@ void Foam::valuePointPatchField<Type>::autoMap
const pointPatchFieldMapper& m
)
{
Field<Type>::autoMap(m);
m(*this, *this);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -75,7 +75,7 @@ void MapInternalField<Type, MeshMapper, pointMesh>::operator()
<< abort(FatalError);
}
field.autoMap(mapper.pointMap());
mapper.pointMap()(field, field);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -32,7 +32,7 @@ Description
#ifndef morphFieldMapper_H
#define morphFieldMapper_H
#include "Field.H"
#include "FieldMapper.H"
#include "Map.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -278,13 +278,13 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::autoMap
}
case fixedHeatFlux:
{
q_.autoMap(m);
m(q_, q_);
break;
}
case fixedHeatTransferCoeff:
{
h_.autoMap(m);
m(h_, h_);
break;
}
@ -292,7 +292,7 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::autoMap
if (qrName_ != "none")
{
qrPrevious_.autoMap(m);
m(qrPrevious_, qrPrevious_);
}
}

View File

@ -303,8 +303,8 @@ void thermalBaffle1DFvPatchScalarField<solidType>::autoMap
if (this->owner())
{
thickness_.autoMap(m);
Qs_.autoMap(m);
m(thickness_, thickness_);
m(Qs_, Qs_);
}
}

View File

@ -131,7 +131,7 @@ void Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField::autoMap
const fvPatchFieldMapper& m
)
{
scalarField::autoMap(m);
m(*this, *this);
}

View File

@ -119,9 +119,9 @@ void Foam::wallHeatTransferFvPatchScalarField::autoMap
const fvPatchFieldMapper& m
)
{
scalarField::autoMap(m);
Tinf_.autoMap(m);
alphaWall_.autoMap(m);
m(*this, *this);
m(Tinf_, Tinf_);
m(alphaWall_, alphaWall_);
}

View File

@ -197,8 +197,8 @@ void nutkRoughWallFunctionFvPatchScalarField::autoMap
)
{
nutkWallFunctionFvPatchScalarField::autoMap(m);
Ks_.autoMap(m);
Cs_.autoMap(m);
m(Ks_, Ks_);
m(Cs_, Cs_);
}

View File

@ -172,9 +172,9 @@ Foam::atmBoundaryLayer::atmBoundaryLayer(const atmBoundaryLayer& abl)
void Foam::atmBoundaryLayer::autoMap(const fvPatchFieldMapper& m)
{
z0_.autoMap(m);
zGround_.autoMap(m);
Ustar_.autoMap(m);
m(z0_, z0_);
m(zGround_, zGround_);
m(Ustar_, Ustar_);
}

View File

@ -156,7 +156,7 @@ void nutkAtmRoughWallFunctionFvPatchScalarField::autoMap
)
{
nutkWallFunctionFvPatchScalarField::autoMap(m);
z0_.autoMap(m);
m(z0_, z0_);
}

View File

@ -100,8 +100,8 @@ void Foam::SRFVelocityFvPatchVectorField::autoMap
const fvPatchFieldMapper& m
)
{
vectorField::autoMap(m);
inletValue_.autoMap(m);
m(*this, *this);
m(inletValue_, inletValue_);
}

View File

@ -90,7 +90,7 @@ void Foam::SRFWallVelocityFvPatchVectorField::autoMap
const fvPatchFieldMapper& m
)
{
vectorField::autoMap(m);
m(*this, *this);
}

View File

@ -108,9 +108,9 @@ void Foam::directionMixedFvPatchField<Type>::autoMap
)
{
transformFvPatchField<Type>::autoMap(m);
refValue_.autoMap(m);
refGrad_.autoMap(m);
valueFraction_.autoMap(m);
m(refValue_, refValue_);
m(refGrad_, refGrad_);
m(valueFraction_, valueFraction_);
}

View File

@ -111,7 +111,7 @@ void Foam::fixedGradientFvPatchField<Type>::autoMap
)
{
fvPatchField<Type>::autoMap(m);
gradient_.autoMap(m);
m(gradient_, gradient_);
}

View File

@ -121,9 +121,9 @@ void Foam::mixedFvPatchField<Type>::autoMap
)
{
fvPatchField<Type>::autoMap(m);
refValue_.autoMap(m);
refGrad_.autoMap(m);
valueFraction_.autoMap(m);
m(refValue_, refValue_);
m(refGrad_, refGrad_);
m(valueFraction_, valueFraction_);
}

View File

@ -132,7 +132,7 @@ void Foam::fixedJumpFvPatchField<Type>::autoMap
)
{
jumpCyclicFvPatchField<Type>::autoMap(m);
jump_.autoMap(m);
m(jump_, jump_);
}

View File

@ -146,7 +146,7 @@ void Foam::fixedJumpAMIFvPatchField<Type>::autoMap
)
{
jumpCyclicAMIFvPatchField<Type>::autoMap(m);
jump_.autoMap(m);
m(jump_, jump_);
}

View File

@ -102,7 +102,7 @@ void Foam::fixedNormalSlipFvPatchField<Type>::autoMap
)
{
transformFvPatchField<Type>::autoMap(m);
fixedValue_.autoMap(m);
m(fixedValue_, fixedValue_);
}

View File

@ -138,7 +138,7 @@ void Foam::inletOutletTotalTemperatureFvPatchScalarField::autoMap
)
{
inletOutletFvPatchScalarField::autoMap(m);
T0_.autoMap(m);
m(T0_, T0_);
}

View File

@ -106,7 +106,7 @@ void Foam::interstitialInletVelocityFvPatchVectorField::autoMap
)
{
fixedValueFvPatchVectorField::autoMap(m);
inletVelocity_.autoMap(m);
m(inletVelocity_, inletVelocity_);
}

View File

@ -101,7 +101,7 @@ void Foam::partialSlipFvPatchField<Type>::autoMap
)
{
transformFvPatchField<Type>::autoMap(m);
valueFraction_.autoMap(m);
m(valueFraction_, valueFraction_);
}

View File

@ -108,7 +108,7 @@ void Foam::pressureFvPatchScalarField::autoMap
)
{
fixedValueFvPatchScalarField::autoMap(m);
p_.autoMap(m);
m(p_, p_);
}

View File

@ -120,7 +120,7 @@ void Foam::pressureDirectedInletOutletVelocityFvPatchVectorField::autoMap
)
{
mixedFvPatchVectorField::autoMap(m);
inletDir_.autoMap(m);
m(inletDir_, inletDir_);
}

View File

@ -112,7 +112,7 @@ void Foam::pressureDirectedInletVelocityFvPatchVectorField::autoMap
)
{
fixedValueFvPatchVectorField::autoMap(m);
inletDir_.autoMap(m);
m(inletDir_, inletDir_);
}

View File

@ -140,7 +140,7 @@ void Foam::pressureInletOutletVelocityFvPatchVectorField::autoMap
directionMixedFvPatchVectorField::autoMap(m);
if (tangentialVelocity_.size())
{
tangentialVelocity_.autoMap(m);
m(tangentialVelocity_, tangentialVelocity_);
}
}

View File

@ -109,7 +109,7 @@ void Foam::surfaceNormalFixedValueFvPatchVectorField::autoMap
)
{
fixedValueFvPatchVectorField::autoMap(m);
refValue_.autoMap(m);
m(refValue_, refValue_);
}

View File

@ -389,8 +389,8 @@ void Foam::timeVaryingMappedFvPatchField<Type>::autoMap
{
if (startSampledValues_.size())
{
startSampledValues_.autoMap(m);
endSampledValues_.autoMap(m);
m(startSampledValues_, startSampledValues_);
m(endSampledValues_, endSampledValues_);
}
// Clear interpolator
mapperPtr_.clear();

View File

@ -134,7 +134,7 @@ void Foam::totalPressureFvPatchScalarField::autoMap
)
{
fixedValueFvPatchScalarField::autoMap(m);
p0_.autoMap(m);
m(p0_, p0_);
}

View File

@ -128,7 +128,7 @@ void Foam::totalTemperatureFvPatchScalarField::autoMap
)
{
fixedValueFvPatchScalarField::autoMap(m);
T0_.autoMap(m);
m(T0_, T0_);
}

View File

@ -130,7 +130,7 @@ void Foam::turbulentInletFvPatchField<Type>::autoMap
)
{
fixedValueFvPatchField<Type>::autoMap(m);
referenceField_.autoMap(m);
m(referenceField_, referenceField_);
}

View File

@ -223,7 +223,7 @@ void Foam::fvPatchField<Type>::autoMap
else
{
// Map all faces provided with mapping data
Field<Type>::autoMap(mapper);
mapper(*this, *this);
// For unmapped faces set to internal field value (zero-gradient)
if (mapper.hasUnmapped())

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -33,6 +33,7 @@ Description
#define fvPatchFieldMapper_H
#include "primitiveFields.H"
#include "FieldMapper.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -154,7 +154,7 @@ void Foam::fvsPatchField<Type>::autoMap
const fvPatchFieldMapper& m
)
{
Field<Type>::autoMap(m);
m(*this, *this);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -69,7 +69,7 @@ void MapInternalField<Type, MeshMapper, surfaceMesh>::operator()
<< abort(FatalError);
}
field.autoMap(mapper.surfaceMap());
mapper.surfaceMap()(field, field);
// Flip the flux
const labelList flipFaces = mapper.surfaceMap().flipFaceFlux().toc();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -69,7 +69,7 @@ void MapInternalField<Type, MeshMapper, volMesh>::operator()
<< abort(FatalError);
}
field.autoMap(mapper.volMap());
mapper.volMap()(field, field);
}

View File

@ -129,7 +129,7 @@ void angularOscillatingDisplacementPointPatchVectorField::autoMap
{
fixedValuePointPatchField<vector>::autoMap(m);
p0_.autoMap(m);
m(p0_, p0_);
}

View File

@ -129,7 +129,7 @@ void angularOscillatingVelocityPointPatchVectorField::autoMap
{
fixedValuePointPatchField<vector>::autoMap(m);
p0_.autoMap(m);
m(p0_, p0_);
}

View File

@ -117,7 +117,7 @@ void oscillatingVelocityPointPatchVectorField::autoMap
{
fixedValuePointPatchField<vector>::autoMap(m);
p0_.autoMap(m);
m(p0_, p0_);
}

View File

@ -210,8 +210,8 @@ void Foam::timeVaryingMappedFixedValuePointPatchField<Type>::autoMap
fixedValuePointPatchField<Type>::autoMap(m);
if (startSampledValues_.size())
{
startSampledValues_.autoMap(m);
endSampledValues_.autoMap(m);
m(startSampledValues_, startSampledValues_);
m(endSampledValues_, endSampledValues_);
}
// Clear interpolator
mapperPtr_.clear();

View File

@ -548,7 +548,7 @@ void Foam::genericFvPatchField<Type>::autoMap
iter
)
{
iter()->autoMap(m);
m(*iter(), *iter());
}
forAllIter
@ -558,7 +558,7 @@ void Foam::genericFvPatchField<Type>::autoMap
iter
)
{
iter()->autoMap(m);
m(*iter(), *iter());
}
forAllIter
@ -568,7 +568,7 @@ void Foam::genericFvPatchField<Type>::autoMap
iter
)
{
iter()->autoMap(m);
m(*iter(), *iter());
}
forAllIter
@ -578,7 +578,7 @@ void Foam::genericFvPatchField<Type>::autoMap
iter
)
{
iter()->autoMap(m);
m(*iter(), *iter());
}
forAllIter
@ -588,7 +588,7 @@ void Foam::genericFvPatchField<Type>::autoMap
iter
)
{
iter()->autoMap(m);
m(*iter(), *iter());
}
}

View File

@ -420,7 +420,7 @@ void Foam::genericPointPatchField<Type>::autoMap
iter
)
{
iter()->autoMap(m);
m(*iter(), *iter());
}
forAllIter
@ -430,7 +430,7 @@ void Foam::genericPointPatchField<Type>::autoMap
iter
)
{
iter()->autoMap(m);
m(*iter(), *iter());
}
forAllIter
@ -440,7 +440,7 @@ void Foam::genericPointPatchField<Type>::autoMap
iter
)
{
iter()->autoMap(m);
m(*iter(), *iter());
}
forAllIter
@ -450,7 +450,7 @@ void Foam::genericPointPatchField<Type>::autoMap
iter
)
{
iter()->autoMap(m);
m(*iter(), *iter());
}
forAllIter
@ -460,7 +460,7 @@ void Foam::genericPointPatchField<Type>::autoMap
iter
)
{
iter()->autoMap(m);
m(*iter(), *iter());
}
}

View File

@ -138,7 +138,7 @@ void Foam::MarshakRadiationFixedTemperatureFvPatchScalarField::autoMap
{
mixedFvPatchScalarField::autoMap(m);
radiationCoupledBase::autoMap(m);
Trad_.autoMap(m);
m(Trad_, Trad_);
}

View File

@ -136,7 +136,7 @@ void Foam::greyDiffusiveViewFactorFixedValueFvPatchScalarField::autoMap
{
fixedValueFvPatchScalarField::autoMap(m);
radiationCoupledBase::autoMap(m);
qro_.autoMap(m);
m(qro_, qro_);
}

View File

@ -204,7 +204,7 @@ Foam::scalarField Foam::radiationCoupledBase::emissivity() const
void Foam::radiationCoupledBase::autoMap(const fvPatchFieldMapper& m)
{
emissivity_.autoMap(m);
m(emissivity_, emissivity_);
}

View File

@ -113,8 +113,8 @@ void Foam::alphaFixedPressureFvPatchScalarField::autoMap
const fvPatchFieldMapper& m
)
{
scalarField::autoMap(m);
p_.autoMap(m);
m(*this, *this);
m(p_, p_);
}