Merge branch 'master' of ssh://dm/home/dm4/OpenFOAM/repositories/OpenFOAM-dev

This commit is contained in:
Henry 2014-01-14 23:10:18 +00:00
commit e39100093f
17 changed files with 496 additions and 124 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-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -30,6 +30,15 @@ License
#include "dlLibraryTable.H"
#include "PstreamReduceOps.H"
#include "OSspecific.H"
#include "regIOobject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(codedBase, 0);
}
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
@ -169,7 +178,9 @@ void Foam::codedBase::createLibrary
const dynamicCodeContext& context
) const
{
bool create = Pstream::master();
bool create =
Pstream::master()
|| (regIOobject::fileModificationSkew <= 0); // not NFS
if (create)
{
@ -206,6 +217,71 @@ void Foam::codedBase::createLibrary
// all processes must wait for compile to finish
if (regIOobject::fileModificationSkew > 0)
{
//- Since the library has only been compiled on the master the
// other nodes need to pick this library up through NFS
// We do this by just polling a few times using the
// fileModificationSkew.
const fileName libPath = dynCode.libPath();
off_t mySize = Foam::fileSize(libPath);
off_t masterSize = mySize;
Pstream::scatter(masterSize);
if (debug)
{
Pout<< endl<< "on processor " << Pstream::myProcNo()
<< " have masterSize:" << masterSize
<< " and localSize:" << mySize
<< endl;
}
if (mySize < masterSize)
{
if (debug)
{
Pout<< "Local file " << libPath
<< " not of same size (" << mySize
<< ") as master ("
<< masterSize << "). Waiting for "
<< regIOobject::fileModificationSkew
<< " seconds." << endl;
}
Foam::sleep(regIOobject::fileModificationSkew);
// Recheck local size
mySize = Foam::fileSize(libPath);
if (mySize < masterSize)
{
FatalIOErrorIn
(
"functionEntries::codeStream::execute(..)",
context.dict()
) << "Cannot read (NFS mounted) library " << nl
<< libPath << nl
<< "on processor " << Pstream::myProcNo()
<< " detected size " << mySize
<< " whereas master size is " << masterSize
<< " bytes." << nl
<< "If your case is not NFS mounted"
<< " (so distributed) set fileModificationSkew"
<< " to 0"
<< exit(FatalIOError);
}
}
if (debug)
{
Pout<< endl<< "on processor " << Pstream::myProcNo()
<< " after waiting: have masterSize:" << masterSize
<< " and localSize:" << mySize
<< endl;
}
}
reduce(create, orOp<bool>());
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -119,6 +119,10 @@ protected:
public:
//- Runtime type information
ClassName("codedBase");
// Constructors
//- Construct null

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -31,6 +31,7 @@ License
#include "OBJstream.H"
#include "DynamicField.H"
#include "edgeMeshFormatsCore.H"
#include "IOmanip.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -1459,23 +1460,41 @@ void Foam::extendedEdgeMesh::writeStats(Ostream& os) const
{
edgeMesh::writeStats(os);
os << indent << "point offsets :" << nl;
os << indent << "point classification (size and offset) :" << nl;
os << incrIndent;
os << indent << "convex feature points : " << convexStart_ << nl;
os << indent << "concave feature points : " << concaveStart_ << nl;
os << indent << "mixed feature points : " << mixedStart_ << nl;
os << indent << "other (non-feature) points : " << nonFeatureStart_ << nl;
os << indent << "convex feature points : "
<< setw(8) << concaveStart_-convexStart_
<< setw(8) << convexStart_ << nl;
os << indent << "concave feature points : "
<< setw(8) << mixedStart_-concaveStart_
<< setw(8) << concaveStart_ << nl;
os << indent << "mixed feature points : "
<< setw(8) << nonFeatureStart_-mixedStart_
<< setw(8) << mixedStart_ << nl;
os << indent << "other (non-feature) points : "
<< setw(8) << points().size()-nonFeatureStart_
<< setw(8) << nonFeatureStart_ << nl;
os << decrIndent;
os << indent << "edge offsets :" << nl;
os << indent << "edge classification (size and offset) :" << nl;
os << incrIndent;
os << indent << "external (convex angle) edges : " << externalStart_
os << indent << "external (convex angle) edges : "
<< setw(8) << internalStart_-externalStart_
<< setw(8) << externalStart_
<< nl;
os << indent << "internal (concave angle) edges : " << internalStart_
os << indent << "internal (concave angle) edges : "
<< setw(8) << flatStart_-internalStart_
<< setw(8) << internalStart_
<< nl;
os << indent << "flat region edges : " << flatStart_ << nl;
os << indent << "open edges : " << openStart_ << nl;
os << indent << "multiply connected edges : " << multipleStart_
os << indent << "flat region edges : "
<< setw(8) << openStart_-flatStart_
<< setw(8) << flatStart_ << nl;
os << indent << "open edges : "
<< setw(8) << multipleStart_-openStart_
<< setw(8) << openStart_ << nl;
os << indent << "multiply connected edges : "
<< setw(8) << edges().size()-multipleStart_
<< setw(8) << multipleStart_
<< nl;
os << decrIndent;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,9 +23,6 @@ License
\*---------------------------------------------------------------------------*/
#include "cyclicAMIFvPatchField.H"
#include "transformField.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
@ -157,7 +154,15 @@ Foam::cyclicAMIFvPatchField<Type>::patchNeighbourField() const
Field<Type> pnf(iField, nbrFaceCells);
tmp<Field<Type> > tpnf(new Field<Type>(cyclicAMIPatch_.interpolate(pnf)));
tmp<Field<Type> > tpnf;
if (cyclicAMIPatch_.applyLowWeightCorrection())
{
tpnf = cyclicAMIPatch_.interpolate(pnf, this->patchInternalField()());
}
else
{
tpnf = cyclicAMIPatch_.interpolate(pnf);
}
if (doTransform())
{
@ -203,7 +208,15 @@ void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix
// Transform according to the transformation tensors
transformCoupleField(pnf, cmpt);
if (cyclicAMIPatch_.applyLowWeightCorrection())
{
scalarField pif(psiInternal, cyclicAMIPatch_.faceCells());
pnf = cyclicAMIPatch_.interpolate(pnf, pif);
}
else
{
pnf = cyclicAMIPatch_.interpolate(pnf);
}
// Multiply the field by coefficients and add into the result
const labelUList& faceCells = cyclicAMIPatch_.faceCells();
@ -232,7 +245,15 @@ void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix
// Transform according to the transformation tensors
transformCoupleField(pnf);
if (cyclicAMIPatch_.applyLowWeightCorrection())
{
Field<Type> pif(psiInternal, cyclicAMIPatch_.faceCells());
pnf = cyclicAMIPatch_.interpolate(pnf, pif);
}
else
{
pnf = cyclicAMIPatch_.interpolate(pnf);
}
// Multiply the field by coefficients and add into the result
const labelUList& faceCells = cyclicAMIPatch_.faceCells();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -55,7 +55,11 @@ void Foam::cyclicAMIFvPatch::makeWeights(scalarField& w) const
const scalarField nbrDeltas
(
interpolate(nbrPatch.nf() & nbrPatch.fvPatch::delta())
interpolate
(
nbrPatch.nf() & nbrPatch.fvPatch::delta(),
scalarField(this->size(), 1.0)
)
);
forAll(deltas, faceI)
@ -82,7 +86,14 @@ Foam::tmp<Foam::vectorField> Foam::cyclicAMIFvPatch::delta() const
{
const vectorField patchD(fvPatch::delta());
const vectorField nbrPatchD(interpolate(nbrPatch.fvPatch::delta()));
const vectorField nbrPatchD
(
interpolate
(
nbrPatch.fvPatch::delta(),
vectorField(this->size(), vector::zero)
)
);
tmp<vectorField> tpdv(new vectorField(patchD.size()));
vectorField& pdv = tpdv();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -154,16 +154,29 @@ public:
//- Return delta (P to N) vectors across coupled patch
virtual tmp<vectorField> delta() const;
template<class Type>
tmp<Field<Type> > interpolate(const Field<Type>& fld) const
bool applyLowWeightCorrection() const
{
return cyclicAMIPolyPatch_.interpolate(fld);
return cyclicAMIPolyPatch_.applyLowWeightCorrection();
}
template<class Type>
tmp<Field<Type> > interpolate(const tmp<Field<Type> >& tFld) const
tmp<Field<Type> > interpolate
(
const Field<Type>& fld,
const UList<Type>& defaultValues = UList<Type>()
) const
{
return cyclicAMIPolyPatch_.interpolate(tFld);
return cyclicAMIPolyPatch_.interpolate(fld, defaultValues);
}
template<class Type>
tmp<Field<Type> > interpolate
(
const tmp<Field<Type> >& tFld,
const UList<Type>& defaultValues = UList<Type>()
) const
{
return cyclicAMIPolyPatch_.interpolate(tFld, defaultValues);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -201,11 +201,14 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::normaliseWeights
scalarListList& wght,
scalarField& wghtSum,
const bool conformal,
const bool output
const bool output,
const scalar lowWeightTol
)
{
// Normalise the weights
wghtSum.setSize(wght.size());
label nLowWeight = 0;
forAll(wght, faceI)
{
scalarList& w = wght[faceI];
@ -225,6 +228,11 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::normaliseWeights
}
wghtSum[faceI] = t;
if (t < lowWeightTol)
{
nLowWeight++;
}
}
@ -241,6 +249,13 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::normaliseWeights
<< gAverage(wghtSum) << endl;
}
}
if (debug && nLowWeight)
{
Pout<< "AMI: Identified " << nLowWeight
<< " faces with weights less than " << lowWeightTol
<< endl;
}
}
@ -502,7 +517,8 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::agglomerate
srcWeights,
srcWeightsSum,
true,
false
false,
-1
);
}
@ -516,12 +532,14 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::AMIInterpolation
const TargetPatch& tgtPatch,
const faceAreaIntersect::triangulationMode& triMode,
const interpolationMethod& method,
const scalar lowWeightCorrection,
const bool reverseTarget
)
:
method_(method),
reverseTarget_(reverseTarget),
singlePatchProc_(-999),
lowWeightCorrection_(lowWeightCorrection),
srcAddress_(),
srcWeights_(),
srcWeightsSum_(),
@ -544,12 +562,14 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::AMIInterpolation
const autoPtr<searchableSurface>& surfPtr,
const faceAreaIntersect::triangulationMode& triMode,
const interpolationMethod& method,
const scalar lowWeightCorrection,
const bool reverseTarget
)
:
method_(method),
reverseTarget_(reverseTarget),
singlePatchProc_(-999),
lowWeightCorrection_(lowWeightCorrection),
srcAddress_(),
srcWeights_(),
srcWeightsSum_(),
@ -632,6 +652,7 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::AMIInterpolation
method_(fineAMI.method_),
reverseTarget_(fineAMI.reverseTarget_),
singlePatchProc_(fineAMI.singlePatchProc_),
lowWeightCorrection_(-1.0),
srcAddress_(),
srcWeights_(),
srcWeightsSum_(),
@ -908,7 +929,8 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::update
srcWeights_,
srcWeightsSum_,
AMIPtr->conformal(),
true
true,
lowWeightCorrection_
);
normaliseWeights
(
@ -918,7 +940,8 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::update
tgtWeights_,
tgtWeightsSum_,
AMIPtr->conformal(),
true
true,
lowWeightCorrection_
);
// cache maps and reset addresses
@ -965,7 +988,8 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::update
srcWeights_,
srcWeightsSum_,
AMIPtr->conformal(),
true
true,
lowWeightCorrection_
);
normaliseWeights
(
@ -975,7 +999,8 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::update
tgtWeights_,
tgtWeightsSum_,
AMIPtr->conformal(),
true
true,
lowWeightCorrection_
);
}
@ -998,7 +1023,8 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget
(
const UList<Type>& fld,
const CombineOp& cop,
List<Type>& result
List<Type>& result,
const UList<Type>& defaultValues
) const
{
if (fld.size() != srcAddress_.size())
@ -1009,7 +1035,8 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget
"("
"const UList<Type>&, "
"const CombineOp&, "
"List<Type>&"
"List<Type>&, "
"const UList<Type>&"
") const"
) << "Supplied field size is not equal to source patch size" << nl
<< " source patch = " << srcAddress_.size() << nl
@ -1018,6 +1045,29 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget
<< abort(FatalError);
}
if (lowWeightCorrection_ > 0)
{
if (defaultValues.size() != tgtAddress_.size())
{
FatalErrorIn
(
"AMIInterpolation::interpolateToTarget"
"("
"const UList<Type>&, "
"const CombineOp&, "
"List<Type>&, "
"const UList<Type>&"
") const"
) << "Employing default values when sum of weights falls below "
<< lowWeightCorrection_
<< " but supplied default field size is not equal to target "
<< "patch size" << nl
<< " default values = " << defaultValues.size() << nl
<< " target patch = " << tgtAddress_.size() << nl
<< abort(FatalError);
}
}
result.setSize(tgtAddress_.size());
if (singlePatchProc_ == -1)
@ -1028,6 +1078,12 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget
map.distribute(work);
forAll(result, faceI)
{
if (tgtWeightsSum_[faceI] < lowWeightCorrection_)
{
result[faceI] = defaultValues[faceI];
}
else
{
const labelList& faces = tgtAddress_[faceI];
const scalarList& weights = tgtWeights_[faceI];
@ -1038,9 +1094,16 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget
}
}
}
}
else
{
forAll(result, faceI)
{
if (tgtWeightsSum_[faceI] < lowWeightCorrection_)
{
result[faceI] = defaultValues[faceI];
}
else
{
const labelList& faces = tgtAddress_[faceI];
const scalarList& weights = tgtWeights_[faceI];
@ -1052,6 +1115,7 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget
}
}
}
}
template<class SourcePatch, class TargetPatch>
@ -1060,7 +1124,8 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToSource
(
const UList<Type>& fld,
const CombineOp& cop,
List<Type>& result
List<Type>& result,
const UList<Type>& defaultValues
) const
{
if (fld.size() != tgtAddress_.size())
@ -1071,7 +1136,8 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToSource
"("
"const UList<Type>&, "
"const CombineOp&, "
"List<Type>&"
"List<Type>&, "
"const UList<Type>&"
") const"
) << "Supplied field size is not equal to target patch size" << nl
<< " source patch = " << srcAddress_.size() << nl
@ -1080,6 +1146,29 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToSource
<< abort(FatalError);
}
if (lowWeightCorrection_ > 0)
{
if (defaultValues.size() != srcAddress_.size())
{
FatalErrorIn
(
"AMIInterpolation::interpolateToSource"
"("
"const UList<Type>&, "
"const CombineOp&, "
"List<Type>&, "
"const UList<Type>&"
") const"
) << "Employing default values when sum of weights falls below "
<< lowWeightCorrection_
<< " but supplied default field size is not equal to target "
<< "patch size" << nl
<< " default values = " << defaultValues.size() << nl
<< " source patch = " << srcAddress_.size() << nl
<< abort(FatalError);
}
}
result.setSize(srcAddress_.size());
if (singlePatchProc_ == -1)
@ -1090,6 +1179,12 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToSource
map.distribute(work);
forAll(result, faceI)
{
if (srcWeightsSum_[faceI] < lowWeightCorrection_)
{
result[faceI] = defaultValues[faceI];
}
else
{
const labelList& faces = srcAddress_[faceI];
const scalarList& weights = srcWeights_[faceI];
@ -1100,9 +1195,16 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToSource
}
}
}
}
else
{
forAll(result, faceI)
{
if (srcWeightsSum_[faceI] < lowWeightCorrection_)
{
result[faceI] = defaultValues[faceI];
}
else
{
const labelList& faces = srcAddress_[faceI];
const scalarList& weights = srcWeights_[faceI];
@ -1114,6 +1216,7 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToSource
}
}
}
}
template<class SourcePatch, class TargetPatch>
@ -1122,7 +1225,8 @@ Foam::tmp<Foam::Field<Type> >
Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToSource
(
const Field<Type>& fld,
const CombineOp& cop
const CombineOp& cop,
const UList<Type>& defaultValues
) const
{
tmp<Field<Type> > tresult
@ -1138,7 +1242,8 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToSource
(
fld,
multiplyWeightedOp<Type, CombineOp>(cop),
tresult()
tresult(),
defaultValues
);
return tresult;
@ -1151,10 +1256,11 @@ Foam::tmp<Foam::Field<Type> >
Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToSource
(
const tmp<Field<Type> >& tFld,
const CombineOp& cop
const CombineOp& cop,
const UList<Type>& defaultValues
) const
{
return interpolateToSource(tFld(), cop);
return interpolateToSource(tFld(), cop, defaultValues);
}
@ -1164,7 +1270,8 @@ Foam::tmp<Foam::Field<Type> >
Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget
(
const Field<Type>& fld,
const CombineOp& cop
const CombineOp& cop,
const UList<Type>& defaultValues
) const
{
tmp<Field<Type> > tresult
@ -1180,7 +1287,8 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget
(
fld,
multiplyWeightedOp<Type, CombineOp>(cop),
tresult()
tresult(),
defaultValues
);
return tresult;
@ -1193,10 +1301,11 @@ Foam::tmp<Foam::Field<Type> >
Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget
(
const tmp<Field<Type> >& tFld,
const CombineOp& cop
const CombineOp& cop,
const UList<Type>& defaultValues
) const
{
return interpolateToTarget(tFld(), cop);
return interpolateToTarget(tFld(), cop, defaultValues);
}
@ -1205,10 +1314,11 @@ template<class Type>
Foam::tmp<Foam::Field<Type> >
Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToSource
(
const Field<Type>& fld
const Field<Type>& fld,
const UList<Type>& defaultValues
) const
{
return interpolateToSource(fld, plusEqOp<Type>());
return interpolateToSource(fld, plusEqOp<Type>(), defaultValues);
}
@ -1217,10 +1327,11 @@ template<class Type>
Foam::tmp<Foam::Field<Type> >
Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToSource
(
const tmp<Field<Type> >& tFld
const tmp<Field<Type> >& tFld,
const UList<Type>& defaultValues
) const
{
return interpolateToSource(tFld(), plusEqOp<Type>());
return interpolateToSource(tFld(), plusEqOp<Type>(), defaultValues);
}
@ -1229,10 +1340,11 @@ template<class Type>
Foam::tmp<Foam::Field<Type> >
Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget
(
const Field<Type>& fld
const Field<Type>& fld,
const UList<Type>& defaultValues
) const
{
return interpolateToTarget(fld, plusEqOp<Type>());
return interpolateToTarget(fld, plusEqOp<Type>(), defaultValues);
}
@ -1241,10 +1353,11 @@ template<class Type>
Foam::tmp<Foam::Field<Type> >
Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget
(
const tmp<Field<Type> >& tFld
const tmp<Field<Type> >& tFld,
const UList<Type>& defaultValues
) const
{
return interpolateToTarget(tFld(), plusEqOp<Type>());
return interpolateToTarget(tFld(), plusEqOp<Type>(), defaultValues);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -120,6 +120,9 @@ private:
// cases
label singlePatchProc_;
//- Threshold weight below which interpolation is deactivated
scalar lowWeightCorrection_;
// Source patch
@ -238,7 +241,8 @@ private:
scalarListList& wght,
scalarField& wghtSum,
const bool conformal,
const bool output
const bool output,
const scalar lowWeightTol
);
@ -273,6 +277,7 @@ public:
const TargetPatch& tgtPatch,
const faceAreaIntersect::triangulationMode& triMode,
const interpolationMethod& method = imFaceAreaWeight,
const scalar lowWeightCorrection = -1,
const bool reverseTarget = false
);
@ -284,6 +289,7 @@ public:
const autoPtr<searchableSurface>& surf,
const faceAreaIntersect::triangulationMode& triMode,
const interpolationMethod& method = imFaceAreaWeight,
const scalar lowWeightCorrection = -1,
const bool reverseTarget = false
);
@ -313,7 +319,13 @@ public:
//- Set to -1, or the processor holding all faces (both sides) of
// the AMI
label singlePatchProc() const;
inline label singlePatchProc() const;
//- Threshold weight below which interpolation is deactivated
inline scalar lowWeightCorrection() const;
//- Return true if employing a 'lowWeightCorrection'
inline bool applyLowWeightCorrection() const;
// Source patch
@ -379,7 +391,8 @@ public:
(
const UList<Type>& fld,
const CombineOp& cop,
List<Type>& result
List<Type>& result,
const UList<Type>& defaultValues = UList<Type>::null()
) const;
//- Interpolate from source to target with supplied op
@ -389,7 +402,8 @@ public:
(
const UList<Type>& fld,
const CombineOp& cop,
List<Type>& result
List<Type>& result,
const UList<Type>& defaultValues = UList<Type>::null()
) const;
@ -398,7 +412,8 @@ public:
tmp<Field<Type> > interpolateToSource
(
const Field<Type>& fld,
const CombineOp& cop
const CombineOp& cop,
const UList<Type>& defaultValues = UList<Type>::null()
) const;
//- Interpolate from target tmp field to source with supplied op
@ -406,7 +421,8 @@ public:
tmp<Field<Type> > interpolateToSource
(
const tmp<Field<Type> >& tFld,
const CombineOp& cop
const CombineOp& cop,
const UList<Type>& defaultValues = UList<Type>::null()
) const;
//- Interpolate from source to target with supplied op
@ -414,7 +430,8 @@ public:
tmp<Field<Type> > interpolateToTarget
(
const Field<Type>& fld,
const CombineOp& cop
const CombineOp& cop,
const UList<Type>& defaultValues = UList<Type>::null()
) const;
//- Interpolate from source tmp field to target with supplied op
@ -422,35 +439,40 @@ public:
tmp<Field<Type> > interpolateToTarget
(
const tmp<Field<Type> >& tFld,
const CombineOp& cop
const CombineOp& cop,
const UList<Type>& defaultValues = UList<Type>::null()
) const;
//- Interpolate from target to source
template<class Type>
tmp<Field<Type> > interpolateToSource
(
const Field<Type>& fld
const Field<Type>& fld,
const UList<Type>& defaultValues = UList<Type>::null()
) const;
//- Interpolate from target tmp field
template<class Type>
tmp<Field<Type> > interpolateToSource
(
const tmp<Field<Type> >& tFld
const tmp<Field<Type> >& tFld,
const UList<Type>& defaultValues = UList<Type>::null()
) const;
//- Interpolate from source to target
template<class Type>
tmp<Field<Type> > interpolateToTarget
(
const Field<Type>& fld
const Field<Type>& fld,
const UList<Type>& defaultValues = UList<Type>::null()
) const;
//- Interpolate from source tmp field
template<class Type>
tmp<Field<Type> > interpolateToTarget
(
const tmp<Field<Type> >& tFld
const tmp<Field<Type> >& tFld,
const UList<Type>& defaultValues = UList<Type>::null()
) const;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -31,6 +31,23 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::singlePatchProc() const
}
template<class SourcePatch, class TargetPatch>
inline Foam::scalar
Foam::AMIInterpolation<SourcePatch, TargetPatch>::lowWeightCorrection() const
{
return lowWeightCorrection_;
}
template<class SourcePatch, class TargetPatch>
inline bool
Foam::AMIInterpolation<SourcePatch, TargetPatch>::
applyLowWeightCorrection() const
{
return lowWeightCorrection_ > 0;
}
template<class SourcePatch, class TargetPatch>
inline const Foam::scalarField&
Foam::AMIInterpolation<SourcePatch, TargetPatch>::srcMagSf() const

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -175,7 +175,22 @@ void Foam::cyclicAMIPointPatchField<Type>::swapAddSeparated
Field<Type> nbrFcFld(nbrPpi().pointToFaceInterpolate(nbrPtFld));
// interpolate to owner
nbrFcFld = cyclicAMIPatch_.cyclicAMIPatch().interpolate(nbrFcFld);
if (cyclicAMIPatch_.cyclicAMIPatch().applyLowWeightCorrection())
{
Field<Type> fcFld(ppi().pointToFaceInterpolate(ptFld));
nbrFcFld =
cyclicAMIPatch_.cyclicAMIPatch().interpolate
(
nbrFcFld,
fcFld
);
}
else
{
nbrFcFld =
cyclicAMIPatch_.cyclicAMIPatch().interpolate(nbrFcFld);
}
// add to internal field
this->addToInternalField
@ -190,11 +205,25 @@ void Foam::cyclicAMIPointPatchField<Type>::swapAddSeparated
Field<Type> fcFld(ppi().pointToFaceInterpolate(ptFld));
// interpolate to neighbour
if (cyclicAMIPatch_.cyclicAMIPatch().applyLowWeightCorrection())
{
Field<Type> nbrFcFld(nbrPpi().pointToFaceInterpolate(nbrPtFld));
fcFld =
cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().interpolate
(
fcFld,
nbrFcFld
);
}
else
{
fcFld =
cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().interpolate
(
fcFld
);
}
// add to internal field
nbr.addToInternalField

