Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop

This commit is contained in:
sergio
2016-06-15 17:01:27 -07:00
22 changed files with 339 additions and 600 deletions

View File

@ -175,9 +175,6 @@ int main(int argc, char *argv[])
{ {
Info<< "Time = " << runTime.timeName() << nl << endl; Info<< "Time = " << runTime.timeName() << nl << endl;
// Clear mesh before checking
mesh.clearOut();
// Reconstruct globalMeshData // Reconstruct globalMeshData
mesh.globalData(); mesh.globalData();

View File

@ -63,7 +63,7 @@ void Foam::constrainPressure
refCast<fixedFluxPressureFvPatchScalarField> refCast<fixedFluxPressureFvPatchScalarField>
( (
pBf[patchi] pBf[patchi]
).updateCoeffs ).updateSnGrad
( (
( (
phiHbyABf[patchi] phiHbyABf[patchi]

View File

@ -137,22 +137,15 @@ Foam::tmp<Foam::Field<Type>>
Foam::cyclicACMIFvPatchField<Type>::patchNeighbourField() const Foam::cyclicACMIFvPatchField<Type>::patchNeighbourField() const
{ {
const Field<Type>& iField = this->internalField(); const Field<Type>& iField = this->internalField();
const labelUList& nbrFaceCellsCoupled = const cyclicACMIPolyPatch& cpp = cyclicACMIPatch_.cyclicACMIPatch();
cyclicACMIPatch_.cyclicACMIPatch().neighbPatch().faceCells();
const labelUList& faceCellsNonOverlap =
cyclicACMIPatch_.cyclicACMIPatch().nonOverlapPatch().faceCells();
Field<Type> pnfCoupled(iField, nbrFaceCellsCoupled);
Field<Type> pfNonOverlap(iField, faceCellsNonOverlap);
tmp<Field<Type>> tpnf tmp<Field<Type>> tpnf
( (
new Field<Type> cyclicACMIPatch_.interpolate
( (
cyclicACMIPatch_.interpolate Field<Type>
( (
pnfCoupled, iField,
pfNonOverlap cpp.neighbPatch().faceCells()
) )
) )
); );
@ -207,10 +200,12 @@ void Foam::cyclicACMIFvPatchField<Type>::updateInterfaceMatrix
const Pstream::commsTypes const Pstream::commsTypes
) const ) const
{ {
const cyclicACMIPolyPatch& cpp = cyclicACMIPatch_.cyclicACMIPatch();
// note: only applying coupled contribution // note: only applying coupled contribution
const labelUList& nbrFaceCellsCoupled = const labelUList& nbrFaceCellsCoupled =
cyclicACMIPatch_.cyclicACMIPatch().neighbPatch().faceCells(); cpp.neighbPatch().faceCells();
scalarField pnf(psiInternal, nbrFaceCellsCoupled); scalarField pnf(psiInternal, nbrFaceCellsCoupled);
@ -237,10 +232,11 @@ void Foam::cyclicACMIFvPatchField<Type>::updateInterfaceMatrix
const Pstream::commsTypes const Pstream::commsTypes
) const ) const
{ {
const cyclicACMIPolyPatch& cpp = cyclicACMIPatch_.cyclicACMIPatch();
// note: only applying coupled contribution // note: only applying coupled contribution
const labelUList& nbrFaceCellsCoupled = const labelUList& nbrFaceCellsCoupled = cpp.neighbPatch().faceCells();
cyclicACMIPatch_.cyclicACMIPatch().neighbPatch().faceCells();
Field<Type> pnf(psiInternal, nbrFaceCellsCoupled); Field<Type> pnf(psiInternal, nbrFaceCellsCoupled);
@ -258,149 +254,6 @@ void Foam::cyclicACMIFvPatchField<Type>::updateInterfaceMatrix
} }
template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::cyclicACMIFvPatchField<Type>::snGrad
(
const scalarField& deltaCoeffs
) const
{
// note: only applying coupled contribution
return coupledFvPatchField<Type>::snGrad(deltaCoeffs);
}
template<class Type>
void Foam::cyclicACMIFvPatchField<Type>::updateCoeffs()
{
// update non-overlap patch - some will implement updateCoeffs, and
// others will implement evaluate
// scale neighbour field by (1 - mask)
const scalarField& mask = cyclicACMIPatch_.cyclicACMIPatch().mask();
const fvPatchField<Type>& npf = nonOverlapPatchField();
const_cast<fvPatchField<Type>&>(npf).updateCoeffs(1.0 - mask);
}
template<class Type>
void Foam::cyclicACMIFvPatchField<Type>::initEvaluate
(
const Pstream::commsTypes comms
)
{
// update non-overlap patch (if not already updated by updateCoeffs)
// scale neighbour field by (1 - mask)
fvPatchField<Type>& npf =
const_cast<fvPatchField<Type>&>(nonOverlapPatchField());
if (!npf.updated())
{
const scalarField& mask = cyclicACMIPatch_.cyclicACMIPatch().mask();
npf.evaluate(comms);
npf *= 1.0 - mask;
}
}
template<class Type>
void Foam::cyclicACMIFvPatchField<Type>::evaluate
(
const Pstream::commsTypes comms
)
{
// blend contributions from the coupled and non-overlap patches
// neighbour patch field is updated via updateCoeffs or initEvaluate
// and is already scaled by (1 - mask)
const fvPatchField<Type>& npf = nonOverlapPatchField();
coupledFvPatchField<Type>::evaluate(comms);
const Field<Type>& cpf = *this;
const scalarField& mask = cyclicACMIPatch_.cyclicACMIPatch().mask();
Field<Type>::operator=(mask*cpf + npf);
fvPatchField<Type>::evaluate();
}
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::cyclicACMIFvPatchField<Type>::valueInternalCoeffs
(
const tmp<scalarField>& w
) const
{
// note: do not blend based on mask field
// - when applied this is scaled by the areas which are already scaled
return coupledFvPatchField<Type>::valueInternalCoeffs(w);
}
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::cyclicACMIFvPatchField<Type>::valueBoundaryCoeffs
(
const tmp<scalarField>& w
) const
{
// note: do not blend based on mask field
// - when applied this is scaled by the areas which are already scaled
return coupledFvPatchField<Type>::valueBoundaryCoeffs(w);
}
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::cyclicACMIFvPatchField<Type>::gradientInternalCoeffs
(
const scalarField& deltaCoeffs
) const
{
// note: do not blend based on mask field
// - when applied this is scaled by the areas which are already scaled
return coupledFvPatchField<Type>::gradientInternalCoeffs(deltaCoeffs);
}
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::cyclicACMIFvPatchField<Type>::gradientInternalCoeffs() const
{
// note: do not blend based on mask field
// - when applied this is scaled by the areas which are already scaled
return coupledFvPatchField<Type>::gradientInternalCoeffs();
}
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::cyclicACMIFvPatchField<Type>::gradientBoundaryCoeffs
(
const scalarField& deltaCoeffs
) const
{
// note: do not blend based on mask field
// - when applied this is scaled by the areas which are already scaled
return coupledFvPatchField<Type>::gradientBoundaryCoeffs(deltaCoeffs);
}
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::cyclicACMIFvPatchField<Type>::gradientBoundaryCoeffs() const
{
// note: do not blend based on mask field
// - when applied this is scaled by the areas which are already scaled
return coupledFvPatchField<Type>::gradientBoundaryCoeffs();
}
template<class Type> template<class Type>
void Foam::cyclicACMIFvPatchField<Type>::manipulateMatrix void Foam::cyclicACMIFvPatchField<Type>::manipulateMatrix
( (
@ -417,6 +270,21 @@ void Foam::cyclicACMIFvPatchField<Type>::manipulateMatrix
} }
template<class Type>
void Foam::cyclicACMIFvPatchField<Type>::updateCoeffs()
{
// Update non-overlap patch - some will implement updateCoeffs, and
// others will implement evaluate
// Pass in (1 - mask) to give non-overlap patch the chance to do
// manipulation of non-face based data
const scalarField& mask = cyclicACMIPatch_.cyclicACMIPatch().mask();
const fvPatchField<Type>& npf = nonOverlapPatchField();
const_cast<fvPatchField<Type>&>(npf).updateCoeffs(1.0 - mask);
}
template<class Type> template<class Type>
void Foam::cyclicACMIFvPatchField<Type>::write(Ostream& os) const void Foam::cyclicACMIFvPatchField<Type>::write(Ostream& os) const
{ {

View File

@ -218,62 +218,8 @@ public:
const Pstream::commsTypes commsType const Pstream::commsTypes commsType
) const; ) const;
//- Return patch-normal gradient
virtual tmp<Field<Type>> snGrad
(
const scalarField& deltaCoeffs
) const;
//- Update the coefficients associated with the patch field //- Update the coefficients associated with the patch field
void updateCoeffs(); virtual void updateCoeffs();
//- Initialise the evaluation of the patch field
virtual void initEvaluate
(
const Pstream::commsTypes commsType
);
//- Evaluate the patch field
virtual void evaluate
(
const Pstream::commsTypes commsType
);
//- Return the matrix diagonal coefficients corresponding to the
// evaluation of the value of this patchField with given weights
virtual tmp<Field<Type>> valueInternalCoeffs
(
const tmp<scalarField>&
) const;
//- Return the matrix source coefficients corresponding to the
// evaluation of the value of this patchField with given weights
virtual tmp<Field<Type>> valueBoundaryCoeffs
(
const tmp<scalarField>&
) const;
//- Return the matrix diagonal coefficients corresponding to the
// evaluation of the gradient of this patchField
virtual tmp<Field<Type>> gradientInternalCoeffs
(
const scalarField& deltaCoeffs
) const;
//- Return the matrix diagonal coefficients corresponding to the
// evaluation of the gradient of this patchField
virtual tmp<Field<Type>> gradientInternalCoeffs() const;
//- Return the matrix source coefficients corresponding to the
// evaluation of the gradient of this patchField
virtual tmp<Field<Type>> gradientBoundaryCoeffs
(
const scalarField& deltaCoeffs
) const;
//- Return the matrix source coefficients corresponding to the
// evaluation of the gradient of this patchField
virtual tmp<Field<Type>> gradientBoundaryCoeffs() const;
//- Manipulate matrix //- Manipulate matrix
virtual void manipulateMatrix(fvMatrix<Type>& matrix); virtual void manipulateMatrix(fvMatrix<Type>& matrix);

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -133,7 +133,7 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fixedFluxPressureFvPatchScalarField::updateCoeffs void Foam::fixedFluxPressureFvPatchScalarField::updateSnGrad
( (
const scalarField& snGradp const scalarField& snGradp
) )

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -144,7 +144,7 @@ public:
// Member functions // Member functions
//- Update the patch pressure gradient field from the given snGradp //- Update the patch pressure gradient field from the given snGradp
virtual void updateCoeffs(const scalarField& snGradp); virtual void updateSnGrad(const scalarField& snGradp);
//- Update the patch pressure gradient field //- Update the patch pressure gradient field
virtual void updateCoeffs(); virtual void updateCoeffs();
@ -175,7 +175,7 @@ namespace Foam
{ {
if (isA<GradBC>(bf[patchi])) if (isA<GradBC>(bf[patchi]))
{ {
refCast<GradBC>(bf[patchi]).updateCoeffs(snGrad[patchi]); refCast<GradBC>(bf[patchi]).updateSnGrad(snGrad[patchi]);
} }
} }
} }

View File

@ -323,9 +323,6 @@ void Foam::fvPatchField<Type>::updateCoeffs(const scalarField& weights)
{ {
updateCoeffs(); updateCoeffs();
Field<Type>& fld = *this;
fld *= weights;
updated_ = true; updated_ = true;
} }
} }

View File

@ -417,7 +417,7 @@ public:
virtual void updateCoeffs(); virtual void updateCoeffs();
//- Update the coefficients associated with the patch field //- Update the coefficients associated with the patch field
// and apply weight field // and optionally apply weight field.
// Sets Updated to true // Sets Updated to true
virtual void updateCoeffs(const scalarField& weights); virtual void updateCoeffs(const scalarField& weights);

View File

@ -43,7 +43,12 @@ void Foam::cyclicACMIFvPatch::updateAreas() const
{ {
if (cyclicACMIPolyPatch_.updated()) if (cyclicACMIPolyPatch_.updated())
{ {
// Set Sf and magSf for both sides' coupled and non-overlapping patches if (debug)
{
Pout<< "cyclicACMIFvPatch::updateAreas() : updating fv areas for "
<< name() << " and " << this->nonOverlapPatch().name()
<< endl;
}
// owner couple // owner couple
const_cast<vectorField&>(Sf()) = patch().faceAreas(); const_cast<vectorField&>(Sf()) = patch().faceAreas();
@ -81,25 +86,37 @@ void Foam::cyclicACMIFvPatch::makeWeights(scalarField& w) const
if (coupled()) if (coupled())
{ {
const cyclicACMIFvPatch& nbrPatch = neighbFvPatch(); const cyclicACMIFvPatch& nbrPatch = neighbFvPatch();
const fvPatch& nbrPatchNonOverlap = nonOverlapPatch();
const scalarField deltas(nf() & coupledFvPatch::delta()); const scalarField deltas(nf() & coupledFvPatch::delta());
const scalarField nbrDeltas // These deltas are of the cyclic part alone - they are
// not affected by the amount of overlap with the nonOverlapPatch
scalarField nbrDeltas
( (
interpolate interpolate
( (
nbrPatch.nf() & nbrPatch.coupledFvPatch::delta(), nbrPatch.nf() & nbrPatch.coupledFvPatch::delta()
nbrPatchNonOverlap.nf() & nbrPatchNonOverlap.delta()
) )
); );
forAll(deltas, faceI) scalar tol = cyclicACMIPolyPatch::tolerance();
{
scalar di = deltas[faceI];
scalar dni = nbrDeltas[faceI];
w[faceI] = dni/(di + dni);
forAll(deltas, facei)
{
scalar di = deltas[facei];
scalar dni = nbrDeltas[facei];
if (dni < tol)
{
// Avoid zero weights on disconnected faces. This value
// will be weighted with the (zero) face area so will not
// influence calculations.
w[facei] = 1.0;
}
else
{
w[facei] = dni/(di + dni);
}
} }
} }
else else
@ -122,30 +139,12 @@ Foam::tmp<Foam::vectorField> Foam::cyclicACMIFvPatch::delta() const
{ {
if (coupled()) if (coupled())
{ {
const cyclicACMIFvPatch& nbrPatchCoupled = neighbFvPatch(); const cyclicACMIFvPatch& nbrPatch = neighbFvPatch();
const fvPatch& nbrPatchNonOverlap = nonOverlapPatch();
const vectorField patchD(coupledFvPatch::delta()); const vectorField patchD(coupledFvPatch::delta());
vectorField nbrPatchD vectorField nbrPatchD(interpolate(nbrPatch.coupledFvPatch::delta()));
(
interpolate
(
nbrPatchCoupled.coupledFvPatch::delta(),
nbrPatchNonOverlap.delta()
)
);
const vectorField nbrPatchD0
(
interpolate
(
vectorField(nbrPatchCoupled.size(), Zero),
nbrPatchNonOverlap.delta()()
)
);
nbrPatchD -= nbrPatchD0;
tmp<vectorField> tpdv(new vectorField(patchD.size())); tmp<vectorField> tpdv(new vectorField(patchD.size()));
vectorField& pdv = tpdv.ref(); vectorField& pdv = tpdv.ref();
@ -153,22 +152,22 @@ Foam::tmp<Foam::vectorField> Foam::cyclicACMIFvPatch::delta() const
// do the transformation if necessary // do the transformation if necessary
if (parallel()) if (parallel())
{ {
forAll(patchD, faceI) forAll(patchD, facei)
{ {
const vector& ddi = patchD[faceI]; const vector& ddi = patchD[facei];
const vector& dni = nbrPatchD[faceI]; const vector& dni = nbrPatchD[facei];
pdv[faceI] = ddi - dni; pdv[facei] = ddi - dni;
} }
} }
else else
{ {
forAll(patchD, faceI) forAll(patchD, facei)
{ {
const vector& ddi = patchD[faceI]; const vector& ddi = patchD[facei];
const vector& dni = nbrPatchD[faceI]; const vector& dni = nbrPatchD[facei];
pdv[faceI] = ddi - transform(forwardT()[0], dni); pdv[facei] = ddi - transform(forwardT()[0], dni);
} }
} }

View File

@ -174,10 +174,11 @@ public:
//- Return delta (P to N) vectors across coupled patch //- Return delta (P to N) vectors across coupled patch
virtual tmp<vectorField> delta() const; virtual tmp<vectorField> delta() const;
//- Interpolate (make sure to have uptodate areas)
template<class Type> template<class Type>
tmp<Field<Type>> interpolate tmp<Field<Type>> interpolate
( (
const Field<Type>& fldCoupled const Field<Type>& fld
) const ) const
{ {
updateAreas(); updateAreas();
@ -185,57 +186,18 @@ public:
return return
cyclicACMIPolyPatch_.cyclicAMIPolyPatch::interpolate cyclicACMIPolyPatch_.cyclicAMIPolyPatch::interpolate
( (
fldCoupled fld
); );
} }
//- Interpolate (make sure to have uptodate areas)
template<class Type> template<class Type>
tmp<Field<Type>> interpolate tmp<Field<Type>> interpolate
( (
const tmp<Field<Type>>& tfldCoupled const tmp<Field<Type>>& tfld
) const ) const
{ {
updateAreas(); return interpolate(tfld());
return
cyclicACMIPolyPatch_.cyclicAMIPolyPatch::interpolate
(
tfldCoupled
);
}
template<class Type>
tmp<Field<Type>> interpolate
(
const Field<Type>& fldCoupled,
const Field<Type>& fldNonOverlap
) const
{
updateAreas();
return
cyclicACMIPolyPatch_.interpolate
(
fldCoupled,
fldNonOverlap
);
}
template<class Type>
tmp<Field<Type>> interpolate
(
const tmp<Field<Type>>& tFldCoupled,
const tmp<Field<Type>>& tFldNonOverlap
) const
{
updateAreas();
return
cyclicACMIPolyPatch_.interpolate
(
tFldCoupled,
tFldNonOverlap
);
} }

View File

@ -378,10 +378,17 @@ public:
//- Return const access to source patch weights //- Return const access to source patch weights
inline const scalarListList& srcWeights() const; inline const scalarListList& srcWeights() const;
//- Return access to source patch weights
inline scalarListList& srcWeights();
//- Return const access to normalisation factor of source //- Return const access to normalisation factor of source
// patch weights (i.e. the sum before normalisation) // patch weights (i.e. the sum before normalisation)
inline const scalarField& srcWeightsSum() const; inline const scalarField& srcWeightsSum() const;
//- Return access to normalisation factor of source
// patch weights (i.e. the sum before normalisation)
inline scalarField& srcWeightsSum();
//- Source map pointer - valid only if singlePatchProc = -1 //- Source map pointer - valid only if singlePatchProc = -1
// This gets source data into a form to be consumed by // This gets source data into a form to be consumed by
// tgtAddress, tgtWeights // tgtAddress, tgtWeights
@ -399,10 +406,17 @@ public:
//- Return const access to target patch weights //- Return const access to target patch weights
inline const scalarListList& tgtWeights() const; inline const scalarListList& tgtWeights() const;
//- Return access to target patch weights
inline scalarListList& tgtWeights();
//- Return const access to normalisation factor of target //- Return const access to normalisation factor of target
// patch weights (i.e. the sum before normalisation) // patch weights (i.e. the sum before normalisation)
inline const scalarField& tgtWeightsSum() const; inline const scalarField& tgtWeightsSum() const;
//- Return access to normalisation factor of target
// patch weights (i.e. the sum before normalisation)
inline scalarField& tgtWeightsSum();
//- Target map pointer - valid only if singlePatchProc=-1. //- Target map pointer - valid only if singlePatchProc=-1.
// This gets target data into a form to be consumed by // This gets target data into a form to be consumed by
// srcAddress, srcWeights // srcAddress, srcWeights
@ -533,7 +547,7 @@ public:
const SourcePatch& srcPatch, const SourcePatch& srcPatch,
const TargetPatch& tgtPatch, const TargetPatch& tgtPatch,
const vector& n, const vector& n,
const label tgtFaceI, const label tgtFacei,
point& tgtPoint point& tgtPoint
) )
const; const;
@ -544,7 +558,7 @@ public:
const SourcePatch& srcPatch, const SourcePatch& srcPatch,
const TargetPatch& tgtPatch, const TargetPatch& tgtPatch,
const vector& n, const vector& n,
const label srcFaceI, const label srcFacei,
point& srcPoint point& srcPoint
) )
const; const;

View File

@ -72,6 +72,14 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::srcWeights() const
} }
template<class SourcePatch, class TargetPatch>
inline Foam::scalarListList&
Foam::AMIInterpolation<SourcePatch, TargetPatch>::srcWeights()
{
return srcWeights_;
}
template<class SourcePatch, class TargetPatch> template<class SourcePatch, class TargetPatch>
inline const Foam::scalarField& inline const Foam::scalarField&
Foam::AMIInterpolation<SourcePatch, TargetPatch>::srcWeightsSum() const Foam::AMIInterpolation<SourcePatch, TargetPatch>::srcWeightsSum() const
@ -80,6 +88,14 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::srcWeightsSum() const
} }
template<class SourcePatch, class TargetPatch>
inline Foam::scalarField&
Foam::AMIInterpolation<SourcePatch, TargetPatch>::srcWeightsSum()
{
return srcWeightsSum_;
}
template<class SourcePatch, class TargetPatch> template<class SourcePatch, class TargetPatch>
inline const Foam::mapDistribute& inline const Foam::mapDistribute&
Foam::AMIInterpolation<SourcePatch, TargetPatch>::srcMap() const Foam::AMIInterpolation<SourcePatch, TargetPatch>::srcMap() const
@ -112,6 +128,14 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::tgtWeights() const
} }
template<class SourcePatch, class TargetPatch>
inline Foam::scalarListList&
Foam::AMIInterpolation<SourcePatch, TargetPatch>::tgtWeights()
{
return tgtWeights_;
}
template<class SourcePatch, class TargetPatch> template<class SourcePatch, class TargetPatch>
inline const Foam::scalarField& inline const Foam::scalarField&
Foam::AMIInterpolation<SourcePatch, TargetPatch>::tgtWeightsSum() const Foam::AMIInterpolation<SourcePatch, TargetPatch>::tgtWeightsSum() const
@ -120,6 +144,14 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::tgtWeightsSum() const
} }
template<class SourcePatch, class TargetPatch>
inline Foam::scalarField&
Foam::AMIInterpolation<SourcePatch, TargetPatch>::tgtWeightsSum()
{
return tgtWeightsSum_;
}
template<class SourcePatch, class TargetPatch> template<class SourcePatch, class TargetPatch>
inline const Foam::mapDistribute& inline const Foam::mapDistribute&
Foam::AMIInterpolation<SourcePatch, TargetPatch>::tgtMap() const Foam::AMIInterpolation<SourcePatch, TargetPatch>::tgtMap() const

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -38,35 +38,10 @@ namespace Foam
addToRunTimeSelectionTable(polyPatch, cyclicACMIPolyPatch, dictionary); addToRunTimeSelectionTable(polyPatch, cyclicACMIPolyPatch, dictionary);
} }
const Foam::scalar Foam::cyclicACMIPolyPatch::tolerance_ = 1e-6; const Foam::scalar Foam::cyclicACMIPolyPatch::tolerance_ = 1e-10;
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::cyclicACMIPolyPatch::initPatchFaceAreas() const
{
if
(
!empty()
&& (faceAreas0_.empty() || boundaryMesh().mesh().moving())
)
{
faceAreas0_ = faceAreas();
}
const cyclicACMIPolyPatch& nbrACMI =
refCast<const cyclicACMIPolyPatch>(this->neighbPatch());
if
(
!nbrACMI.empty()
&& (nbrACMI.faceAreas0().empty() || boundaryMesh().mesh().moving())
)
{
nbrACMI.faceAreas0_ = nbrACMI.faceAreas();
}
}
void Foam::cyclicACMIPolyPatch::resetAMI void Foam::cyclicACMIPolyPatch::resetAMI
( (
const AMIPatchToPatchInterpolation::interpolationMethod& const AMIPatchToPatchInterpolation::interpolationMethod&
@ -76,37 +51,117 @@ void Foam::cyclicACMIPolyPatch::resetAMI
{ {
const polyPatch& nonOverlapPatch = this->nonOverlapPatch(); const polyPatch& nonOverlapPatch = this->nonOverlapPatch();
initPatchFaceAreas(); if (debug)
// Reset patch face areas based on original patch for AMI calculation
vectorField::subField Sf = faceAreas();
vectorField::subField noSf = nonOverlapPatch.faceAreas();
forAll(Sf, faceI)
{ {
Sf[faceI] = faceAreas0_[faceI]; Pout<< "cyclicACMIPolyPatch::resetAMI : recalculating weights"
noSf[faceI] = faceAreas0_[faceI]; << " for " << name() << " and " << nonOverlapPatch.name()
<< endl;
} }
// Calculate the AMI using partial face-area-weighted if (boundaryMesh().mesh().hasCellCentres())
{
if (debug)
{
Pout<< "cyclicACMIPolyPatch::resetAMI : detected cell centres."
<< " Clearing cell centres to guarantee closed volumes"
<< endl;
}
const_cast<polyMesh&>
(
boundaryMesh().mesh()
).primitiveMesh::clearGeom();
}
// Trigger re-building of faceAreas
(void)boundaryMesh().mesh().faceAreas();
// Calculate the AMI using partial face-area-weighted. This leaves
// the weights as fractions of local areas (sum(weights) = 1 means
// face is fully covered)
cyclicAMIPolyPatch::resetAMI cyclicAMIPolyPatch::resetAMI
( (
AMIPatchToPatchInterpolation::imPartialFaceAreaWeight AMIPatchToPatchInterpolation::imPartialFaceAreaWeight
); );
AMIPatchToPatchInterpolation& AMI =
const_cast<AMIPatchToPatchInterpolation&>(this->AMI());
srcMask_ = srcMask_ =
min(scalar(1) - tolerance_, max(tolerance_, AMI().srcWeightsSum())); min(scalar(1) - tolerance_, max(tolerance_, AMI.srcWeightsSum()));
tgtMask_ = tgtMask_ =
min(scalar(1) - tolerance_, max(tolerance_, AMI().tgtWeightsSum())); min(scalar(1) - tolerance_, max(tolerance_, AMI.tgtWeightsSum()));
forAll(Sf, faceI)
// Adapt owner side areas. Note that in uncoupled situations (e.g.
// decomposePar) srcMask, tgtMask can be zero size.
if (srcMask_.size())
{ {
Sf[faceI] *= srcMask_[faceI]; vectorField::subField Sf = faceAreas();
noSf[faceI] *= 1.0 - srcMask_[faceI]; vectorField::subField noSf = nonOverlapPatch.faceAreas();
forAll(Sf, facei)
{
Sf[facei] *= srcMask_[facei];
noSf[facei] *= 1.0 - srcMask_[facei];
}
}
// Adapt slave side areas
if (tgtMask_.size())
{
const cyclicACMIPolyPatch& cp =
refCast<const cyclicACMIPolyPatch>(this->neighbPatch());
const polyPatch& pp = cp.nonOverlapPatch();
vectorField::subField Sf = cp.faceAreas();
vectorField::subField noSf = pp.faceAreas();
forAll(Sf, facei)
{
Sf[facei] *= tgtMask_[facei];
noSf[facei] *= 1.0 - tgtMask_[facei];
}
} }
setNeighbourFaceAreas(); // Re-normalise the weights since the effect of overlap is already
// accounted for in the area.
{
scalarListList& srcWeights = AMI.srcWeights();
scalarField& srcWeightsSum = AMI.srcWeightsSum();
forAll(srcWeights, i)
{
scalarList& wghts = srcWeights[i];
if (wghts.size())
{
scalar& sum = srcWeightsSum[i];
forAll(wghts, j)
{
wghts[j] /= sum;
}
sum = 1.0;
}
}
}
{
scalarListList& tgtWeights = AMI.tgtWeights();
scalarField& tgtWeightsSum = AMI.tgtWeightsSum();
forAll(tgtWeights, i)
{
scalarList& wghts = tgtWeights[i];
if (wghts.size())
{
scalar& sum = tgtWeightsSum[i];
forAll(wghts, j)
{
wghts[j] /= sum;
}
sum = 1.0;
}
}
}
// Set the updated flag // Set the updated flag
updated_ = true; updated_ = true;
@ -114,48 +169,26 @@ void Foam::cyclicACMIPolyPatch::resetAMI
} }
void Foam::cyclicACMIPolyPatch::setNeighbourFaceAreas() const
{
const cyclicACMIPolyPatch& cp =
refCast<const cyclicACMIPolyPatch>(this->neighbPatch());
const polyPatch& pp = cp.nonOverlapPatch();
const vectorField& faceAreas0 = cp.faceAreas0();
if (tgtMask_.size() == cp.size())
{
vectorField::subField Sf = cp.faceAreas();
vectorField::subField noSf = pp.faceAreas();
forAll(Sf, faceI)
{
Sf[faceI] = tgtMask_[faceI]*faceAreas0[faceI];
noSf[faceI] = (1.0 - tgtMask_[faceI])*faceAreas0[faceI];
}
}
else
{
WarningInFunction
<< "Target mask size differs to that of the neighbour patch\n"
<< " May occur when decomposing." << endl;
}
}
void Foam::cyclicACMIPolyPatch::initGeometry(PstreamBuffers& pBufs) void Foam::cyclicACMIPolyPatch::initGeometry(PstreamBuffers& pBufs)
{ {
// Note: cyclicAMIPolyPatch clears AMI so do first if (debug)
{
Pout<< "cyclicACMIPolyPatch::initGeometry : " << name() << endl;
}
cyclicAMIPolyPatch::initGeometry(pBufs); cyclicAMIPolyPatch::initGeometry(pBufs);
// Initialise the AMI so that base geometry (e.g. cell volumes) are // Initialise the AMI
// correctly evaluated before e.g. any of the processor patches gets
// hit (since uses cell volumes in its initGeometry)
resetAMI(); resetAMI();
} }
void Foam::cyclicACMIPolyPatch::calcGeometry(PstreamBuffers& pBufs) void Foam::cyclicACMIPolyPatch::calcGeometry(PstreamBuffers& pBufs)
{ {
if (debug)
{
Pout<< "cyclicACMIPolyPatch::calcGeometry : " << name() << endl;
}
cyclicAMIPolyPatch::calcGeometry(pBufs); cyclicAMIPolyPatch::calcGeometry(pBufs);
} }
@ -166,12 +199,13 @@ void Foam::cyclicACMIPolyPatch::initMovePoints
const pointField& p const pointField& p
) )
{ {
// Note: cyclicAMIPolyPatch clears AMI so do first if (debug)
{
Pout<< "cyclicACMIPolyPatch::initMovePoints : " << name() << endl;
}
cyclicAMIPolyPatch::initMovePoints(pBufs, p); cyclicAMIPolyPatch::initMovePoints(pBufs, p);
// Initialise the AMI so that base geometry (e.g. cell volumes) are // Initialise the AMI
// correctly evaluated before e.g. any of the processor patches gets
// hit (since uses cell volumes in its initGeometry)
resetAMI(); resetAMI();
} }
@ -182,24 +216,40 @@ void Foam::cyclicACMIPolyPatch::movePoints
const pointField& p const pointField& p
) )
{ {
if (debug)
{
Pout<< "cyclicACMIPolyPatch::movePoints : " << name() << endl;
}
cyclicAMIPolyPatch::movePoints(pBufs, p); cyclicAMIPolyPatch::movePoints(pBufs, p);
} }
void Foam::cyclicACMIPolyPatch::initUpdateMesh(PstreamBuffers& pBufs) void Foam::cyclicACMIPolyPatch::initUpdateMesh(PstreamBuffers& pBufs)
{ {
if (debug)
{
Pout<< "cyclicACMIPolyPatch::initUpdateMesh : " << name() << endl;
}
cyclicAMIPolyPatch::initUpdateMesh(pBufs); cyclicAMIPolyPatch::initUpdateMesh(pBufs);
} }
void Foam::cyclicACMIPolyPatch::updateMesh(PstreamBuffers& pBufs) void Foam::cyclicACMIPolyPatch::updateMesh(PstreamBuffers& pBufs)
{ {
if (debug)
{
Pout<< "cyclicACMIPolyPatch::updateMesh : " << name() << endl;
}
cyclicAMIPolyPatch::updateMesh(pBufs); cyclicAMIPolyPatch::updateMesh(pBufs);
} }
void Foam::cyclicACMIPolyPatch::clearGeom() void Foam::cyclicACMIPolyPatch::clearGeom()
{ {
if (debug)
{
Pout<< "cyclicACMIPolyPatch::clearGeom : " << name() << endl;
}
cyclicAMIPolyPatch::clearGeom(); cyclicAMIPolyPatch::clearGeom();
} }
@ -230,7 +280,6 @@ Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch
) )
: :
cyclicAMIPolyPatch(name, size, start, index, bm, patchType, transform), cyclicAMIPolyPatch(name, size, start, index, bm, patchType, transform),
faceAreas0_(),
nonOverlapPatchName_(word::null), nonOverlapPatchName_(word::null),
nonOverlapPatchID_(-1), nonOverlapPatchID_(-1),
srcMask_(), srcMask_(),
@ -254,7 +303,6 @@ Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch
) )
: :
cyclicAMIPolyPatch(name, dict, index, bm, patchType), cyclicAMIPolyPatch(name, dict, index, bm, patchType),
faceAreas0_(),
nonOverlapPatchName_(dict.lookup("nonOverlapPatch")), nonOverlapPatchName_(dict.lookup("nonOverlapPatch")),
nonOverlapPatchID_(-1), nonOverlapPatchID_(-1),
srcMask_(), srcMask_(),
@ -285,7 +333,6 @@ Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch
) )
: :
cyclicAMIPolyPatch(pp, bm), cyclicAMIPolyPatch(pp, bm),
faceAreas0_(),
nonOverlapPatchName_(pp.nonOverlapPatchName_), nonOverlapPatchName_(pp.nonOverlapPatchName_),
nonOverlapPatchID_(-1), nonOverlapPatchID_(-1),
srcMask_(), srcMask_(),
@ -311,7 +358,6 @@ Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch
) )
: :
cyclicAMIPolyPatch(pp, bm, index, newSize, newStart, nbrPatchName), cyclicAMIPolyPatch(pp, bm, index, newSize, newStart, nbrPatchName),
faceAreas0_(),
nonOverlapPatchName_(nonOverlapPatchName), nonOverlapPatchName_(nonOverlapPatchName),
nonOverlapPatchID_(-1), nonOverlapPatchID_(-1),
srcMask_(), srcMask_(),
@ -343,7 +389,6 @@ Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch
) )
: :
cyclicAMIPolyPatch(pp, bm, index, mapAddressing, newStart), cyclicAMIPolyPatch(pp, bm, index, mapAddressing, newStart),
faceAreas0_(),
nonOverlapPatchName_(pp.nonOverlapPatchName_), nonOverlapPatchName_(pp.nonOverlapPatchName_),
nonOverlapPatchID_(-1), nonOverlapPatchID_(-1),
srcMask_(), srcMask_(),
@ -406,9 +451,9 @@ Foam::label Foam::cyclicACMIPolyPatch::nonOverlapPatchID() const
const scalarField magSf(mag(faceAreas())); const scalarField magSf(mag(faceAreas()));
const scalarField noMagSf(mag(noPp.faceAreas())); const scalarField noMagSf(mag(noPp.faceAreas()));
forAll(magSf, faceI) forAll(magSf, facei)
{ {
scalar ratio = mag(magSf[faceI]/(noMagSf[faceI] + ROOTVSMALL)); scalar ratio = mag(magSf[facei]/(noMagSf[facei] + ROOTVSMALL));
if (ratio - 1 > tolerance_) if (ratio - 1 > tolerance_)
{ {

View File

@ -57,8 +57,8 @@ private:
// Private data // Private data
//- Copy of the original patch face areas //- Fraction of face area below which face is considered disconnected
mutable vectorField faceAreas0_; static const scalar tolerance_;
//- Name of non-overlapping patch //- Name of non-overlapping patch
const word nonOverlapPatchName_; const word nonOverlapPatchName_;
@ -78,14 +78,8 @@ private:
protected: protected:
static const scalar tolerance_;
// Protected Member Functions // Protected Member Functions
//- Initialise patch face areas
virtual void initPatchFaceAreas() const;
//- Reset the AMI interpolator //- Reset the AMI interpolator
virtual void resetAMI virtual void resetAMI
( (
@ -93,9 +87,6 @@ protected:
AMIPatchToPatchInterpolation::imFaceAreaWeight AMIPatchToPatchInterpolation::imFaceAreaWeight
) const; ) const;
//- Set neighbour ACMI patch areas
virtual void setNeighbourFaceAreas() const;
//- Initialise the calculation of the patch geometry //- Initialise the calculation of the patch geometry
virtual void initGeometry(PstreamBuffers&); virtual void initGeometry(PstreamBuffers&);
@ -254,9 +245,6 @@ public:
//- Return access to the updated flag //- Return access to the updated flag
inline bool updated() const; inline bool updated() const;
//- Return access to the original patch face areas
inline const vectorField& faceAreas0() const;
//- Return a reference to the neighbour patch //- Return a reference to the neighbour patch
virtual const cyclicACMIPolyPatch& neighbPatch() const; virtual const cyclicACMIPolyPatch& neighbPatch() const;
@ -275,34 +263,8 @@ public:
//- Mask field where 1 = overlap, 0 = no-overlap //- Mask field where 1 = overlap, 0 = no-overlap
inline const scalarField& mask() const; inline const scalarField& mask() const;
//- Overlap tolerance
// Interpolations inline static scalar tolerance();
//- Interpolate field
template<class Type>
tmp<Field<Type>> interpolate
(
const Field<Type>& fldCouple,
const Field<Type>& fldNonOverlap
) const;
//- Interpolate tmp field
template<class Type>
tmp<Field<Type>> interpolate
(
const tmp<Field<Type>>& tFldCouple,
const tmp<Field<Type>>& tFldNonOverlap
) const;
//- Low-level interpolate List
template<class Type, class CombineOp>
void interpolate
(
const UList<Type>& fldCouple,
const UList<Type>& fldNonOverlap,
const CombineOp& cop,
List<Type>& result
) const;
//- Calculate the patch geometry //- Calculate the patch geometry
@ -353,12 +315,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "cyclicACMIPolyPatchTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -37,12 +37,6 @@ inline bool Foam::cyclicACMIPolyPatch::updated() const
} }
inline const Foam::vectorField& Foam::cyclicACMIPolyPatch::faceAreas0() const
{
return faceAreas0_;
}
inline const Foam::word& Foam::cyclicACMIPolyPatch::nonOverlapPatchName() const inline const Foam::word& Foam::cyclicACMIPolyPatch::nonOverlapPatchName() const
{ {
return nonOverlapPatchName_; return nonOverlapPatchName_;
@ -80,4 +74,10 @@ inline const Foam::scalarField& Foam::cyclicACMIPolyPatch::mask() const
} }
inline Foam::scalar Foam::cyclicACMIPolyPatch::tolerance()
{
return tolerance_;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -1,102 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2016 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/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::cyclicACMIPolyPatch::interpolate
(
const Field<Type>& fldCouple,
const Field<Type>& fldNonOverlap
) const
{
// Note: do not scale AMI field as face areas have already been taken
// into account
if (owner())
{
const scalarField& w = AMI().srcWeightsSum();
tmp<Field<Type>> interpField(AMI().interpolateToSource(fldCouple));
return interpField + (1.0 - w)*fldNonOverlap;
}
else
{
const scalarField& w = neighbPatch().AMI().tgtWeightsSum();
tmp<Field<Type>> interpField
(
neighbPatch().AMI().interpolateToTarget(fldCouple)
);
return interpField + (1.0 - w)*fldNonOverlap;
}
}
template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::cyclicACMIPolyPatch::interpolate
(
const tmp<Field<Type>>& tFldCouple,
const tmp<Field<Type>>& tFldNonOverlap
) const
{
return interpolate(tFldCouple(), tFldNonOverlap());
}
template<class Type, class CombineOp>
void Foam::cyclicACMIPolyPatch::interpolate
(
const UList<Type>& fldCouple,
const UList<Type>& fldNonOverlap,
const CombineOp& cop,
List<Type>& result
) const
{
// Note: do not scale AMI field as face areas have already been taken
// into account
if (owner())
{
const scalarField& w = AMI().srcWeightsSum();
AMI().interpolateToSource(fldCouple, cop, result);
result = result + (1.0 - w)*fldNonOverlap;
}
else
{
const scalarField& w = neighbPatch().AMI().tgtWeightsSum();
neighbPatch().AMI().interpolateToTarget(fldCouple, cop, result);
result = result + (1.0 - w)*fldNonOverlap;
}
}
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -778,6 +778,10 @@ void Foam::streamLineBase::write()
} }
// Note: filenames scattered below since used in global call
fileName scalarVtkFile;
fileName vectorVtkFile;
if (Pstream::master()) if (Pstream::master())
{ {
if (bounds_ != boundBox::greatBox) if (bounds_ != boundBox::greatBox)
@ -873,7 +877,7 @@ void Foam::streamLineBase::write()
} }
} }
fileName vtkFile scalarVtkFile = fileName
( (
vtkPath vtkPath
/ scalarFormatterPtr_().getFileName / scalarFormatterPtr_().getFileName
@ -884,7 +888,7 @@ void Foam::streamLineBase::write()
); );
if (log_) Info if (log_) Info
<< " Writing data to " << vtkFile.path() << endl; << " Writing data to " << scalarVtkFile.path() << endl;
scalarFormatterPtr_().write scalarFormatterPtr_().write
( (
@ -892,16 +896,8 @@ void Foam::streamLineBase::write()
tracks, tracks,
scalarNames_, scalarNames_,
scalarValues, scalarValues,
OFstream(vtkFile)() OFstream(scalarVtkFile)()
); );
forAll(scalarNames_, nameI)
{
dictionary propsDict;
propsDict.add("file", vtkFile);
const word& fieldName = scalarNames_[nameI];
setProperty(fieldName, propsDict);
}
} }
// Convert vector values // Convert vector values
@ -927,7 +923,7 @@ void Foam::streamLineBase::write()
} }
} }
fileName vtkFile vectorVtkFile = fileName
( (
vtkPath vtkPath
/ vectorFormatterPtr_().getFileName / vectorFormatterPtr_().getFileName
@ -937,7 +933,8 @@ void Foam::streamLineBase::write()
) )
); );
//if (log_) Info<< " Writing vector data to " << vtkFile << endl; //if (log_) Info<< " Writing vector data to "
// << vectorVtkFile << endl;
vectorFormatterPtr_().write vectorFormatterPtr_().write
( (
@ -945,18 +942,31 @@ void Foam::streamLineBase::write()
tracks, tracks,
vectorNames_, vectorNames_,
vectorValues, vectorValues,
OFstream(vtkFile)() OFstream(vectorVtkFile)()
); );
forAll(vectorNames_, nameI)
{
dictionary propsDict;
propsDict.add("file", vtkFile);
const word& fieldName = vectorNames_[nameI];
setProperty(fieldName, propsDict);
}
} }
} }
// fileNames are generated on the master but setProperty needs to
// be across all procs
Pstream::scatter(scalarVtkFile);
forAll(scalarNames_, nameI)
{
dictionary propsDict;
propsDict.add("file", scalarVtkFile);
const word& fieldName = scalarNames_[nameI];
setProperty(fieldName, propsDict);
}
Pstream::scatter(vectorVtkFile);
forAll(vectorNames_, nameI)
{
dictionary propsDict;
propsDict.add("file", vectorVtkFile);
const word& fieldName = vectorNames_[nameI];
setProperty(fieldName, propsDict);
}
} }
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -227,8 +227,9 @@ class sampledSets
PtrList<volFieldSampler<T>>& masterFields PtrList<volFieldSampler<T>>& masterFields
); );
//- Write set on master, return fileName
template<class Type> template<class Type>
void writeSampleFile fileName writeSampleFile
( (
const coordSet& masterSampleSet, const coordSet& masterSampleSet,
const PtrList<volFieldSampler<Type>>& masterFields, const PtrList<volFieldSampler<Type>>& masterFields,

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -122,7 +122,7 @@ Foam::sampledSets::volFieldSampler<Type>::volFieldSampler
template<class Type> template<class Type>
void Foam::sampledSets::writeSampleFile Foam::fileName Foam::sampledSets::writeSampleFile
( (
const coordSet& masterSampleSet, const coordSet& masterSampleSet,
const PtrList<volFieldSampler<Type>>& masterFields, const PtrList<volFieldSampler<Type>>& masterFields,
@ -155,20 +155,14 @@ void Foam::sampledSets::writeSampleFile
valueSets, valueSets,
ofs ofs
); );
return fName;
forAll(masterFields, fieldi)
{
dictionary propsDict;
propsDict.add("file", fName);
const word& fieldName = masterFields[fieldi].name();
setProperty(fieldName, propsDict);
}
} }
else else
{ {
WarningInFunction WarningInFunction
<< "File " << ofs.name() << " could not be opened. " << "File " << ofs.name() << " could not be opened. "
<< "No data will be written" << endl; << "No data will be written" << endl;
return fileName::null;
} }
} }
@ -326,11 +320,12 @@ void Foam::sampledSets::sampleAndWrite(fieldGroup<Type>& fields)
PtrList<volFieldSampler<Type>> masterFields(sampledFields.size()); PtrList<volFieldSampler<Type>> masterFields(sampledFields.size());
combineSampledValues(sampledFields, indexSets_, masterFields); combineSampledValues(sampledFields, indexSets_, masterFields);
if (Pstream::master()) forAll(masterSampledSets_, setI)
{ {
forAll(masterSampledSets_, setI) fileName sampleFile;
if (Pstream::master())
{ {
writeSampleFile sampleFile = writeSampleFile
( (
masterSampledSets_[setI], masterSampledSets_[setI],
masterFields, masterFields,
@ -339,6 +334,18 @@ void Foam::sampledSets::sampleAndWrite(fieldGroup<Type>& fields)
fields.formatter() fields.formatter()
); );
} }
Pstream::scatter(sampleFile);
if (sampleFile.size())
{
forAll(masterFields, fieldi)
{
dictionary propsDict;
propsDict.add("file", sampleFile);
const word& fieldName = masterFields[fieldi].name();
setProperty(fieldName, propsDict);
}
}
} }
} }
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -49,6 +49,9 @@ void Foam::sampledSurfaces::writeSurface
gatheredValues[Pstream::myProcNo()] = values; gatheredValues[Pstream::myProcNo()] = values;
Pstream::gatherList(gatheredValues); Pstream::gatherList(gatheredValues);
fileName sampleFile;
if (Pstream::master()) if (Pstream::master())
{ {
// Combine values into single field // Combine values into single field
@ -72,7 +75,7 @@ void Foam::sampledSurfaces::writeSurface
// skip surface without faces (eg, a failed cut-plane) // skip surface without faces (eg, a failed cut-plane)
if (mergeList_[surfI].faces.size()) if (mergeList_[surfI].faces.size())
{ {
fileName fName = formatter_->write sampleFile = formatter_->write
( (
outputDir, outputDir,
s.name(), s.name(),
@ -82,12 +85,16 @@ void Foam::sampledSurfaces::writeSurface
allValues, allValues,
s.interpolate() s.interpolate()
); );
dictionary propsDict;
propsDict.add("file", fName);
setProperty(fieldName, propsDict);
} }
} }
Pstream::scatter(sampleFile);
if (sampleFile.size())
{
dictionary propsDict;
propsDict.add("file", sampleFile);
setProperty(fieldName, propsDict);
}
} }
else else
{ {

View File

@ -35,7 +35,7 @@ purgeWrite 0;
writeFormat ascii; writeFormat ascii;
writePrecision 6; writePrecision 10;
writeCompression off; writeCompression off;

View File

@ -39,7 +39,7 @@ solvers
pFinal pFinal
{ {
$p; $p;
tolerance 1e-6; tolerance 1e-10;
relTol 0; relTol 0;
} }