mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop
This commit is contained in:
@ -30,6 +30,26 @@ Group
|
||||
Description
|
||||
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"
|
||||
@ -356,6 +376,8 @@ int main(int argc, char *argv[])
|
||||
const bool checkSelfIntersect = args.optionFound("checkSelfIntersection");
|
||||
const bool verbose = args.optionFound("verbose");
|
||||
const bool splitNonManifold = args.optionFound("splitNonManifold");
|
||||
label outputThreshold = 10;
|
||||
args.optionReadIfPresent("outputThreshold", outputThreshold);
|
||||
|
||||
Info<< "Reading surface from " << surfFileName << " ..." << nl << endl;
|
||||
|
||||
@ -465,10 +487,14 @@ int main(int argc, char *argv[])
|
||||
Info<< "Surface has " << illegalFaces.size()
|
||||
<< " illegal triangles." << endl;
|
||||
|
||||
OFstream str("illegalFaces");
|
||||
Info<< "Dumping conflicting face labels to " << str.name() << endl
|
||||
<< "Paste this into the input for surfaceSubset" << endl;
|
||||
str << illegalFaces;
|
||||
if (outputThreshold > 0)
|
||||
{
|
||||
OFstream str("illegalFaces");
|
||||
Info<< "Dumping conflicting face labels to " << str.name()
|
||||
<< endl
|
||||
<< "Paste this into the input for surfaceSubset" << endl;
|
||||
str << illegalFaces;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -543,6 +569,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// Dump for subsetting
|
||||
if (outputThreshold > 0)
|
||||
{
|
||||
DynamicList<label> problemFaces(surf.size()/100+1);
|
||||
|
||||
@ -723,12 +750,15 @@ int main(int argc, char *argv[])
|
||||
|
||||
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
|
||||
<< "Paste this into the input for surfaceSubset" << endl;
|
||||
Info<< "Dumping conflicting face labels to " << str.name() << endl
|
||||
<< "Paste this into the input for surfaceSubset" << endl;
|
||||
|
||||
str << problemFaces;
|
||||
str << problemFaces;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -760,7 +790,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "Number of unconnected parts : " << numZones << endl;
|
||||
|
||||
if (numZones > 1)
|
||||
if (numZones > 1 && outputThreshold > 0)
|
||||
{
|
||||
Info<< "Splitting surface into parts ..." << endl << endl;
|
||||
|
||||
@ -768,7 +798,7 @@ int main(int argc, char *argv[])
|
||||
writeParts
|
||||
(
|
||||
surf,
|
||||
numZones,
|
||||
min(outputThreshold, numZones),
|
||||
faceZone,
|
||||
surfFilePath,
|
||||
surfFileNameBase
|
||||
@ -808,15 +838,26 @@ int main(int argc, char *argv[])
|
||||
if (numNormalZones > 1)
|
||||
{
|
||||
Info<< "More than one normal orientation." << endl;
|
||||
writeZoning(surf, normalZone, "normal", surfFilePath, surfFileNameBase);
|
||||
writeParts
|
||||
(
|
||||
surf,
|
||||
numNormalZones,
|
||||
normalZone,
|
||||
surfFilePath,
|
||||
surfFileNameBase + "_normal"
|
||||
);
|
||||
|
||||
if (outputThreshold > 0)
|
||||
{
|
||||
writeZoning
|
||||
(
|
||||
surf,
|
||||
normalZone,
|
||||
"normal",
|
||||
surfFilePath,
|
||||
surfFileNameBase
|
||||
);
|
||||
writeParts
|
||||
(
|
||||
surf,
|
||||
min(outputThreshold, numNormalZones),
|
||||
normalZone,
|
||||
surfFilePath,
|
||||
surfFileNameBase + "_normal"
|
||||
);
|
||||
}
|
||||
}
|
||||
Info<< endl;
|
||||
|
||||
@ -833,7 +874,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
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;
|
||||
|
||||
@ -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++;
|
||||
}
|
||||
}
|
||||
@ -870,36 +915,13 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Info<< "Surface is self-intersecting at " << nInt
|
||||
<< " locations." << endl;
|
||||
Info<< "Writing intersection points to " << intStream.name()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
//surfaceIntersection inter(querySurf);
|
||||
//
|
||||
//if (inter.cutEdges().empty() && inter.cutPoints().empty())
|
||||
//{
|
||||
// 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;
|
||||
// }
|
||||
//}
|
||||
if (intStreamPtr.valid())
|
||||
{
|
||||
Info<< "Writing intersection points to "
|
||||
<< intStreamPtr().name() << endl;
|
||||
}
|
||||
}
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
@ -106,11 +106,19 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
//- Return reference, without checking pointer validity.
|
||||
inline T& refOrNull();
|
||||
//- Return the pointer, without nullptr checking.
|
||||
// Pointer remains under autoPtr management.
|
||||
inline T* rawPtr();
|
||||
|
||||
//- Return const reference, without checking pointer validity.
|
||||
inline const T& refOrNull() const;
|
||||
//- Const access to the pointer, without nullptr checking.
|
||||
// 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
|
||||
|
||||
@ -130,14 +130,28 @@ inline void Foam::autoPtr<T>::clear()
|
||||
|
||||
|
||||
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_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const T& Foam::autoPtr<T>::refOrNull() const
|
||||
inline const T& Foam::autoPtr<T>::rawRef() const
|
||||
{
|
||||
return *ptr_;
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
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")
|
||||
.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_)
|
||||
{
|
||||
@ -146,7 +152,13 @@ Foam::wallDist::wallDist
|
||||
static_cast<const fvSchemes&>(mesh).subDict(patchTypeName_ & "Dist")
|
||||
.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_)
|
||||
{
|
||||
@ -185,8 +197,21 @@ const Foam::volVectorField& Foam::wallDist::n() const
|
||||
|
||||
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_)
|
||||
{
|
||||
return pdm_->correct(y_, n_.ref());
|
||||
@ -206,6 +231,12 @@ bool Foam::wallDist::movePoints()
|
||||
void Foam::wallDist::updateMesh(const mapPolyMesh& 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();
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -37,6 +37,10 @@ Description
|
||||
// Optional entry enabling the calculation
|
||||
// of the normal-to-wall field
|
||||
nRequired false;
|
||||
|
||||
// Optional entry delaying wall distance update to every n steps
|
||||
// Default is 1 (update every step)
|
||||
updateInterval 5;
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
@ -90,6 +94,12 @@ class wallDist
|
||||
//- Normal-to-wall field
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user