Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop

This commit is contained in:
Andrew Heather
2016-10-04 09:35:11 +01:00
5 changed files with 147 additions and 62 deletions

View File

@ -30,6 +30,26 @@ Group
Description Description
Checks geometric and topological quality of a surface. Checks geometric and topological quality of a surface.
Usage
- surfaceCheck surfaceFile [OPTION]
\param -checkSelfIntersection \n
Check for self-intersection.
\param -splitNonManifold \n
Split surface along non-manifold edges.
\param -verbose \n
Extra verbosity.
\param -blockMesh \n
Write vertices/blocks for tight-fitting 1 cell blockMeshDict.
\param -outputThreshold \<num files\> \n
Specifies upper limit for the number of files written. This is useful to
prevent surfaces with lots of disconnected parts to write lots of files.
Default is 10. A special case is 0 which prevents writing any files.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "triangle.H" #include "triangle.H"
@ -356,6 +376,8 @@ int main(int argc, char *argv[])
const bool checkSelfIntersect = args.optionFound("checkSelfIntersection"); const bool checkSelfIntersect = args.optionFound("checkSelfIntersection");
const bool verbose = args.optionFound("verbose"); const bool verbose = args.optionFound("verbose");
const bool splitNonManifold = args.optionFound("splitNonManifold"); const bool splitNonManifold = args.optionFound("splitNonManifold");
label outputThreshold = 10;
args.optionReadIfPresent("outputThreshold", outputThreshold);
Info<< "Reading surface from " << surfFileName << " ..." << nl << endl; Info<< "Reading surface from " << surfFileName << " ..." << nl << endl;
@ -465,10 +487,14 @@ int main(int argc, char *argv[])
Info<< "Surface has " << illegalFaces.size() Info<< "Surface has " << illegalFaces.size()
<< " illegal triangles." << endl; << " illegal triangles." << endl;
OFstream str("illegalFaces"); if (outputThreshold > 0)
Info<< "Dumping conflicting face labels to " << str.name() << endl {
<< "Paste this into the input for surfaceSubset" << endl; OFstream str("illegalFaces");
str << illegalFaces; Info<< "Dumping conflicting face labels to " << str.name()
<< endl
<< "Paste this into the input for surfaceSubset" << endl;
str << illegalFaces;
}
} }
else else
{ {
@ -543,6 +569,7 @@ int main(int argc, char *argv[])
} }
// Dump for subsetting // Dump for subsetting
if (outputThreshold > 0)
{ {
DynamicList<label> problemFaces(surf.size()/100+1); DynamicList<label> problemFaces(surf.size()/100+1);
@ -723,12 +750,15 @@ int main(int argc, char *argv[])
Info<< "Conflicting face labels:" << problemFaces.size() << endl; Info<< "Conflicting face labels:" << problemFaces.size() << endl;
OFstream str("problemFaces"); if (outputThreshold > 0)
{
OFstream str("problemFaces");
Info<< "Dumping conflicting face labels to " << str.name() << endl Info<< "Dumping conflicting face labels to " << str.name() << endl
<< "Paste this into the input for surfaceSubset" << endl; << "Paste this into the input for surfaceSubset" << endl;
str << problemFaces; str << problemFaces;
}
} }
else else
{ {
@ -760,7 +790,7 @@ int main(int argc, char *argv[])
Info<< "Number of unconnected parts : " << numZones << endl; Info<< "Number of unconnected parts : " << numZones << endl;
if (numZones > 1) if (numZones > 1 && outputThreshold > 0)
{ {
Info<< "Splitting surface into parts ..." << endl << endl; Info<< "Splitting surface into parts ..." << endl << endl;
@ -768,7 +798,7 @@ int main(int argc, char *argv[])
writeParts writeParts
( (
surf, surf,
numZones, min(outputThreshold, numZones),
faceZone, faceZone,
surfFilePath, surfFilePath,
surfFileNameBase surfFileNameBase
@ -808,15 +838,26 @@ int main(int argc, char *argv[])
if (numNormalZones > 1) if (numNormalZones > 1)
{ {
Info<< "More than one normal orientation." << endl; Info<< "More than one normal orientation." << endl;
writeZoning(surf, normalZone, "normal", surfFilePath, surfFileNameBase);
writeParts if (outputThreshold > 0)
( {
surf, writeZoning
numNormalZones, (
normalZone, surf,
surfFilePath, normalZone,
surfFileNameBase + "_normal" "normal",
); surfFilePath,
surfFileNameBase
);
writeParts
(
surf,
min(outputThreshold, numNormalZones),
normalZone,
surfFilePath,
surfFileNameBase + "_normal"
);
}
} }
Info<< endl; Info<< endl;
@ -833,7 +874,11 @@ int main(int argc, char *argv[])
const indexedOctree<treeDataTriSurface>& tree = querySurf.tree(); const indexedOctree<treeDataTriSurface>& tree = querySurf.tree();
OBJstream intStream("selfInterPoints.obj"); autoPtr<OBJstream> intStreamPtr;
if (outputThreshold > 0)
{
intStreamPtr.reset(new OBJstream("selfInterPoints.obj"));
}
label nInt = 0; label nInt = 0;
@ -855,9 +900,9 @@ int main(int argc, char *argv[])
) )
); );
if (hitInfo.hit()) if (hitInfo.hit() && intStreamPtr.valid())
{ {
intStream.write(hitInfo.hitPoint()); intStreamPtr().write(hitInfo.hitPoint());
nInt++; nInt++;
} }
} }
@ -870,36 +915,13 @@ int main(int argc, char *argv[])
{ {
Info<< "Surface is self-intersecting at " << nInt Info<< "Surface is self-intersecting at " << nInt
<< " locations." << endl; << " locations." << endl;
Info<< "Writing intersection points to " << intStream.name()
<< endl;
}
//surfaceIntersection inter(querySurf); if (intStreamPtr.valid())
// {
//if (inter.cutEdges().empty() && inter.cutPoints().empty()) Info<< "Writing intersection points to "
//{ << intStreamPtr().name() << endl;
// Info<< "Surface is not self-intersecting" << endl; }
//} }
//else
//{
// Info<< "Surface is self-intersecting" << endl;
// Info<< "Writing edges of intersection to selfInter.obj" << endl;
//
// OFstream intStream("selfInter.obj");
// forAll(inter.cutPoints(), cutPointI)
// {
// const point& pt = inter.cutPoints()[cutPointI];
//
// intStream << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z()
// << endl;
// }
// forAll(inter.cutEdges(), cutEdgeI)
// {
// const edge& e = inter.cutEdges()[cutEdgeI];
//
// intStream << "l " << e.start()+1 << ' ' << e.end()+1 << endl;
// }
//}
Info<< endl; Info<< endl;
} }

