mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
mapFieldsPar: updated to enable mapping from source patches (instead of recreating)
- patchFields now get mapped (instead of created)
- with -consistent it now maps all patches except for processor ones (they are
the only ones that are processor-local)
- all constraint patches get evaluated after mapping to bring them up to date.
Patch contributed by Mattijs Janssens
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -35,6 +35,88 @@ License
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
template<class Type>
|
||||
void evaluateConstraintTypes(GeometricField<Type, fvPatchField, volMesh>& fld)
|
||||
{
|
||||
typename GeometricField<Type, fvPatchField, volMesh>::
|
||||
Boundary& fldBf = fld.boundaryFieldRef();
|
||||
|
||||
if
|
||||
(
|
||||
Pstream::defaultCommsType == Pstream::blocking
|
||||
|| Pstream::defaultCommsType == Pstream::nonBlocking
|
||||
)
|
||||
{
|
||||
label nReq = Pstream::nRequests();
|
||||
|
||||
forAll(fldBf, patchi)
|
||||
{
|
||||
fvPatchField<Type>& tgtField = fldBf[patchi];
|
||||
|
||||
if
|
||||
(
|
||||
tgtField.type() == tgtField.patch().patch().type()
|
||||
&& polyPatch::constraintType(tgtField.patch().patch().type())
|
||||
)
|
||||
{
|
||||
tgtField.initEvaluate(Pstream::defaultCommsType);
|
||||
}
|
||||
}
|
||||
|
||||
// Block for any outstanding requests
|
||||
if
|
||||
(
|
||||
Pstream::parRun()
|
||||
&& Pstream::defaultCommsType == Pstream::nonBlocking
|
||||
)
|
||||
{
|
||||
Pstream::waitRequests(nReq);
|
||||
}
|
||||
|
||||
forAll(fldBf, patchi)
|
||||
{
|
||||
fvPatchField<Type>& tgtField = fldBf[patchi];
|
||||
|
||||
if
|
||||
(
|
||||
tgtField.type() == tgtField.patch().patch().type()
|
||||
&& polyPatch::constraintType(tgtField.patch().patch().type())
|
||||
)
|
||||
{
|
||||
tgtField.evaluate(Pstream::defaultCommsType);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Pstream::defaultCommsType == Pstream::scheduled)
|
||||
{
|
||||
const lduSchedule& patchSchedule =
|
||||
fld.mesh().globalData().patchSchedule();
|
||||
|
||||
forAll(patchSchedule, patchEvali)
|
||||
{
|
||||
label patchi = patchSchedule[patchEvali].patch;
|
||||
fvPatchField<Type>& tgtField = fldBf[patchi];
|
||||
|
||||
if
|
||||
(
|
||||
tgtField.type() == tgtField.patch().patch().type()
|
||||
&& polyPatch::constraintType(tgtField.patch().patch().type())
|
||||
)
|
||||
{
|
||||
if (patchSchedule[patchEvali].init)
|
||||
{
|
||||
tgtField.initEvaluate(Pstream::scheduled);
|
||||
}
|
||||
else
|
||||
{
|
||||
tgtField.evaluate(Pstream::scheduled);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type, class CombineOp>
|
||||
void MapVolFields
|
||||
(
|
||||
@ -57,8 +139,6 @@ void MapVolFields
|
||||
|
||||
if (selectedFields.empty() || selectedFields.found(fieldName))
|
||||
{
|
||||
Info<< " interpolating " << fieldName << endl;
|
||||
|
||||
const fieldType fieldSource(*fieldIter(), meshSource);
|
||||
|
||||
IOobject targetIO
|
||||
@ -71,14 +151,21 @@ void MapVolFields
|
||||
|
||||
if (targetIO.headerOk())
|
||||
{
|
||||
Info<< " interpolating onto existing field "
|
||||
<< fieldName << endl;
|
||||
fieldType fieldTarget(targetIO, meshTarget);
|
||||
|
||||
interp.mapSrcToTgt(fieldSource, cop, fieldTarget);
|
||||
|
||||
evaluateConstraintTypes(fieldTarget);
|
||||
|
||||
fieldTarget.write();
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " creating new field "
|
||||
<< fieldName << endl;
|
||||
|
||||
targetIO.readOpt() = IOobject::NO_READ;
|
||||
|
||||
tmp<fieldType>
|
||||
@ -86,6 +173,8 @@ void MapVolFields
|
||||
|
||||
fieldType fieldTarget(targetIO, tfieldTarget);
|
||||
|
||||
evaluateConstraintTypes(fieldTarget);
|
||||
|
||||
fieldTarget.write();
|
||||
}
|
||||
}
|
||||
|
||||
@ -263,11 +263,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (!consistent)
|
||||
{
|
||||
IOdictionary mapFieldsParDict
|
||||
IOdictionary mapFieldsDict
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"mapFieldsParDict",
|
||||
"mapFieldsDict",
|
||||
runTimeTarget.system(),
|
||||
runTimeTarget,
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
@ -276,8 +276,8 @@ int main(int argc, char *argv[])
|
||||
)
|
||||
);
|
||||
|
||||
mapFieldsParDict.lookup("patchMap") >> patchMap;
|
||||
mapFieldsParDict.lookup("cuttingPatches") >> cuttingPatches;
|
||||
mapFieldsDict.lookup("patchMap") >> patchMap;
|
||||
mapFieldsDict.lookup("cuttingPatches") >> cuttingPatches;
|
||||
}
|
||||
|
||||
#include "setTimeIndex.H"
|
||||
@ -326,7 +326,7 @@ int main(int argc, char *argv[])
|
||||
meshSource,
|
||||
meshTarget,
|
||||
patchMap,
|
||||
addProcessorPatches(meshTarget, cuttingPatches),
|
||||
cuttingPatches,
|
||||
mapMethod,
|
||||
subtract,
|
||||
selectedFields,
|
||||
|
||||
@ -1,5 +1,13 @@
|
||||
{
|
||||
instantList sourceTimes = runTimeSource.times();
|
||||
|
||||
if (sourceTimes.empty())
|
||||
{
|
||||
FatalErrorInFunction << "No result times in source "
|
||||
<< runTimeSource.caseName()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
label sourceTimeIndex = runTimeSource.timeIndex();
|
||||
if (args.optionFound("sourceTime"))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user