View File

@ -359,6 +359,7 @@ void Foam::cyclicAMIPolyPatch::resetAMI
surfPtr(),
faceAreaIntersect::tmMesh,
AMIMethod,
AMILowWeightCorrection_,
AMIReverse_
)
);
@ -470,6 +471,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
separationVector_(vector::zero),
AMIPtr_(NULL),
AMIReverse_(false),
AMILowWeightCorrection_(-1.0),
surfPtr_(NULL),
surfDict_(fileName("surface"))
{
@ -498,6 +500,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
separationVector_(vector::zero),
AMIPtr_(NULL),
AMIReverse_(dict.lookupOrDefault<bool>("flipNormals", false)),
AMILowWeightCorrection_(dict.lookupOrDefault("lowWeightCorrection", -1.0)),
surfPtr_(NULL),
surfDict_(dict.subOrEmptyDict("surface"))
{
@ -606,6 +609,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
separationVector_(pp.separationVector_),
AMIPtr_(NULL),
AMIReverse_(pp.AMIReverse_),
AMILowWeightCorrection_(pp.AMILowWeightCorrection_),
surfPtr_(NULL),
surfDict_(pp.surfDict_)
{
@ -635,6 +639,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
separationVector_(pp.separationVector_),
AMIPtr_(NULL),
AMIReverse_(pp.AMIReverse_),
AMILowWeightCorrection_(pp.AMILowWeightCorrection_),
surfPtr_(NULL),
surfDict_(pp.surfDict_)
{
@ -678,6 +683,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
separationVector_(pp.separationVector_),
AMIPtr_(NULL),
AMIReverse_(pp.AMIReverse_),
AMILowWeightCorrection_(pp.AMILowWeightCorrection_),
surfPtr_(NULL),
surfDict_(pp.surfDict_)
{}
@ -793,6 +799,19 @@ const Foam::AMIPatchToPatchInterpolation& Foam::cyclicAMIPolyPatch::AMI() const
}
bool Foam::cyclicAMIPolyPatch::applyLowWeightCorrection() const
{
if (owner())
{
return AMI().applyLowWeightCorrection();
}
else
{
return neighbPatch().AMI().applyLowWeightCorrection();
}
}
void Foam::cyclicAMIPolyPatch::transformPosition(pointField& l) const
{
if (!parallel())
@ -970,7 +989,6 @@ void Foam::cyclicAMIPolyPatch::write(Ostream& os) const
{
os.writeKeyword("rotationAngle") << radToDeg(rotationAngle_)
<< token::END_STATEMENT << nl;
}
break;
@ -997,6 +1015,12 @@ void Foam::cyclicAMIPolyPatch::write(Ostream& os) const
<< token::END_STATEMENT << nl;
}
if (AMILowWeightCorrection_ > 0)
{
os.writeKeyword("lowWeightCorrection") << AMILowWeightCorrection_
<< token::END_STATEMENT << nl;
}
if (!surfDict_.empty())
{
os.writeKeyword(surfDict_.dictName());

View File

@ -97,6 +97,9 @@ private:
//- Flag to indicate that slave patch should be reversed for AMI
const bool AMIReverse_;
//- Low weight correction threshold for AMI
const scalar AMILowWeightCorrection_;
//- Projection surface
mutable autoPtr<searchableSurface> surfPtr_;
@ -298,6 +301,9 @@ public:
//- Return a reference to the AMI interpolator
const AMIPatchToPatchInterpolation& AMI() const;
//- Return true if applying the low weight correction
bool applyLowWeightCorrection() const;
// Transformations
@ -325,13 +331,18 @@ public:
//- Interpolate field
template<class Type>
tmp<Field<Type> > interpolate(const Field<Type>& fld) const;
tmp<Field<Type> > interpolate
(
const Field<Type>& fld,
const UList<Type>& defaultValues = UList<Type>()
) const;
//- Interpolate tmp field
template<class Type>
tmp<Field<Type> > interpolate
(
const tmp<Field<Type> >& tFld
const tmp<Field<Type> >& tFld,
const UList<Type>& defaultValues = UList<Type>()
) const;
//- Low-level interpolate List
@ -340,7 +351,8 @@ public:
(
const UList<Type>& fld,
const CombineOp& cop,
List<Type>& result
List<Type>& result,
const UList<Type>& defaultValues = UList<Type>()
) const;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -28,16 +28,17 @@ License
template<class Type>
Foam::tmp<Foam::Field<Type> > Foam::cyclicAMIPolyPatch::interpolate
(
const Field<Type>& fld
const Field<Type>& fld,
const UList<Type>& defaultValues
) const
{
if (owner())
{
return AMI().interpolateToSource(fld);
return AMI().interpolateToSource(fld, defaultValues);
}
else
{
return neighbPatch().AMI().interpolateToTarget(fld);
return neighbPatch().AMI().interpolateToTarget(fld, defaultValues);
}
}
@ -45,17 +46,11 @@ Foam::tmp<Foam::Field<Type> > Foam::cyclicAMIPolyPatch::interpolate
template<class Type>
Foam::tmp<Foam::Field<Type> > Foam::cyclicAMIPolyPatch::interpolate
(
const tmp<Field<Type> >& tFld
const tmp<Field<Type> >& tFld,
const UList<Type>& defaultValues
) const
{
if (owner())
{
return AMI().interpolateToSource(tFld);
}
else
{
return neighbPatch().AMI().interpolateToTarget(tFld);
}
return interpolate(tFld(), defaultValues);
}
@ -64,16 +59,29 @@ void Foam::cyclicAMIPolyPatch::interpolate
(
const UList<Type>& fld,
const CombineOp& cop,
List<Type>& result
List<Type>& result,
const UList<Type>& defaultValues
) const
{
if (owner())
{
AMI().interpolateToSource(fld, cop, result);
AMI().interpolateToSource
(
fld,
cop,
result,
defaultValues
);
}
else
{
neighbPatch().AMI().interpolateToTarget(fld, cop, result);
neighbPatch().AMI().interpolateToTarget
(
fld,
cop,
result,
defaultValues
);
}
}

View File

@ -354,7 +354,8 @@ void Foam::meshToMesh::mapSrcToTgt
(
srcField,
multiplyWeightedOp<Type, CombineOp>(cop),
tgtField
tgtField,
UList<Type>::null()
);
}
@ -385,7 +386,7 @@ Foam::meshToMesh::mapSrcToTgt
(
IOobject
(
type() + ".interpolate(" + field.name() + ")",
type() + ":interpolate(" + field.name() + ")",
tgtMesh.time().timeName(),
tgtMesh,
IOobject::NO_READ,
@ -498,7 +499,7 @@ Foam::meshToMesh::mapTgtToSrc
(
IOobject
(
type() + ".interpolate(" + field.name() + ")",
type() + ":interpolate(" + field.name() + ")",
srcMesh.time().timeName(),
srcMesh,
IOobject::NO_READ,

View File

@ -8,6 +8,6 @@ cd ${0%/*} || exit 1 # run from this directory
./Allrun-pre
## Run simulation
#./Allrun-simulation
./Allrun-simulation
# ----------------------------------------------------------------- end-of-file

View File

@ -31,7 +31,7 @@ runApplication setFields
runApplication decomposePar -force
# Run
runParallel $application 8
runParallel $application $nProcs
# Reconstruct
runApplication reconstructPar -noFunctionObjects

View File

@ -81,6 +81,7 @@ baffles
matchTolerance 0.0001;
neighbourPatch AMI2;
transform noOrdering;
lowWeightCorrection 0.2;
// Note: since imperfect meshing around feature edge make
// sure to project both sides onto 'proper' geometry to
// avoid errors leading to zero weights
@ -99,6 +100,7 @@ baffles
matchTolerance 0.0001;
neighbourPatch AMI1;
transform noOrdering;
lowWeightCorrection 0.2;
surface
{
type triSurfaceMesh;