View File

@ -106,11 +106,19 @@ public:
// Access // Access
//- Return reference, without checking pointer validity. //- Return the pointer, without nullptr checking.
inline T& refOrNull(); // Pointer remains under autoPtr management.
inline T* rawPtr();
//- Return const reference, without checking pointer validity. //- Const access to the pointer, without nullptr checking.
inline const T& refOrNull() const; // Pointer remains under autoPtr management.
inline const T* rawPtr() const;
//- Return the reference, without nullptr checking.
inline T& rawRef();
//- Return the const reference, without nullptr checking.
inline const T& rawRef() const;
// Member operators // Member operators

View File

@ -130,14 +130,28 @@ inline void Foam::autoPtr<T>::clear()
template<class T> template<class T>
inline T& Foam::autoPtr<T>::refOrNull() inline T* Foam::autoPtr<T>::rawPtr()
{
return ptr_;
}
template<class T>
inline const T* Foam::autoPtr<T>::rawPtr() const
{
return ptr_;
}
template<class T>
inline T& Foam::autoPtr<T>::rawRef()
{ {
return *ptr_; return *ptr_;
} }
template<class T> template<class T>
inline const T& Foam::autoPtr<T>::refOrNull() const inline const T& Foam::autoPtr<T>::rawRef() const
{ {
return *ptr_; return *ptr_;
} }

