Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev

This commit is contained in:
Sergio Ferraris
2013-06-10 15:18:02 +01:00
14 changed files with 286 additions and 121 deletions

View File

@ -26,21 +26,18 @@ Application
Description Description
Combination of heatConductionFoam and buoyantFoam for conjugate heat Combination of heatConductionFoam and buoyantFoam for conjugate heat
transfer between a solid region and fluid region. It includes transfer between solid regions and fluid regions. Both regions include
porous media in the primary fluid region treated explicitly. the fvOptions framework.
It handles secondary fluid or solid circuits which can be coupled It handles secondary fluid or solid circuits which can be coupled
thermally with the main fluid region. i.e radiators, etc. thermally with the main fluid region. i.e radiators, etc.
The secondary fluid region is
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "fvCFD.H" #include "fvCFD.H"
#include "rhoThermo.H" #include "rhoThermo.H"
#include "turbulenceModel.H" #include "turbulenceModel.H"
#include "fixedGradientFvPatchFields.H" #include "fixedGradientFvPatchFields.H"
#include "zeroGradientFvPatchFields.H"
#include "regionProperties.H" #include "regionProperties.H"
#include "compressibleCourantNo.H" #include "compressibleCourantNo.H"
#include "solidRegionDiffNo.H" #include "solidRegionDiffNo.H"

View File

@ -30,7 +30,7 @@ Description
Sub-models include: Sub-models include:
- turbulence modelling, i.e. laminar, RAS or LES - 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
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/

View File

@ -653,6 +653,36 @@ int main(int argc, char *argv[])
Info<< "Checking self-intersection." << endl; Info<< "Checking self-intersection." << endl;
triSurfaceSearch querySurf(surf); triSurfaceSearch querySurf(surf);
//{
// OBJstream intStream("selfInter2.obj");
// const indexedOctree<treeDataTriSurface>& 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); surfaceIntersection inter(querySurf);
if (inter.cutEdges().empty() && inter.cutPoints().empty()) if (inter.cutEdges().empty() && inter.cutPoints().empty())

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License 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() void ${typeName}FunctionObject::write()
{ {
if (${verbose:-false}) if (${verbose:-false})

View File

@ -127,6 +127,9 @@ public:
//- Write, execute the "writeCalls" //- Write, execute the "writeCalls"
virtual void write(); virtual void write();
//- Called when time was set at the end of the Time::operator++
virtual void timeSet();
//- Update for changes of mesh //- Update for changes of mesh
virtual void updateMesh(const mapPolyMesh&) virtual void updateMesh(const mapPolyMesh&)
{} {}

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -27,6 +27,7 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "scalarField.H" #include "scalarField.H"
#include "unitConversion.H"
#define TEMPLATE #define TEMPLATE
#include "FieldFunctionsM.C" #include "FieldFunctionsM.C"
@ -155,6 +156,11 @@ UNARY_FUNCTION(scalar, scalar, j1)
UNARY_FUNCTION(scalar, scalar, y0) UNARY_FUNCTION(scalar, scalar, y0)
UNARY_FUNCTION(scalar, scalar, y1) 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) \ #define BesselFunc(func) \
void func(scalarField& res, const int n, const UList<scalar>& sf) \ void func(scalarField& res, const int n, const UList<scalar>& sf) \

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -130,6 +130,10 @@ UNARY_FUNCTION(scalar, scalar, j1)
UNARY_FUNCTION(scalar, scalar, y0) UNARY_FUNCTION(scalar, scalar, y0)
UNARY_FUNCTION(scalar, scalar, y1) 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) \ #define BesselFunc(func) \
void func(scalarField& Res, const int n, const UList<scalar>& sf); \ void func(scalarField& Res, const int n, const UList<scalar>& sf); \

View File

