diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/Make/options b/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/Make/options index 365e64d1b1..ca2936633a 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/Make/options +++ b/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/Make/options @@ -1,5 +1,8 @@ EXE_INC = \ -I../buoyantBoussinesqSimpleFoam \ + -I$(LIB_SRC)/sampling/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/fvOptions/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/turbulenceModels \ -I$(LIB_SRC)/turbulenceModels/incompressible/RAS/lnInclude \ @@ -9,6 +12,8 @@ EXE_INC = \ EXE_LIBS = \ -lfiniteVolume \ + -lfvOptions \ + -lsampling \ -lmeshTools \ -lincompressibleTurbulenceModel \ -lincompressibleRASModels \ diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/TEqn.H b/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/TEqn.H index 65c92dab51..76b0ef0168 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/TEqn.H +++ b/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/TEqn.H @@ -11,12 +11,18 @@ - fvm::laplacian(alphaEff, T) == radiation->ST(rhoCpRef, T) + + fvOptions(T) ); TEqn.relax(); + + fvOptions.constrain(TEqn); + TEqn.solve(); radiation->correct(); + fvOptions.correct(T); + rhok = 1.0 - beta*(T - TRef); } diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/UEqn.H b/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/UEqn.H index 07f46ec998..92768088b9 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/UEqn.H +++ b/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/UEqn.H @@ -5,10 +5,14 @@ fvm::ddt(U) + fvm::div(phi, U) + turbulence->divDevReff(U) + == + fvOptions(U) ); UEqn.relax(); + fvOptions.constrain(UEqn); + if (pimple.momentumPredictor()) { solve @@ -23,4 +27,6 @@ )*mesh.magSf() ) ); + + fvOptions.correct(U); } diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/buoyantBoussinesqPimpleFoam.C b/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/buoyantBoussinesqPimpleFoam.C index 65dda0653e..6168082e1d 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/buoyantBoussinesqPimpleFoam.C +++ b/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/buoyantBoussinesqPimpleFoam.C @@ -48,8 +48,9 @@ Description #include "fvCFD.H" #include "singlePhaseTransportModel.H" #include "RASModel.H" -#include "pimpleControl.H" #include "radiationModel.H" +#include "fvIOoptionList.H" +#include "pimpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -61,6 +62,7 @@ int main(int argc, char *argv[]) #include "readGravitationalAcceleration.H" #include "createFields.H" #include "createIncompressibleRadiationModel.H" + #include "createFvOptions.H" #include "initContinuityErrs.H" #include "readTimeControls.H" #include "CourantNo.H" diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/Make/options b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/Make/options index 6905967f04..6a6311e47c 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/Make/options +++ b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/Make/options @@ -1,5 +1,8 @@ EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/fvOptions/lnInclude \ -I$(LIB_SRC)/turbulenceModels \ -I$(LIB_SRC)/turbulenceModels/incompressible/RAS/lnInclude \ -I$(LIB_SRC)/transportModels \ @@ -7,7 +10,9 @@ EXE_INC = \ EXE_LIBS = \ -lfiniteVolume \ + -lsampling \ -lmeshTools \ + -lfvOptions \ -lincompressibleTurbulenceModel \ -lincompressibleRASModels \ -lincompressibleTransportModels diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/TEqn.H b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/TEqn.H index a0c5d24b2b..c495e58285 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/TEqn.H +++ b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/TEqn.H @@ -8,10 +8,17 @@ ( fvm::div(phi, T) - fvm::laplacian(alphaEff, T) + == + fvOptions(T) ); TEqn.relax(); + + fvOptions.constrain(TEqn); + TEqn.solve(); + fvOptions.correct(T); + rhok = 1.0 - beta*(T - TRef); } diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/UEqn.H b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/UEqn.H index cbe464fc02..dd516edf2f 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/UEqn.H +++ b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/UEqn.H @@ -4,16 +4,20 @@ ( fvm::div(phi, U) + turbulence->divDevReff(U) + == + fvOptions(U) ); UEqn().relax(); + fvOptions.constrain(UEqn()); + if (simple.momentumPredictor()) { solve ( UEqn() - == + == fvc::reconstruct ( ( @@ -22,4 +26,6 @@ )*mesh.magSf() ) ); + + fvOptions.correct(U); } diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/buoyantBoussinesqSimpleFoam.C b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/buoyantBoussinesqSimpleFoam.C index 4fc37efd28..b0d2f98aeb 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/buoyantBoussinesqSimpleFoam.C +++ b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/buoyantBoussinesqSimpleFoam.C @@ -48,6 +48,7 @@ Description #include "fvCFD.H" #include "singlePhaseTransportModel.H" #include "RASModel.H" +#include "fvIOoptionList.H" #include "simpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -59,6 +60,7 @@ int main(int argc, char *argv[]) #include "createMesh.H" #include "readGravitationalAcceleration.H" #include "createFields.H" + #include "createFvOptions.H" #include "initContinuityErrs.H" simpleControl simple(mesh); diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C index 5297be327f..b2cd9ac54e 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C @@ -26,21 +26,18 @@ Application Description Combination of heatConductionFoam and buoyantFoam for conjugate heat - transfer between a solid region and fluid region. It includes - porous media in the primary fluid region treated explicitly. + transfer between solid regions and fluid regions. Both regions include + the fvOptions framework. It handles secondary fluid or solid circuits which can be coupled thermally with the main fluid region. i.e radiators, etc. - The secondary fluid region is - \*---------------------------------------------------------------------------*/ #include "fvCFD.H" #include "rhoThermo.H" #include "turbulenceModel.H" #include "fixedGradientFvPatchFields.H" -#include "zeroGradientFvPatchFields.H" #include "regionProperties.H" #include "compressibleCourantNo.H" #include "solidRegionDiffNo.H" diff --git a/applications/solvers/incompressible/pimpleFoam/pimpleFoam.C b/applications/solvers/incompressible/pimpleFoam/pimpleFoam.C index 000948514e..de963fe3b2 100644 --- a/applications/solvers/incompressible/pimpleFoam/pimpleFoam.C +++ b/applications/solvers/incompressible/pimpleFoam/pimpleFoam.C @@ -30,7 +30,7 @@ Description Sub-models include: - turbulence modelling, i.e. laminar, RAS or LES - - run-time selectable finitie volume options, e.g. MRF, explicit porosity + - run-time selectable finite volume options, e.g. MRF, explicit porosity \*---------------------------------------------------------------------------*/ diff --git a/applications/utilities/postProcessing/velocityField/Pe/Pe.C b/applications/utilities/postProcessing/velocityField/Pe/Pe.C index 0c4f61729c..544a116921 100644 --- a/applications/utilities/postProcessing/velocityField/Pe/Pe.C +++ b/applications/utilities/postProcessing/velocityField/Pe/Pe.C @@ -130,7 +130,7 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) mesh.magSf() * mesh.surfaceInterpolation::deltaCoeffs() * fvc::interpolate(RASModel->nuEff()) - ) + ) ) ); } @@ -192,8 +192,12 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) mesh, IOobject::NO_READ ), - mesh.surfaceInterpolation::deltaCoeffs() - * (mag(phi)/mesh.magSf())*(runTime.deltaT()/nu) + mag(phi) + /( + mesh.magSf() + * mesh.surfaceInterpolation::deltaCoeffs() + * nu + ) ) ); } @@ -317,8 +321,12 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) mesh, IOobject::NO_READ ), - mesh.surfaceInterpolation::deltaCoeffs() - * (mag(phi)/(mesh.magSf()))*(runTime.deltaT()/mu) + mag(phi) + /( + mesh.magSf() + * mesh.surfaceInterpolation::deltaCoeffs() + * mu + ) ) ); } @@ -330,26 +338,6 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) << abort(FatalError); } - - // can also check how many cells exceed a particular Pe limit - /* - { - label count = 0; - label PeLimit = 200; - forAll(PePtr(), i) - { - if (PePtr()[i] > PeLimit) - { - count++; - } - - } - - Info<< "Fraction > " << PeLimit << " = " - << scalar(count)/Pe.size() << endl; - } - */ - Info<< "Pe max : " << max(PePtr()).value() << endl; if (writeResults) diff --git a/applications/utilities/surface/surfaceCheck/surfaceCheck.C b/applications/utilities/surface/surfaceCheck/surfaceCheck.C index a017055958..29707e303c 100644 --- a/applications/utilities/surface/surfaceCheck/surfaceCheck.C +++ b/applications/utilities/surface/surfaceCheck/surfaceCheck.C @@ -653,6 +653,36 @@ int main(int argc, char *argv[]) Info<< "Checking self-intersection." << endl; triSurfaceSearch querySurf(surf); + + //{ + // OBJstream intStream("selfInter2.obj"); + // const indexedOctree& tree = querySurf.tree(); + // forAll(surf.edges(), edgeI) + // { + // const edge& e = surf.edges()[edgeI]; + // + // pointIndexHit hitInfo + // ( + // tree.findLine + // ( + // surf.points()[surf.meshPoints()[e[0]]], + // surf.points()[surf.meshPoints()[e[1]]], + // treeDataTriSurface::findSelfIntersectOp + // ( + // tree, + // edgeI + // ) + // ) + // ); + // + // if (hitInfo.hit()) + // { + // Pout<< "Found hit:" << hitInfo.hitPoint() << endl; + // intStream.write(hitInfo.hitPoint()); + // } + // } + //} + surfaceIntersection inter(querySurf); if (inter.cutEdges().empty() && inter.cutPoints().empty()) diff --git a/etc/codeTemplates/dynamicCode/functionObjectTemplate.C b/etc/codeTemplates/dynamicCode/functionObjectTemplate.C index b44bdfb8dc..91b31dda2b 100644 --- a/etc/codeTemplates/dynamicCode/functionObjectTemplate.C +++ b/etc/codeTemplates/dynamicCode/functionObjectTemplate.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 @@ -123,6 +123,19 @@ void ${typeName}FunctionObject::end() } +void ${typeName}FunctionObject::timeSet() +{ + if (${verbose:-false}) + { + Info<<"timeSet ${typeName} sha1: ${SHA1sum}\n"; + } + +//{{{ begin codeTime + ${codeTimeSet} +//}}} end code +} + + void ${typeName}FunctionObject::write() { if (${verbose:-false}) diff --git a/etc/codeTemplates/dynamicCode/functionObjectTemplate.H b/etc/codeTemplates/dynamicCode/functionObjectTemplate.H index 211c0868ec..a139f25a8b 100644 --- a/etc/codeTemplates/dynamicCode/functionObjectTemplate.H +++ b/etc/codeTemplates/dynamicCode/functionObjectTemplate.H @@ -127,6 +127,9 @@ public: //- Write, execute the "writeCalls" virtual void write(); + //- Called when time was set at the end of the Time::operator++ + virtual void timeSet(); + //- Update for changes of mesh virtual void updateMesh(const mapPolyMesh&) {} diff --git a/src/OpenFOAM/fields/Fields/Field/Field.C b/src/OpenFOAM/fields/Fields/Field/Field.C index 334eba8e41..7460dba215 100644 --- a/src/OpenFOAM/fields/Fields/Field/Field.C +++ b/src/OpenFOAM/fields/Fields/Field/Field.C @@ -677,6 +677,7 @@ template template void Foam::Field::operator=(const VectorSpace& vs) { + typedef VectorSpace VSType; TFOR_ALL_F_OP_S(Type, *this, =, VSType, vs) } diff --git a/src/OpenFOAM/fields/Fields/scalarField/scalarField.C b/src/OpenFOAM/fields/Fields/scalarField/scalarField.C index 96e41d9571..7ae37531de 100644 --- a/src/OpenFOAM/fields/Fields/scalarField/scalarField.C +++ b/src/OpenFOAM/fields/Fields/scalarField/scalarField.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 @@ -27,6 +27,7 @@ Description \*---------------------------------------------------------------------------*/ #include "scalarField.H" +#include "unitConversion.H" #define TEMPLATE #include "FieldFunctionsM.C" @@ -155,6 +156,11 @@ UNARY_FUNCTION(scalar, scalar, j1) UNARY_FUNCTION(scalar, scalar, y0) UNARY_FUNCTION(scalar, scalar, y1) +UNARY_FUNCTION(scalar, scalar, degToRad) +UNARY_FUNCTION(scalar, scalar, radToDeg) +UNARY_FUNCTION(scalar, scalar, atmToPa) +UNARY_FUNCTION(scalar, scalar, paToAtm) + #define BesselFunc(func) \ void func(scalarField& res, const int n, const UList& sf) \ diff --git a/src/OpenFOAM/fields/Fields/scalarField/scalarField.H b/src/OpenFOAM/fields/Fields/scalarField/scalarField.H index ff322d3fe4..f30938e9b6 100644 --- a/src/OpenFOAM/fields/Fields/scalarField/scalarField.H +++ b/src/OpenFOAM/fields/Fields/scalarField/scalarField.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 @@ -130,6 +130,10 @@ UNARY_FUNCTION(scalar, scalar, j1) UNARY_FUNCTION(scalar, scalar, y0) UNARY_FUNCTION(scalar, scalar, y1) +UNARY_FUNCTION(scalar, scalar, degToRad) +UNARY_FUNCTION(scalar, scalar, radToDeg) +UNARY_FUNCTION(scalar, scalar, atmToPa) +UNARY_FUNCTION(scalar, scalar, paToAtm) #define BesselFunc(func) \ void func(scalarField& Res, const int n, const UList& sf); \ diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshCheck/polyMeshTools.H b/src/OpenFOAM/meshes/polyMesh/polyMeshCheck/polyMeshTools.H index 7f23facd04..ef500b4b8b 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshCheck/polyMeshTools.H +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshCheck/polyMeshTools.H @@ -63,16 +63,6 @@ public: const vectorField& cellCtrs ); -// static tmp faceOrthogonality(const polyMesh& mesh) -// { -// return faceOrthogonality -// ( -// mesh, -// mesh.faceAreas(), -// mesh.cellCentres() -// ); -// } - //- Generate skewness field static tmp faceSkewness ( @@ -83,18 +73,6 @@ public: const vectorField& cellCtrs ); -// static tmp faceSkewness(const polyMesh& mesh) -// { -// return faceSkewness -// ( -// mesh, -// mesh.points(), -// mesh.faceCentres(), -// mesh.faceAreas(), -// mesh.cellCentres() -// ); -// } - //- Generate interpolation factors field static tmp faceWeights ( diff --git a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.C b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.C index 738f87d0a8..81d722a57b 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.C +++ b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.C @@ -88,7 +88,17 @@ Foam::porosityModel::porosityModel const word& cellZoneName ) : - MeshObject(mesh), + regIOobject + ( + IOobject + ( + name, + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ) + ), name_(name), mesh_(mesh), dict_(dict), diff --git a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.H b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.H index 36a5a9eafb..06df0bfdae 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.H +++ b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.H @@ -36,7 +36,6 @@ SourceFiles #ifndef porosityModel_H #define porosityModel_H -#include "MeshObject.H" #include "fvMesh.H" #include "dictionary.H" #include "fvMatricesFwd.H" @@ -56,7 +55,7 @@ namespace Foam class porosityModel : - public MeshObject + public regIOobject { private: diff --git a/src/meshTools/indexedOctree/treeDataEdge.C b/src/meshTools/indexedOctree/treeDataEdge.C index 4d0b9b4d81..2499380b32 100644 --- a/src/meshTools/indexedOctree/treeDataEdge.C +++ b/src/meshTools/indexedOctree/treeDataEdge.C @@ -109,8 +109,6 @@ Foam::treeDataEdge::findIntersectOp::findIntersectOp ( const indexedOctree& tree ) -: - tree_(tree) {} diff --git a/src/meshTools/indexedOctree/treeDataEdge.H b/src/meshTools/indexedOctree/treeDataEdge.H index 12fd0d6aa1..be82a2a09c 100644 --- a/src/meshTools/indexedOctree/treeDataEdge.H +++ b/src/meshTools/indexedOctree/treeDataEdge.H @@ -121,8 +121,6 @@ public: class findIntersectOp { - const indexedOctree& tree_; - public: findIntersectOp(const indexedOctree& tree); diff --git a/src/meshTools/indexedOctree/treeDataPoint.C b/src/meshTools/indexedOctree/treeDataPoint.C index fd7f4404b4..82a9bd257b 100644 --- a/src/meshTools/indexedOctree/treeDataPoint.C +++ b/src/meshTools/indexedOctree/treeDataPoint.C @@ -70,8 +70,6 @@ Foam::treeDataPoint::findIntersectOp::findIntersectOp ( const indexedOctree& tree ) -: - tree_(tree) {} diff --git a/src/meshTools/indexedOctree/treeDataPoint.H b/src/meshTools/indexedOctree/treeDataPoint.H index 020f60a11d..73cec8a212 100644 --- a/src/meshTools/indexedOctree/treeDataPoint.H +++ b/src/meshTools/indexedOctree/treeDataPoint.H @@ -104,8 +104,6 @@ public: class findIntersectOp { - const indexedOctree& tree_; - public: findIntersectOp(const indexedOctree& tree); diff --git a/src/meshTools/indexedOctree/treeDataPrimitivePatch.C b/src/meshTools/indexedOctree/treeDataPrimitivePatch.C index 488104a345..51e5252121 100644 --- a/src/meshTools/indexedOctree/treeDataPrimitivePatch.C +++ b/src/meshTools/indexedOctree/treeDataPrimitivePatch.C @@ -66,76 +66,6 @@ void Foam::treeDataPrimitivePatch::update() } -template -bool Foam::treeDataPrimitivePatch::findIntersection -( - const indexedOctree >& tree, - const label index, - const point& start, - const point& end, - point& intersectionPoint -) -{ - const treeDataPrimitivePatch& shape = tree.shapes(); - const PatchType& patch = shape.patch(); - - const pointField& points = patch.points(); - const typename PatchType::FaceType& f = patch[index]; - - // Do quick rejection test - if (shape.cacheBb_) - { - const treeBoundBox& faceBb = shape.bbs_[index]; - - if ((faceBb.posBits(start) & faceBb.posBits(end)) != 0) - { - // start and end in same block outside of faceBb. - return false; - } - } - - const vector dir(end - start); - pointHit inter; - - if (f.size() == 3) - { - inter = triPointRef - ( - points[f[0]], - points[f[1]], - points[f[2]] - ).intersection(start, dir, intersection::HALF_RAY, shape.planarTol_); - } - else - { - const pointField& faceCentres = patch.faceCentres(); - - inter = f.intersection - ( - start, - dir, - faceCentres[index], - points, - intersection::HALF_RAY, - shape.planarTol_ - ); - } - - if (inter.hit() && inter.distance() <= 1) - { - // Note: no extra test on whether intersection is in front of us - // since using half_ray - intersectionPoint = inter.hitPoint(); - - return true; - } - else - { - return false; - } -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // Construct from components @@ -187,6 +117,19 @@ Foam::treeDataPrimitivePatch::findAllIntersectOp::findAllIntersectOp {} +template +Foam::treeDataPrimitivePatch:: +findSelfIntersectOp::findSelfIntersectOp +( + const indexedOctree >& tree, + const label edgeID +) +: + tree_(tree), + edgeID_(edgeID) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template @@ -645,4 +588,116 @@ bool Foam::treeDataPrimitivePatch::findAllIntersectOp::operator() } +template +bool Foam::treeDataPrimitivePatch::findSelfIntersectOp::operator() +( + const label index, + const point& start, + const point& end, + point& intersectionPoint +) const +{ + if (edgeID_ == -1) + { + FatalErrorIn + ( + "findSelfIntersectOp::operator()\n" + "(\n" + " const label index,\n" + " const point& start,\n" + " const point& end,\n" + " point& intersectionPoint\n" + ") const" + ) << "EdgeID not set. Please set edgeID to the index of" + << " the edge you are testing" + << exit(FatalError); + } + + const treeDataPrimitivePatch& shape = tree_.shapes(); + const PatchType& patch = shape.patch(); + + const typename PatchType::FaceType& f = patch.localFaces()[index]; + const edge& e = patch.edges()[edgeID_]; + + if (findIndex(f, e[0]) == -1 && findIndex(f, e[1]) == -1) + { + return findIntersection(tree_, index, start, end, intersectionPoint); + } + else + { + return false; + } +} + + +template +bool Foam::treeDataPrimitivePatch::findIntersection +( + const indexedOctree >& tree, + const label index, + const point& start, + const point& end, + point& intersectionPoint +) +{ + const treeDataPrimitivePatch& shape = tree.shapes(); + const PatchType& patch = shape.patch(); + + const pointField& points = patch.points(); + const typename PatchType::FaceType& f = patch[index]; + + // Do quick rejection test + if (shape.cacheBb_) + { + const treeBoundBox& faceBb = shape.bbs_[index]; + + if ((faceBb.posBits(start) & faceBb.posBits(end)) != 0) + { + // start and end in same block outside of faceBb. + return false; + } + } + + const vector dir(end - start); + pointHit inter; + + if (f.size() == 3) + { + inter = triPointRef + ( + points[f[0]], + points[f[1]], + points[f[2]] + ).intersection(start, dir, intersection::HALF_RAY, shape.planarTol_); + } + else + { + const pointField& faceCentres = patch.faceCentres(); + + inter = f.intersection + ( + start, + dir, + faceCentres[index], + points, + intersection::HALF_RAY, + shape.planarTol_ + ); + } + + if (inter.hit() && inter.distance() <= 1) + { + // Note: no extra test on whether intersection is in front of us + // since using half_ray + intersectionPoint = inter.hitPoint(); + + return true; + } + else + { + return false; + } +} + + // ************************************************************************* // diff --git a/src/meshTools/indexedOctree/treeDataPrimitivePatch.H b/src/meshTools/indexedOctree/treeDataPrimitivePatch.H index 9d43d2ba85..18c901244e 100644 --- a/src/meshTools/indexedOctree/treeDataPrimitivePatch.H +++ b/src/meshTools/indexedOctree/treeDataPrimitivePatch.H @@ -86,16 +86,6 @@ class treeDataPrimitivePatch //- Initialise all member data void update(); - //- Find intersection of line with shapes - static bool findIntersection - ( - const indexedOctree >& tree, - const label index, - const point& start, - const point& end, - point& intersectionPoint - ); - public: @@ -141,8 +131,8 @@ public: findIntersectOp(const indexedOctree& tree); - //- Calculate intersection of triangle with ray. Sets result - // accordingly + //- Calculate intersection of any face with ray. Sets result + // accordingly. Used to find first intersection. bool operator() ( const label index, @@ -167,8 +157,34 @@ public: DynamicList