diff --git a/applications/solvers/multiphase/interDyMFoam/Make/options b/applications/solvers/multiphase/interDyMFoam/Make/options index 24d71bc7ee..6755d5bc59 100644 --- a/applications/solvers/multiphase/interDyMFoam/Make/options +++ b/applications/solvers/multiphase/interDyMFoam/Make/options @@ -1,4 +1,6 @@ EXE_INC = \ + -I../rasInterFoam \ + -I../interFoam \ -I$(LIB_SRC)/transportModels \ -I$(LIB_SRC)/transportModels/incompressible/lnInclude \ -I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \ diff --git a/applications/solvers/multiphase/interDyMFoam/UEqn.H b/applications/solvers/multiphase/interDyMFoam/UEqn.H deleted file mode 100644 index 4c14afe1a6..0000000000 --- a/applications/solvers/multiphase/interDyMFoam/UEqn.H +++ /dev/null @@ -1,34 +0,0 @@ -surfaceScalarField muEff -( - "muEff", - twoPhaseProperties.muf() - + fvc::interpolate(rho*turbulence->nut()) -); - -fvVectorMatrix UEqn -( - fvm::ddt(rho, U) - + fvm::div(rhoPhi, U) - - fvm::laplacian(muEff, U) - - (fvc::grad(U) & fvc::grad(muEff)) -//- fvc::div(muEff*(fvc::interpolate(dev(fvc::grad(U))) & mesh.Sf())) -); - -UEqn.relax(); - -if (momentumPredictor) -{ - solve - ( - UEqn - == - fvc::reconstruct - ( - ( - fvc::interpolate(interface.sigmaK())*fvc::snGrad(gamma) - - ghf*fvc::snGrad(rho) - - fvc::snGrad(pd) - )*mesh.magSf() - ) - ); -} diff --git a/applications/solvers/multiphase/interDyMFoam/gammaEqn.H b/applications/solvers/multiphase/interDyMFoam/gammaEqn.H deleted file mode 100644 index 8978d1d293..0000000000 --- a/applications/solvers/multiphase/interDyMFoam/gammaEqn.H +++ /dev/null @@ -1,35 +0,0 @@ -{ - word gammaScheme("div(phi,gamma)"); - word gammarScheme("div(phirb,gamma)"); - - surfaceScalarField phic = mag(phi/mesh.magSf()); - phic = min(interface.cGamma()*phic, max(phic)); - surfaceScalarField phir = phic*interface.nHatf(); - - for (int gCorr=0; gCorr 1) -{ - dimensionedScalar totalDeltaT = runTime.deltaT(); - surfaceScalarField rhoPhiSum = 0.0*rhoPhi; - - for - ( - subCycle gammaSubCycle(gamma, nGammaSubCycles); - !(++gammaSubCycle).end(); - ) - { -# include "gammaEqn.H" - rhoPhiSum += (runTime.deltaT()/totalDeltaT)*rhoPhi; - } - - rhoPhi = rhoPhiSum; -} -else -{ -# include "gammaEqn.H" -} - -interface.correct(); - -rho == gamma*rho1 + (scalar(1) - gamma)*rho2; diff --git a/applications/solvers/multiphase/interDyMFoam/interDyMFoam.C b/applications/solvers/multiphase/interDyMFoam/interDyMFoam.C index a126edaa92..915fee9a97 100644 --- a/applications/solvers/multiphase/interDyMFoam/interDyMFoam.C +++ b/applications/solvers/multiphase/interDyMFoam/interDyMFoam.C @@ -41,7 +41,6 @@ Description #include "twoPhaseMixture.H" #include "incompressible/RASModel/RASModel.H" #include "probes.H" -#include "EulerDdtScheme.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/utilities/preProcessing/mapFields/mapFields.C b/applications/utilities/preProcessing/mapFields/mapFields.C index 0fb8e40fff..5d4a6471e4 100644 --- a/applications/utilities/preProcessing/mapFields/mapFields.C +++ b/applications/utilities/preProcessing/mapFields/mapFields.C @@ -504,7 +504,7 @@ int main(int argc, char *argv[]) !bbsTargetSet[procITarget] || ( bbsTargetSet[procITarget] - && bbsTarget[procITarget].intersects(bbSource) + && bbsTarget[procITarget].overlaps(bbSource) ) ) { @@ -533,7 +533,7 @@ int main(int argc, char *argv[]) bbsTarget[procITarget] = meshTarget.bounds(); bbsTargetSet[procITarget] = true; - if (bbsTarget[procITarget].intersects(bbSource)) + if (bbsTarget[procITarget].overlaps(bbSource)) { if (consistent) { diff --git a/src/OpenFOAM/containers/Lists/SortableList/SortableList.C b/src/OpenFOAM/containers/Lists/SortableList/SortableList.C index 7cde863a63..a4264578d1 100644 --- a/src/OpenFOAM/containers/Lists/SortableList/SortableList.C +++ b/src/OpenFOAM/containers/Lists/SortableList/SortableList.C @@ -86,28 +86,7 @@ void Foam::SortableList::sort() indices_[i] = i; } - Foam::sort(indices_, less(*this)); - - List tmpValues(this->size()); - - forAll(indices_, i) - { - tmpValues[i] = this->operator[](indices_[i]); - } - - List::transfer(tmpValues); -} - - - -template -void Foam::SortableList::stableSort() -{ - forAll(indices_, i) - { - indices_[i] = i; - } - + //Foam::sort(indices_, less(*this)); Foam::stableSort(indices_, less(*this)); List tmpValues(this->size()); diff --git a/src/OpenFOAM/containers/Lists/SortableList/SortableList.H b/src/OpenFOAM/containers/Lists/SortableList/SortableList.H index a9ab2ae829..dd0f0af0d4 100644 --- a/src/OpenFOAM/containers/Lists/SortableList/SortableList.H +++ b/src/OpenFOAM/containers/Lists/SortableList/SortableList.H @@ -109,12 +109,9 @@ public: //- Size the list. If grow can cause undefined indices (until next sort) void setSize(const label); - //- Sort the list (if changed after construction time) + //- (stable) sort the list (if changed after construction time) void sort(); - //- Sort the list (if changed after construction time) - void stableSort(); - // Member Operators diff --git a/src/OpenFOAM/meshes/boundBox/boundBox.H b/src/OpenFOAM/meshes/boundBox/boundBox.H index a11aa68266..40287e53eb 100644 --- a/src/OpenFOAM/meshes/boundBox/boundBox.H +++ b/src/OpenFOAM/meshes/boundBox/boundBox.H @@ -118,7 +118,7 @@ public: // Query //- Intersects other boundingbox? - bool intersects(const boundBox& bb) const + bool overlaps(const boundBox& bb) const { if ( diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C index 796cb0983a..5421b328d8 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C @@ -31,7 +31,11 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void Foam::mapDistribute::calcSchedule() const +Foam::List Foam::mapDistribute::schedule +( + const labelListList& subMap, + const labelListList& constructMap +) { // Communications: send and receive processor List allComms; @@ -40,16 +44,16 @@ void Foam::mapDistribute::calcSchedule() const HashSet > commsSet(Pstream::nProcs()); // Find what communication is required - forAll(subMap_, procI) + forAll(subMap, procI) { if (procI != Pstream::myProcNo()) { - if (subMap_[procI].size() > 0) + if (subMap[procI].size() > 0) { // I need to send to procI commsSet.insert(labelPair(Pstream::myProcNo(), procI)); } - if (constructMap_[procI].size() > 0) + if (constructMap[procI].size() > 0) { // I need to receive from procI commsSet.insert(labelPair(procI, Pstream::myProcNo())); @@ -120,13 +124,7 @@ void Foam::mapDistribute::calcSchedule() const ); // Processors involved in my schedule - schedulePtr_.reset - ( - new List - ( - IndirectList(allComms, mySchedule) - ) - ); + return IndirectList(allComms, mySchedule); //if (debug) @@ -152,6 +150,22 @@ void Foam::mapDistribute::calcSchedule() const } +const Foam::List& Foam::mapDistribute::schedule() const +{ + if (!schedulePtr_.valid()) + { + schedulePtr_.reset + ( + new List + ( + schedule(subMap_, constructMap_) + ) + ); + } + return schedulePtr_(); +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // //- Construct from components @@ -257,13 +271,4 @@ Foam::mapDistribute::mapDistribute } -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // - - // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H index bdc71c286d..65888ea79e 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H @@ -36,6 +36,8 @@ Note: Schedule is a list of processor pairs (one send, one receive. One of them will be myself) which forms a scheduled (i.e. non-buffered) exchange. See distribute on how to use it. + Note2: number of items send on one processor have to equal the number + of items received on the other processor. SourceFiles @@ -80,8 +82,6 @@ class mapDistribute // Private Member Functions - void calcSchedule() const; - //- Disallow default bitwise copy construct mapDistribute(const mapDistribute&); @@ -142,15 +142,15 @@ public: return constructMap_; } + //- Calculate a schedule. See above. + static List schedule + ( + const labelListList& subMap, + const labelListList& constructMap + ); + //- Return a schedule. Demand driven. See above. - const List& schedule() const - { - if (!schedulePtr_.valid()) - { - calcSchedule(); - } - return schedulePtr_(); - } + const List& schedule() const; // Other diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C index 86ee3d96cf..6ad85c7971 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C @@ -48,15 +48,28 @@ void Foam::mapDistribute::distribute // Send sub field to neighbour for (label domain = 0; domain < Pstream::nProcs(); domain++) { - if (domain != Pstream::myProcNo()) + const labelList& map = subMap[domain]; + + if (domain != Pstream::myProcNo() && map.size() > 0) { + List subField(map.size()); + forAll(map, i) + { + subField[i] = field[map[i]]; + } OPstream toNbr(Pstream::blocking, domain); - toNbr << IndirectList(field, subMap[domain])(); + toNbr << subField; } } // Subset myself - List subField(IndirectList(field, subMap[Pstream::myProcNo()])); + const labelList& mySubMap = subMap[Pstream::myProcNo()]; + + List subField(mySubMap.size()); + forAll(mySubMap, i) + { + subField[i] = field[mySubMap[i]]; + } // Receive sub field from myself (subField) const labelList& map = constructMap[Pstream::myProcNo()]; @@ -71,7 +84,11 @@ void Foam::mapDistribute::distribute // Receive sub field from neighbour for (label domain = 0; domain < Pstream::nProcs(); domain++) { - if (domain != Pstream::myProcNo()) + if + ( + domain != Pstream::myProcNo() + && constructMap[domain].size() > 0 + ) { IPstream fromNbr(Pstream::blocking, domain); List subField(fromNbr); @@ -93,7 +110,13 @@ void Foam::mapDistribute::distribute List newField(constructSize); // Subset myself - List subField(IndirectList(field, subMap[Pstream::myProcNo()])); + const labelList& mySubMap = subMap[Pstream::myProcNo()]; + + List subField(mySubMap.size()); + forAll(mySubMap, i) + { + subField[i] = field[mySubMap[i]]; + } // Receive sub field from myself (subField) const labelList& map = constructMap[Pstream::myProcNo()]; @@ -112,8 +135,16 @@ void Foam::mapDistribute::distribute if (Pstream::myProcNo() == sendProc) { // I am sender. Send to recvProc. + const labelList& map = subMap[recvProc]; + + List subField(map.size()); + forAll(map, i) + { + subField[i] = field[map[i]]; + } + OPstream toNbr(Pstream::scheduled, recvProc); - toNbr << IndirectList(field, subMap[recvProc])(); + toNbr << subField; } else { @@ -136,7 +167,13 @@ void Foam::mapDistribute::distribute List newField(constructSize); // Subset myself - List subField(IndirectList(field, subMap[Pstream::myProcNo()])); + const labelList& mySubMap = subMap[Pstream::myProcNo()]; + + List subField(mySubMap.size()); + forAll(mySubMap, i) + { + subField[i] = field[mySubMap[i]]; + } // Receive sub field from myself (subField) const labelList& map = constructMap[Pstream::myProcNo()]; @@ -149,10 +186,19 @@ void Foam::mapDistribute::distribute // Send sub field to neighbour for (label domain = 0; domain < Pstream::nProcs(); domain++) { - if (domain != Pstream::myProcNo()) + const labelList& map = subMap[domain]; + + if (domain != Pstream::myProcNo() && map.size() > 0) { + + List subField(map.size()); + forAll(map, i) + { + subField[i] = field[map[i]]; + } + OPstream toNbr(Pstream::nonBlocking, domain); - toNbr << IndirectList(field, subMap[domain])(); + toNbr << subField; } } @@ -160,13 +206,13 @@ void Foam::mapDistribute::distribute // Receive sub field from neighbour for (label domain = 0; domain < Pstream::nProcs(); domain++) { - if (domain != Pstream::myProcNo()) + const labelList& map = constructMap[domain]; + + if (domain != Pstream::myProcNo() && map.size() > 0) { IPstream fromNbr(Pstream::nonBlocking, domain); List subField(fromNbr); - const labelList& map = constructMap[domain]; - forAll(map, i) { newField[map[i]] = subField[i]; diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.C index af86f37fed..f4e073d4e1 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.C @@ -25,7 +25,6 @@ License \*---------------------------------------------------------------------------*/ #include "coupledPolyPatch.H" -#include "SortableList.H" #include "ListOps.H" #include "transform.H" #include "OFstream.H" diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.C index a47c9c7d8c..835f884399 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.C @@ -68,6 +68,42 @@ PrimitivePatch::PrimitivePatch {} +// Construct from components +template +< + class Face, + template class FaceList, + class PointField, + class PointType +> +PrimitivePatch::PrimitivePatch +( + FaceList& faces, + Field& points, + const bool reUse +) +: + FaceList(faces, reUse), + points_(points, reUse), + edgesPtr_(NULL), + nInternalEdges_(-1), + boundaryPointsPtr_(NULL), + faceFacesPtr_(NULL), + edgeFacesPtr_(NULL), + faceEdgesPtr_(NULL), + pointEdgesPtr_(NULL), + pointFacesPtr_(NULL), + localFacesPtr_(NULL), + meshPointsPtr_(NULL), + meshPointMapPtr_(NULL), + edgeLoopsPtr_(NULL), + localPointsPtr_(NULL), + localPointOrderPtr_(NULL), + faceNormalsPtr_(NULL), + pointNormalsPtr_(NULL) +{} + + // Construct as copy template < diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.H b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.H index c22514d25f..49b3be8260 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.H +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.H @@ -235,6 +235,14 @@ public: const Field& points ); + //- Construct from components, reuse storage + PrimitivePatch + ( + FaceList& faces, + Field& points, + const bool reUse + ); + //- Construct as copy PrimitivePatch ( diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdges.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdges.C index 8b5fa7bb03..6b3039ff30 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdges.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdges.C @@ -467,7 +467,8 @@ const edgeList& primitiveMesh::edges() const { if (!edgesPtr_) { - calcEdges(true); + //calcEdges(true); + calcEdges(false); } return *edgesPtr_; @@ -477,10 +478,8 @@ const labelListList& primitiveMesh::pointEdges() const { if (!pePtr_) { - //// Invert edges - //pePtr_ = new labelListList(nPoints()); - //invertManyToMany(nPoints(), edges(), *pePtr_); - calcEdges(true); + //calcEdges(true); + calcEdges(false); } return *pePtr_; @@ -491,12 +490,53 @@ const labelListList& primitiveMesh::faceEdges() const { if (!fePtr_) { - calcEdges(true); + if (debug) + { + Pout<< "primitiveMesh::faceEdges() : " + << "calculating faceEdges" << endl; + } + + //calcEdges(true); + const faceList& fcs = faces(); + const labelListList& pe = pointEdges(); + const edgeList& es = edges(); + + fePtr_ = new labelListList(fcs.size()); + labelListList& faceEdges = *fePtr_; + + forAll(fcs, faceI) + { + const face& f = fcs[faceI]; + + labelList& fEdges = faceEdges[faceI]; + fEdges.setSize(f.size()); + + forAll(f, fp) + { + label pointI = f[fp]; + label nextPointI = f[f.fcIndex(fp)]; + + // Find edge between pointI, nextPontI + const labelList& pEdges = pe[pointI]; + + forAll(pEdges, i) + { + label edgeI = pEdges[i]; + + if (es[edgeI].otherVertex(pointI) == nextPointI) + { + fEdges[fp] = edgeI; + break; + } + } + } + } } return *fePtr_; } + void primitiveMesh::clearOutEdges() { deleteDemandDrivenData(edgesPtr_); diff --git a/src/decompositionAgglomeration/parMetisDecomp/parMetisDecomp.C b/src/decompositionAgglomeration/parMetisDecomp/parMetisDecomp.C index a5778bcdf0..8b3092f08f 100644 --- a/src/decompositionAgglomeration/parMetisDecomp/parMetisDecomp.C +++ b/src/decompositionAgglomeration/parMetisDecomp/parMetisDecomp.C @@ -41,8 +41,7 @@ extern "C" # include "parmetis.h" } - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { @@ -57,6 +56,8 @@ namespace Foam } +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + //- Does prevention of 0 cell domains and calls parmetis. Foam::label Foam::parMetisDecomp::decompose ( @@ -76,6 +77,16 @@ Foam::label Foam::parMetisDecomp::decompose // Number of dimensions int nDims = 3; + + if (cellCentres.size() != xadj.size()-1) + { + FatalErrorIn("parMetisDecomp::decompose(..)") + << "cellCentres:" << cellCentres.size() + << " xadj:" << xadj.size() + << abort(FatalError); + } + + // Get number of cells on all processors List nLocalCells(Pstream::nProcs()); nLocalCells[Pstream::myProcNo()] = xadj.size()-1; @@ -106,12 +117,12 @@ Foam::label Foam::parMetisDecomp::decompose // Make sure every domain has at least one cell // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // (Metis falls over with zero sized domains) - // Trickle cells from processors that have them down to those that + // Trickle cells from processors that have them up to those that // don't. - // Number of cells to send down (is same as number of cells next processor - // has to receive) + // Number of cells to send to the next processor + // (is same as number of cells next processor has to receive) List nSendCells(Pstream::nProcs(), 0); for (label procI = nLocalCells.size()-1; procI >=1; procI--) @@ -135,6 +146,15 @@ Foam::label Foam::parMetisDecomp::decompose Field prevCellWeights(fromPrevProc); Field prevFaceWeights(fromPrevProc); + if (prevXadj.size() != nSendCells[Pstream::myProcNo()-1]) + { + FatalErrorIn("parMetisDecomp::decompose(..)") + << "Expected from processor " << Pstream::myProcNo()-1 + << " connectivity for " << nSendCells[Pstream::myProcNo()-1] + << " nCells but only received " << prevXadj.size() + << abort(FatalError); + } + // Insert adjncy prepend(prevAdjncy, adjncy); // Adapt offsets and prepend xadj @@ -222,6 +242,14 @@ Foam::label Foam::parMetisDecomp::decompose } + if (nLocalCells[Pstream::myProcNo()] != (xadj.size()-1)) + { + FatalErrorIn("parMetisDecomp::decompose(..)") + << "Have connectivity for " << xadj.size()-1 + << " cells but nLocalCells:" << nLocalCells[Pstream::myProcNo()] + << abort(FatalError); + } + // Weight info int wgtFlag = 0; int* vwgtPtr = NULL; @@ -292,6 +320,15 @@ Foam::label Foam::parMetisDecomp::decompose List nextFinalDecomp(fromNextProc); + if (nextFinalDecomp.size() != nSendCells[Pstream::myProcNo()]) + { + FatalErrorIn("parMetisDecomp::decompose(..)") + << "Expected from processor " << Pstream::myProcNo()+1 + << " decomposition for " << nSendCells[Pstream::myProcNo()] + << " nCells but only received " << nextFinalDecomp.size() + << abort(FatalError); + } + append(nextFinalDecomp, finalDecomp); } diff --git a/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C b/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C index fedd050a78..da7e6368c1 100644 --- a/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C +++ b/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C @@ -24,7 +24,6 @@ License \*---------------------------------------------------------------------------*/ -#include "SortableList.H" #include "dynamicRefineFvMesh.H" #include "addToRunTimeSelectionTable.H" #include "volFields.H" @@ -32,7 +31,6 @@ License #include "surfaceFields.H" #include "fvCFD.H" #include "syncTools.H" -#include "ListListOps.H" #include "pointFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/dynamicMesh/boundaryMesh/octreeDataFaceList.C b/src/dynamicMesh/boundaryMesh/octreeDataFaceList.C index 2249bc006e..2ce870af9d 100644 --- a/src/dynamicMesh/boundaryMesh/octreeDataFaceList.C +++ b/src/dynamicMesh/boundaryMesh/octreeDataFaceList.C @@ -399,7 +399,7 @@ bool Foam::octreeDataFaceList::overlaps const treeBoundBox& sampleBb ) const { - return sampleBb.intersects(allBb_[index]); + return sampleBb.overlaps(allBb_[index]); } diff --git a/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C b/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C index 9c6a50177a..6d97285d73 100644 --- a/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C +++ b/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C @@ -32,7 +32,6 @@ License #include "octreeDataFace.H" #include "octree.H" #include "OFstream.H" -#include "SortableList.H" #include "IndirectList.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index d4a3e0ff78..83dff1819d 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -84,6 +84,7 @@ $(derivedFvPatchFields)/oscillatingFixedValue/oscillatingFixedValueFvPatchFields $(derivedFvPatchFields)/outletInlet/outletInletFvPatchFields.C $(derivedFvPatchFields)/partialSlip/partialSlipFvPatchFields.C $(derivedFvPatchFields)/pressureDirectedInletOutletVelocity/pressureDirectedInletOutletVelocityFvPatchVectorField.C +$(derivedFvPatchFields)/pressureNormalInletOutletVelocity/pressureNormalInletOutletVelocityFvPatchVectorField.C $(derivedFvPatchFields)/pressureDirectedInletVelocity/pressureDirectedInletVelocityFvPatchVectorField.C $(derivedFvPatchFields)/pressureInletOutletVelocity/pressureInletOutletVelocityFvPatchVectorField.C $(derivedFvPatchFields)/pressureInletUniformVelocity/pressureInletUniformVelocityFvPatchVectorField.C diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fluxCorrectedVelocity/fluxCorrectedVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/fluxCorrectedVelocity/fluxCorrectedVelocityFvPatchVectorField.C index 2908681eb0..7082962d9f 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fluxCorrectedVelocity/fluxCorrectedVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fluxCorrectedVelocity/fluxCorrectedVelocityFvPatchVectorField.C @@ -74,20 +74,10 @@ fluxCorrectedVelocityFvPatchVectorField ) : zeroGradientFvPatchVectorField(p, iF), - phiName_("phi"), - rhoName_("rho") + phiName_(dict.lookupOrDefault("phi", "phi")), + rhoName_(dict.lookupOrDefault("rho", "rho")) { fvPatchVectorField::operator=(patchInternalField()); - - if (dict.found("phi")) - { - dict.lookup("phi") >> phiName_; - } - - if (dict.found("rho")) - { - dict.lookup("rho") >> rhoName_; - } } @@ -118,10 +108,8 @@ void fluxCorrectedVelocityFvPatchVectorField::evaluate zeroGradientFvPatchVectorField::evaluate(); - const surfaceScalarField& phi = db().lookupObject - ( - phiName_ - ); + const surfaceScalarField& phi = + db().lookupObject(phiName_); const fvsPatchField& phip = patch().patchField(phi); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fluxCorrectedVelocity/fluxCorrectedVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/fluxCorrectedVelocity/fluxCorrectedVelocityFvPatchVectorField.H index 438eb0deb9..239db2cd33 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fluxCorrectedVelocity/fluxCorrectedVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/fluxCorrectedVelocity/fluxCorrectedVelocityFvPatchVectorField.H @@ -26,7 +26,10 @@ Class Foam::fluxCorrectedVelocityFvPatchVectorField Description - Foam::fluxCorrectedVelocityFvPatchVectorField + Velocity outlet boundary condition for patches where the pressure is + specified. The outflow velocity is obtained by "zeroGradient" and then + corrected from the flux. If reverse flow is possible or expected use + the "pressureInletOutletVelocityFvPatchVectorField" BC instead. SourceFiles fluxCorrectedVelocityFvPatchVectorField.C diff --git a/src/finiteVolume/fields/fvPatchFields/derived/inletOutlet/inletOutletFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/inletOutlet/inletOutletFvPatchField.C index 819807927b..c41d207724 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/inletOutlet/inletOutletFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/inletOutlet/inletOutletFvPatchField.C @@ -158,6 +158,22 @@ void inletOutletFvPatchField::write(Ostream& os) const } +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +template +void inletOutletFvPatchField::operator= +( + const fvPatchField& ptf +) +{ + fvPatchField::operator= + ( + this->valueFraction()*this->refValue() + + (1 - this->valueFraction())*ptf + ); +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/finiteVolume/fields/fvPatchFields/derived/inletOutlet/inletOutletFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/inletOutlet/inletOutletFvPatchField.H index 788285ff98..a7c72aa038 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/inletOutlet/inletOutletFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/inletOutlet/inletOutletFvPatchField.H @@ -134,6 +134,11 @@ public: //- Write virtual void write(Ostream&) const; + + + // Member operators + + virtual void operator=(const fvPatchField& pvf); }; diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletOutletVelocity/pressureDirectedInletOutletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletOutletVelocity/pressureDirectedInletOutletVelocityFvPatchVectorField.C index 66a535c6a7..afbccbd03a 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletOutletVelocity/pressureDirectedInletOutletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletOutletVelocity/pressureDirectedInletOutletVelocityFvPatchVectorField.C @@ -45,6 +45,8 @@ pressureDirectedInletOutletVelocityFvPatchVectorField ) : mixedFvPatchVectorField(p, iF), + phiName_("phi"), + rhoName_("rho"), inletDir_(p.size()) { refValue() = *this; @@ -63,6 +65,8 @@ pressureDirectedInletOutletVelocityFvPatchVectorField ) : mixedFvPatchVectorField(ptf, p, iF, mapper), + phiName_(ptf.phiName_), + rhoName_(ptf.rhoName_), inletDir_(ptf.inletDir_, mapper) {} @@ -76,6 +80,8 @@ pressureDirectedInletOutletVelocityFvPatchVectorField ) : mixedFvPatchVectorField(p, iF), + phiName_(dict.lookupOrDefault("phi", "phi")), + rhoName_(dict.lookupOrDefault("rho", "rho")), inletDir_("inletDirection", dict, p.size()) { fvPatchVectorField::operator=(vectorField("value", dict, p.size())); @@ -92,6 +98,8 @@ pressureDirectedInletOutletVelocityFvPatchVectorField ) : mixedFvPatchVectorField(pivpvf), + phiName_(pivpvf.phiName_), + rhoName_(pivpvf.rhoName_), inletDir_(pivpvf.inletDir_) {} @@ -104,6 +112,8 @@ pressureDirectedInletOutletVelocityFvPatchVectorField ) : mixedFvPatchVectorField(pivpvf, iF), + phiName_(pivpvf.phiName_), + rhoName_(pivpvf.rhoName_), inletDir_(pivpvf.inletDir_) {} @@ -129,7 +139,8 @@ void pressureDirectedInletOutletVelocityFvPatchVectorField::rmap mixedFvPatchVectorField::rmap(ptf, addr); const pressureDirectedInletOutletVelocityFvPatchVectorField& tiptf = - refCast(ptf); + refCast + (ptf); inletDir_.rmap(tiptf.inletDir_, addr); } @@ -143,7 +154,7 @@ void pressureDirectedInletOutletVelocityFvPatchVectorField::updateCoeffs() } const surfaceScalarField& phi = - db().lookupObject("phi"); + db().lookupObject(phiName_); const fvsPatchField& phip = patch().patchField(phi); @@ -158,7 +169,7 @@ void pressureDirectedInletOutletVelocityFvPatchVectorField::updateCoeffs() else if (phi.dimensions() == dimDensity*dimVelocity*dimArea) { const fvPatchField& rhop = - patch().lookupPatchField("rho"); + patch().lookupPatchField(rhoName_); refValue() = inletDir_*phip/(rhop*ndmagS); } @@ -185,11 +196,28 @@ void pressureDirectedInletOutletVelocityFvPatchVectorField:: write(Ostream& os) const { fvPatchVectorField::write(os); + os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; + os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; inletDir_.writeEntry("inletDirection", os); writeEntry("value", os); } +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +void pressureDirectedInletOutletVelocityFvPatchVectorField::operator= +( + const fvPatchField& pvf +) +{ + fvPatchField::operator= + ( + valueFraction()*(inletDir_*(inletDir_ & pvf)) + + (1 - valueFraction())*pvf + ); +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // makePatchTypeField diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletOutletVelocity/pressureDirectedInletOutletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletOutletVelocity/pressureDirectedInletOutletVelocityFvPatchVectorField.H index 8907c1d1af..4eaa0586e6 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletOutletVelocity/pressureDirectedInletOutletVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletOutletVelocity/pressureDirectedInletOutletVelocityFvPatchVectorField.H @@ -26,7 +26,10 @@ Class Foam::pressureDirectedInletOutletVelocityFvPatchVectorField Description - Foam::pressureDirectedInletOutletVelocityFvPatchVectorField + Velocity inlet/outlet boundary condition for pressure boundary where the + pressure is specified. zero-gradient is applied for outflow (as defined + by the flux) and for inflow the velocity is obtained from the flux with + the specified `inletDirection'. SourceFiles pressureDirectedInletOutletVelocityFvPatchVectorField.C @@ -53,7 +56,9 @@ class pressureDirectedInletOutletVelocityFvPatchVectorField public mixedFvPatchVectorField { // Private data - + + word phiName_; + word rhoName_; vectorField inletDir_; @@ -133,9 +138,35 @@ public: } - // Member functions + // Access + + //- Return the name of rho + const word& rhoName() const + { + return rhoName_; + } + + //- Return reference to the name of rho to allow adjustment + word& rhoName() + { + return rhoName_; + } + + //- Return the name of phi + const word& phiName() const + { + return phiName_; + } + + //- Return reference to the name of phi to allow adjustment + word& phiName() + { + return phiName_; + } + + // Mapping functions //- Map (and resize as needed) from self given a mapping object @@ -157,6 +188,11 @@ public: //- Write virtual void write(Ostream&) const; + + + // Member operators + + virtual void operator=(const fvPatchField& pvf); }; diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletVelocity/pressureDirectedInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletVelocity/pressureDirectedInletVelocityFvPatchVectorField.C index 1fe26fd649..fa9b68f545 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletVelocity/pressureDirectedInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletVelocity/pressureDirectedInletVelocityFvPatchVectorField.C @@ -45,6 +45,8 @@ pressureDirectedInletVelocityFvPatchVectorField ) : fixedValueFvPatchVectorField(p, iF), + phiName_("phi"), + rhoName_("rho"), inletDir_(p.size()) {} @@ -59,6 +61,8 @@ pressureDirectedInletVelocityFvPatchVectorField ) : fixedValueFvPatchVectorField(ptf, p, iF, mapper), + phiName_(ptf.phiName_), + rhoName_(ptf.rhoName_), inletDir_(ptf.inletDir_, mapper) {} @@ -72,6 +76,8 @@ pressureDirectedInletVelocityFvPatchVectorField ) : fixedValueFvPatchVectorField(p, iF), + phiName_(dict.lookupOrDefault("phi", "phi")), + rhoName_(dict.lookupOrDefault("rho", "rho")), inletDir_("inletDirection", dict, p.size()) { fvPatchVectorField::operator=(vectorField("value", dict, p.size())); @@ -85,6 +91,8 @@ pressureDirectedInletVelocityFvPatchVectorField ) : fixedValueFvPatchVectorField(pivpvf), + phiName_(pivpvf.phiName_), + rhoName_(pivpvf.rhoName_), inletDir_(pivpvf.inletDir_) {} @@ -97,6 +105,8 @@ pressureDirectedInletVelocityFvPatchVectorField ) : fixedValueFvPatchVectorField(pivpvf, iF), + phiName_(pivpvf.phiName_), + rhoName_(pivpvf.rhoName_), inletDir_(pivpvf.inletDir_) {} @@ -135,8 +145,8 @@ void pressureDirectedInletVelocityFvPatchVectorField::updateCoeffs() return; } - const surfaceScalarField& phi = - db().lookupObject("phi"); + const surfaceScalarField& phi = + db().lookupObject(phiName_); const fvsPatchField& phip = patch().patchField(phi); @@ -151,7 +161,7 @@ void pressureDirectedInletVelocityFvPatchVectorField::updateCoeffs() else if (phi.dimensions() == dimDensity*dimVelocity*dimArea) { const fvPatchField& rhop = - patch().lookupPatchField("rho"); + patch().lookupPatchField(rhoName_); operator==(inletDir_*phip/(rhop*ndmagS)); } @@ -174,11 +184,24 @@ void pressureDirectedInletVelocityFvPatchVectorField::updateCoeffs() void pressureDirectedInletVelocityFvPatchVectorField::write(Ostream& os) const { fvPatchVectorField::write(os); + os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; + os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; inletDir_.writeEntry("inletDirection", os); writeEntry("value", os); } +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +void pressureDirectedInletVelocityFvPatchVectorField::operator= +( + const fvPatchField& pvf +) +{ + fvPatchField::operator=(inletDir_*(inletDir_ & pvf)); +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // makePatchTypeField diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletVelocity/pressureDirectedInletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletVelocity/pressureDirectedInletVelocityFvPatchVectorField.H index a80e7779b2..4de0c84f48 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletVelocity/pressureDirectedInletVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletVelocity/pressureDirectedInletVelocityFvPatchVectorField.H @@ -23,10 +23,14 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - Foam::pressureDirectedInletVelocityFvPatchVectorField + Foam::pressureDirectedInletVelocityFvPatchVectorField Description - Foam::pressureDirectedInletOutletVelocityFvPatchVectorField + Velocity inlet boundary condition for patches where the pressure is + specified. The inflow velocity is obtained from the flux with the + specified "inletDirection" direction. If reverse flow is possible or + expected use the "pressureDirectedInletOutletVelocityFvPatchVectorField" + BC instead. SourceFiles pressureDirectedInletVelocityFvPatchVectorField.C @@ -53,7 +57,9 @@ class pressureDirectedInletVelocityFvPatchVectorField public fixedValueFvPatchVectorField { // Private data - + + word phiName_; + word rhoName_; vectorField inletDir_; @@ -130,9 +136,35 @@ public: } - // Member functions + // Access + + //- Return the name of rho + const word& rhoName() const + { + return rhoName_; + } + + //- Return reference to the name of rho to allow adjustment + word& rhoName() + { + return rhoName_; + } + + //- Return the name of phi + const word& phiName() const + { + return phiName_; + } + + //- Return reference to the name of phi to allow adjustment + word& phiName() + { + return phiName_; + } + + // Mapping functions //- Map (and resize as needed) from self given a mapping object @@ -154,6 +186,11 @@ public: //- Write virtual void write(Ostream&) const; + + + // Member operators + + virtual void operator=(const fvPatchField& pvf); }; diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletVelocity/pressureInletOutletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletVelocity/pressureInletOutletVelocityFvPatchVectorField.H index 538e17ae18..29eed3bfc3 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletVelocity/pressureInletOutletVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletVelocity/pressureInletOutletVelocityFvPatchVectorField.H @@ -26,7 +26,10 @@ Class Foam::pressureInletOutletVelocityFvPatchVectorField Description - Foam::pressureInletOutletVelocityFvPatchVectorField + Velocity inlet/outlet boundary condition patches for where the pressure is + specified. zero-gradient is applied for outflow (as defined by the flux) + and for inflow the velocity is obtained from the patch-face normal + component of the internal-cell value. SourceFiles pressureInletOutletVelocityFvPatchVectorField.C diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletUniformVelocity/pressureInletUniformVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletUniformVelocity/pressureInletUniformVelocityFvPatchVectorField.C index fb2787c164..0acfc62f01 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletUniformVelocity/pressureInletUniformVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletUniformVelocity/pressureInletUniformVelocityFvPatchVectorField.C @@ -108,6 +108,17 @@ void pressureInletUniformVelocityFvPatchVectorField::updateCoeffs() } +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +void pressureInletUniformVelocityFvPatchVectorField::operator= +( + const fvPatchField& pvf +) +{ + operator==(patch().nf()*sum(patch().Sf() & pvf)/sum(patch().magSf())); +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // makePatchTypeField diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletUniformVelocity/pressureInletUniformVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletUniformVelocity/pressureInletUniformVelocityFvPatchVectorField.H index 4440cdfbe8..0eadf62472 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletUniformVelocity/pressureInletUniformVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletUniformVelocity/pressureInletUniformVelocityFvPatchVectorField.H @@ -26,7 +26,9 @@ Class Foam::pressureInletUniformVelocityFvPatchVectorField Description - Foam::pressureInletUniformVelocityFvPatchVectorField + Velocity inlet boundary condition for patches where the pressure is + specified. The uniform inflow velocity is obtained by averaging the flux + over the patch and apply it in the direction normal to the patch faces. SourceFiles pressureInletUniformVelocityFvPatchVectorField.C @@ -124,6 +126,11 @@ public: //- Update the coefficients associated with the patch field virtual void updateCoeffs(); + + + // Member operators + + virtual void operator=(const fvPatchField& pvf); }; diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletVelocity/pressureInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletVelocity/pressureInletVelocityFvPatchVectorField.C index c349bc3260..75242aabb5 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletVelocity/pressureInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletVelocity/pressureInletVelocityFvPatchVectorField.C @@ -70,20 +70,10 @@ pressureInletVelocityFvPatchVectorField::pressureInletVelocityFvPatchVectorField ) : fixedValueFvPatchVectorField(p, iF), - phiName_("phi"), - rhoName_("rho") + phiName_(dict.lookupOrDefault("phi", "phi")), + rhoName_(dict.lookupOrDefault("rho", "rho")) { fvPatchVectorField::operator=(vectorField("value", dict, p.size())); - - if (dict.found("phi")) - { - dict.lookup("phi") >> phiName_; - } - - if (dict.found("rho")) - { - dict.lookup("rho") >> rhoName_; - } } @@ -164,6 +154,17 @@ void pressureInletVelocityFvPatchVectorField::write(Ostream& os) const } +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +void pressureInletVelocityFvPatchVectorField::operator= +( + const fvPatchField& pvf +) +{ + fvPatchField::operator=(patch().nf()*(patch().nf() & pvf)); +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // makePatchTypeField diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletVelocity/pressureInletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletVelocity/pressureInletVelocityFvPatchVectorField.H index 75348775bc..bb7b7f5b9b 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletVelocity/pressureInletVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletVelocity/pressureInletVelocityFvPatchVectorField.H @@ -26,7 +26,10 @@ Class Foam::pressureInletVelocityFvPatchVectorField Description - Foam::pressureInletVelocityFvPatchVectorField + Velocity inlet boundary condition for patches where the pressure is + specified. The inflow velocity is obtained from the flux with a direction + normal to the patch faces. If reverse flow is possible or expected use + the "pressureInletOutletVelocityFvPatchVectorField" BC instead. SourceFiles pressureInletVelocityFvPatchVectorField.C @@ -57,6 +60,7 @@ class pressureInletVelocityFvPatchVectorField word phiName_; word rhoName_; + public: //- Runtime type information @@ -127,6 +131,33 @@ public: // Member functions + // Access + + //- Return the name of rho + const word& rhoName() const + { + return rhoName_; + } + + //- Return reference to the name of rho to allow adjustment + word& rhoName() + { + return rhoName_; + } + + //- Return the name of phi + const word& phiName() const + { + return phiName_; + } + + //- Return reference to the name of phi to allow adjustment + word& phiName() + { + return phiName_; + } + + //- Update the coefficients associated with the patch field virtual void updateCoeffs(); @@ -136,10 +167,7 @@ public: // Member operators - virtual void operator=(const fvPatchField& pvf) - { - fvPatchField::operator=(pvf); - } + virtual void operator=(const fvPatchField& pvf); }; diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureNormalInletOutletVelocity/pressureNormalInletOutletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressureNormalInletOutletVelocity/pressureNormalInletOutletVelocityFvPatchVectorField.C new file mode 100644 index 0000000000..30b7b12ff7 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureNormalInletOutletVelocity/pressureNormalInletOutletVelocityFvPatchVectorField.C @@ -0,0 +1,201 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "pressureNormalInletOutletVelocityFvPatchVectorField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "surfaceFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +pressureNormalInletOutletVelocityFvPatchVectorField:: +pressureNormalInletOutletVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF +) +: + mixedFvPatchVectorField(p, iF), + phiName_("phi"), + rhoName_("rho") +{ + refValue() = *this; + refGrad() = vector::zero; + valueFraction() = 0.0; +} + + +pressureNormalInletOutletVelocityFvPatchVectorField:: +pressureNormalInletOutletVelocityFvPatchVectorField +( + const pressureNormalInletOutletVelocityFvPatchVectorField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchVectorField(ptf, p, iF, mapper), + phiName_(ptf.phiName_), + rhoName_(ptf.rhoName_) +{} + + +pressureNormalInletOutletVelocityFvPatchVectorField:: +pressureNormalInletOutletVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + mixedFvPatchVectorField(p, iF), + phiName_(dict.lookupOrDefault("phi", "phi")), + rhoName_(dict.lookupOrDefault("rho", "rho")) +{ + fvPatchVectorField::operator=(vectorField("value", dict, p.size())); + refValue() = *this; + refGrad() = vector::zero; + valueFraction() = 0.0; +} + + +pressureNormalInletOutletVelocityFvPatchVectorField:: +pressureNormalInletOutletVelocityFvPatchVectorField +( + const pressureNormalInletOutletVelocityFvPatchVectorField& pivpvf +) +: + mixedFvPatchVectorField(pivpvf), + phiName_(pivpvf.phiName_), + rhoName_(pivpvf.rhoName_) +{} + + +pressureNormalInletOutletVelocityFvPatchVectorField:: +pressureNormalInletOutletVelocityFvPatchVectorField +( + const pressureNormalInletOutletVelocityFvPatchVectorField& pivpvf, + const DimensionedField& iF +) +: + mixedFvPatchVectorField(pivpvf, iF), + phiName_(pivpvf.phiName_), + rhoName_(pivpvf.rhoName_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void pressureNormalInletOutletVelocityFvPatchVectorField::updateCoeffs() +{ + if (updated()) + { + return; + } + + const surfaceScalarField& phi = + db().lookupObject(phiName_); + + const fvsPatchField& phip = + patch().patchField(phi); + + vectorField n = patch().nf(); + const Field& magS = patch().magSf(); + + if (phi.dimensions() == dimVelocity*dimArea) + { + refValue() = n*phip/magS; + } + else if (phi.dimensions() == dimDensity*dimVelocity*dimArea) + { + const fvPatchField& rhop = + patch().lookupPatchField(rhoName_); + + refValue() = n*phip/(rhop*magS); + } + else + { + FatalErrorIn + ( + "pressureNormalInletOutletVelocityFvPatchVectorField::" + "updateCoeffs()" + ) << "dimensions of phi are not correct" + << "\n on patch " << this->patch().name() + << " of field " << this->dimensionedInternalField().name() + << " in file " << this->dimensionedInternalField().objectPath() + << exit(FatalError); + } + + valueFraction() = 1.0 - pos(phip); + + mixedFvPatchVectorField::updateCoeffs(); +} + + +void pressureNormalInletOutletVelocityFvPatchVectorField:: +write(Ostream& os) const +{ + fvPatchVectorField::write(os); + os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; + os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +void pressureNormalInletOutletVelocityFvPatchVectorField::operator= +( + const fvPatchField& pvf +) +{ + fvPatchField::operator= + ( + valueFraction()*(patch().nf()*(patch().nf() & pvf)) + + (1 - valueFraction())*pvf + ); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchVectorField, + pressureNormalInletOutletVelocityFvPatchVectorField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureNormalInletOutletVelocity/pressureNormalInletOutletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/pressureNormalInletOutletVelocity/pressureNormalInletOutletVelocityFvPatchVectorField.H new file mode 100644 index 0000000000..e1f576d012 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureNormalInletOutletVelocity/pressureNormalInletOutletVelocityFvPatchVectorField.H @@ -0,0 +1,191 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::pressureNormalInletOutletVelocityFvPatchVectorField + +Description + Velocity inlet/outlet boundary condition for patches where the pressure is + specified. zero-gradient is applied for outflow (as defined by the flux) + and for inflow the velocity is obtained from the flux with a direction + normal to the patch faces. + +SourceFiles + pressureNormalInletOutletVelocityFvPatchVectorField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef pressureNormalInletOutletVelocityFvPatchVectorField_H +#define pressureNormalInletOutletVelocityFvPatchVectorField_H + +#include "fvPatchFields.H" +#include "mixedFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class pressureNormalInletOutletVelocityFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class pressureNormalInletOutletVelocityFvPatchVectorField +: + public mixedFvPatchVectorField +{ + // Private data + + word phiName_; + word rhoName_; + + +public: + + //- Runtime type information + TypeName("pressureNormalInletOutletVelocity"); + + + // Constructors + + //- Construct from patch and internal field + pressureNormalInletOutletVelocityFvPatchVectorField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + pressureNormalInletOutletVelocityFvPatchVectorField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // pressureNormalInletOutletVelocityFvPatchVectorField + // onto a new patch + pressureNormalInletOutletVelocityFvPatchVectorField + ( + const pressureNormalInletOutletVelocityFvPatchVectorField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + pressureNormalInletOutletVelocityFvPatchVectorField + ( + const pressureNormalInletOutletVelocityFvPatchVectorField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new pressureNormalInletOutletVelocityFvPatchVectorField + ( + *this + ) + ); + } + + //- Construct as copy setting internal field reference + pressureNormalInletOutletVelocityFvPatchVectorField + ( + const pressureNormalInletOutletVelocityFvPatchVectorField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new pressureNormalInletOutletVelocityFvPatchVectorField + ( + *this, + iF + ) + ); + } + + + // Member functions + + // Access + + //- Return the name of rho + const word& rhoName() const + { + return rhoName_; + } + + //- Return reference to the name of rho to allow adjustment + word& rhoName() + { + return rhoName_; + } + + //- Return the name of phi + const word& phiName() const + { + return phiName_; + } + + + //- Return reference to the name of phi to allow adjustment + word& phiName() + { + return phiName_; + } + + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; + + + // Member operators + + virtual void operator=(const fvPatchField& pvf); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.H index e97cb203cf..86ef7a8961 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.H @@ -26,7 +26,10 @@ Class Foam::rotatingPressureInletOutletVelocityFvPatchVectorField Description - Foam::rotatingPressureInletOutletVelocityFvPatchVectorField + Velocity inlet/outlet boundary condition in a rotating frame + for patches where the pressure is specified. zero-gradient is applied for + outflow (as defined by the flux) and for inflow the velocity is obtained + from the flux with a direction normal to the patch faces. SourceFiles rotatingPressureInletOutletVelocityFvPatchVectorField.C diff --git a/src/finiteVolume/finiteVolume/convectionSchemes/gaussConvectionScheme/gaussConvectionScheme.C b/src/finiteVolume/finiteVolume/convectionSchemes/gaussConvectionScheme/gaussConvectionScheme.C index 90b8139264..6b0f66f245 100644 --- a/src/finiteVolume/finiteVolume/convectionSchemes/gaussConvectionScheme/gaussConvectionScheme.C +++ b/src/finiteVolume/finiteVolume/convectionSchemes/gaussConvectionScheme/gaussConvectionScheme.C @@ -22,8 +22,6 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - \*---------------------------------------------------------------------------*/ #include "gaussConvectionScheme.H" diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicholsonDdtScheme/CrankNicholsonDdtScheme.C b/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicholsonDdtScheme/CrankNicholsonDdtScheme.C index dbbda95fcf..f591376bf5 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicholsonDdtScheme/CrankNicholsonDdtScheme.C +++ b/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicholsonDdtScheme/CrankNicholsonDdtScheme.C @@ -978,14 +978,14 @@ CrankNicholsonDdtScheme::fvcDdtPhiCorr ddt0_ > ( "ddt0(" + U.name() + ')', - rho.dimensions()*U.dimensions() + U.dimensions() ); DDt0Field& dphidt0 = ddt0_ ( "ddt0(" + phi.name() + ')', - phi.dimensions() + U.dimensions()*dimArea ); IOobject ddtIOobject diff --git a/src/meshTools/directMapped/directMappedPolyPatch/directMappedPolyPatch.C b/src/meshTools/directMapped/directMappedPolyPatch/directMappedPolyPatch.C index 83f621363e..e519da59d9 100644 --- a/src/meshTools/directMapped/directMappedPolyPatch/directMappedPolyPatch.C +++ b/src/meshTools/directMapped/directMappedPolyPatch/directMappedPolyPatch.C @@ -29,6 +29,8 @@ License #include "ListListOps.H" #include "meshSearch.H" #include "mapDistribute.H" +#include "meshTools.H" +#include "OFstream.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -47,16 +49,18 @@ void Foam::directMappedPolyPatch::collectSamples ( pointField& samples, labelList& patchFaceProcs, - labelList& patchFaces + labelList& patchFaces, + pointField& patchFc ) const { - const vectorField::subField fc = this->faceCentres(); // Collect all sample points and the faces they come from. + List globalFc(Pstream::nProcs()); List globalSamples(Pstream::nProcs()); labelListList globalFaces(Pstream::nProcs()); - globalSamples[Pstream::myProcNo()] = fc+offset_; + globalFc[Pstream::myProcNo()] = this->faceCentres(); + globalSamples[Pstream::myProcNo()] = globalFc[Pstream::myProcNo()]+offset_; globalFaces[Pstream::myProcNo()] = identity(size()); // Distribute to all processors @@ -64,6 +68,8 @@ void Foam::directMappedPolyPatch::collectSamples Pstream::scatterList(globalSamples); Pstream::gatherList(globalFaces); Pstream::scatterList(globalFaces); + Pstream::gatherList(globalFc); + Pstream::scatterList(globalFc); // Rework into straight list samples = ListListOps::combine @@ -76,6 +82,11 @@ void Foam::directMappedPolyPatch::collectSamples globalFaces, accessOp() ); + patchFc = ListListOps::combine + ( + globalFc, + accessOp() + ); patchFaceProcs.setSize(patchFaces.size()); labelList nPerProc @@ -103,11 +114,14 @@ void Foam::directMappedPolyPatch::findSamples ( const pointField& samples, labelList& sampleCellProcs, - labelList& sampleCells + labelList& sampleCells, + pointField& sampleCc ) const { sampleCellProcs.setSize(samples.size()); sampleCells.setSize(samples.size()); + sampleCc.setSize(samples.size()); + sampleCc = point(-GREAT, -GREAT, -GREAT); { // Octree based search engine @@ -124,6 +138,8 @@ void Foam::directMappedPolyPatch::findSamples else { sampleCellProcs[sampleI] = Pstream::myProcNo(); + sampleCc[sampleI] = + boundaryMesh().mesh().cellCentres()[sampleCells[sampleI]]; } } } @@ -136,6 +152,9 @@ void Foam::directMappedPolyPatch::findSamples Pstream::listCombineGather(sampleCellProcs, maxEqOp