From 35487d3bd3bad5c304b4df332370757dc2725b77 Mon Sep 17 00:00:00 2001 From: Sergio Ferraris Date: Wed, 10 Jul 2013 12:45:12 +0100 Subject: [PATCH 1/4] ENH: Adding flaf for re-start to loop over uncover faces in AMI method faceAreaWeight --- .../AMIMethod/faceAreaWeightAMI/faceAreaWeightAMI.C | 8 +++++--- .../AMIMethod/faceAreaWeightAMI/faceAreaWeightAMI.H | 10 +++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/faceAreaWeightAMI/faceAreaWeightAMI.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/faceAreaWeightAMI/faceAreaWeightAMI.C index ed4ae2d9f0..2d5115f3eb 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/faceAreaWeightAMI/faceAreaWeightAMI.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/faceAreaWeightAMI/faceAreaWeightAMI.C @@ -481,7 +481,8 @@ Foam::faceAreaWeightAMI::faceAreaWeightAMI const scalarField& srcMagSf, const scalarField& tgtMagSf, const faceAreaIntersect::triangulationMode& triMode, - const bool reverseTarget + const bool reverseTarget, + const bool restartUncoveredSourceFace ) : AMIMethod @@ -492,7 +493,8 @@ Foam::faceAreaWeightAMI::faceAreaWeightAMI tgtMagSf, triMode, reverseTarget - ) + ), + restartUncoveredSourceFace_(restartUncoveredSourceFace) {} @@ -557,7 +559,7 @@ void Foam::faceAreaWeightAMI::calculate // Check for badly covered faces - if (debug) + if (restartUncoveredSourceFace_) { restartUncoveredSourceFace ( diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/faceAreaWeightAMI/faceAreaWeightAMI.H b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/faceAreaWeightAMI/faceAreaWeightAMI.H index 2aff197745..d1a48a5423 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/faceAreaWeightAMI/faceAreaWeightAMI.H +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/faceAreaWeightAMI/faceAreaWeightAMI.H @@ -51,6 +51,13 @@ class faceAreaWeightAMI : public AMIMethod { +private: + + // Private data + + //- Flag to restart uncovered source faces + const bool restartUncoveredSourceFace_; + protected: @@ -136,7 +143,8 @@ public: const scalarField& srcMagSf, const scalarField& tgtMagSf, const faceAreaIntersect::triangulationMode& triMode, - const bool reverseTarget = false + const bool reverseTarget = false, + const bool restartUncoveredSourceFace = true ); From 5eed286378d573dff95a02152adb11b624d30523 Mon Sep 17 00:00:00 2001 From: Sergio Ferraris Date: Wed, 10 Jul 2013 17:32:58 +0100 Subject: [PATCH 2/4] ENH: Adding gradient() and value() field reading from full restart for buoyantPressureFvPatchScalarField and writing value() field for fixedFluxPressureFvPatchScalarField --- .../buoyantPressureFvPatchScalarField.C | 15 +++++++++++++-- .../fixedFluxPressureFvPatchScalarField.C | 13 +++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/buoyantPressure/buoyantPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/buoyantPressure/buoyantPressureFvPatchScalarField.C index 290c89eb5e..734bbb18d7 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/buoyantPressure/buoyantPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/buoyantPressure/buoyantPressureFvPatchScalarField.C @@ -55,8 +55,19 @@ buoyantPressureFvPatchScalarField fixedGradientFvPatchScalarField(p, iF), rhoName_(dict.lookupOrDefault("rho", "rho")) { - fvPatchField::operator=(patchInternalField()); - gradient() = 0.0; + if (dict.found("value") && dict.found("gradient")) + { + fvPatchField::operator= + ( + scalarField("value", dict, p.size()) + ); + gradient() = scalarField("gradient", dict, p.size()); + } + else + { + fvPatchField::operator=(patchInternalField()); + gradient() = 0.0; + } } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C index 893dc030dc..48ab0f5abd 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C @@ -77,11 +77,15 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField DpName_(dict.lookupOrDefault("Dp", "Dp")), adjoint_(dict.lookupOrDefault("adjoint", false)) { - if (dict.found("gradient")) + if (dict.found("value") && dict.found("gradient")) { + fvPatchField::operator= + ( + scalarField("value", dict, p.size()) + ); gradient() = scalarField("gradient", dict, p.size()); - fixedGradientFvPatchScalarField::updateCoeffs(); - fixedGradientFvPatchScalarField::evaluate(); + //fixedGradientFvPatchScalarField::updateCoeffs(); + //fixedGradientFvPatchScalarField::evaluate(); } else { @@ -190,7 +194,7 @@ void Foam::fixedFluxPressureFvPatchScalarField::updateCoeffs() void Foam::fixedFluxPressureFvPatchScalarField::write(Ostream& os) const { - fvPatchScalarField::write(os); + fixedGradientFvPatchScalarField::write(os); writeEntryIfDifferent(os, "phiHbyA", "phiHbyA", phiHbyAName_); writeEntryIfDifferent(os, "phi", "phi", phiName_); writeEntryIfDifferent(os, "rho", "rho", rhoName_); @@ -200,6 +204,7 @@ void Foam::fixedFluxPressureFvPatchScalarField::write(Ostream& os) const os.writeKeyword("adjoint") << adjoint_ << token::END_STATEMENT << nl; } gradient().writeEntry("gradient", os); + writeEntry("value", os); } From 0350efb5ed5d254cba1d6e2e889fa88a9bd35845 Mon Sep 17 00:00:00 2001 From: Sergio Ferraris Date: Wed, 10 Jul 2013 17:36:43 +0100 Subject: [PATCH 3/4] STY: Improving style --- .../buoyantPressure/buoyantPressureFvPatchScalarField.C | 2 +- .../fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/buoyantPressure/buoyantPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/buoyantPressure/buoyantPressureFvPatchScalarField.C index 734bbb18d7..95f88fd0a3 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/buoyantPressure/buoyantPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/buoyantPressure/buoyantPressureFvPatchScalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C index 48ab0f5abd..12f59c1d11 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.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-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -84,8 +84,6 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField scalarField("value", dict, p.size()) ); gradient() = scalarField("gradient", dict, p.size()); - //fixedGradientFvPatchScalarField::updateCoeffs(); - //fixedGradientFvPatchScalarField::evaluate(); } else { @@ -203,7 +201,6 @@ void Foam::fixedFluxPressureFvPatchScalarField::write(Ostream& os) const { os.writeKeyword("adjoint") << adjoint_ << token::END_STATEMENT << nl; } - gradient().writeEntry("gradient", os); writeEntry("value", os); } From 6b91eb3baefcdbac5c2ae6a49fc6ce081e940cda Mon Sep 17 00:00:00 2001 From: laurence Date: Thu, 11 Jul 2013 11:28:15 +0100 Subject: [PATCH 4/4] BUG: searchableSphere: findNearest --- src/meshTools/searchableSurface/searchableSphere.C | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/meshTools/searchableSurface/searchableSphere.C b/src/meshTools/searchableSurface/searchableSphere.C index 5c07f0b00d..c367c6281b 100644 --- a/src/meshTools/searchableSurface/searchableSphere.C +++ b/src/meshTools/searchableSurface/searchableSphere.C @@ -47,13 +47,11 @@ Foam::pointIndexHit Foam::searchableSphere::findNearest { pointIndexHit info(false, sample, -1); - const vector n(sample-centre_); - scalar magSqrN = magSqr(n); + const vector n(sample - centre_); + scalar magN = mag(n); - if (nearestDistSqr >= magSqrN) + if (nearestDistSqr >= sqr(magN - radius_)) { - scalar magN = Foam::sqrt(magSqrN); - if (magN < ROOTVSMALL) { info.rawPoint() = centre_ + vector(1,0,0)*radius_;