fieldMapper: Moved distributed functionality to distributedWeightedFvPatchFieldMapper

This commit is contained in:
Henry Weller
2019-05-07 15:58:23 +01:00
parent 5203a84a0f
commit 69eccc7742
8 changed files with 353 additions and 147 deletions

View File

@ -27,15 +27,6 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::mapDistributeBase& Foam::fieldMapper::distributeMap() const
{
FatalErrorInFunction
<< "attempt to access null distributeMap"
<< abort(FatalError);
return *(new mapDistributeBase());
}
const Foam::labelUList& Foam::fieldMapper::directAddressing() const
{
FatalErrorInFunction

View File

@ -75,13 +75,6 @@ public:
virtual bool direct() const = 0;
virtual bool distributed() const
{
return false;
}
virtual const mapDistributeBase& distributeMap() const;
//- Are there unmapped values? I.e. do all size() elements get
// get value
virtual bool hasUnmapped() const = 0;

View File

@ -30,58 +30,22 @@ License
template<class Type>
void Foam::fieldMapper::map(Field<Type>& f, const Field<Type>& mapF) const
{
if (distributed())
if
(
direct()
&& notNull(directAddressing())
&& directAddressing().size()
)
{
// Fetch remote parts of mapF
const mapDistributeBase& distMap = distributeMap();
Field<Type> newMapF(mapF);
// Moved flux "flip" functionality to higher level
// if (applyFlip)
// {
// distMap.distribute(newMapF);
// }
// else
{
distMap.distribute(newMapF, noOp());
}
if (direct() && notNull(directAddressing()))
{
f.map(newMapF, directAddressing());
}
else if (!direct())
{
f.map(newMapF, addressing(), weights());
}
else if (direct() && isNull(directAddressing()))
{
// Special case, no local Assume ordering already correct
// from distribution. Note: this behaviour is different compared
// to local
f.transfer(newMapF);
f.setSize(size());
}
f.map(mapF, directAddressing());
}
else if (!direct() && addressing().size())
{
f.map(mapF, addressing(), weights());
}
else
{
if
(
direct()
&& notNull(directAddressing())
&& directAddressing().size()
)
{
f.map(mapF, directAddressing());
}
else if (!direct() && addressing().size())
{
f.map(mapF, addressing(), weights());
}
else
{
f.setSize(size());
}
f.setSize(size());
}
}

View File

@ -53,6 +53,7 @@ class IOobjectList;
class fvFieldDecomposer
{
public:
//- Patch field decomposer class
@ -147,54 +148,6 @@ public:
};
//- Processor patch field decomposer class. Surface field is assumed
// to have direction (so manipulates sign when mapping)
class processorSurfacePatchFieldDecomposer
:
public fvPatchFieldMapper
{
labelListList addressing_;
scalarListList weights_;
public:
//- Construct given addressing
processorSurfacePatchFieldDecomposer
(
const labelUList& addressingSlice
);
// Member functions
label size() const
{
return addressing_.size();
}
bool direct() const
{
return false;
}
//- Are there unmapped values
bool hasUnmapped() const
{
return false;
}
const labelListList& addressing() const
{
return addressing_;
}
const scalarListList& weights() const
{
return weights_;
}
};
private:
// Private data

View File

@ -53,6 +53,7 @@ graphField/makeGraph.C
meshToMesh/meshToMesh.C
meshToMesh/meshToMeshParallelOps.C
meshToMesh/distributedWeightedFvPatchFieldMapper.C
meshToMeshMethods = meshToMesh/calcMethod
$(meshToMeshMethods)/meshToMeshMethod/meshToMeshMethod.C
$(meshToMeshMethods)/meshToMeshMethod/meshToMeshMethodNew.C

View File

@ -0,0 +1,146 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "distributedWeightedFvPatchFieldMapper.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::labelListList&
Foam::distributedWeightedFvPatchFieldMapper::addressing() const
{
return addressing_;
}
const Foam::scalarListList&
Foam::distributedWeightedFvPatchFieldMapper::weights() const
{
return weights_;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
Foam::tmp<Foam::Field<Foam::scalar>>
Foam::distributedWeightedFvPatchFieldMapper::operator()
(
const Field<scalar>& mapF
) const
{
return map(mapF);
}
Foam::tmp<Foam::Field<Foam::vector>>
Foam::distributedWeightedFvPatchFieldMapper::operator()
(
const Field<vector>& mapF
) const
{
return map(mapF);
}
Foam::tmp<Foam::Field<Foam::sphericalTensor>>
Foam::distributedWeightedFvPatchFieldMapper::operator()
(
const Field<sphericalTensor>& mapF
) const
{
return map(mapF);
}
Foam::tmp<Foam::Field<Foam::symmTensor>>
Foam::distributedWeightedFvPatchFieldMapper::operator()
(
const Field<symmTensor>& mapF
) const
{
return map(mapF);
}
Foam::tmp<Foam::Field<Foam::tensor>>
Foam::distributedWeightedFvPatchFieldMapper::operator()
(
const Field<tensor>& mapF
) const
{
return map(mapF);
}
void Foam::distributedWeightedFvPatchFieldMapper::operator()
(
Field<scalar>& f,
const Field<scalar>& mapF
) const
{
return map(f, mapF);
}
void Foam::distributedWeightedFvPatchFieldMapper::operator()
(
Field<vector>& f,
const Field<vector>& mapF
) const
{
return map(f, mapF);
}
void Foam::distributedWeightedFvPatchFieldMapper::operator()
(
Field<sphericalTensor>& f,
const Field<sphericalTensor>& mapF
) const
{
return map(f, mapF);
}
void Foam::distributedWeightedFvPatchFieldMapper::operator()
(
Field<symmTensor>& f,
const Field<symmTensor>& mapF
) const
{
return map(f, mapF);
}
void Foam::distributedWeightedFvPatchFieldMapper::operator()
(
Field<tensor>& f,
const Field<tensor>& mapF
) const
{
return map(f, mapF);
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2015-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -48,15 +48,27 @@ class distributedWeightedFvPatchFieldMapper
:
public fvPatchFieldMapper
{
const label singlePatchProc_;
// Private member data
const mapDistributeBase* distMapPtr_;
const label singlePatchProc_;
const labelListList& addressing_;
const mapDistributeBase* distMapPtr_;
const scalarListList& weights_;
const labelListList& addressing_;
const scalarListList& weights_;
bool hasUnmapped_;
// Private member functions
template<class Type>
void map(Field<Type>& f, const Field<Type>& mapF) const;
template<class Type>
tmp<Field<Type>> map(const Field<Type>& f) const;
bool hasUnmapped_;
public:
@ -99,6 +111,7 @@ public:
}
}
//- Destructor
virtual ~distributedWeightedFvPatchFieldMapper()
{}
@ -108,9 +121,9 @@ public:
virtual label size() const
{
if (distributed())
if (singlePatchProc_ == -1)
{
return distributeMap().constructSize();
return distMapPtr_->constructSize();
}
else
{
@ -123,48 +136,94 @@ public:
return false;
}
virtual bool distributed() const
{
return singlePatchProc_ == -1;
}
virtual const mapDistributeBase& distributeMap() const
{
if (!distMapPtr_)
{
FatalErrorIn
(
"distributedWeightedFvPatchFieldMapper::"
"distributeMap()"
) << "Cannot ask for distributeMap on a non-distributed"
<< " mapper" << exit(FatalError);
}
return *distMapPtr_;
}
virtual bool hasUnmapped() const
{
return hasUnmapped_;
}
virtual const labelListList& addressing() const
{
return addressing_;
}
virtual const labelListList& addressing() const;
virtual const scalarListList& weights() const
{
return weights_;
}
virtual const scalarListList& weights() const;
// Member Operators
virtual void operator()
(
Field<scalar>& f,
const Field<scalar>& mapF
) const;
virtual void operator()
(
Field<vector>& f,
const Field<vector>& mapF
) const;
virtual void operator()
(
Field<sphericalTensor>& f,
const Field<sphericalTensor>& mapF
) const;
virtual void operator()
(
Field<symmTensor>& f,
const Field<symmTensor>& mapF
) const;
virtual void operator()
(
Field<tensor>& f,
const Field<tensor>& mapF
) const;
template<class Type>
void operator()(Field<Type>& f, const tmp<Field<Type>>& tmapF) const;
virtual tmp<Field<scalar>> operator()
(
const Field<scalar>& mapF
) const;
virtual tmp<Field<vector>> operator()
(
const Field<vector>& mapF
) const;
virtual tmp<Field<sphericalTensor>> operator()
(
const Field<sphericalTensor>& mapF
) const;
virtual tmp<Field<symmTensor>> operator()
(
const Field<symmTensor>& mapF
) const;
virtual tmp<Field<tensor>> operator()
(
const Field<tensor>& mapF
) const;
template<class Type>
tmp<Field<Type>> operator()(const tmp<Field<Type>>& tmapF) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "distributedWeightedFvPatchFieldMapperTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,99 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "distributedWeightedFvPatchFieldMapper.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::distributedWeightedFvPatchFieldMapper::map
(
Field<Type>& f,
const Field<Type>& mapF
) const
{
if (singlePatchProc_ == -1)
{
// Fetch remote parts of mapF
const mapDistributeBase& distMap = *distMapPtr_;
Field<Type> newMapF(mapF);
// Moved flux "flip" functionality to higher level
// if (applyFlip)
// {
// distMap.distribute(newMapF);
// }
// else
{
distMap.distribute(newMapF, noOp());
}
f.map(newMapF, addressing(), weights());
}
else
{
f.map(mapF, addressing(), weights());
}
}
template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::distributedWeightedFvPatchFieldMapper::map
(
const Field<Type>& mapF
) const
{
tmp<Field<Type>> tf(new Field<Type>(size()));
map(tf.ref(), mapF);
return tf;
}
template<class Type>
void Foam::distributedWeightedFvPatchFieldMapper::operator()
(
Field<Type>& f,
const tmp<Field<Type>>& tmapF
) const
{
map(f, tmapF());
tmapF.clear();
}
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::distributedWeightedFvPatchFieldMapper::operator()
(
const tmp<Field<Type>>& tmapF
) const
{
tmp<Foam::Field<Type>> tf(map(tmapF()));
tmapF.clear();
return tf;
}
// ************************************************************************* //