diff --git a/applications/solvers/combustion/reactingFoam/rhoReactingFoam/pEqn.H b/applications/solvers/combustion/reactingFoam/rhoReactingFoam/pEqn.H index 3fb6dfe45e..7a5c717cff 100644 --- a/applications/solvers/combustion/reactingFoam/rhoReactingFoam/pEqn.H +++ b/applications/solvers/combustion/reactingFoam/rhoReactingFoam/pEqn.H @@ -27,7 +27,7 @@ fvScalarMatrix pDDtEqn ( fvc::ddt(rho) + fvc::div(phiHbyA) - + correction(fvm::ddt(psi, p) + fvm::div(phid, p)) + + correction(psi*fvm::ddt(p) + fvm::div(phid, p)) ); while (pimple.correctNonOrthogonal()) diff --git a/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/correctPhi.H b/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/correctPhi.H index 117790446e..9bed803d1e 100644 --- a/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/correctPhi.H +++ b/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/correctPhi.H @@ -68,4 +68,6 @@ } } +phi.oldTime() = phi; + #include "continuityErrs.H" diff --git a/applications/solvers/multiphase/compressibleInterFoam/TEqn.H b/applications/solvers/multiphase/compressibleInterFoam/TEqn.H index 92a2bd64d8..d97e8b2a35 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/TEqn.H +++ b/applications/solvers/multiphase/compressibleInterFoam/TEqn.H @@ -1,11 +1,11 @@ { - solve + fvScalarMatrix TEqn ( fvm::ddt(rho, T) + fvm::div(rhoPhi, T) - fvm::laplacian(twoPhaseProperties.alphaEff(turbulence->mut()), T) + ( - p*fvc::div(phi) + fvc::div(fvc::absolute(phi, U), p) + fvc::ddt(rho, K) + fvc::div(rhoPhi, K) ) *( @@ -14,5 +14,8 @@ ) ); + TEqn.relax(); + TEqn.solve(); + twoPhaseProperties.correct(); } diff --git a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/correctPhi.H b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/correctPhi.H index 1d7b9ca624..513ef961bd 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/correctPhi.H +++ b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/correctPhi.H @@ -56,6 +56,8 @@ phi -= pcorrEqn.flux(); } } - - #include "continuityErrs.H" } + +phi.oldTime() = phi; + +#include "continuityErrs.H" diff --git a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFoam.C b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFoam.C index 3148382ad2..a42d911980 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFoam.C +++ b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFoam.C @@ -104,8 +104,6 @@ int main(int argc, char *argv[]) } } - rho = alpha1*rho1 + alpha2*rho2; - runTime.write(); Info<< "ExecutionTime = " diff --git a/applications/solvers/multiphase/compressibleInterFoam/createFields.H b/applications/solvers/multiphase/compressibleInterFoam/createFields.H index 102d4d57a9..c7289b23f9 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/createFields.H +++ b/applications/solvers/multiphase/compressibleInterFoam/createFields.H @@ -38,9 +38,9 @@ volScalarField& p = twoPhaseProperties.p(); volScalarField& T = twoPhaseProperties.T(); - const volScalarField& rho1 = twoPhaseProperties.thermo1().rho(); + volScalarField& rho1 = twoPhaseProperties.thermo1().rho(); const volScalarField& psi1 = twoPhaseProperties.thermo1().psi(); - const volScalarField& rho2 = twoPhaseProperties.thermo2().rho(); + volScalarField& rho2 = twoPhaseProperties.thermo2().rho(); const volScalarField& psi2 = twoPhaseProperties.thermo2().psi(); volScalarField rho @@ -93,18 +93,5 @@ compressible::turbulenceModel::New(rho, U, rhoPhi, twoPhaseProperties) ); - Info<< "Creating field dpdt\n" << endl; - volScalarField dpdt - ( - IOobject - ( - "dpdt", - runTime.timeName(), - mesh - ), - mesh, - dimensionedScalar("dpdt", p.dimensions()/dimTime, 0) - ); - Info<< "Creating field kinetic energy K\n" << endl; volScalarField K("K", 0.5*magSqr(U)); diff --git a/applications/solvers/multiphase/compressibleInterFoam/pEqn.H b/applications/solvers/multiphase/compressibleInterFoam/pEqn.H index 71745c0168..73babb08f0 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/pEqn.H +++ b/applications/solvers/multiphase/compressibleInterFoam/pEqn.H @@ -26,28 +26,44 @@ tmp p_rghEqnComp1; tmp p_rghEqnComp2; - //if (transonic) - //{ - //} - //else + if (pimple.transonic()) { surfaceScalarField phid1("phid1", fvc::interpolate(psi1)*phi); surfaceScalarField phid2("phid2", fvc::interpolate(psi2)*phi); + p_rghEqnComp1 = + fvc::ddt(rho1) + fvc::div(phi, rho1) - fvc::Sp(fvc::div(phi), rho1) + + correction + ( + psi1*fvm::ddt(p_rgh) + + fvm::div(phid1, p_rgh) - fvm::Sp(fvc::div(phid1), p_rgh) + ); + deleteDemandDrivenData(p_rghEqnComp1().faceFluxCorrectionPtr()); + p_rghEqnComp1().relax(); + + p_rghEqnComp2 = + fvc::ddt(rho2) + fvc::div(phi, rho2) - fvc::Sp(fvc::div(phi), rho2) + + correction + ( + psi2*fvm::ddt(p_rgh) + + fvm::div(phid2, p_rgh) - fvm::Sp(fvc::div(phid2), p_rgh) + ); + deleteDemandDrivenData(p_rghEqnComp2().faceFluxCorrectionPtr()); + p_rghEqnComp2().relax(); + } + else + { p_rghEqnComp1 = fvc::ddt(rho1) + psi1*correction(fvm::ddt(p_rgh)) - + fvc::div(phid1, p_rgh) - - fvc::Sp(fvc::div(phid1), p_rgh); + + fvc::div(phi, rho1) - fvc::Sp(fvc::div(phi), rho1); p_rghEqnComp2 = fvc::ddt(rho2) + psi2*correction(fvm::ddt(p_rgh)) - + fvc::div(phid2, p_rgh) - - fvc::Sp(fvc::div(phid2), p_rgh); + + fvc::div(phi, rho2) - fvc::Sp(fvc::div(phi), rho2); } - // Thermodynamic density needs to be updated by psi*d(p) after the - // pressure solution - done in 2 parts. Part 1: - //twoPhaseProperties.rho() -= psi*p_rgh; + // Cache p_rgh prior to solve for density update + volScalarField p_rgh_0(p_rgh); while (pimple.correctNonOrthogonal()) { @@ -69,8 +85,8 @@ if (pimple.finalNonOrthogonalIter()) { - // Second part of thermodynamic density update - //twoPhaseProperties.rho() += psi*p_rgh; + //p = max(p_rgh + (alpha1*rho1 + alpha2*rho2)*gh, pMin); + //p_rgh = p - (alpha1*rho1 + alpha2*rho2)*gh; dgdt = ( @@ -88,15 +104,14 @@ p = max(p_rgh + (alpha1*rho1 + alpha2*rho2)*gh, pMin); - // twoPhaseProperties.correct(); + // Update densities from change in p_rgh + rho1 += psi1*(p_rgh - p_rgh_0); + rho2 += psi2*(p_rgh - p_rgh_0); - Info<< "max(U) " << max(mag(U)).value() << endl; - Info<< "min(p_rgh) " << min(p_rgh).value() << endl; + rho = alpha1*rho1 + alpha2*rho2; K = 0.5*magSqr(U); - if (twoPhaseProperties.dpdt()) - { - dpdt = fvc::ddt(p); - } + Info<< "max(U) " << max(mag(U)).value() << endl; + Info<< "min(p_rgh) " << min(p_rgh).value() << endl; } diff --git a/applications/solvers/multiphase/compressibleInterFoam/twoPhaseMixtureThermo/twoPhaseMixtureThermo.H b/applications/solvers/multiphase/compressibleInterFoam/twoPhaseMixtureThermo/twoPhaseMixtureThermo.H index b2e636a4c4..608dc91a9b 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/twoPhaseMixtureThermo/twoPhaseMixtureThermo.H +++ b/applications/solvers/multiphase/compressibleInterFoam/twoPhaseMixtureThermo/twoPhaseMixtureThermo.H @@ -94,6 +94,16 @@ public: return thermo2_(); } + rhoThermo& thermo1() + { + return thermo1_(); + } + + rhoThermo& thermo2() + { + return thermo2_(); + } + //- Update properties virtual void correct(); diff --git a/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/createFields.H b/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/createFields.H index 54a61f51d2..cc5b3ebe21 100644 --- a/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/createFields.H +++ b/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/createFields.H @@ -62,10 +62,10 @@ volScalarField& p = thermo1.p(); - volScalarField rho1("rho" + phase1Name, thermo1.rho()); + volScalarField& rho1 = thermo1.rho(); const volScalarField& psi1 = thermo1.psi(); - volScalarField rho2("rho" + phase2Name, thermo2.rho()); + volScalarField& rho2 = thermo2.rho(); const volScalarField& psi2 = thermo2.psi(); volVectorField U diff --git a/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/pEqn.H b/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/pEqn.H index bf75b28d05..02e49b5661 100644 --- a/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/pEqn.H +++ b/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/pEqn.H @@ -1,7 +1,4 @@ { - rho1 = thermo1.rho(); - rho2 = thermo2.rho(); - surfaceScalarField alpha1f(fvc::interpolate(alpha1)); surfaceScalarField alpha2f(scalar(1) - alpha1f); @@ -91,10 +88,7 @@ tmp pEqnComp1; tmp pEqnComp2; - //if (transonic) - //{ - //} - //else + if (pimple.transonic()) { surfaceScalarField phid1 ( @@ -107,17 +101,42 @@ fvc::interpolate(psi2)*phi2 ); + pEqnComp1 = + fvc::ddt(rho1) + + fvc::div(phi1, rho1) - fvc::Sp(fvc::div(phi1), rho1) + + correction + ( + psi1*fvm::ddt(p) + + fvm::div(phid1, p) - fvm::Sp(fvc::div(phid1), p) + ); + deleteDemandDrivenData(pEqnComp1().faceFluxCorrectionPtr()); + pEqnComp1().relax(); + + pEqnComp2 = + fvc::ddt(rho2) + + fvc::div(phi2, rho2) - fvc::Sp(fvc::div(phi2), rho2) + + correction + ( + psi2*fvm::ddt(p) + + fvm::div(phid2, p) - fvm::Sp(fvc::div(phid2), p) + ); + deleteDemandDrivenData(pEqnComp2().faceFluxCorrectionPtr()); + pEqnComp2().relax(); + } + else + { pEqnComp1 = fvc::ddt(rho1) + psi1*correction(fvm::ddt(p)) - + fvc::div(phid1, p) - - fvc::Sp(fvc::div(phid1), p); + + fvc::div(phi1, rho1) - fvc::Sp(fvc::div(phi1), rho1); pEqnComp2 = fvc::ddt(rho2) + psi2*correction(fvm::ddt(p)) - + fvc::div(phid2, p) - - fvc::Sp(fvc::div(phid2), p); + + fvc::div(phi2, rho2) - fvc::Sp(fvc::div(phi2), rho2); } + // Cache p prior to solve for density update + volScalarField p_0(p); + while (pimple.correctNonOrthogonal()) { fvScalarMatrix pEqnIncomp @@ -182,10 +201,9 @@ p = max(p, pMin); - thermo1.correct(); - thermo2.correct(); - rho1 = thermo1.rho(); - rho2 = thermo2.rho(); + // Update densities from change in p + rho1 += psi1*(p - p_0); + rho2 += psi2*(p - p_0); K1 = 0.5*magSqr(U1); K2 = 0.5*magSqr(U2); diff --git a/applications/solvers/multiphase/interFoam/interDyMFoam/correctPhi.H b/applications/solvers/multiphase/interFoam/interDyMFoam/correctPhi.H index 0e373e1f40..c4cdbc044b 100644 --- a/applications/solvers/multiphase/interFoam/interDyMFoam/correctPhi.H +++ b/applications/solvers/multiphase/interFoam/interDyMFoam/correctPhi.H @@ -53,6 +53,8 @@ fvc::makeRelative(phi, U); } } - - #include "continuityErrs.H" } + +phi.oldTime() = phi; + +#include "continuityErrs.H" diff --git a/src/OSspecific/POSIX/signals/sigFpe.C b/src/OSspecific/POSIX/signals/sigFpe.C index a275fd7a3a..501ff95c4e 100644 --- a/src/OSspecific/POSIX/signals/sigFpe.C +++ b/src/OSspecific/POSIX/signals/sigFpe.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 @@ -263,8 +263,8 @@ void Foam::sigFpe::set(const bool verbose) { if (supported) { - Info<< "SetNaN : Initialising allocated memory to NaN" - << " (FOAM_SETNAN)." << endl; + Info<< "SetNaN : Initialising allocated memory to NaN" + << " (FOAM_SETNAN)." << endl; } else { diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index dc8e946baa..033dd4f62c 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -367,6 +367,8 @@ $(cellShape)/cellShapeIOList.C meshes/Identifiers/patch/patchIdentifier.C +meshes/MeshObject/meshObject.C + polyMesh = meshes/polyMesh polyPatches = $(polyMesh)/polyPatches diff --git a/src/OpenFOAM/containers/Lists/PtrList/PtrListI.H b/src/OpenFOAM/containers/Lists/PtrList/PtrListI.H index 3f29e9238f..979e862d4a 100644 --- a/src/OpenFOAM/containers/Lists/PtrList/PtrListI.H +++ b/src/OpenFOAM/containers/Lists/PtrList/PtrListI.H @@ -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 @@ -132,7 +132,9 @@ inline const T& Foam::PtrList::operator[](const label i) const if (!ptrs_[i]) { FatalErrorIn("PtrList::operator[] const") - << "hanging pointer, cannot dereference" + << "hanging pointer at index " << i + << " (size " << size() + << "), cannot dereference" << abort(FatalError); } @@ -146,7 +148,9 @@ inline T& Foam::PtrList::operator[](const label i) if (!ptrs_[i]) { FatalErrorIn("PtrList::operator[]") - << "hanging pointer, cannot dereference" + << "hanging pointer at index " << i + << " (size " << size() + << "), cannot dereference" << abort(FatalError); } diff --git a/src/OpenFOAM/containers/Lists/UPtrList/UPtrListI.H b/src/OpenFOAM/containers/Lists/UPtrList/UPtrListI.H index dceeb1f279..38bb430931 100644 --- a/src/OpenFOAM/containers/Lists/UPtrList/UPtrListI.H +++ b/src/OpenFOAM/containers/Lists/UPtrList/UPtrListI.H @@ -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 @@ -107,7 +107,9 @@ inline const T& Foam::UPtrList::operator[](const label i) const if (!ptrs_[i]) { FatalErrorIn("UPtrList::operator[] const") - << "hanging pointer, cannot dereference" + << "hanging pointer at index " << i + << " (size " << size() + << "), cannot dereference" << abort(FatalError); } @@ -121,7 +123,9 @@ inline T& Foam::UPtrList::operator[](const label i) if (!ptrs_[i]) { FatalErrorIn("UPtrList::operator[]") - << "hanging pointer, cannot dereference" + << "hanging pointer at index " << i + << " (size " << size() + << "), cannot dereference" << abort(FatalError); } diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/processor/processorPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/constraint/processor/processorPointPatchField.C index c3d68e2837..8a647b6db0 100644 --- a/src/OpenFOAM/fields/pointPatchFields/constraint/processor/processorPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/processor/processorPointPatchField.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 @@ -24,7 +24,6 @@ License \*---------------------------------------------------------------------------*/ #include "processorPointPatchField.H" -//#include "transformField.H" #include "processorPolyPatch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -92,73 +91,6 @@ processorPointPatchField::~processorPointPatchField() {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -void processorPointPatchField::initSwapAddSeparated -( - const Pstream::commsTypes commsType, - Field& pField -) -const -{ -// if (Pstream::parRun()) -// { -// // Get internal field into correct order for opposite side -// Field pf -// ( -// this->patchInternalField -// ( -// pField, -// procPatch_.reverseMeshPoints() -// ) -// ); -// -// OPstream::write -// ( -// commsType, -// procPatch_.neighbProcNo(), -// reinterpret_cast(pf.begin()), -// pf.byteSize(), -// procPatch_.tag() -// ); -// } -} - - -template -void processorPointPatchField::swapAddSeparated -( - const Pstream::commsTypes commsType, - Field& pField -) const -{ -// if (Pstream::parRun()) -// { -// Field pnf(this->size()); -// -// IPstream::read -// ( -// commsType, -// procPatch_.neighbProcNo(), -// reinterpret_cast(pnf.begin()), -// pnf.byteSize(), -// procPatch_.tag() -// ); -// -// if (doTransform()) -// { -// const processorPolyPatch& ppp = procPatch_.procPolyPatch(); -// const tensor& forwardT = ppp.forwardT(); -// -// transform(pnf, forwardT, pnf); -// } -// -// addToInternalField(pField, pnf, procPatch_.separatedPoints()); -// } -} - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/processor/processorPointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/constraint/processor/processorPointPatchField.H index 6582b62861..5dfceda2d1 100644 --- a/src/OpenFOAM/fields/pointPatchFields/constraint/processor/processorPointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/processor/processorPointPatchField.H @@ -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 @@ -57,7 +57,6 @@ class processorPointPatchField //- Local reference to processor patch const processorPointPatch& procPatch_; - public: //- Runtime type information @@ -176,19 +175,13 @@ public: ) {} - //- Initialise swap of non-collocated patch point values - virtual void initSwapAddSeparated - ( - const Pstream::commsTypes commsType, - Field& - ) const; - - //- Complete swap of patch point values and add to local values + //- Assume processor patch always collocated virtual void swapAddSeparated ( const Pstream::commsTypes commsType, Field& - ) const; + ) const + {} }; diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/processorCyclic/processorCyclicPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/constraint/processorCyclic/processorCyclicPointPatchField.C index 4e28c3466d..6bea99a1bc 100644 --- a/src/OpenFOAM/fields/pointPatchFields/constraint/processorCyclic/processorCyclicPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/processorCyclic/processorCyclicPointPatchField.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 @@ -38,7 +38,8 @@ Foam::processorCyclicPointPatchField::processorCyclicPointPatchField ) : coupledPointPatchField(p, iF), - procPatch_(refCast(p)) + procPatch_(refCast(p)), + receiveBuf_(0) {} @@ -51,7 +52,8 @@ Foam::processorCyclicPointPatchField::processorCyclicPointPatchField ) : coupledPointPatchField(p, iF, dict), - procPatch_(refCast(p)) + procPatch_(refCast(p)), + receiveBuf_(0) {} @@ -65,7 +67,8 @@ Foam::processorCyclicPointPatchField::processorCyclicPointPatchField ) : coupledPointPatchField(ptf, p, iF, mapper), - procPatch_(refCast(ptf.patch())) + procPatch_(refCast(ptf.patch())), + receiveBuf_(0) {} @@ -77,7 +80,8 @@ Foam::processorCyclicPointPatchField::processorCyclicPointPatchField ) : coupledPointPatchField(ptf, iF), - procPatch_(refCast(ptf.patch())) + procPatch_(refCast(ptf.patch())), + receiveBuf_(0) {} @@ -109,6 +113,18 @@ void Foam::processorCyclicPointPatchField::initSwapAddSeparated ) ); + if (commsType == Pstream::nonBlocking) + { + receiveBuf_.setSize(pf.size()); + IPstream::read + ( + commsType, + procPatch_.neighbProcNo(), + reinterpret_cast(receiveBuf_.begin()), + receiveBuf_.byteSize(), + procPatch_.tag() + ); + } OPstream::write ( commsType, @@ -130,16 +146,19 @@ void Foam::processorCyclicPointPatchField::swapAddSeparated { if (Pstream::parRun()) { - Field pnf(this->size()); - - IPstream::read - ( - commsType, - procPatch_.neighbProcNo(), - reinterpret_cast(pnf.begin()), - pnf.byteSize(), - procPatch_.tag() - ); + // If nonblocking data has already been received into receiveBuf_ + if (commsType != Pstream::nonBlocking) + { + receiveBuf_.setSize(this->size()); + IPstream::read + ( + commsType, + procPatch_.neighbProcNo(), + reinterpret_cast(receiveBuf_.begin()), + receiveBuf_.byteSize(), + procPatch_.tag() + ); + } if (doTransform()) { @@ -147,11 +166,11 @@ void Foam::processorCyclicPointPatchField::swapAddSeparated procPatch_.procCyclicPolyPatch(); const tensor& forwardT = ppp.forwardT()[0]; - transform(pnf, forwardT, pnf); + transform(receiveBuf_, forwardT, receiveBuf_); } // All points are separated - this->addToInternalField(pField, pnf); + this->addToInternalField(pField, receiveBuf_); } } diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/processorCyclic/processorCyclicPointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/constraint/processorCyclic/processorCyclicPointPatchField.H index c857524060..6aa358b868 100644 --- a/src/OpenFOAM/fields/pointPatchFields/constraint/processorCyclic/processorCyclicPointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/processorCyclic/processorCyclicPointPatchField.H @@ -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 @@ -57,6 +57,9 @@ class processorCyclicPointPatchField //- Local reference to processor patch const processorCyclicPointPatch& procPatch_; + //- Receive buffer for non-blocking communication + mutable Field receiveBuf_; + public: diff --git a/src/OpenFOAM/meshes/MeshObject/MeshObject.C b/src/OpenFOAM/meshes/MeshObject/MeshObject.C index 8f25049242..01e86da379 100644 --- a/src/OpenFOAM/meshes/MeshObject/MeshObject.C +++ b/src/OpenFOAM/meshes/MeshObject/MeshObject.C @@ -25,6 +25,7 @@ License #include "MeshObject.H" #include "objectRegistry.H" +#include "IOstreams.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -59,6 +60,11 @@ const Type& Foam::MeshObject::New } else { + if (meshObject::debug) + { + Pout<< "MeshObject::New(const Mesh&) : constructing new " + << Type::typeName << endl; + } return regIOobject::store(new Type(mesh)); } } @@ -87,6 +93,11 @@ const Type& Foam::MeshObject::New } else { + if (meshObject::debug) + { + Pout<< "MeshObject::New(const Mesh&) : constructing new " + << Type::typeName << endl; + } return regIOobject::store(new Type(mesh, d)); } } @@ -116,6 +127,11 @@ const Type& Foam::MeshObject::New } else { + if (meshObject::debug) + { + Pout<< "MeshObject(const Mesh&) : constructing new " + << Type::typeName << endl; + } return regIOobject::store(new Type(mesh, d1, d2)); } } @@ -146,6 +162,11 @@ const Type& Foam::MeshObject::New } else { + if (meshObject::debug) + { + Pout<< "MeshObject(const Mesh&) : constructing new " + << Type::typeName << endl; + } return regIOobject::store(new Type(mesh, d1, d2, d3)); } } @@ -177,6 +198,11 @@ const Type& Foam::MeshObject::New } else { + if (meshObject::debug) + { + Pout<< "MeshObject(const Mesh&) : constructing new " + << Type::typeName << endl; + } return regIOobject::store(new Type(mesh, d1, d2, d3, d4)); } } @@ -195,6 +221,12 @@ bool Foam::MeshObject::Delete(const Mesh& mesh) ) ) { + if (meshObject::debug) + { + Pout<< "MeshObject::Delete(const Mesh&) : deleting " + << Type::typeName << endl; + } + return mesh.thisDb().checkOut ( const_cast @@ -237,10 +269,22 @@ void Foam::meshObject::movePoints(objectRegistry& obr) { if (isA >(*iter())) { + if (meshObject::debug) + { + Pout<< "meshObject::movePoints(objectRegistry&) :" + << " movePoints on " + << iter()->name() << endl; + } dynamic_cast*>(iter())->movePoints(); } else { + if (meshObject::debug) + { + Pout<< "meshObject::movePoints(objectRegistry&) :" + << " destroying " + << iter()->name() << endl; + } obr.checkOut(*iter()); } } @@ -264,10 +308,21 @@ void Foam::meshObject::updateMesh(objectRegistry& obr, const mapPolyMesh& mpm) { if (isA >(*iter())) { + if (meshObject::debug) + { + Pout<< "meshObject::updateMesh(objectRegistry&) :" + << " updateMesh on " + << iter()->name() << endl; + } dynamic_cast*>(iter())->updateMesh(mpm); } else { + if (meshObject::debug) + { + Pout<< "meshObject::updateMesh(objectRegistry&) : destroying " + << iter()->name() << endl; + } obr.checkOut(*iter()); } } @@ -284,6 +339,11 @@ void Foam::meshObject::clear(objectRegistry& obr) forAllIter(typename HashTable*>, meshObjects, iter) { + if (meshObject::debug) + { + Pout<< "meshObject::clear(objectRegistry&) : destroying " + << iter()->name() << endl; + } obr.checkOut(*iter()); } } diff --git a/src/OpenFOAM/meshes/MeshObject/MeshObject.H b/src/OpenFOAM/meshes/MeshObject/MeshObject.H index 8efa89f944..b95c631e52 100644 --- a/src/OpenFOAM/meshes/MeshObject/MeshObject.H +++ b/src/OpenFOAM/meshes/MeshObject/MeshObject.H @@ -164,20 +164,12 @@ class meshObject { public: + // Declare name of the class and its debug switch + ClassName("meshObject"); + // Constructors - meshObject(const word& typeName, const objectRegistry& obr) - : - regIOobject - ( - IOobject - ( - typeName, - obr.instance(), - obr - ) - ) - {} + meshObject(const word& typeName, const objectRegistry& obr); // Static member functions diff --git a/src/OpenFOAM/meshes/MeshObject/meshObject.C b/src/OpenFOAM/meshes/MeshObject/meshObject.C new file mode 100644 index 0000000000..7130f38b5d --- /dev/null +++ b/src/OpenFOAM/meshes/MeshObject/meshObject.C @@ -0,0 +1,52 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2013 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 . + +\*---------------------------------------------------------------------------*/ + +#include "MeshObject.H" + +/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */ + +namespace Foam +{ + defineTypeNameAndDebug(meshObject, 0); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::meshObject::meshObject(const word& typeName, const objectRegistry& obr) +: + regIOobject + ( + IOobject + ( + typeName, + obr.instance(), + obr + ) + ) +{} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C index 8988a06eb2..7e45266d24 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.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 @@ -37,10 +37,7 @@ namespace Foam } -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::processorCyclicPolyPatch::processorCyclicPolyPatch ( @@ -66,20 +63,10 @@ Foam::processorCyclicPolyPatch::processorCyclicPolyPatch neighbProcNo, transform ), - tag_ - ( - Pstream::nProcs()*max(myProcNo, neighbProcNo) - + min(myProcNo, neighbProcNo) - ), referPatchName_(referPatchName), + tag_(-1), referPatchID_(-1) -{ - if (debug) - { - Pout<< "processorCyclicPolyPatch " << name << " uses tag " << tag_ - << endl; - } -} +{} Foam::processorCyclicPolyPatch::processorCyclicPolyPatch @@ -92,20 +79,10 @@ Foam::processorCyclicPolyPatch::processorCyclicPolyPatch ) : processorPolyPatch(name, dict, index, bm, patchType), - tag_ - ( - Pstream::nProcs()*max(myProcNo(), neighbProcNo()) - + min(myProcNo(), neighbProcNo()) - ), referPatchName_(dict.lookup("referPatch")), + tag_(dict.lookupOrDefault("tag", -1)), referPatchID_(-1) -{ - if (debug) - { - Pout<< "processorCyclicPolyPatch " << name << " uses tag " << tag_ - << endl; - } -} +{} Foam::processorCyclicPolyPatch::processorCyclicPolyPatch @@ -115,8 +92,8 @@ Foam::processorCyclicPolyPatch::processorCyclicPolyPatch ) : processorPolyPatch(pp, bm), - tag_(pp.tag_), referPatchName_(pp.referPatchName()), + tag_(pp.tag()), referPatchID_(-1) {} @@ -132,8 +109,8 @@ Foam::processorCyclicPolyPatch::processorCyclicPolyPatch ) : processorPolyPatch(pp, bm, index, newSize, newStart), - tag_(pp.tag_), referPatchName_(referPatchName), + tag_(-1), referPatchID_(-1) {} @@ -148,8 +125,8 @@ Foam::processorCyclicPolyPatch::processorCyclicPolyPatch ) : processorPolyPatch(pp, bm, index, mapAddressing, newStart), - tag_(pp.tag_), referPatchName_(pp.referPatchName()), + tag_(-1), referPatchID_(-1) {} @@ -162,6 +139,45 @@ Foam::processorCyclicPolyPatch::~processorCyclicPolyPatch() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +int Foam::processorCyclicPolyPatch::tag() const +{ + if (tag_ == -1) + { + // Get unique tag to use for all comms. Make sure that both sides + // use the same tag + const cyclicPolyPatch& cycPatch = refCast + ( + referPatch() + ); + + if (cycPatch.owner()) + { + tag_ = Hash()(cycPatch.name()); + } + else + { + tag_ = Hash()(cycPatch.neighbPatch().name()); + } + + if (tag_ == Pstream::msgType() || tag_ == -1) + { + FatalErrorIn("processorCyclicPolyPatch::tag() const") + << "Tag calculated from cyclic patch name " << tag_ + << " is the same as the current message type " + << Pstream::msgType() << " or -1" << nl + << "Please set a non-conflicting, unique, tag by hand" + << " using the 'tag' entry" + << exit(FatalError); + } + if (debug) + { + Pout<< "processorCyclicPolyPatch " << name() << " uses tag " << tag_ + << endl; + } + } + return tag_; +} + void Foam::processorCyclicPolyPatch::initGeometry(PstreamBuffers& pBufs) { @@ -283,6 +299,11 @@ void Foam::processorCyclicPolyPatch::write(Ostream& os) const processorPolyPatch::write(os); os.writeKeyword("referPatch") << referPatchName_ << token::END_STATEMENT << nl; + if (tag_ != -1) + { + os.writeKeyword("tag") << tag_ + << token::END_STATEMENT << nl; + } } diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.H index fa59414586..0b9d4f70d9 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.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-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -54,12 +54,12 @@ class processorCyclicPolyPatch { // Private data - //- Message tag to use for communication - const int tag_; - //- Name of originating patch const word referPatchName_; + //- Message tag to use for communication + mutable int tag_; + //- Index of originating patch mutable label referPatchID_; @@ -264,10 +264,7 @@ public: } //- Return message tag to use for communication - virtual int tag() const - { - return tag_; - } + virtual int tag() const; //- Does this side own the patch ? virtual bool owner() const diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedFieldFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedFieldFvPatchField.C index bd15d4764a..5d359bc691 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedFieldFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedFieldFvPatchField.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 @@ -42,12 +42,9 @@ mappedFieldFvPatchField::mappedFieldFvPatchField const DimensionedField& iF ) : - mappedPatchBase(p.patch()), fixedValueFvPatchField(p, iF), - fieldName_(iF.name()), - setAverage_(false), - average_(pTraits::zero), - interpolationScheme_(interpolationCell::typeName) + mappedPatchBase(p.patch()), + mappedPatchFieldBase(*this, *this) {} @@ -60,12 +57,9 @@ mappedFieldFvPatchField::mappedFieldFvPatchField const fvPatchFieldMapper& mapper ) : - mappedPatchBase(p.patch(), ptf), fixedValueFvPatchField(ptf, p, iF, mapper), - fieldName_(ptf.fieldName_), - setAverage_(ptf.setAverage_), - average_(ptf.average_), - interpolationScheme_(ptf.interpolationScheme_) + mappedPatchBase(p.patch(), ptf), + mappedPatchFieldBase(*this, *this, ptf) {} @@ -77,18 +71,10 @@ mappedFieldFvPatchField::mappedFieldFvPatchField const dictionary& dict ) : - mappedPatchBase(p.patch(), dict), fixedValueFvPatchField(p, iF, dict), - fieldName_(dict.template lookupOrDefault("fieldName", iF.name())), - setAverage_(readBool(dict.lookup("setAverage"))), - average_(pTraits(dict.lookup("average"))), - interpolationScheme_(interpolationCell::typeName) -{ - if (mode() == mappedPatchBase::NEARESTCELL) - { - dict.lookup("interpolationScheme") >> interpolationScheme_; - } -} + mappedPatchBase(p.patch(), dict), + mappedPatchFieldBase(*this, *this, dict) +{} template @@ -110,6 +96,7 @@ mappedFieldFvPatchField::mappedFieldFvPatchField const word& interpolationScheme ) : + fixedValueFvPatchField(p, iF), mappedPatchBase ( p.patch(), @@ -118,11 +105,15 @@ mappedFieldFvPatchField::mappedFieldFvPatchField samplePatch, distance ), - fixedValueFvPatchField(p, iF), - fieldName_(fieldName), - setAverage_(setAverage), - average_(average), - interpolationScheme_(interpolationScheme) + mappedPatchFieldBase + ( + *this, + *this, + fieldName, + setAverage, + average, + interpolationScheme + ) {} @@ -132,12 +123,9 @@ mappedFieldFvPatchField::mappedFieldFvPatchField const mappedFieldFvPatchField& ptf ) : - mappedPatchBase(ptf.patch().patch(), ptf), fixedValueFvPatchField(ptf), - fieldName_(ptf.fieldName_), - setAverage_(ptf.setAverage_), - average_(ptf.average_), - interpolationScheme_(ptf.interpolationScheme_) + mappedPatchBase(ptf.patch().patch(), ptf), + mappedPatchFieldBase(ptf) {} @@ -148,65 +136,14 @@ mappedFieldFvPatchField::mappedFieldFvPatchField const DimensionedField& iF ) : - mappedPatchBase(ptf.patch().patch(), ptf), fixedValueFvPatchField(ptf, iF), - fieldName_(ptf.fieldName_), - setAverage_(ptf.setAverage_), - average_(ptf.average_), - interpolationScheme_(ptf.interpolationScheme_) + mappedPatchBase(ptf.patch().patch(), ptf), + mappedPatchFieldBase(*this, *this, ptf) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -const GeometricField& -mappedFieldFvPatchField::sampleField() const -{ - typedef GeometricField fieldType; - - const fvMesh& nbrMesh = refCast(sampleMesh()); - - if (sameRegion()) - { - if (fieldName_ == this->dimensionedInternalField().name()) - { - // Optimisation: bypass field lookup - return - dynamic_cast - ( - this->dimensionedInternalField() - ); - } - else - { - const fvMesh& thisMesh = this->patch().boundaryMesh().mesh(); - return thisMesh.template lookupObject(fieldName_); - } - } - else - { - return nbrMesh.template lookupObject(fieldName_); - } -} - - -template -const interpolation& -mappedFieldFvPatchField::interpolator() const -{ - if (!interpolator_.valid()) - { - interpolator_ = interpolation::New - ( - interpolationScheme_, - sampleField() - ); - } - return interpolator_(); -} - - template void mappedFieldFvPatchField::updateCoeffs() { @@ -215,132 +152,7 @@ void mappedFieldFvPatchField::updateCoeffs() return; } - typedef GeometricField fieldType; - - // Since we're inside initEvaluate/evaluate there might be processor - // comms underway. Change the tag we use. - int oldTag = UPstream::msgType(); - UPstream::msgType() = oldTag + 1; - - const fvMesh& thisMesh = this->patch().boundaryMesh().mesh(); - const fvMesh& nbrMesh = refCast(sampleMesh()); - - // Result of obtaining remote values - Field newValues; - - switch (mode()) - { - case NEARESTCELL: - { - const mapDistribute& mapDist = this->mappedPatchBase::map(); - - if (interpolationScheme_ != interpolationCell::typeName) - { - // Need to do interpolation so need cells to sample - - // Send back sample points to the processor that holds the cell - vectorField samples(samplePoints()); - mapDist.reverseDistribute - ( - (sameRegion() ? thisMesh.nCells() : nbrMesh.nCells()), - point::max, - samples - ); - - const interpolation& interp = interpolator(); - - newValues.setSize(samples.size(), pTraits::max); - forAll(samples, cellI) - { - if (samples[cellI] != point::max) - { - newValues[cellI] = interp.interpolate - ( - samples[cellI], - cellI - ); - } - } - } - else - { - newValues = sampleField(); - } - - mapDist.distribute(newValues); - - break; - } - case NEARESTPATCHFACE: case NEARESTPATCHFACEAMI: - { - const label nbrPatchID = - nbrMesh.boundaryMesh().findPatchID(samplePatch()); - if (nbrPatchID < 0) - { - FatalErrorIn - ( - "void mappedFieldFvPatchField::updateCoeffs()" - )<< "Unable to find sample patch " << samplePatch() - << " in region " << sampleRegion() - << " for patch " << this->patch().name() << nl - << abort(FatalError); - } - - const fieldType& nbrField = sampleField(); - - newValues = nbrField.boundaryField()[nbrPatchID]; - this->distribute(newValues); - - break; - } - case NEARESTFACE: - { - Field allValues(nbrMesh.nFaces(), pTraits::zero); - - const fieldType& nbrField = sampleField(); - - forAll(nbrField.boundaryField(), patchI) - { - const fvPatchField& pf = - nbrField.boundaryField()[patchI]; - label faceStart = pf.patch().patch().start(); - - forAll(pf, faceI) - { - allValues[faceStart++] = pf[faceI]; - } - } - - this->distribute(allValues); - newValues.transfer(allValues); - - break; - } - default: - { - FatalErrorIn("mappedFieldFvPatchField::updateCoeffs()") - << "Unknown sampling mode: " << mode() - << nl << abort(FatalError); - } - } - - if (setAverage_) - { - Type averagePsi = - gSum(this->patch().magSf()*newValues) - /gSum(this->patch().magSf()); - - if (mag(averagePsi)/mag(average_) > 0.5) - { - newValues *= mag(average_)/mag(averagePsi); - } - else - { - newValues += (average_ - averagePsi); - } - } - - this->operator==(newValues); + this->operator==(this->mappedField()); if (debug) { @@ -352,9 +164,6 @@ void mappedFieldFvPatchField::updateCoeffs() << endl; } - // Restore tag - UPstream::msgType() = oldTag; - fixedValueFvPatchField::updateCoeffs(); } @@ -364,11 +173,7 @@ void mappedFieldFvPatchField::write(Ostream& os) const { fvPatchField::write(os); mappedPatchBase::write(os); - os.writeKeyword("fieldName") << fieldName_ << token::END_STATEMENT << nl; - os.writeKeyword("setAverage") << setAverage_ << token::END_STATEMENT << nl; - os.writeKeyword("average") << average_ << token::END_STATEMENT << nl; - os.writeKeyword("interpolationScheme") << interpolationScheme_ - << token::END_STATEMENT << nl; + mappedPatchFieldBase::write(os); this->writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedFieldFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedFieldFvPatchField.H index 6dd9f3efb5..983df12eb4 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedFieldFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedFieldFvPatchField.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-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -75,6 +75,7 @@ SourceFiles #define mappedFieldFvPatchField_H #include "mappedPatchBase.H" +#include "mappedPatchFieldBase.H" #include "fixedValueFvPatchFields.H" #include "interpolation.H" @@ -90,37 +91,10 @@ namespace Foam template class mappedFieldFvPatchField : + public fixedValueFvPatchField, public mappedPatchBase, - public fixedValueFvPatchField + public mappedPatchFieldBase { - // Private data - - //- Name of field to sample - defaults to field associated with this - // patchField if not specified - word fieldName_; - - //- If true adjust the mapped field to maintain average value average_ - const bool setAverage_; - - //- Average value the mapped field is adjusted to maintain if - // setAverage_ is set true - const Type average_; - - //- Interpolation scheme to use for nearestCell mode - word interpolationScheme_; - - //- Pointer to the cell interpolator - mutable autoPtr > interpolator_; - - - // Private Member Functions - - //- Field to sample. Either on my or nbr mesh - const GeometricField& sampleField() const; - - //- Access the interpolation method - const interpolation& interpolator() const; - public: diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.C b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.C new file mode 100644 index 0000000000..291fe316dc --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.C @@ -0,0 +1,340 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 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 . + +\*---------------------------------------------------------------------------*/ + +#include "mappedPatchFieldBase.H" +#include "mappedPatchBase.H" +#include "interpolationCell.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +mappedPatchFieldBase::mappedPatchFieldBase +( + const mappedPatchBase& mapper, + const fvPatchField& patchField, + const word& fieldName, + const bool setAverage, + const Type average, + const word& interpolationScheme +) +: + mapper_(mapper), + patchField_(patchField), + fieldName_(fieldName), + setAverage_(setAverage), + average_(average), + interpolationScheme_(interpolationScheme) +{} + + +template +mappedPatchFieldBase::mappedPatchFieldBase +( + const mappedPatchBase& mapper, + const fvPatchField& patchField, + const dictionary& dict +) +: + mapper_(mapper), + patchField_(patchField), + fieldName_ + ( + dict.template lookupOrDefault + ( + "fieldName", + patchField_.dimensionedInternalField().name() + ) + ), + setAverage_(readBool(dict.lookup("setAverage"))), + average_(pTraits(dict.lookup("average"))), + interpolationScheme_(interpolationCell::typeName) +{ + if (mapper_.mode() == mappedPatchBase::NEARESTCELL) + { + dict.lookup("interpolationScheme") >> interpolationScheme_; + } +} + + +template +mappedPatchFieldBase::mappedPatchFieldBase +( + const mappedPatchBase& mapper, + const fvPatchField& patchField +) +: + mapper_(mapper), + patchField_(patchField), + fieldName_(patchField_.dimensionedInternalField().name()), + setAverage_(false), + average_(pTraits::zero), + interpolationScheme_(interpolationCell::typeName) +{} + + +template +mappedPatchFieldBase::mappedPatchFieldBase +( + const mappedPatchFieldBase& mapper +) +: + mapper_(mapper.mapper_), + patchField_(mapper.patchField_), + fieldName_(mapper.fieldName_), + setAverage_(mapper.setAverage_), + average_(mapper.average_), + interpolationScheme_(mapper.interpolationScheme_) +{} + + +template +mappedPatchFieldBase::mappedPatchFieldBase +( + const mappedPatchBase& mapper, + const fvPatchField& patchField, + const mappedPatchFieldBase& base +) +: + mapper_(mapper), + patchField_(patchField), + fieldName_(base.fieldName_), + setAverage_(base.setAverage_), + average_(base.average_), + interpolationScheme_(base.interpolationScheme_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +const GeometricField& +mappedPatchFieldBase::sampleField() const +{ + typedef GeometricField fieldType; + + const fvMesh& nbrMesh = refCast(mapper_.sampleMesh()); + + if (mapper_.sameRegion()) + { + if (fieldName_ == patchField_.dimensionedInternalField().name()) + { + // Optimisation: bypass field lookup + return + dynamic_cast + ( + patchField_.dimensionedInternalField() + ); + } + else + { + const fvMesh& thisMesh = patchField_.patch().boundaryMesh().mesh(); + return thisMesh.template lookupObject(fieldName_); + } + } + else + { + return nbrMesh.template lookupObject(fieldName_); + } +} + + +template +const interpolation& mappedPatchFieldBase::interpolator() const +{ + if (!interpolator_.valid()) + { + interpolator_ = interpolation::New + ( + interpolationScheme_, + sampleField() + ); + } + return interpolator_(); +} + + +template +tmp > mappedPatchFieldBase::mappedField() const +{ + typedef GeometricField fieldType; + + // Since we're inside initEvaluate/evaluate there might be processor + // comms underway. Change the tag we use. + int oldTag = UPstream::msgType(); + UPstream::msgType() = oldTag + 1; + + const fvMesh& thisMesh = patchField_.patch().boundaryMesh().mesh(); + const fvMesh& nbrMesh = refCast(mapper_.sampleMesh()); + + // Result of obtaining remote values + tmp > tnewValues(new Field(0)); + Field& newValues = tnewValues(); + + switch (mapper_.mode()) + { + case mappedPatchBase::NEARESTCELL: + { + const mapDistribute& distMap = mapper_.map(); + + if (interpolationScheme_ != interpolationCell::typeName) + { + // Send back sample points to the processor that holds the cell + vectorField samples(mapper_.samplePoints()); + distMap.reverseDistribute + ( + ( + mapper_.sameRegion() + ? thisMesh.nCells() + : nbrMesh.nCells() + ), + point::max, + samples + ); + + const interpolation& interp = interpolator(); + + newValues.setSize(samples.size(), pTraits::max); + forAll(samples, cellI) + { + if (samples[cellI] != point::max) + { + newValues[cellI] = interp.interpolate + ( + samples[cellI], + cellI + ); + } + } + } + else + { + newValues = sampleField(); + } + + distMap.distribute(newValues); + + break; + } + case mappedPatchBase::NEARESTPATCHFACE: + case mappedPatchBase::NEARESTPATCHFACEAMI: + { + const label nbrPatchID = + nbrMesh.boundaryMesh().findPatchID(mapper_.samplePatch()); + + if (nbrPatchID < 0) + { + FatalErrorIn + ( + "void mappedPatchFieldBase::updateCoeffs()" + )<< "Unable to find sample patch " << mapper_.samplePatch() + << " in region " << mapper_.sampleRegion() + << " for patch " << patchField_.patch().name() << nl + << abort(FatalError); + } + + const fieldType& nbrField = sampleField(); + + newValues = nbrField.boundaryField()[nbrPatchID]; + mapper_.distribute(newValues); + + break; + } + case mappedPatchBase::NEARESTFACE: + { + Field allValues(nbrMesh.nFaces(), pTraits::zero); + + const fieldType& nbrField = sampleField(); + + forAll(nbrField.boundaryField(), patchI) + { + const fvPatchField& pf = + nbrField.boundaryField()[patchI]; + label faceStart = pf.patch().start(); + + forAll(pf, faceI) + { + allValues[faceStart++] = pf[faceI]; + } + } + + mapper_.distribute(allValues); + newValues.transfer(allValues); + + break; + } + default: + { + FatalErrorIn + ( + "mappedPatchFieldBase::updateCoeffs()" + )<< "Unknown sampling mode: " << mapper_.mode() + << nl << abort(FatalError); + } + } + + if (setAverage_) + { + Type averagePsi = + gSum(patchField_.patch().magSf()*newValues) + /gSum(patchField_.patch().magSf()); + + if (mag(averagePsi)/mag(average_) > 0.5) + { + newValues *= mag(average_)/mag(averagePsi); + } + else + { + newValues += (average_ - averagePsi); + } + } + + // Restore tag + UPstream::msgType() = oldTag; + + return tnewValues; +} + + +template +void mappedPatchFieldBase::write(Ostream& os) const +{ + os.writeKeyword("fieldName") << fieldName_ << token::END_STATEMENT << nl; + os.writeKeyword("setAverage") << setAverage_ << token::END_STATEMENT << nl; + os.writeKeyword("average") << average_ << token::END_STATEMENT << nl; + os.writeKeyword("interpolationScheme") << interpolationScheme_ + << token::END_STATEMENT << nl; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.H b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.H new file mode 100644 index 0000000000..5072841094 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.H @@ -0,0 +1,166 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 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 . + +Class + Foam::mappedPatchFieldBase + +Description + Functionality for sampling fields using mappedPatchBase. + +SourceFiles + mappedPatchFieldBase.C + +\*---------------------------------------------------------------------------*/ + +#ifndef mappedPatchFieldBase_H +#define mappedPatchFieldBase_H + +#include "fixedValueFvPatchFields.H" +#include "volFieldsFwd.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +class mappedPatchBase; +template class interpolation; + +/*---------------------------------------------------------------------------*\ + Class mappedPatchFieldBase Declaration +\*---------------------------------------------------------------------------*/ + +template +class mappedPatchFieldBase +{ + +protected: + + // Protected data + + //- Mapping engine + const mappedPatchBase& mapper_; + + //- Underlying patch field + const fvPatchField& patchField_; + + //- Name of field to sample + word fieldName_; + + //- If true adjust the mapped field to maintain average value average_ + const bool setAverage_; + + //- Average value the mapped field is adjusted to maintain if + // setAverage_ is set true + const Type average_; + + //- Interpolation scheme to use for nearestcell mode + word interpolationScheme_; + + mutable autoPtr > interpolator_; + + + // Protected Member Functions + + +public: + + // Constructors + + //- Construct from components + mappedPatchFieldBase + ( + const mappedPatchBase& mapper, + const fvPatchField& patchField, + const word& fieldName, + const bool setAverage, + const Type average, + const word& interpolationScheme + ); + + //- Construct from dictionary + mappedPatchFieldBase + ( + const mappedPatchBase& mapper, + const fvPatchField& patchField, + const dictionary& dict + ); + + //- Construct empty + mappedPatchFieldBase + ( + const mappedPatchBase& mapper, + const fvPatchField& patchField + ); + + //- Construct copy + mappedPatchFieldBase + ( + const mappedPatchFieldBase& mapper + ); + + //- Construct copy, resetting patch and field + mappedPatchFieldBase + ( + const mappedPatchBase& mapper, + const fvPatchField& patchField, + const mappedPatchFieldBase& base + ); + + + //- Destructor + virtual ~mappedPatchFieldBase() + {} + + + // Member functions + + //- Field to sample. Either on my or nbr mesh + const GeometricField& sampleField() const; + + //- Access the interpolation method + const interpolation& interpolator() const; + + //- Map sampleField onto *this patch + virtual tmp > mappedField() const; + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "mappedPatchFieldBase.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedFixedValue/mappedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/mappedFixedValue/mappedFixedValueFvPatchField.C index 77cc8d61a9..851344194b 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/mappedFixedValue/mappedFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedFixedValue/mappedFixedValueFvPatchField.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 @@ -26,7 +26,6 @@ License #include "mappedFixedValueFvPatchField.H" #include "mappedPatchBase.H" #include "volFields.H" -#include "interpolationCell.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -43,10 +42,7 @@ mappedFixedValueFvPatchField::mappedFixedValueFvPatchField ) : fixedValueFvPatchField(p, iF), - fieldName_(iF.name()), - setAverage_(false), - average_(pTraits::zero), - interpolationScheme_(interpolationCell::typeName) + mappedPatchFieldBase(this->mapper(p, iF), *this) {} @@ -60,31 +56,8 @@ mappedFixedValueFvPatchField::mappedFixedValueFvPatchField ) : fixedValueFvPatchField(ptf, p, iF, mapper), - fieldName_(ptf.fieldName_), - setAverage_(ptf.setAverage_), - average_(ptf.average_), - interpolationScheme_(ptf.interpolationScheme_) -{ - if (!isA(this->patch().patch())) - { - FatalErrorIn - ( - "mappedFixedValueFvPatchField::" - "mappedFixedValueFvPatchField\n" - "(\n" - " const mappedFixedValueFvPatchField&,\n" - " const fvPatch&,\n" - " const Field&,\n" - " const fvPatchFieldMapper&\n" - ")\n" - ) << "\n patch type '" << p.type() - << "' not type '" << mappedPatchBase::typeName << "'" - << "\n for patch " << p.name() - << " of field " << this->dimensionedInternalField().name() - << " in file " << this->dimensionedInternalField().objectPath() - << exit(FatalError); - } -} + mappedPatchFieldBase(this->mapper(p, iF), *this, ptf) +{} template @@ -96,39 +69,8 @@ mappedFixedValueFvPatchField::mappedFixedValueFvPatchField ) : fixedValueFvPatchField(p, iF, dict), - fieldName_(dict.lookupOrDefault("fieldName", iF.name())), - setAverage_(readBool(dict.lookup("setAverage"))), - average_(pTraits(dict.lookup("average"))), - interpolationScheme_(interpolationCell::typeName) -{ - if (!isA(this->patch().patch())) - { - FatalErrorIn - ( - "mappedFixedValueFvPatchField::" - "mappedFixedValueFvPatchField\n" - "(\n" - " const fvPatch& p,\n" - " const DimensionedField& iF,\n" - " const dictionary& dict\n" - ")\n" - ) << "\n patch type '" << p.type() - << "' not type '" << mappedPatchBase::typeName << "'" - << "\n for patch " << p.name() - << " of field " << this->dimensionedInternalField().name() - << " in file " << this->dimensionedInternalField().objectPath() - << exit(FatalError); - } - - const mappedPatchBase& mpp = refCast - ( - mappedFixedValueFvPatchField::patch().patch() - ); - if (mpp.mode() == mappedPatchBase::NEARESTCELL) - { - dict.lookup("interpolationScheme") >> interpolationScheme_; - } -} + mappedPatchFieldBase(this->mapper(p, iF), *this, dict) +{} template @@ -138,10 +80,7 @@ mappedFixedValueFvPatchField::mappedFixedValueFvPatchField ) : fixedValueFvPatchField(ptf), - fieldName_(ptf.fieldName_), - setAverage_(ptf.setAverage_), - average_(ptf.average_), - interpolationScheme_(ptf.interpolationScheme_) + mappedPatchFieldBase(ptf) {} @@ -153,64 +92,32 @@ mappedFixedValueFvPatchField::mappedFixedValueFvPatchField ) : fixedValueFvPatchField(ptf, iF), - fieldName_(ptf.fieldName_), - setAverage_(ptf.setAverage_), - average_(ptf.average_), - interpolationScheme_(ptf.interpolationScheme_) + mappedPatchFieldBase(this->mapper(this->patch(), iF), *this, ptf) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -const GeometricField& -mappedFixedValueFvPatchField::sampleField() const +const mappedPatchBase& mappedFixedValueFvPatchField::mapper +( + const fvPatch& p, + const DimensionedField& iF +) { - typedef GeometricField fieldType; - - const mappedPatchBase& mpp = refCast - ( - mappedFixedValueFvPatchField::patch().patch() - ); - const fvMesh& nbrMesh = refCast(mpp.sampleMesh()); - - if (mpp.sameRegion()) + if (!isA(p.patch())) { - if (fieldName_ == this->dimensionedInternalField().name()) - { - // Optimisation: bypass field lookup - return - dynamic_cast - ( - this->dimensionedInternalField() - ); - } - else - { - const fvMesh& thisMesh = this->patch().boundaryMesh().mesh(); - return thisMesh.lookupObject(fieldName_); - } - } - else - { - return nbrMesh.lookupObject(fieldName_); - } -} - - -template -const interpolation& -mappedFixedValueFvPatchField::interpolator() const -{ - if (!interpolator_.valid()) - { - interpolator_ = interpolation::New + FatalErrorIn ( - interpolationScheme_, - sampleField() - ); + "mappedFixedValueFvPatchField::mapper()" + ) << "\n patch type '" << p.patch().type() + << "' not type '" << mappedPatchBase::typeName << "'" + << "\n for patch " << p.patch().name() + << " of field " << iF.name() + << " in file " << iF.objectPath() + << exit(FatalError); } - return interpolator_(); + return refCast(p.patch()); } @@ -222,140 +129,7 @@ void mappedFixedValueFvPatchField::updateCoeffs() return; } - typedef GeometricField fieldType; - - // Since we're inside initEvaluate/evaluate there might be processor - // comms underway. Change the tag we use. - int oldTag = UPstream::msgType(); - UPstream::msgType() = oldTag + 1; - - // Get the scheduling information from the mappedPatchBase - const mappedPatchBase& mpp = refCast - ( - mappedFixedValueFvPatchField::patch().patch() - ); - - const fvMesh& thisMesh = this->patch().boundaryMesh().mesh(); - const fvMesh& nbrMesh = refCast(mpp.sampleMesh()); - - // Result of obtaining remote values - Field newValues; - - switch (mpp.mode()) - { - case mappedPatchBase::NEARESTCELL: - { - const mapDistribute& distMap = mpp.map(); - - if (interpolationScheme_ != interpolationCell::typeName) - { - // Send back sample points to the processor that holds the cell - vectorField samples(mpp.samplePoints()); - distMap.reverseDistribute - ( - (mpp.sameRegion() ? thisMesh.nCells() : nbrMesh.nCells()), - point::max, - samples - ); - - const interpolation& interp = interpolator(); - - newValues.setSize(samples.size(), pTraits::max); - forAll(samples, cellI) - { - if (samples[cellI] != point::max) - { - newValues[cellI] = interp.interpolate - ( - samples[cellI], - cellI - ); - } - } - } - else - { - newValues = sampleField(); - } - - distMap.distribute(newValues); - - break; - } - case mappedPatchBase::NEARESTPATCHFACE: - case mappedPatchBase::NEARESTPATCHFACEAMI: - { - const label nbrPatchID = - nbrMesh.boundaryMesh().findPatchID(mpp.samplePatch()); - - if (nbrPatchID < 0) - { - FatalErrorIn - ( - "void mappedFixedValueFvPatchField::updateCoeffs()" - )<< "Unable to find sample patch " << mpp.samplePatch() - << " in region " << mpp.sampleRegion() - << " for patch " << this->patch().name() << nl - << abort(FatalError); - } - - const fieldType& nbrField = sampleField(); - - newValues = nbrField.boundaryField()[nbrPatchID]; - mpp.distribute(newValues); - - break; - } - case mappedPatchBase::NEARESTFACE: - { - Field allValues(nbrMesh.nFaces(), pTraits::zero); - - const fieldType& nbrField = sampleField(); - - forAll(nbrField.boundaryField(), patchI) - { - const fvPatchField& pf = - nbrField.boundaryField()[patchI]; - label faceStart = pf.patch().start(); - - forAll(pf, faceI) - { - allValues[faceStart++] = pf[faceI]; - } - } - - mpp.distribute(allValues); - newValues.transfer(allValues); - - break; - } - default: - { - FatalErrorIn - ( - "mappedFixedValueFvPatchField::updateCoeffs()" - )<< "Unknown sampling mode: " << mpp.mode() - << nl << abort(FatalError); - } - } - - if (setAverage_) - { - Type averagePsi = - gSum(this->patch().magSf()*newValues) - /gSum(this->patch().magSf()); - - if (mag(averagePsi)/mag(average_) > 0.5) - { - newValues *= mag(average_)/mag(averagePsi); - } - else - { - newValues += (average_ - averagePsi); - } - } - - this->operator==(newValues); + this->operator==(this->mappedField()); if (debug) { @@ -368,9 +142,6 @@ void mappedFixedValueFvPatchField::updateCoeffs() << endl; } - // Restore tag - UPstream::msgType() = oldTag; - fixedValueFvPatchField::updateCoeffs(); } @@ -379,11 +150,7 @@ template void mappedFixedValueFvPatchField::write(Ostream& os) const { fvPatchField::write(os); - os.writeKeyword("fieldName") << fieldName_ << token::END_STATEMENT << nl; - os.writeKeyword("setAverage") << setAverage_ << token::END_STATEMENT << nl; - os.writeKeyword("average") << average_ << token::END_STATEMENT << nl; - os.writeKeyword("interpolationScheme") << interpolationScheme_ - << token::END_STATEMENT << nl; + mappedPatchFieldBase::write(os); this->writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedFixedValue/mappedFixedValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/mappedFixedValue/mappedFixedValueFvPatchField.H index dd52f2a2b6..6267e88ab2 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/mappedFixedValue/mappedFixedValueFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedFixedValue/mappedFixedValueFvPatchField.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-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -83,7 +83,8 @@ SourceFiles #define mappedFixedValueFvPatchField_H #include "fixedValueFvPatchFields.H" -#include "interpolation.H" +//#include "interpolation.H" +#include "mappedPatchFieldBase.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -97,37 +98,19 @@ namespace Foam template class mappedFixedValueFvPatchField : - public fixedValueFvPatchField + public fixedValueFvPatchField, + public mappedPatchFieldBase { protected: - // Protected data - - //- Name of field to sample - defaults to field associated with this - // patchField if not specified - word fieldName_; - - //- If true adjust the mapped field to maintain average value average_ - const bool setAverage_; - - //- Average value the mapped field is adjusted to maintain if - // setAverage_ is set true - const Type average_; - - //- Interpolation scheme to use for nearestcell mode - word interpolationScheme_; - - mutable autoPtr > interpolator_; - - // Protected Member Functions - //- Field to sample. Either on my or nbr mesh - const GeometricField& sampleField() const; - - //- Access the interpolation method - const interpolation& interpolator() const; + const mappedPatchBase& mapper + ( + const fvPatch& p, + const DimensionedField& iF + ); public: diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C index f5622451cb..fa3d6d7a31 100644 --- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C @@ -198,10 +198,61 @@ void Foam::fvPatchField::patchInternalField(Field& pif) const template void Foam::fvPatchField::autoMap ( - const fvPatchFieldMapper& m + const fvPatchFieldMapper& mapper ) { - Field::autoMap(m); + Field& f = *this; + + if (!this->size()) + { + f.setSize(mapper.size()); + if (f.size()) + { + f = this->patchInternalField(); + } + } + else + { + // Map all faces provided with mapping data + Field::autoMap(mapper); + + // For unmapped faces set to internal field value (zero-gradient) + if + ( + mapper.direct() + && &mapper.directAddressing() + && mapper.directAddressing().size() + ) + { + Field pif(this->patchInternalField()); + + const labelList& mapAddressing = mapper.directAddressing(); + + forAll(mapAddressing, i) + { + if (mapAddressing[i] < 0) + { + f[i] = pif[i]; + } + } + } + else if (!mapper.direct() && mapper.addressing().size()) + { + Field pif(this->patchInternalField()); + + const labelListList& mapAddressing = mapper.addressing(); + + forAll(mapAddressing, i) + { + const labelList& localAddrs = mapAddressing[i]; + + if (!localAddrs.size()) + { + f[i] = pif[i]; + } + } + } + } } diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolationScheme/surfaceInterpolationScheme.C b/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolationScheme/surfaceInterpolationScheme.C index d1ed7e01c0..1a69959095 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolationScheme/surfaceInterpolationScheme.C +++ b/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolationScheme/surfaceInterpolationScheme.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 @@ -171,7 +171,10 @@ surfaceInterpolationScheme::interpolate "(const GeometricField&, " "const tmp&, " "const tmp&) : " - "interpolating volTypeField from cells to faces " + "interpolating " + << vf.type() << " " + << vf.name() + << " from cells to faces " "without explicit correction" << endl; } @@ -252,7 +255,10 @@ surfaceInterpolationScheme::interpolate Info<< "surfaceInterpolationScheme::interpolate" "(const GeometricField&, " "const tmp&) : " - "interpolating volTypeField from cells to faces " + "interpolating " + << vf.type() << " " + << vf.name() + << " from cells to faces " "without explicit correction" << endl; } @@ -326,7 +332,10 @@ surfaceInterpolationScheme::interpolate { Info<< "surfaceInterpolationScheme::interpolate" "(const GeometricField&) : " - << "interpolating volTypeField from cells to faces" + "interpolating " + << vf.type() << " " + << vf.name() + << " from cells to faces" << endl; } diff --git a/src/meshTools/sets/topoSets/faceZoneSet.C b/src/meshTools/sets/topoSets/faceZoneSet.C index 10d9c0b9bf..5b4849c1ef 100644 --- a/src/meshTools/sets/topoSets/faceZoneSet.C +++ b/src/meshTools/sets/topoSets/faceZoneSet.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 @@ -49,8 +49,8 @@ void faceZoneSet::updateSet() { labelList order; sortedOrder(addressing_, order); - inplaceReorder(order, addressing_); - inplaceReorder(order, flipMap_); + addressing_ = UIndirectList