@ -63,16 +63,6 @@ public:
const vectorField& cellCtrs const vectorField& cellCtrs
); );
// static tmp<scalarField> faceOrthogonality(const polyMesh& mesh)
// {
// return faceOrthogonality
// (
// mesh,
// mesh.faceAreas(),
// mesh.cellCentres()
// );
// }
//- Generate skewness field //- Generate skewness field
static tmp<scalarField> faceSkewness static tmp<scalarField> faceSkewness
( (
@ -83,18 +73,6 @@ public:
const vectorField& cellCtrs const vectorField& cellCtrs
); );
// static tmp<scalarField> faceSkewness(const polyMesh& mesh)
// {
// return faceSkewness
// (
// mesh,
// mesh.points(),
// mesh.faceCentres(),
// mesh.faceAreas(),
// mesh.cellCentres()
// );
// }
//- Generate interpolation factors field //- Generate interpolation factors field
static tmp<scalarField> faceWeights static tmp<scalarField> faceWeights
( (

View File

@ -66,76 +66,6 @@ void Foam::treeDataPrimitivePatch<PatchType>::update()
} }
template<class PatchType>
bool Foam::treeDataPrimitivePatch<PatchType>::findIntersection
(
const indexedOctree<treeDataPrimitivePatch<PatchType> >& tree,
const label index,
const point& start,
const point& end,
point& intersectionPoint
)
{
const treeDataPrimitivePatch<PatchType>& 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 * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components // Construct from components
@ -187,6 +117,19 @@ Foam::treeDataPrimitivePatch<PatchType>::findAllIntersectOp::findAllIntersectOp
{} {}
template<class PatchType>
Foam::treeDataPrimitivePatch<PatchType>::
findSelfIntersectOp::findSelfIntersectOp
(
const indexedOctree<treeDataPrimitivePatch<PatchType> >& tree,
const label edgeID
)
:
tree_(tree),
edgeID_(edgeID)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class PatchType> template<class PatchType>
@ -645,4 +588,116 @@ bool Foam::treeDataPrimitivePatch<PatchType>::findAllIntersectOp::operator()
} }
template<class PatchType>
bool Foam::treeDataPrimitivePatch<PatchType>::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<PatchType>& 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<class PatchType>
bool Foam::treeDataPrimitivePatch<PatchType>::findIntersection
(
const indexedOctree<treeDataPrimitivePatch<PatchType> >& tree,
const label index,
const point& start,
const point& end,
point& intersectionPoint
)
{
const treeDataPrimitivePatch<PatchType>& 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;
}
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -86,16 +86,6 @@ class treeDataPrimitivePatch
//- Initialise all member data //- Initialise all member data
void update(); void update();
//- Find intersection of line with shapes
static bool findIntersection
(
const indexedOctree<treeDataPrimitivePatch<PatchType> >& tree,
const label index,
const point& start,
const point& end,
point& intersectionPoint
);
public: public:
@ -141,8 +131,8 @@ public:
findIntersectOp(const indexedOctree<treeDataPrimitivePatch>& tree); findIntersectOp(const indexedOctree<treeDataPrimitivePatch>& tree);
//- Calculate intersection of triangle with ray. Sets result //- Calculate intersection of any face with ray. Sets result
// accordingly // accordingly. Used to find first intersection.
bool operator() bool operator()
( (
const label index, const label index,
@ -167,8 +157,34 @@ public:
DynamicList<label>& shapeMask DynamicList<label>& shapeMask
); );
//- Calculate intersection of triangle with ray. Sets result //- Calculate intersection of unique face with ray. Sets result
// accordingly // accordingly. Used to find all faces.
bool operator()
(
const label index,
const point& start,
const point& end,
point& intersectionPoint
) const;
};
class findSelfIntersectOp
{
const indexedOctree<treeDataPrimitivePatch>& tree_;
const label edgeID_;
public:
findSelfIntersectOp
(
const indexedOctree<treeDataPrimitivePatch>& tree,
const label edgeID
);
//- Calculate intersection of face with edge of patch. Excludes
// faces that use edgeID. Used to find self intersection.
bool operator() bool operator()
( (
const label index, const label index,
@ -234,6 +250,16 @@ public:
const point& centre, const point& centre,
const scalar radiusSqr const scalar radiusSqr
) const; ) const;
//- Helper: find intersection of line with shapes
static bool findIntersection
(
const indexedOctree<treeDataPrimitivePatch<PatchType> >& tree,
const label index,
const point& start,
const point& end,
point& intersectionPoint
);
}; };

View File

