mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
GIT: Resolved conflict
This commit is contained in:
@ -1,3 +1,3 @@
|
||||
Test-namedEnum.C
|
||||
Test-NamedEnum.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-NamedEnum
|
||||
|
||||
@ -34,26 +34,28 @@ class namedEnumTest
|
||||
{
|
||||
public:
|
||||
|
||||
enum options
|
||||
enum option
|
||||
{
|
||||
a,
|
||||
b,
|
||||
c
|
||||
c,
|
||||
d
|
||||
};
|
||||
|
||||
static const Foam::NamedEnum<options, 3> namedEnum;
|
||||
static const Foam::NamedEnum<option, 4> namedEnum;
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
const char* Foam::NamedEnum<namedEnumTest::options, 3>::names[] =
|
||||
const char* Foam::NamedEnum<namedEnumTest::option, 4>::names[] =
|
||||
{
|
||||
"a",
|
||||
"b",
|
||||
"c"
|
||||
"c",
|
||||
"d"
|
||||
};
|
||||
|
||||
const Foam::NamedEnum<namedEnumTest::options, 3> namedEnumTest::namedEnum;
|
||||
const Foam::NamedEnum<namedEnumTest::option, 4> namedEnumTest::namedEnum;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -61,11 +63,47 @@ const Foam::NamedEnum<namedEnumTest::options, 3> namedEnumTest::namedEnum;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Info<< namedEnumTest::namedEnum["a"] << endl;
|
||||
Info<< namedEnumTest::namedEnum[namedEnumTest::a] << endl;
|
||||
const List<namedEnumTest::option> options
|
||||
= namedEnumTest::namedEnum.enums();
|
||||
|
||||
namedEnumTest::options hmm(namedEnumTest::namedEnum.read(Sin));
|
||||
Info<< namedEnumTest::namedEnum[hmm] << endl;
|
||||
Info<< "enums: " << options << nl;
|
||||
|
||||
Info<< "loop over enums (as list):" << nl;
|
||||
forAll(options, i)
|
||||
{
|
||||
const namedEnumTest::option& opt = options[i];
|
||||
|
||||
Info<< "option[" << opt
|
||||
<< "] = '" << namedEnumTest::namedEnum[opt] << "'" << nl;
|
||||
}
|
||||
|
||||
#if __cplusplus > 201100L
|
||||
// C++11
|
||||
Info<< "loop over enums (C++11 for range):" << nl;
|
||||
for (auto const& opt : options)
|
||||
{
|
||||
Info<< "option[" << opt
|
||||
<< "] = '" << namedEnumTest::namedEnum[opt] << "'" << nl;
|
||||
}
|
||||
#else
|
||||
Info<< "loop over enums (via iterator):" << nl;
|
||||
forAllConstIter(List<namedEnumTest::option>, options, iter)
|
||||
{
|
||||
const namedEnumTest::option& opt = *iter;
|
||||
|
||||
Info<< "option[" << opt
|
||||
<< "] = '" << namedEnumTest::namedEnum[opt] << "'" << nl;
|
||||
}
|
||||
#endif
|
||||
|
||||
Info<< nl
|
||||
<< namedEnumTest::namedEnum["a"] << nl
|
||||
<< namedEnumTest::namedEnum[namedEnumTest::a] << nl;
|
||||
|
||||
Info<< "--- test read construction ---" << endl;
|
||||
|
||||
namedEnumTest::option dummy(namedEnumTest::namedEnum.read(Sin));
|
||||
Info<< namedEnumTest::namedEnum[dummy] << endl;
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
@ -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,11 +487,15 @@ int main(int argc, char *argv[])
|
||||
Info<< "Surface has " << illegalFaces.size()
|
||||
<< " illegal triangles." << endl;
|
||||
|
||||
if (outputThreshold > 0)
|
||||
{
|
||||
OFstream str("illegalFaces");
|
||||
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;
|
||||
str << illegalFaces;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Surface has no illegal triangles." << endl;
|
||||
@ -543,6 +569,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// Dump for subsetting
|
||||
if (outputThreshold > 0)
|
||||
{
|
||||
DynamicList<label> problemFaces(surf.size()/100+1);
|
||||
|
||||
@ -723,6 +750,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "Conflicting face labels:" << problemFaces.size() << endl;
|
||||
|
||||
if (outputThreshold > 0)
|
||||
{
|
||||
OFstream str("problemFaces");
|
||||
|
||||
Info<< "Dumping conflicting face labels to " << str.name() << endl
|
||||
@ -730,6 +759,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
str << problemFaces;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Surface is closed. All edges connected to two faces." << endl;
|
||||
@ -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,16 +838,27 @@ int main(int argc, char *argv[])
|
||||
if (numNormalZones > 1)
|
||||
{
|
||||
Info<< "More than one normal orientation." << endl;
|
||||
writeZoning(surf, normalZone, "normal", surfFilePath, surfFileNameBase);
|
||||
|
||||
if (outputThreshold > 0)
|
||||
{
|
||||
writeZoning
|
||||
(
|
||||
surf,
|
||||
normalZone,
|
||||
"normal",
|
||||
surfFilePath,
|
||||
surfFileNameBase
|
||||
);
|
||||
writeParts
|
||||
(
|
||||
surf,
|
||||
numNormalZones,
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@ -120,4 +120,23 @@ Foam::wordList Foam::NamedEnum<Enum, nEnum>::words()
|
||||
}
|
||||
|
||||
|
||||
template<class Enum, int nEnum>
|
||||
Foam::List<Enum> Foam::NamedEnum<Enum, nEnum>::enums()
|
||||
{
|
||||
List<Enum> lst(nEnum);
|
||||
|
||||
label nElem = 0;
|
||||
for (int enumI = 0; enumI < nEnum; ++enumI)
|
||||
{
|
||||
if (names[enumI] && names[enumI][0])
|
||||
{
|
||||
lst[nElem++] = Enum(enumI);
|
||||
}
|
||||
}
|
||||
|
||||
lst.setSize(nElem);
|
||||
return lst;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -45,6 +45,9 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration
|
||||
template<class Enum, int> class NamedEnum;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class NamedEnum Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -60,10 +63,10 @@ class NamedEnum
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
NamedEnum(const NamedEnum&);
|
||||
NamedEnum(const NamedEnum&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const NamedEnum&);
|
||||
void operator=(const NamedEnum&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
@ -95,6 +98,9 @@ public:
|
||||
//- The set of names as a list of words
|
||||
static wordList words();
|
||||
|
||||
//- List of enumerations
|
||||
static List<Enum> enums();
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -108,6 +108,23 @@ public:
|
||||
inline void clear();
|
||||
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the pointer, without nullptr checking.
|
||||
// Pointer remains under autoPtr management.
|
||||
inline T* rawPtr();
|
||||
|
||||
//- 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
|
||||
|
||||
//- Return reference to the object data
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -129,6 +129,34 @@ inline void Foam::autoPtr<T>::clear()
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
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>::rawRef() const
|
||||
{
|
||||
return *ptr_;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
|
||||
@ -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.
|
||||
@ -100,7 +100,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_)
|
||||
{
|
||||
@ -148,7 +154,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_)
|
||||
{
|
||||
@ -187,8 +199,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());
|
||||
@ -208,6 +233,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-2016 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
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -1766,6 +1766,8 @@ void Foam::distributedTriSurfaceMesh::findLineAll
|
||||
e1.setSize(compactI);
|
||||
pointMap.setSize(compactI);
|
||||
|
||||
|
||||
label iter = 0;
|
||||
while (returnReduce(e0.size(), sumOp<label>()) > 0)
|
||||
{
|
||||
findLine
|
||||
@ -1791,7 +1793,12 @@ void Foam::distributedTriSurfaceMesh::findLineAll
|
||||
|
||||
point pt = hitInfo[i].hitPoint() + smallVec[pointI];
|
||||
|
||||
if (((pt-start[pointI])&dirVec[pointI]) <= magSqrDirVec[pointI])
|
||||
// Check current coordinate along ray
|
||||
scalar d = ((pt-start[pointI])&dirVec[pointI]);
|
||||
|
||||
// Note check for d>0. Very occasionally the octree will find
|
||||
// an intersection to the left of the ray due to tolerances.
|
||||
if (d > 0 && d <= magSqrDirVec[pointI])
|
||||
{
|
||||
e0[compactI] = pt;
|
||||
e1[compactI] = end[pointI];
|
||||
@ -1805,6 +1812,21 @@ void Foam::distributedTriSurfaceMesh::findLineAll
|
||||
e0.setSize(compactI);
|
||||
e1.setSize(compactI);
|
||||
pointMap.setSize(compactI);
|
||||
|
||||
iter++;
|
||||
|
||||
if (iter == 1000)
|
||||
{
|
||||
Pout<< "distributedTriSurfaceMesh::findLineAll :"
|
||||
<< " Exiting loop due to excessive number of"
|
||||
<< " intersections along ray"
|
||||
<< " start:" << UIndirectList<point>(start, pointMap)
|
||||
<< " end:" << UIndirectList<point>(end, pointMap)
|
||||
<< " e0:" << UIndirectList<point>(e0, pointMap)
|
||||
<< " e1:" << UIndirectList<point>(e1, pointMap)
|
||||
<< endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user