diff --git a/src/finiteArea/faMatrices/faMatrix/faMatrix.C b/src/finiteArea/faMatrices/faMatrix/faMatrix.C index 7eba126e8..17b202b5d 100644 --- a/src/finiteArea/faMatrices/faMatrix/faMatrix.C +++ b/src/finiteArea/faMatrices/faMatrix/faMatrix.C @@ -1036,6 +1036,30 @@ void checkMethod } +template +void checkMethod +( + const faMatrix& fam, + const DimensionedField& vf, + const char* op +) +{ + if (dimensionSet::debug && fam.dimensions()/dimArea != vf.dimensions()) + { + FatalErrorIn + ( + "checkMethod(const faMatrix&, const DimensionedField&)" + ) << "incompatible dimensions for operation " + << endl << " " + << "[" << fam.psi().name() << fam.dimensions()/dimArea << " ] " + << op + << " [" << vf.name() << vf.dimensions() << " ]" + << abort(FatalError); + } +} + + template void checkMethod ( @@ -1103,6 +1127,32 @@ lduSolverPerformance solve(const tmp >& tfam) // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // +// Unary operators for negation +template +tmp > operator- +( + const faMatrix& A +) +{ + tmp > tC(new faMatrix(A)); + tC().negate(); + return tC; +} + + +template +tmp > operator- +( + const tmp >& tA +) +{ + tmp > tC(tA.ptr()); + tC().negate(); + return tC; +} + + +// Operators for faMatrix and faMatrix template tmp > operator+ ( @@ -1160,30 +1210,6 @@ tmp > operator+ } -template -tmp > operator- -( - const faMatrix& A -) -{ - tmp > tC(new faMatrix(A)); - tC().negate(); - return tC; -} - - -template -tmp > operator- -( - const tmp >& tA -) -{ - tmp > tC(tA.ptr()); - tC().negate(); - return tC; -} - - template tmp > operator- ( @@ -1290,6 +1316,7 @@ tmp > operator== } +// Operators for faMatrix and GeometricField template tmp > operator+ ( @@ -1516,6 +1543,238 @@ tmp > operator- } +// Operators for faMatrix and DimensionedField +template +tmp > operator+ +( + const faMatrix& A, + const DimensionedField& su +) +{ + checkMethod(A, su, "+"); + tmp > tC(new faMatrix(A)); + tC().source() -= su.mesh().S()*su.field(); + return tC; +} + + +template +tmp > operator+ +( + const tmp >& tA, + const DimensionedField& su +) +{ + checkMethod(tA(), su, "+"); + tmp > tC(tA.ptr()); + tC().source() -= su.mesh().S()*su.field(); + return tC; +} + + +template +tmp > operator+ +( + const faMatrix& A, + const tmp >& tsu +) +{ + checkMethod(A, tsu(), "+"); + tmp > tC(new faMatrix(A)); + tC().source() -= tsu().mesh().S()*tsu().field(); + tsu.clear(); + return tC; +} + + +template +tmp > operator+ +( + const tmp >& tA, + const tmp >& tsu +) +{ + checkMethod(tA(), tsu(), "+"); + tmp > tC(tA.ptr()); + tC().source() -= tsu().mesh().S()*tsu().field(); + tsu.clear(); + return tC; +} + + +template +tmp > operator+ +( + const DimensionedField& su, + const faMatrix& A +) +{ + checkMethod(A, su, "+"); + tmp > tC(new faMatrix(A)); + tC().source() -= su.mesh().S()*su.field(); + return tC; +} + + +template +tmp > operator+ +( + const DimensionedField& su, + const tmp >& tA +) +{ + checkMethod(tA(), su, "+"); + tmp > tC(tA.ptr()); + tC().source() -= su.mesh().S()*su.field(); + return tC; +} + +template +tmp > operator+ +( + const tmp >& tsu, + const faMatrix& A +) +{ + checkMethod(A, tsu(), "+"); + tmp > tC(new faMatrix(A)); + tC().source() -= tsu().mesh().S()*tsu().field(); + tsu.clear(); + return tC; +} + +template +tmp > operator+ +( + const tmp >& tsu, + const tmp >& tA +) +{ + checkMethod(tA(), tsu(), "+"); + tmp > tC(tA.ptr()); + tC().source() -= tsu().mesh().S()*tsu().field(); + tsu.clear(); + return tC; +} + + +template +tmp > operator- +( + const faMatrix& A, + const DimensionedField& su +) +{ + checkMethod(A, su, "-"); + tmp > tC(new faMatrix(A)); + tC().source() += su.mesh().S()*su.field(); + return tC; +} + +template +tmp > operator- +( + const tmp >& tA, + const DimensionedField& su +) +{ + checkMethod(tA(), su, "-"); + tmp > tC(tA.ptr()); + tC().source() += su.mesh().S()*su.field(); + return tC; +} + +template +tmp > operator- +( + const faMatrix& A, + const tmp >& tsu +) +{ + checkMethod(A, tsu(), "-"); + tmp > tC(new faMatrix(A)); + tC().source() += tsu().mesh().S()*tsu().field(); + tsu.clear(); + return tC; +} + +template +tmp > operator- +( + const tmp >& tA, + const tmp >& tsu +) +{ + checkMethod(tA(), tsu(), "-"); + tmp > tC(tA.ptr()); + tC().source() += tsu().mesh().S()*tsu().field(); + tsu.clear(); + return tC; +} + + +template +tmp > operator- +( + const DimensionedField& su, + const faMatrix& A +) +{ + checkMethod(A, su, "-"); + tmp > tC(new faMatrix(A)); + tC().negate(); + tC().source() -= su.mesh().S()*su.field(); + return tC; +} + + +template +tmp > operator- +( + const DimensionedField& su, + const tmp >& tA +) +{ + checkMethod(tA(), su, "-"); + tmp > tC(tA.ptr()); + tC().negate(); + tC().source() -= su.mesh().S()*su.field(); + return tC; +} + +template +tmp > operator- +( + const tmp >& tsu, + const faMatrix& A +) +{ + checkMethod(A, tsu(), "-"); + tmp > tC(new faMatrix(A)); + tC().negate(); + tC().source() -= tsu().mesh().S()*tsu().field(); + tsu.clear(); + return tC; +} + + +template +tmp > operator- +( + const tmp >& tsu, + const tmp >& tA +) +{ + checkMethod(tA(), tsu(), "-"); + tmp > tC(tA.ptr()); + tC().negate(); + tC().source() -= tsu().mesh().S()*tsu().field(); + tsu.clear(); + return tC; +} + + +// Operators for faMatrix and dimensionedType template tmp > operator+ ( @@ -1530,6 +1789,49 @@ tmp > operator+ } +template +tmp > operator+ +( + const dimensioned& su, + const faMatrix& A +) +{ + checkMethod(A, su, "+"); + tmp > tC(new faMatrix(A)); + tC().source() -= su.value()*A.psi().mesh().S(); + return tC; +} + + +template +tmp > operator- +( + const faMatrix& A, + const dimensioned& su +) +{ + checkMethod(A, su, "-"); + tmp > tC(new faMatrix(A)); + tC().source() += su.value()*tC().psi().mesh().S(); + return tC; +} + + +template +tmp > operator- +( + const dimensioned& su, + const faMatrix& A +) +{ + checkMethod(A, su, "-"); + tmp > tC(new faMatrix(A)); + tC().negate(); + tC().source() -= su.value()*A.psi().mesh().S(); + return tC; +} + + template tmp > operator+ ( @@ -1544,20 +1846,6 @@ tmp > operator+ } -template -tmp > operator+ -( - const dimensioned& su, - const faMatrix& A -) -{ - checkMethod(A, su, "+"); - tmp > tC(new faMatrix(A)); - tC().source() -= su.value()*A.psi().mesh().S(); - return tC; -} - - template tmp > operator+ ( @@ -1572,20 +1860,6 @@ tmp > operator+ } -template -tmp > operator- -( - const faMatrix& A, - const dimensioned& su -) -{ - checkMethod(A, su, "-"); - tmp > tC(new faMatrix(A)); - tC().source() += su.value()*tC().psi().mesh().S(); - return tC; -} - - template tmp > operator- ( @@ -1600,21 +1874,6 @@ tmp > operator- } -template -tmp > operator- -( - const dimensioned& su, - const faMatrix& A -) -{ - checkMethod(A, su, "-"); - tmp > tC(new faMatrix(A)); - tC().negate(); - tC().source() -= su.value()*A.psi().mesh().S(); - return tC; -} - - template tmp > operator- ( @@ -1630,6 +1889,9 @@ tmp > operator- } +// Subtraction operators + +// Operations for faMatrix and GeometricField template tmp > operator== ( @@ -1685,6 +1947,7 @@ tmp > operator== } +// Operators for faMatrix and dimensionedType template tmp > operator== ( @@ -1713,6 +1976,9 @@ tmp > operator== } +// Multiplication operators + +// Operators for faMatrix and areaScalarField template tmp > operator* ( @@ -1762,6 +2028,7 @@ tmp > operator* } +// Operators for faMatrix and dimensionedScalar template tmp > operator* ( diff --git a/src/finiteArea/faMatrices/faMatrix/faMatrix.H b/src/finiteArea/faMatrices/faMatrix/faMatrix.H index 2ebd26a62..8085d547d 100644 --- a/src/finiteArea/faMatrices/faMatrix/faMatrix.H +++ b/src/finiteArea/faMatrices/faMatrix/faMatrix.H @@ -384,6 +384,14 @@ void checkMethod const char* ); +template +void checkMethod +( + const faMatrix&, + const GeometricField&, + const char* +); + template void checkMethod ( @@ -421,6 +429,7 @@ lduSolverPerformance solve(const tmp >&); // * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * // +// Unary operators for negation template tmp > operator- ( @@ -433,6 +442,7 @@ tmp > operator- const tmp >& ); +// Operators for faMatrix and faMatrix template tmp > operator+ ( @@ -517,6 +527,8 @@ tmp > operator== const tmp >& ); + +// Operators for faMatrix and GeometricField template tmp > operator+ ( @@ -629,6 +641,150 @@ tmp > operator- const tmp >& ); + +// Operators for faMatrix and DimensionedField +template +tmp > operator+ +( + const faMatrix&, + const DimensionedField& +); + +template +tmp > operator+ +( + const tmp >&, + const DimensionedField& +); + +template +tmp > operator+ +( + const faMatrix&, + const tmp >& +); + +template +tmp > operator+ +( + const tmp >&, + const tmp >& +); + +template +tmp > operator+ +( + const DimensionedField&, + const faMatrix& +); + +template +tmp > operator+ +( + const DimensionedField&, + const tmp >& +); + +template +tmp > operator+ +( + const tmp >&, + const faMatrix& +); + +template +tmp > operator+ +( + const tmp >&, + const tmp >& +); + +template +tmp > operator- +( + const faMatrix&, + const DimensionedField& +); + +template +tmp > operator- +( + const tmp >&, + const DimensionedField& +); + +template +tmp > operator- +( + const faMatrix&, + const tmp >& +); + +template +tmp > operator- +( + const tmp >&, + const tmp >& +); + +template +tmp > operator- +( + const DimensionedField&, + const faMatrix& +); + +template +tmp > operator- +( + const DimensionedField&, + const tmp >& +); + +template +tmp > operator- +( + const tmp >&, + const faMatrix& +); + +template +tmp > operator- +( + const tmp >&, + const tmp >& +); + + +// Operators for faMatrix and dimensionedType +template +tmp > operator+ +( + const faMatrix&, + const dimensioned& +); + +template +tmp > operator+ +( + const dimensioned&, + const faMatrix& +); + +template +tmp > operator- +( + const faMatrix&, + const dimensioned& +); + +template +tmp > operator- +( + const dimensioned&, + const faMatrix& +); + template tmp > operator+ ( @@ -657,6 +813,10 @@ tmp > operator- const tmp >& ); + +// Subtraction operators + +// Operators for faMatrix and GeometricField template tmp > operator== ( @@ -685,6 +845,7 @@ tmp > operator== const tmp >& ); +// Operators for faMatrix and dimensionedType template tmp > operator== ( @@ -700,6 +861,9 @@ tmp > operator== ); +// Multiplication operators + +// Operators for faMatrix and areaScalarField template tmp > operator* ( @@ -728,7 +892,7 @@ tmp > operator* const tmp >& ); - +// Operators for faMatrix and dimensionedScalar template tmp > operator* ( diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/ggi/ggiFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/ggi/ggiFvPatchField.C index 4d818a408..4bc35db57 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/ggi/ggiFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/ggi/ggiFvPatchField.C @@ -189,6 +189,9 @@ tmp > ggiFvPatchField::patchNeighbourField() const // Note: bridging now takes into account fully uncovered and partially // covered faces. VV, 18/Oct/2017. ggiPatch_.bridge(bridgeField, pnf); + + // Correct partially overlapping (partially bridged) faces + ggiPatch_.correctPartialFaces(bridgeField, pnf); } return tpnf; diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/ggi/ggiFvPatch.H b/src/finiteVolume/fvMesh/fvPatches/constraint/ggi/ggiFvPatch.H index c063d185d..06eaea307 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/ggi/ggiFvPatch.H +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/ggi/ggiFvPatch.H @@ -154,6 +154,18 @@ public: return ggiPolyPatch_.bridge(bridgeField, ff); } + //- Correct partially overlapping (partially bridged) faces + template + void correctPartialFaces + ( + const Field& bridgeField, + Field& ff + ) + const + { + return ggiPolyPatch_.correctPartialFaces(bridgeField, ff); + } + // Interface transfer functions diff --git a/src/foam/fields/PointPatchFieldTemplates/constraint/processor/ProcessorPointPatchField.C b/src/foam/fields/PointPatchFieldTemplates/constraint/processor/ProcessorPointPatchField.C index ccd7b5bce..e5e475fe5 100644 --- a/src/foam/fields/PointPatchFieldTemplates/constraint/processor/ProcessorPointPatchField.C +++ b/src/foam/fields/PointPatchFieldTemplates/constraint/processor/ProcessorPointPatchField.C @@ -84,7 +84,7 @@ sendField // This needs complete rewrite: // - move communications into a patch - // - allow for various types of communication - done HR, 12/6/2017 + // HR, 12/6/2017 // HJ, 15/Apr/2009 if (commsType == Pstream::blocking || commsType == Pstream::scheduled) diff --git a/src/foam/interpolations/GGIInterpolation/GGIInterpolationTemplate.H b/src/foam/interpolations/GGIInterpolation/GGIInterpolationTemplate.H index 48dcf2f1c..21fc570cd 100644 --- a/src/foam/interpolations/GGIInterpolation/GGIInterpolationTemplate.H +++ b/src/foam/interpolations/GGIInterpolation/GGIInterpolationTemplate.H @@ -501,6 +501,28 @@ class GGIInterpolation const scalarField& coveredFractions ); + //- Correct partially covered faces given addressing + template + static void correctPartiallyCoveredFaces + ( + const Field& bridgeField, + Field& result, + const labelList& partiallyCoveredAddr, + const scalarField& coveredFractions + ); + + //- Correct partially covered faces given addressing for masked faces + // only + template + static void maskedCorrectPartiallyCoveredFaces + ( + const Field& bridgeField, + Field& result, + const labelList& mask, + const labelList& partiallyCoveredAddr, + const scalarField& coveredFractions + ); + //- Is a transform required? inline bool doTransform() const { @@ -665,6 +687,24 @@ public: const labelList& mask ) const; + //- Correct partially covered master patch field + template + void correctPartialMaster + ( + const Field& bridgeField, + Field& ff + ) const; + + //- Correct partially covered master patch field, only for marked master + // faces + template + void maskedCorrectPartialMaster + ( + const Field& bridgeField, + Field& ff, + const labelList& mask + ) const; + //- Bridge uncovered slave patch field template void bridgeSlave @@ -682,6 +722,24 @@ public: const labelList& mask ) const; + //- Correct partially covered slave patch field + template + void correctPartialSlave + ( + const Field& bridgeField, + Field& ff + ) const; + + //- Correct partially covered slave patch field, only for marked slave + // faces + template + void maskedCorrectPartialSlave + ( + const Field& bridgeField, + Field& ff, + const labelList& mask + ) const; + //- Interpolate point field template tmp > masterToSlavePointInterpolate diff --git a/src/foam/meshes/polyMesh/polyPatches/constraint/ggi/ggiPolyPatch.H b/src/foam/meshes/polyMesh/polyPatches/constraint/ggi/ggiPolyPatch.H index 8e585b6dc..c3025c0ec 100644 --- a/src/foam/meshes/polyMesh/polyPatches/constraint/ggi/ggiPolyPatch.H +++ b/src/foam/meshes/polyMesh/polyPatches/constraint/ggi/ggiPolyPatch.H @@ -378,6 +378,14 @@ public: Field& ff ) const; + //- Correct interpolated face field for partially covered faces + template + void correctPartialFaces + ( + const Field& bridgeField, + Field& ff + ) const; + // Geometric data diff --git a/src/foam/meshes/polyMesh/polyPatches/constraint/ggi/ggiPolyPatchTemplates.C b/src/foam/meshes/polyMesh/polyPatches/constraint/ggi/ggiPolyPatchTemplates.C index 6edd844c9..c205f0df2 100644 --- a/src/foam/meshes/polyMesh/polyPatches/constraint/ggi/ggiPolyPatchTemplates.C +++ b/src/foam/meshes/polyMesh/polyPatches/constraint/ggi/ggiPolyPatchTemplates.C @@ -267,4 +267,70 @@ void Foam::ggiPolyPatch::bridge } +template +void Foam::ggiPolyPatch::correctPartialFaces +( + const Field& bridgeField, + Field& ff +) const +{ + // Check + if (ff.size() != size()) + { + FatalErrorIn + ( + "tmp > ggiPolyPatch::correctPartialFaces\n" + "(\n" + " Field& ff\n" + ") const" + ) << "Incorrect patch field size for partial face correction. " + << "Field size: " << ff.size() << " patch size: " << size() + << abort(FatalError); + } + + if (bridgeOverlap()) + { + if (empty()) + { + // Patch empty, no bridging + return; + } + + if (localParallel()) + { + if (master()) + { + patchToPatch().correctPartialMaster(bridgeField, ff); + } + else + { + patchToPatch().correctPartialSlave(bridgeField, ff); + } + } + else + { + // Note: since bridging is only a local operation + if (master()) + { + patchToPatch().maskedCorrectPartialMaster + ( + bridgeField, + ff, + zoneAddressing() + ); + } + else + { + patchToPatch().maskedCorrectPartialSlave + ( + bridgeField, + ff, + zoneAddressing() + ); + } + } + } +} + + // ************************************************************************* // diff --git a/tutorials/incompressible/RichardsonFoam/oneDimensionalSoilTransport/0/psi b/tutorials/incompressible/RichardsonFoam/oneDimensionalSoilTransport/0/psi index 626b7fe7d..60b289784 100755 --- a/tutorials/incompressible/RichardsonFoam/oneDimensionalSoilTransport/0/psi +++ b/tutorials/incompressible/RichardsonFoam/oneDimensionalSoilTransport/0/psi @@ -23,14 +23,14 @@ boundaryField { top { - type fixedValue; - value uniform 0.01; + type fixedValue; + value uniform 0.01; } bottom { - type fixedGradient; - gradient uniform 0; + type fixedGradient; + gradient uniform 0; } sides diff --git a/tutorials/incompressible/RichardsonFoam/oneDimensionalSoilTransport/system/controlDict b/tutorials/incompressible/RichardsonFoam/oneDimensionalSoilTransport/system/controlDict index f929d861d..d1d32c093 100644 --- a/tutorials/incompressible/RichardsonFoam/oneDimensionalSoilTransport/system/controlDict +++ b/tutorials/incompressible/RichardsonFoam/oneDimensionalSoilTransport/system/controlDict @@ -50,29 +50,27 @@ adjustTimeStep yes; maxDeltaT 3600; functions - ( +( probes1 { type probes; // Type of functionObject // Where to load it from (if not already in solver) functionObjectLibs ("libsampling.so"); probeLocations // Locations to be probed. runTime modifiable! - ( - (0.5 0.5 1.) - ); + ( + (0.5 0.5 1.) + ); + // Fields to be probed. runTime modifiable! fields - ( - U - ); + ( + U + ); - outputControl timeStep; - outputInterval 1; - } - ); + outputControl timeStep; + outputInterval 1; + } +); -//libs ( "libOpenFOAM.so" ); -//libs ("libuserBCs.so"); - // ************************************************************************* //