@ -203,10 +203,6 @@ void Foam::distributedTriSurfaceMesh::distributeSegment
List<DynamicList<label> >& sendMap List<DynamicList<label> >& sendMap
) const ) const
{ {
// Work points
point clipPt;
// 1. Fully local already handled outside. Note: retest is cheap. // 1. Fully local already handled outside. Note: retest is cheap.
if (isLocal(procBb_[Pstream::myProcNo()], start, end)) if (isLocal(procBb_[Pstream::myProcNo()], start, end))
{ {
@ -247,6 +243,9 @@ void Foam::distributedTriSurfaceMesh::distributeSegment
// Scheme a: any processor that intersects the segment gets // Scheme a: any processor that intersects the segment gets
// the segment. // the segment.
// Intersection point
point clipPt;
if (bb.intersects(start, end, clipPt)) if (bb.intersects(start, end, clipPt))
{ {
sendMap[procI].append(allSegments.size()); sendMap[procI].append(allSegments.size());

View File

@ -61,6 +61,7 @@ void Foam::codedFunctionObject::prepare
dynCode.setFilterVariable("codeExecute", codeExecute_); dynCode.setFilterVariable("codeExecute", codeExecute_);
dynCode.setFilterVariable("codeEnd", codeEnd_); dynCode.setFilterVariable("codeEnd", codeEnd_);
dynCode.setFilterVariable("codeData", codeData_); dynCode.setFilterVariable("codeData", codeData_);
dynCode.setFilterVariable("codeTimeSet", codeTimeSet_);
//dynCode.setFilterVariable("codeWrite", codeWrite_); //dynCode.setFilterVariable("codeWrite", codeWrite_);
// compile filtered C template // compile filtered C template
@ -187,7 +188,8 @@ bool Foam::codedFunctionObject::end()
bool Foam::codedFunctionObject::timeSet() bool Foam::codedFunctionObject::timeSet()
{ {
return false; updateLibrary(redirectType_);
return redirectFunctionObject().timeSet();
} }
@ -267,6 +269,24 @@ bool Foam::codedFunctionObject::read(const dictionary& dict)
); );
} }
const entry* timeSetPtr = dict.lookupEntryPtr
(
"codeTimeSet",
false,
false
);
if (timeSetPtr)
{
codeTimeSet_ = stringOps::trim(timeSetPtr->stream());
stringOps::inplaceExpand(codeTimeSet_, dict);
dynamicCodeContext::addLineDirective
(
codeTimeSet_,
timeSetPtr->startLineNumber(),
dict.name()
);
}
updateLibrary(redirectType_); updateLibrary(redirectType_);
return redirectFunctionObject().read(dict); return redirectFunctionObject().read(dict);
} }

View File

@ -31,6 +31,39 @@ Description
This function object provides a general interface to enable dynamic code This function object provides a general interface to enable dynamic code
compilation. compilation.
The entries are
code : c++; upon functionObject::write()
codeInclude : include files
codeOptions : include paths; inserted into EXE_INC in Make/options
codeLibs : link line; inserted into LIB_LIBS in Make/options
codeExecute : c++;upon functionObject::execute();
codeRead : c++; upon functionObject::read();
codeEnd : c++; upon functionObject::end();
codeData : c++; local member data (null constructed);
codeTimeSet : c++; upon functionObject::timeSet();
localCode : c++; local static functions
Example of function object specification:
\verbatim
difference
{
functionObjectLibs ("libutilityFunctionObjects.so");
type coded;
// Name of on-the-fly generated functionObject
redirectType writeMagU;
code
#{
// Lookup U
const volVectorField& U = mesh().lookupObject<volVectorField>("U");
// Write
mag(U).write();
}
}
\endverbatim
SeeAlso SeeAlso
Foam::functionObject Foam::functionObject
Foam::OutputFilterFunctionObject Foam::OutputFilterFunctionObject
@ -77,6 +110,7 @@ protected:
string codeRead_; string codeRead_;
string codeExecute_; string codeExecute_;
string codeEnd_; string codeEnd_;
string codeTimeSet_;
//- Underlying functionObject //- Underlying functionObject
mutable autoPtr<functionObject> redirectFunctionObjectPtr_; mutable autoPtr<functionObject> redirectFunctionObjectPtr_;

View File

@ -80,7 +80,7 @@ public:
//- Construct null //- Construct null
inline deltaData(); inline deltaData();
//- Construct from origin, yStar, distance //- Construct from delta value
inline deltaData(const scalar delta); inline deltaData(const scalar delta);