diff --git a/applications/utilities/preProcessing/applyBoundaryLayer/applyBoundaryLayer.C b/applications/utilities/preProcessing/applyBoundaryLayer/applyBoundaryLayer.C index 4c16ae0e541b6fdccd4adaa916ceca13583beef8..18fa6a61ef6cf6294c2eb905c28a165af914e3ca 100644 --- a/applications/utilities/preProcessing/applyBoundaryLayer/applyBoundaryLayer.C +++ b/applications/utilities/preProcessing/applyBoundaryLayer/applyBoundaryLayer.C @@ -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 @@ -104,13 +104,15 @@ int main(int argc, char *argv[]) Info<< "Setting boundary layer velocity" << nl << endl; scalar yblv = ybl.value(); - forAll(U, celli) + forAll(U, cellI) { - if (y[celli] <= yblv) + if (y[cellI] <= yblv) { - U[celli] *= ::pow(y[celli]/yblv, (1.0/7.0)); + mask[cellI] = 1; + U[cellI] *= ::pow(y[cellI]/yblv, (1.0/7.0)); } } + mask.correctBoundaryConditions(); Info<< "Writing U\n" << endl; U.write(); @@ -128,11 +130,15 @@ int main(int argc, char *argv[]) if (isA<incompressible::RASModel>(turbulence())) { - // Calculate nut + // Calculate nut - reference nut is calculated by the turbulence model + // on its construction tmp<volScalarField> tnut = turbulence->nut(); volScalarField& nut = tnut(); volScalarField S(mag(dev(symm(fvc::grad(U))))); - nut = sqr(kappa*min(y, ybl))*::sqrt(2)*S; + nut = (1 - mask)*nut + mask*sqr(kappa*min(y, ybl))*::sqrt(2)*S; + + // do not correct BC - wall functions will 'undo' manipulation above + // by using nut from turbulence model if (args.optionFound("writenut")) { @@ -140,9 +146,6 @@ int main(int argc, char *argv[]) nut.write(); } - // Create G field - used by RAS wall functions - volScalarField G(turbulence().GName(), nut*2*sqr(S)); - //--- Read and modify turbulence fields @@ -150,8 +153,11 @@ int main(int argc, char *argv[]) tmp<volScalarField> tk = turbulence->k(); volScalarField& k = tk(); scalar ck0 = pow025(Cmu)*kappa; - k = sqr(nut/(ck0*min(y, ybl))); - k.correctBoundaryConditions(); + k = (1 - mask)*k + mask*sqr(nut/(ck0*min(y, ybl))); + + // do not correct BC - operation may use inconsistent fields wrt these + // local manipulations + // k.correctBoundaryConditions(); Info<< "Writing k\n" << endl; k.write(); @@ -161,8 +167,11 @@ int main(int argc, char *argv[]) tmp<volScalarField> tepsilon = turbulence->epsilon(); volScalarField& epsilon = tepsilon(); scalar ce0 = ::pow(Cmu, 0.75)/kappa; - epsilon = ce0*k*sqrt(k)/min(y, ybl); - epsilon.correctBoundaryConditions(); + epsilon = (1 - mask)*epsilon + mask*ce0*k*sqrt(k)/min(y, ybl); + + // do not correct BC - wall functions will use non-updated k from + // turbulence model + // epsilon.correctBoundaryConditions(); Info<< "Writing epsilon\n" << endl; epsilon.write(); @@ -181,12 +190,12 @@ int main(int argc, char *argv[]) if (omegaHeader.headerOk()) { volScalarField omega(omegaHeader, mesh); - omega = - epsilon - /( - Cmu*k+dimensionedScalar("VSMALL", k.dimensions(), VSMALL) - ); - omega.correctBoundaryConditions(); + dimensionedScalar k0("VSMALL", k.dimensions(), VSMALL); + omega = (1 - mask)*omega + mask*epsilon/(Cmu*k + k0); + + // do not correct BC - wall functions will use non-updated k from + // turbulence model + // omega.correctBoundaryConditions(); Info<< "Writing omega\n" << endl; omega.write(); @@ -207,7 +216,9 @@ int main(int argc, char *argv[]) { volScalarField nuTilda(nuTildaHeader, mesh); nuTilda = nut; - nuTilda.correctBoundaryConditions(); + + // do not correct BC + // nuTilda.correctBoundaryConditions(); Info<< "Writing nuTilda\n" << endl; nuTilda.write(); diff --git a/applications/utilities/preProcessing/applyBoundaryLayer/createFields.H b/applications/utilities/preProcessing/applyBoundaryLayer/createFields.H index e7d72692fc1f640e0b25c6023d0eaccf729f61b4..22515ac83270fdd31dd712aa50e3dd4b214208ab 100644 --- a/applications/utilities/preProcessing/applyBoundaryLayer/createFields.H +++ b/applications/utilities/preProcessing/applyBoundaryLayer/createFields.H @@ -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 @@ -23,39 +23,55 @@ License \*---------------------------------------------------------------------------*/ - Info<< "Reading field U\n" << endl; - volVectorField U +Info<< "Reading field U\n" << endl; +volVectorField U +( + IOobject ( - IOobject - ( - "U", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE - ), - mesh - ); - - Info<< "Calculating wall distance field" << endl; - volScalarField y(wallDist(mesh).y()); - - // Set the mean boundary-layer thickness - dimensionedScalar ybl("ybl", dimLength, 0); - - if (args.optionFound("ybl")) - { - // If the boundary-layer thickness is provided use it - ybl.value() = args.optionRead<scalar>("ybl"); - } - else if (args.optionFound("Cbl")) - { - // Calculate boundary layer thickness as Cbl * mean distance to wall - ybl.value() = gAverage(y) * args.optionRead<scalar>("Cbl"); - } - - Info<< "\nCreating boundary-layer for U of thickness " - << ybl.value() << " m" << nl << endl; + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ), + mesh +); + +Info<< "Calculating wall distance field" << endl; +volScalarField y(wallDist(mesh).y()); + +// Set the mean boundary-layer thickness +dimensionedScalar ybl("ybl", dimLength, 0); + +if (args.optionFound("ybl")) +{ + // If the boundary-layer thickness is provided use it + ybl.value() = args.optionRead<scalar>("ybl"); +} +else if (args.optionFound("Cbl")) +{ + // Calculate boundary layer thickness as Cbl*mean distance to wall + ybl.value() = gAverage(y)*args.optionRead<scalar>("Cbl"); +} + +Info<< "\nCreating boundary-layer for U of thickness " + << ybl.value() << " m" << nl << endl; + +Info<< "Creating mask field" << endl; +volScalarField mask +( + IOobject + ( + "mask", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("zero", dimless, 0.0), + zeroGradientFvPatchScalarField::typeName +); // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C index 197179a115438fa8d60521924bcf5e5133e774ed..3fe24cfad86e92731e668f8ab496e56d7f63dee1 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C @@ -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); - pnf = cyclicAMIPatch_.interpolate(pnf); + 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); - pnf = cyclicAMIPatch_.interpolate(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(); diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C index 8d2f1b4cddc7d575c32e8afbefa57dea8a1527db..abf1a6b395c6509cf33ada99b712db939cd95d4f 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C @@ -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(); diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.H b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.H index a44049077e5f57db2d14b96b7ed0c3a931834004..0263fb52df91c5d2e21c767e8452bf61a08ee7ab 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.H +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.H @@ -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; + bool applyLowWeightCorrection() const + { + return cyclicAMIPolyPatch_.applyLowWeightCorrection(); + } + 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 { - return cyclicAMIPolyPatch_.interpolate(fld); + return cyclicAMIPolyPatch_.interpolate(fld, defaultValues); } template<class Type> - tmp<Field<Type> > interpolate(const tmp<Field<Type> >& tFld) const + tmp<Field<Type> > interpolate + ( + const tmp<Field<Type> >& tFld, + const UList<Type>& defaultValues = UList<Type>() + ) const { - return cyclicAMIPolyPatch_.interpolate(tFld); + return cyclicAMIPolyPatch_.interpolate(tFld, defaultValues); } diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C index 897e7ec42d18e25fe6141f9701f2ce9165516379..16714be445b622ad67f2efc1d87042dab2a8e55f 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C @@ -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) @@ -1029,12 +1079,19 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget forAll(result, faceI) { - const labelList& faces = tgtAddress_[faceI]; - const scalarList& weights = tgtWeights_[faceI]; - - forAll(faces, i) + if (tgtWeightsSum_[faceI] < lowWeightCorrection_) { - cop(result[faceI], faceI, work[faces[i]], weights[i]); + result[faceI] = defaultValues[faceI]; + } + else + { + const labelList& faces = tgtAddress_[faceI]; + const scalarList& weights = tgtWeights_[faceI]; + + forAll(faces, i) + { + cop(result[faceI], faceI, work[faces[i]], weights[i]); + } } } } @@ -1042,12 +1099,19 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget { forAll(result, faceI) { - const labelList& faces = tgtAddress_[faceI]; - const scalarList& weights = tgtWeights_[faceI]; - - forAll(faces, i) + if (tgtWeightsSum_[faceI] < lowWeightCorrection_) + { + result[faceI] = defaultValues[faceI]; + } + else { - cop(result[faceI], faceI, fld[faces[i]], weights[i]); + const labelList& faces = tgtAddress_[faceI]; + const scalarList& weights = tgtWeights_[faceI]; + + forAll(faces, i) + { + cop(result[faceI], faceI, fld[faces[i]], weights[i]); + } } } } @@ -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) @@ -1091,12 +1180,19 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToSource forAll(result, faceI) { - const labelList& faces = srcAddress_[faceI]; - const scalarList& weights = srcWeights_[faceI]; - - forAll(faces, i) + if (srcWeightsSum_[faceI] < lowWeightCorrection_) + { + result[faceI] = defaultValues[faceI]; + } + else { - cop(result[faceI], faceI, work[faces[i]], weights[i]); + const labelList& faces = srcAddress_[faceI]; + const scalarList& weights = srcWeights_[faceI]; + + forAll(faces, i) + { + cop(result[faceI], faceI, work[faces[i]], weights[i]); + } } } } @@ -1104,12 +1200,19 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToSource { forAll(result, faceI) { - const labelList& faces = srcAddress_[faceI]; - const scalarList& weights = srcWeights_[faceI]; - - forAll(faces, i) + if (srcWeightsSum_[faceI] < lowWeightCorrection_) { - cop(result[faceI], faceI, fld[faces[i]], weights[i]); + result[faceI] = defaultValues[faceI]; + } + else + { + const labelList& faces = srcAddress_[faceI]; + const scalarList& weights = srcWeights_[faceI]; + + forAll(faces, i) + { + cop(result[faceI], faceI, fld[faces[i]], weights[i]); + } } } } @@ -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); } diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H index cc30379df1c44aac017a076dd8db4fcccc7d2c85..a8193358c49fdd8b0c3b28f76cc54aee9af1da44 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H @@ -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; diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationI.H b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationI.H index 84291ce326c799bb781bd44ed9f6fd1871614bc1..9c59cb68651e97d503aca2ddbd474bc688006eae 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationI.H +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationI.H @@ -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 diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/faceAreaWeightAMI/faceAreaWeightAMI.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/faceAreaWeightAMI/faceAreaWeightAMI.C index 2c303eb39fcb56e1d0cf449c065c48b198fd1419..05dcd1e29595262643d454d22f5f2e98b2be9980 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/faceAreaWeightAMI/faceAreaWeightAMI.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/faceAreaWeightAMI/faceAreaWeightAMI.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -310,6 +310,8 @@ Foam::scalar Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::interArea const label tgtFaceI ) const { + scalar area = 0; + const pointField& srcPoints = this->srcPatch_.points(); const pointField& tgtPoints = this->tgtPatch_.points(); @@ -322,7 +324,7 @@ Foam::scalar Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::interArea const scalar tgtMag = tgt.mag(tgtPoints); if ((this->srcMagSf_[srcFaceI] < ROOTVSMALL) || (tgtMag < ROOTVSMALL)) { - return 0.0; + return area; } // create intersection object @@ -338,12 +340,11 @@ Foam::scalar Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::interArea { n += this->tgtPatch_.faceNormals()[tgtFaceI]; } - n *= 0.5; + scalar magN = mag(n); - scalar area = 0; - if (mag(n) > ROOTVSMALL) + if (magN > ROOTVSMALL) { - area = inter.calc(src, tgt, n, this->triMode_); + area = inter.calc(src, tgt, n/magN, this->triMode_); } else { @@ -549,7 +550,7 @@ void Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::calculate tgtFaceI ); - if (this->srcNonOverlap_.size() != 0) + if (debug && !this->srcNonOverlap_.empty()) { Pout<< " AMI: " << this->srcNonOverlap_.size() << " non-overlap faces identified" diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.C b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.C index 1bf86bea351b6c3374e985c5b1498d6fe5261501..a959b9b3afb8ae8a0ac5ef6fa7235e3bf5c92c3f 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.C @@ -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 - fcFld = - cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().interpolate - ( - fcFld - ); + 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 diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C index 98ce25d2600acc5048b6f0f86cdbacbf0506c9fb..e55d5f96a9374331249ee5b00fdccc9755e9e76d 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C @@ -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()); diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H index fbdffb3deeed5d6ae646aad1bb6a68d375c977e2..c9c0055a47f1374ef8f631930fe28ba1073a1b8a 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H @@ -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; diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatchTemplates.C b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatchTemplates.C index 3c5fc6e02754cddcaebb266fc0e1e6fdbb751931..50f285a4448ba9ff614052b0b26cf030b7aab869 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatchTemplates.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatchTemplates.C @@ -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 + ); } } diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C index 4c6858a79bfe614e919313118465d57be8ecddbc..d4e157635a9c58013f8a613e2c620b239bf0a0f6 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C @@ -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 @@ -837,6 +837,7 @@ void Foam::mappedPatchBase::calcAMI() const surfPtr(), faceAreaIntersect::tmMesh, AMIPatchToPatchInterpolation::imFaceAreaWeight, + -1, AMIReverse_ ) ); diff --git a/src/meshTools/regionCoupled/patches/regionCoupledPolyPatch/regionCoupledBase.C b/src/meshTools/regionCoupled/patches/regionCoupledPolyPatch/regionCoupledBase.C index 3664bb420516d45ebcb80b46e27dfa680007af10..224a104c3c6fc59f3763572fb0138526189e221d 100644 --- a/src/meshTools/regionCoupled/patches/regionCoupledPolyPatch/regionCoupledBase.C +++ b/src/meshTools/regionCoupled/patches/regionCoupledPolyPatch/regionCoupledBase.C @@ -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 @@ -92,6 +92,7 @@ void Foam::regionCoupledBase::resetAMI() const surfPtr(), faceAreaIntersect::tmMesh, AMIPatchToPatchInterpolation::imFaceAreaWeight, + -1, AMIReverse_ ) ); diff --git a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C index 283a93e426c0d0d28e497b7bf6d0939b3939864b..6c20c0a19b7dabd7738a3a1c86305bd040a584c1 100644 --- a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C +++ b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C @@ -33,7 +33,7 @@ License namespace Foam { -defineTypeNameAndDebug(forceCoeffs, 0); + defineTypeNameAndDebug(forceCoeffs, 0); } @@ -100,7 +100,7 @@ void Foam::forceCoeffs::writeFileHeader(const label i) for (label j = 0; j < nBin_; j++) { - const word jn('[' + Foam::name(j) + ']'); + const word jn('(' + Foam::name(j) + ')'); writeTabbed(file(i), "Cm" + jn); writeTabbed(file(i), "Cd" + jn); writeTabbed(file(i), "Cl" + jn); diff --git a/src/postProcessing/functionObjects/forces/forces/forces.C b/src/postProcessing/functionObjects/forces/forces/forces.C index d624554e93d473ea63b051c66730b0378edd7b12..84863f7f7b98312e810d3c6eca5e21dcdd5e7b11 100644 --- a/src/postProcessing/functionObjects/forces/forces/forces.C +++ b/src/postProcessing/functionObjects/forces/forces/forces.C @@ -39,7 +39,7 @@ License namespace Foam { -defineTypeNameAndDebug(forces, 0); + defineTypeNameAndDebug(forces, 0); } @@ -78,8 +78,8 @@ void Foam::forces::writeFileHeader(const label i) writeCommented(file(i), "Time"); file(i) - << "forces[pressure,viscous,porous] " - << "moment[pressure,viscous,porous]"; + << "forces(pressure viscous porous) " + << "moment(pressure viscous porous)"; if (localSystem_) { @@ -126,7 +126,7 @@ void Foam::forces::writeFileHeader(const label i) for (label j = 0; j < nBin_; j++) { - const word jn('[' + Foam::name(j) + ']'); + const word jn('(' + Foam::name(j) + ')'); const word f("forces" + jn + "[pressure,viscous,porous]"); const word m("moments" + jn + "[pressure,viscous,porous]"); @@ -136,7 +136,7 @@ void Foam::forces::writeFileHeader(const label i) { for (label j = 0; j < nBin_; j++) { - const word jn('[' + Foam::name(j) + ']'); + const word jn('(' + Foam::name(j) + ')'); const word f("localForces" + jn + "[pressure,viscous,porous]"); const word m("localMoments" + jn + "[pressure,viscous,porous]"); @@ -403,13 +403,13 @@ void Foam::forces::writeForces() << " porous : " << sum(moment_[2]) << endl; - file(0) << obr_.time().value() << tab << setw(1) << '[' - << sum(force_[0]) << setw(1) << ',' - << sum(force_[1]) << setw(1) << "," - << sum(force_[2]) << setw(3) << "] [" - << sum(moment_[0]) << setw(1) << "," - << sum(moment_[1]) << setw(1) << "," - << sum(moment_[2]) << setw(1) << "]" + file(0) << obr_.time().value() << tab << setw(1) << '(' + << sum(force_[0]) << setw(1) << ' ' + << sum(force_[1]) << setw(1) << ' ' + << sum(force_[2]) << setw(3) << ") (" + << sum(moment_[0]) << setw(1) << ' ' + << sum(moment_[1]) << setw(1) << ' ' + << sum(moment_[2]) << setw(1) << ')' << endl; if (localSystem_) @@ -421,13 +421,13 @@ void Foam::forces::writeForces() vectorField localMomentT(coordSys_.localVector(moment_[1])); vectorField localMomentP(coordSys_.localVector(moment_[2])); - file(0) << obr_.time().value() << tab << setw(1) << "[" - << sum(localForceN) << setw(1) << "," - << sum(localForceT) << setw(1) << "," - << sum(localForceP) << setw(3) << "] [" - << sum(localMomentN) << setw(1) << "," - << sum(localMomentT) << setw(1) << "," - << sum(localMomentP) << setw(1) << "]" + file(0) << obr_.time().value() << tab << setw(1) << '(' + << sum(localForceN) << setw(1) << ' ' + << sum(localForceT) << setw(1) << ' ' + << sum(localForceP) << setw(3) << ") (" + << sum(localMomentN) << setw(1) << ' ' + << sum(localMomentT) << setw(1) << ' ' + << sum(localMomentP) << setw(1) << ')' << endl; } } @@ -462,13 +462,13 @@ void Foam::forces::writeBins() forAll(f[0], i) { file(1) - << tab << setw(1) << "[" - << f[0][i] << setw(1) << "," - << f[1][i] << setw(1) << "," - << f[2][i] << setw(3) << "] [" - << m[0][i] << setw(1) << "," - << m[1][i] << setw(1) << "," - << m[2][i] << setw(1) << "]"; + << tab << setw(1) << '(' + << f[0][i] << setw(1) << ' ' + << f[1][i] << setw(1) << ' ' + << f[2][i] << setw(3) << ") (" + << m[0][i] << setw(1) << ' ' + << m[1][i] << setw(1) << ' ' + << m[2][i] << setw(1) << ')'; } if (localSystem_) @@ -498,13 +498,13 @@ void Foam::forces::writeBins() forAll(lf[0], i) { file(1) - << tab << setw(1) << "[" - << lf[0][i] << setw(1) << "," - << lf[1][i] << setw(1) << "," - << lf[2][i] << setw(3) << "] [" - << lm[0][i] << setw(1) << "," - << lm[1][i] << setw(1) << "," - << lm[2][i] << setw(1) << "]"; + << tab << setw(1) << '(' + << lf[0][i] << setw(1) << ' ' + << lf[1][i] << setw(1) << ' ' + << lf[2][i] << setw(3) << ") (" + << lm[0][i] << setw(1) << ' ' + << lm[1][i] << setw(1) << ' ' + << lm[2][i] << setw(1) << ')'; } } diff --git a/src/regionModels/regionModel/regionModel/regionModel.C b/src/regionModels/regionModel/regionModel/regionModel.C index 9643348e1df0d56629eb648ecff43eb3ec3f2d9f..5e147d22f5910f703ae4f9702740b6b66a9fab01 100644 --- a/src/regionModels/regionModel/regionModel/regionModel.C +++ b/src/regionModels/regionModel/regionModel/regionModel.C @@ -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 @@ -243,6 +243,7 @@ Foam::regionModels::regionModel::interRegionAMI nbrP, faceAreaIntersect::tmMesh, AMIPatchToPatchInterpolation::imFaceAreaWeight, + -1, flip ) ); @@ -284,6 +285,7 @@ Foam::regionModels::regionModel::interRegionAMI nbrP, faceAreaIntersect::tmMesh, AMIPatchToPatchInterpolation::imFaceAreaWeight, + -1, flip ) ); diff --git a/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMesh.C b/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMesh.C index 12b271ee0ef346b17bd6837cce4bc0f7b1297b1b..eebb219a6fc5efecfd6ecdd75620adff60512709 100644 --- a/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMesh.C +++ b/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMesh.C @@ -420,6 +420,7 @@ Foam::meshToMesh::patchAMIs() const tgtPP, faceAreaIntersect::tmMesh, interpolationMethodAMI(method_), + -1, true // flip target patch since patch normals are aligned ) ); diff --git a/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMeshTemplates.C b/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMeshTemplates.C index ed848d75226bae39402401c8010a77ed3191ccb8..b5981d522ce933823507345cb8b7542960a17eea 100644 --- a/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMeshTemplates.C +++ b/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMeshTemplates.C @@ -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, diff --git a/tutorials/mesh/foamyHexMesh/mixerVessel/0.org/alpha.water b/tutorials/mesh/foamyHexMesh/mixerVessel/0.org/alpha.phase1 similarity index 97% rename from tutorials/mesh/foamyHexMesh/mixerVessel/0.org/alpha.water rename to tutorials/mesh/foamyHexMesh/mixerVessel/0.org/alpha.phase1 index 17678343e2d014de148a1de85f3af8b02e62f8d6..a4f5aa39cbee69a917595b2189a169e1d501e50e 100644 --- a/tutorials/mesh/foamyHexMesh/mixerVessel/0.org/alpha.water +++ b/tutorials/mesh/foamyHexMesh/mixerVessel/0.org/alpha.phase1 @@ -10,7 +10,7 @@ FoamFile version 2.0; format ascii; class volScalarField; - object alpha.water; + object alpha.phase1; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun b/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun index 99d75a9906847222fb3701cef5a25a476470e508..6f1f804faaa19e5396e9291c15353ab7bf0f5eb0 100755 --- a/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun +++ b/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun @@ -8,6 +8,6 @@ cd ${0%/*} || exit 1 # run from this directory ./Allrun-pre ## Run simulation -#./Allrun-simulation +./Allrun-simulation # ----------------------------------------------------------------- end-of-file diff --git a/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun-pre b/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun-pre index e1314946c8e1b965165e5c9ee2e8fb8af8867781..e0e9ab1256c482411a07e29893854bf168f1376b 100755 --- a/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun-pre +++ b/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun-pre @@ -93,17 +93,17 @@ runParallel foamyHexMesh $nProcs runParallel collapseEdges $nProcs -collapseFaces -latestTime mv log.collapseEdges log.collapseFaces -\cp system/collapseDict.indirectPatchFaces system/collapseDict -runParallel collapseEdges $nProcs -collapseFaceSet indirectPatchFaces -latestTime -mv log.collapseEdges log.collapseFaceSet +#\cp system/collapseDict.indirectPatchFaces system/collapseDict +#runParallel collapseEdges $nProcs -collapseFaceSet indirectPatchFaces -latestTime +#mv log.collapseEdges log.collapseFaceSet runParallel checkMesh $nProcs -allTopology -allGeometry -latestTime runApplication reconstructParMesh -latestTime # Copy the mesh into polyMesh and delete the 102 directory -\cp -r 102/polyMesh constant -\rm -rf 102 +\cp -r 101/polyMesh constant +\rm -rf 101 # ----------------------------------------------------------------- end-of-file diff --git a/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun-simulation b/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun-simulation index e789caef9fdf7c456a2ce7e532f670f14d3b11ac..f7ad32e4747b59e50a05405ebbf05befd33c1e23 100755 --- a/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun-simulation +++ b/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun-simulation @@ -31,7 +31,7 @@ runApplication setFields runApplication decomposePar -force # Run -runParallel $application 8 +runParallel $application $nProcs # Reconstruct runApplication reconstructPar -noFunctionObjects diff --git a/tutorials/mesh/foamyHexMesh/mixerVessel/constant/transportProperties b/tutorials/mesh/foamyHexMesh/mixerVessel/constant/transportProperties index 0d7bbe9e603245b7f70fbfe67c89ca2132e03492..572195459a624d4d96c8a6bd544b365d1152d51b 100644 --- a/tutorials/mesh/foamyHexMesh/mixerVessel/constant/transportProperties +++ b/tutorials/mesh/foamyHexMesh/mixerVessel/constant/transportProperties @@ -15,16 +15,16 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -phases (water air); +phases (phase1 phase2); -water +phase1 { transportModel Newtonian; nu nu [ 0 2 -1 0 0 0 0 ] 1e-06; rho rho [ 1 -3 0 0 0 0 0 ] 300; } -air +phase2 { transportModel Newtonian; nu nu [ 0 2 -1 0 0 0 0 ] 1e-6; diff --git a/tutorials/mesh/foamyHexMesh/mixerVessel/system/createBafflesDict b/tutorials/mesh/foamyHexMesh/mixerVessel/system/createBafflesDict index e0c2c4366098e0febf150a09a54d1dd61380f475..877d6154c023b1c26284e921d3207e7035368c96 100644 --- a/tutorials/mesh/foamyHexMesh/mixerVessel/system/createBafflesDict +++ b/tutorials/mesh/foamyHexMesh/mixerVessel/system/createBafflesDict @@ -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; diff --git a/tutorials/mesh/foamyHexMesh/mixerVessel/system/fvSolution b/tutorials/mesh/foamyHexMesh/mixerVessel/system/fvSolution index 6798f4b2e09f0c1d317590b3552bdb1a8e3b7468..f7f15bc378ff50e6bce68362c35d17d9d1fa3fdd 100644 --- a/tutorials/mesh/foamyHexMesh/mixerVessel/system/fvSolution +++ b/tutorials/mesh/foamyHexMesh/mixerVessel/system/fvSolution @@ -17,7 +17,7 @@ FoamFile solvers { - alpha.water + alpha.phase1 { nAlphaCorr 1; nAlphaSubCycles 2; diff --git a/tutorials/mesh/foamyHexMesh/mixerVessel/system/setFieldsDict b/tutorials/mesh/foamyHexMesh/mixerVessel/system/setFieldsDict index defca08b47fc2dc5c35ec6eb306ccaf2cebde967..1cdb64006fc87eb35026ebe3074cf30347883281 100644 --- a/tutorials/mesh/foamyHexMesh/mixerVessel/system/setFieldsDict +++ b/tutorials/mesh/foamyHexMesh/mixerVessel/system/setFieldsDict @@ -17,7 +17,7 @@ FoamFile defaultFieldValues ( - volScalarFieldValue alpha.water 1 + volScalarFieldValue alpha.phase1 1 ); regions @@ -27,7 +27,7 @@ regions box (-4 -4 -1) (4 4 0.74); fieldValues ( - volScalarFieldValue alpha.water 0 + volScalarFieldValue alpha.phase1 0 ); } );