mapFields: Minimum hack provided by Mattijs to get mapFields working again
This version is very inefficient in parallel and does not provide the -parallelSource or -parallelTarget options which will need to be reinstanted in the future or we could revert mapFields to the OpenFOAM-2.2 version.
This commit is contained in:
@ -41,8 +41,7 @@ void mapConsistentMesh
|
||||
(
|
||||
const fvMesh& meshSource,
|
||||
const fvMesh& meshTarget,
|
||||
const word& mapMethod,
|
||||
const word& AMIMapMethod,
|
||||
const meshToMesh::interpolationMethod& mapMethod,
|
||||
const bool subtract,
|
||||
const HashSet<word>& selectedFields,
|
||||
const bool noLagrangian
|
||||
@ -51,7 +50,7 @@ void mapConsistentMesh
|
||||
Info<< nl << "Consistently creating and mapping fields for time "
|
||||
<< meshSource.time().timeName() << nl << endl;
|
||||
|
||||
meshToMesh interp(meshSource, meshTarget, mapMethod, AMIMapMethod);
|
||||
meshToMesh interp(meshSource, meshTarget, mapMethod);
|
||||
|
||||
if (subtract)
|
||||
{
|
||||
@ -80,8 +79,7 @@ void mapSubMesh
|
||||
const fvMesh& meshTarget,
|
||||
const HashTable<word>& patchMap,
|
||||
const wordList& cuttingPatches,
|
||||
const word& mapMethod,
|
||||
const word& AMIMapMethod,
|
||||
const meshToMesh::interpolationMethod& mapMethod,
|
||||
const bool subtract,
|
||||
const HashSet<word>& selectedFields,
|
||||
const bool noLagrangian
|
||||
@ -95,7 +93,6 @@ void mapSubMesh
|
||||
meshSource,
|
||||
meshTarget,
|
||||
mapMethod,
|
||||
AMIMapMethod,
|
||||
patchMap,
|
||||
cuttingPatches
|
||||
);
|
||||
@ -187,13 +184,7 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
"mapMethod",
|
||||
"word",
|
||||
"specify the mapping method (direct|mapNearest|cellVolumeWeight)"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"patchMapMethod",
|
||||
"word",
|
||||
"specify the patch mapping method (direct|mapNearest|faceAreaWeight)"
|
||||
"specify the mapping method"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
@ -240,50 +231,17 @@ int main(int argc, char *argv[])
|
||||
|
||||
const bool consistent = args.optionFound("consistent");
|
||||
|
||||
meshToMesh::interpolationMethod mapMethod =
|
||||
meshToMesh::imCellVolumeWeight;
|
||||
|
||||
word mapMethod = meshToMesh::interpolationMethodNames_
|
||||
[
|
||||
meshToMesh::imCellVolumeWeight
|
||||
];
|
||||
|
||||
if (args.optionReadIfPresent("mapMethod", mapMethod))
|
||||
if (args.optionFound("mapMethod"))
|
||||
{
|
||||
Info<< "Mapping method: " << mapMethod << endl;
|
||||
mapMethod = meshToMesh::interpolationMethodNames_[args["mapMethod"]];
|
||||
|
||||
Info<< "Mapping method: "
|
||||
<< meshToMesh::interpolationMethodNames_[mapMethod] << endl;
|
||||
}
|
||||
|
||||
|
||||
word patchMapMethod;
|
||||
if (meshToMesh::interpolationMethodNames_.found(mapMethod))
|
||||
{
|
||||
// Lookup corresponding AMI method
|
||||
meshToMesh::interpolationMethod method =
|
||||
meshToMesh::interpolationMethodNames_[mapMethod];
|
||||
|
||||
patchMapMethod = AMIPatchToPatchInterpolation::interpolationMethodToWord
|
||||
(
|
||||
meshToMesh::interpolationMethodAMI(method)
|
||||
);
|
||||
}
|
||||
|
||||
// Optionally override
|
||||
if (args.optionFound("patchMapMethod"))
|
||||
{
|
||||
patchMapMethod = args["patchMapMethod"];
|
||||
|
||||
Info<< "Patch mapping method: " << patchMapMethod << endl;
|
||||
}
|
||||
|
||||
|
||||
if (patchMapMethod.empty())
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "No valid patchMapMethod for method " << mapMethod
|
||||
<< ". Please supply one through the 'patchMapMethod' option"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
|
||||
|
||||
const bool subtract = args.optionFound("subtract");
|
||||
if (subtract)
|
||||
{
|
||||
@ -356,7 +314,6 @@ int main(int argc, char *argv[])
|
||||
meshSource,
|
||||
meshTarget,
|
||||
mapMethod,
|
||||
patchMapMethod,
|
||||
subtract,
|
||||
selectedFields,
|
||||
noLagrangian
|
||||
@ -371,7 +328,6 @@ int main(int argc, char *argv[])
|
||||
patchMap,
|
||||
addProcessorPatches(meshTarget, cuttingPatches),
|
||||
mapMethod,
|
||||
patchMapMethod,
|
||||
subtract,
|
||||
selectedFields,
|
||||
noLagrangian
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -27,6 +27,7 @@ License
|
||||
#include "volFields.H"
|
||||
#include "directFvPatchFieldMapper.H"
|
||||
#include "calculatedFvPatchField.H"
|
||||
#include "weightedFvPatchFieldMapper.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -347,8 +348,33 @@ void Foam::meshToMesh::mapSrcToTgt
|
||||
label srcPatchI = srcPatchID_[i];
|
||||
label tgtPatchI = tgtPatchID_[i];
|
||||
|
||||
const Field<Type>& srcField = field.boundaryField()[srcPatchI];
|
||||
Field<Type>& tgtField = result.boundaryField()[tgtPatchI];
|
||||
const fvPatchField<Type>& srcField = field.boundaryField()[srcPatchI];
|
||||
fvPatchField<Type>& tgtField = result.boundaryField()[tgtPatchI];
|
||||
|
||||
// 2.3 does not do distributed mapping yet so only do if
|
||||
// running on single processor
|
||||
if (AMIList[i].singlePatchProc() != -1)
|
||||
{
|
||||
// Clone and map (since rmap does not do general mapping)
|
||||
tmp<fvPatchField<Type> > tnewTgt
|
||||
(
|
||||
fvPatchField<Type>::New
|
||||
(
|
||||
srcField,
|
||||
tgtField.patch(),
|
||||
result.dimensionedInternalField(),
|
||||
weightedFvPatchFieldMapper
|
||||
(
|
||||
AMIList[i].tgtAddress(),
|
||||
AMIList[i].tgtWeights()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Transfer all mapped quantities (value and e.g. gradient) onto
|
||||
// tgtField. Value will get overwritten below.
|
||||
tgtField.rmap(tnewTgt(), identity(tgtField.size()));
|
||||
}
|
||||
|
||||
tgtField = pTraits<Type>::zero;
|
||||
|
||||
@ -511,8 +537,33 @@ void Foam::meshToMesh::mapTgtToSrc
|
||||
label srcPatchI = srcPatchID_[i];
|
||||
label tgtPatchI = tgtPatchID_[i];
|
||||
|
||||
Field<Type>& srcField = result.boundaryField()[srcPatchI];
|
||||
const Field<Type>& tgtField = field.boundaryField()[tgtPatchI];
|
||||
fvPatchField<Type>& srcField = result.boundaryField()[srcPatchI];
|
||||
const fvPatchField<Type>& tgtField = field.boundaryField()[tgtPatchI];
|
||||
|
||||
// 2.3 does not do distributed mapping yet so only do if
|
||||
// running on single processor
|
||||
if (AMIList[i].singlePatchProc() != -1)
|
||||
{
|
||||
// Clone and map (since rmap does not do general mapping)
|
||||
tmp<fvPatchField<Type> > tnewSrc
|
||||
(
|
||||
fvPatchField<Type>::New
|
||||
(
|
||||
tgtField,
|
||||
srcField.patch(),
|
||||
result.dimensionedInternalField(),
|
||||
weightedFvPatchFieldMapper
|
||||
(
|
||||
AMIList[i].srcAddress(),
|
||||
AMIList[i].srcWeights()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Transfer all mapped quantities (value and e.g. gradient) onto
|
||||
// srcField. Value will get overwritten below
|
||||
srcField.rmap(tnewSrc(), identity(srcField.size()));
|
||||
}
|
||||
|
||||
srcField = pTraits<Type>::zero;
|
||||
|
||||
|
||||
@ -0,0 +1,122 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
Class
|
||||
Foam::weightedFvPatchFieldMapper
|
||||
|
||||
Description
|
||||
FieldMapper with weighted mapping.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef weightedFvPatchFieldMapper_H
|
||||
#define weightedFvPatchFieldMapper_H
|
||||
|
||||
#include "fvPatchFieldMapper.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class weightedFvPatchFieldMapper Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class weightedFvPatchFieldMapper
|
||||
:
|
||||
public fvPatchFieldMapper
|
||||
{
|
||||
const labelListList& addressing_;
|
||||
|
||||
const scalarListList& weights_;
|
||||
|
||||
bool hasUnmapped_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct given addressing
|
||||
weightedFvPatchFieldMapper
|
||||
(
|
||||
const labelListList& addressing,
|
||||
const scalarListList& weights
|
||||
)
|
||||
:
|
||||
addressing_(addressing),
|
||||
weights_(weights),
|
||||
hasUnmapped_(false)
|
||||
{
|
||||
forAll(addressing_, i)
|
||||
{
|
||||
if (addressing_[i].size() == 0)
|
||||
{
|
||||
hasUnmapped_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//- Destructor
|
||||
virtual ~weightedFvPatchFieldMapper()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual label size() const
|
||||
{
|
||||
return addressing().size();
|
||||
}
|
||||
|
||||
virtual bool direct() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool hasUnmapped() const
|
||||
{
|
||||
return hasUnmapped_;
|
||||
}
|
||||
|
||||
virtual const labelListList& addressing() const
|
||||
{
|
||||
return addressing_;
|
||||
}
|
||||
|
||||
virtual const scalarListList& weights() const
|
||||
{
|
||||
return weights_;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user