View File

@ -3,7 +3,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) 2015-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -98,7 +98,13 @@ Foam::wallDist::wallDist(const fvMesh& mesh, const word& patchTypeName)
static_cast<const fvSchemes&>(mesh).subDict(patchTypeName_ & "Dist") static_cast<const fvSchemes&>(mesh).subDict(patchTypeName_ & "Dist")
.lookupOrDefault<Switch>("nRequired", false) .lookupOrDefault<Switch>("nRequired", false)
), ),
n_(volVectorField::null()) n_(volVectorField::null()),
updateInterval_
(
static_cast<const fvSchemes&>(mesh).subDict(patchTypeName_ & "Dist")
.lookupOrDefault<label>("updateInterval", 1)
),
requireUpdate_(true)
{ {
if (nRequired_) if (nRequired_)
{ {
@ -146,7 +152,13 @@ Foam::wallDist::wallDist
static_cast<const fvSchemes&>(mesh).subDict(patchTypeName_ & "Dist") static_cast<const fvSchemes&>(mesh).subDict(patchTypeName_ & "Dist")
.lookupOrDefault<Switch>("nRequired", false) .lookupOrDefault<Switch>("nRequired", false)
), ),
n_(volVectorField::null()) n_(volVectorField::null()),
updateInterval_
(
static_cast<const fvSchemes&>(mesh).subDict(patchTypeName_ & "Dist")
.lookupOrDefault<label>("updateInterval", 1)
),
requireUpdate_(true)
{ {
if (nRequired_) if (nRequired_)
{ {
@ -185,8 +197,21 @@ const Foam::volVectorField& Foam::wallDist::n() const
bool Foam::wallDist::movePoints() bool Foam::wallDist::movePoints()
{ {
if (pdm_->movePoints()) if
(
(updateInterval_ != 0)
&& ((mesh_.time().timeIndex() % updateInterval_) == 0)
)
{ {
requireUpdate_ = true;
}
if (requireUpdate_ && pdm_->movePoints())
{
DebugInfo<< "Updating wall distance" << endl;
requireUpdate_ = false;
if (nRequired_) if (nRequired_)
{ {
return pdm_->correct(y_, n_.ref()); return pdm_->correct(y_, n_.ref());
@ -206,6 +231,12 @@ bool Foam::wallDist::movePoints()
void Foam::wallDist::updateMesh(const mapPolyMesh& mpm) void Foam::wallDist::updateMesh(const mapPolyMesh& mpm)
{ {
pdm_->updateMesh(mpm); pdm_->updateMesh(mpm);
// Force update if performing topology change
// Note: needed?
// - field would have been mapped, so if using updateInterval option (!= 1)
// live with error associated of not updating and use mapped values?
requireUpdate_ = true;
movePoints(); movePoints();
} }

View File

@ -3,7 +3,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) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -37,6 +37,10 @@ Description
// Optional entry enabling the calculation // Optional entry enabling the calculation
// of the normal-to-wall field // of the normal-to-wall field
nRequired false; nRequired false;
// Optional entry delaying wall distance update to every n steps
// Default is 1 (update every step)
updateInterval 5;
} }
\endverbatim \endverbatim
@ -90,6 +94,12 @@ class wallDist
//- Normal-to-wall field //- Normal-to-wall field
mutable tmp<volVectorField> n_; mutable tmp<volVectorField> n_;
//- Update wall distance every updateInterval_ steps
const label updateInterval_;
//- Flag to indicate whether the wall distance requires updating
bool requireUpdate_;
// Private Member Functions // Private Member Functions