41 void Foam::conformationSurfaces::hasBoundedVolume
43 List<volumeType>& referenceVolumeTypes
47 label totalTriangles = 0;
51 const searchableSurface& surface(allGeometry_[surfaces_[
s]]);
55 surface.hasVolumeType()
57 normalVolumeTypes_[regionOffset_[
s]]
64 List<volumeType> vTypes
70 surface.getVolumeType(pts, vTypes);
72 referenceVolumeTypes[
s] = vTypes[0];
76 <<
" surface " << surface.name()
80 if (isA<triSurface>(surface))
82 const triSurface& triSurf = refCast<const triSurface>(surface);
86 Info<<
" Checking " << surface.name() <<
endl;
90 Info<<
" Index = " << surfaces_[
s] <<
endl;
91 Info<<
" Offset = " << regionOffset_[
s] <<
endl;
102 normalVolumeTypes_[patchID]
106 sum += triSurf[sI].area(surfPts);
113 Info<<
" has " << nBaffles <<
" baffles out of " 114 << triSurf.size() <<
" triangles" <<
endl;
116 totalTriangles += triSurf.size();
120 Info<<
" Sum of all the surface normals (if near zero, surface is" 121 <<
" probably closed):" <<
nl 122 <<
" Note: Does not include baffle surfaces in calculation" <<
nl 123 <<
" Sum = " <<
sum/(totalTriangles + small) <<
nl 124 <<
" mag(Sum) = " <<
mag(
sum)/(totalTriangles + small)
129 void Foam::conformationSurfaces::readFeatures
132 const dictionary& featureDict,
133 const word& surfaceName,
138 featureDict.lookupOrDefault<word>(
"featureMethod",
"none");
140 if (featureMethod ==
"extendedFeatureEdgeMesh")
142 fileName feMeshName(featureDict.lookup(
"extendedFeatureEdgeMesh"));
144 Info<<
" features: " << feMeshName <<
endl;
149 new extendedFeatureEdgeMesh
154 runTime_.time().constant(),
155 "extendedFeatureEdgeMesh",
165 else if (featureMethod ==
"extractFeatures")
167 const searchableSurface& surface = allGeometry_[surfaces_[surfI]];
169 Info<<
" features: " << surface.name()
170 <<
" of type " << surface.type()
171 <<
", id: " << featureIndex <<
endl;
173 autoPtr<searchableSurfaceFeatures> ssFeatures
178 if (ssFeatures().hasFeatures())
183 ssFeatures().features()
191 << surface.name() <<
" of type " 192 << surface.type() <<
" does not have features" 196 else if (featureMethod ==
"none")
203 <<
"No valid featureMethod found for surface " << surfaceName
204 <<
nl <<
"Use \"extendedFeatureEdgeMesh\" " 205 <<
"or \"extractFeatures\"." 210 void Foam::conformationSurfaces::readFeatures
212 const dictionary& featureDict,
213 const word& surfaceName,
218 featureDict.lookupOrDefault<word>(
"featureMethod",
"none");
220 if (featureMethod ==
"extendedFeatureEdgeMesh")
222 fileName feMeshName(featureDict.lookup(
"extendedFeatureEdgeMesh"));
224 Info<<
" features: " << feMeshName <<
", id: " << featureIndex
230 new extendedFeatureEdgeMesh
235 runTime_.time().constant(),
236 "extendedFeatureEdgeMesh",
246 else if (featureMethod ==
"none")
253 <<
"No valid featureMethod found for surface " << surfaceName
254 <<
nl <<
"Use \"extendedFeatureEdgeMesh\" " 255 <<
"or \"extractFeatures\"." 267 const searchableSurfaces& allGeometry,
268 const dictionary& surfaceConformationDict
272 allGeometry_(allGeometry),
274 insidePoint_(surfaceConformationDict.
lookup(
"insidePoint")),
276 allGeometryToSurfaces_(),
277 normalVolumeTypes_(),
283 referenceVolumeTypes_(0)
285 const dictionary& surfacesDict
287 surfaceConformationDict.subDict(
"geometryToConformTo")
290 const dictionary& additionalFeaturesDict
292 surfaceConformationDict.subDict(
"additionalFeatures")
301 forAll(allGeometry.names(), geomI)
303 const word& geomName = allGeometry_.names()[geomI];
305 if (surfacesDict.found(geomName))
311 const label nAddFeat = additionalFeaturesDict.size();
313 Info<<
nl <<
"Reading geometryToConformTo" <<
endl;
315 allGeometryToSurfaces_.setSize(allGeometry_.size(), -1);
317 normalVolumeTypes_.setSize(surfI);
318 surfaces_.setSize(surfI);
319 surfZones_.setSize(surfI);
322 features_.setSize(surfI + nAddFeat);
326 regionOffset_.setSize(surfI, 0);
328 PtrList<dictionary> globalPatchInfo(surfI);
329 List<Map<autoPtr<dictionary>>> regionPatchInfo(surfI);
330 List<sideVolumeType> globalVolumeTypes(surfI);
331 List<Map<sideVolumeType>> regionVolumeTypes(surfI);
333 HashSet<word> unmatchedKeys(surfacesDict.toc());
336 forAll(allGeometry_.names(), geomI)
338 const word& geomName = allGeometry_.names()[geomI];
340 const entry* ePtr = surfacesDict.lookupEntryPtr(geomName,
false,
true);
344 const dictionary& dict = ePtr->dict();
345 unmatchedKeys.erase(ePtr->keyword());
347 surfaces_[surfI] = geomI;
349 const searchableSurface& surface = allGeometry_[surfaces_[surfI]];
352 if (dict.found(
"faceZone"))
354 surfZones_.set(surfI,
new surfaceZonesInfo(surface, dict));
357 allGeometryToSurfaces_[surfaces_[surfI]] = surfI;
362 allGeometry_.regionNames()[surfaces_[surfI]];
364 patchNames_.
append(regionNames);
366 globalVolumeTypes[surfI] =
370 dict.lookupOrDefault<word>
378 if (!globalVolumeTypes[surfI])
380 if (!surface.hasVolumeType())
383 <<
"Non-baffle surface " 385 <<
" does not allow inside/outside queries." 386 <<
" This usually is an error." <<
endl;
391 if (dict.found(
"patchInfo"))
396 dict.subDict(
"patchInfo").clone()
408 const wordList& rNames = surface.regions();
410 if (dict.found(
"regions"))
412 const dictionary& regionsDict = dict.subDict(
"regions");
416 const word& regionName = rNames[regionI];
418 if (regionsDict.found(regionName))
420 Info<<
" region " << regionName <<
endl;
423 const dictionary& regionDict = regionsDict.subDict
428 if (regionDict.found(
"patchInfo"))
430 regionPatchInfo[surfI].insert
433 regionDict.subDict(
"patchInfo").clone()
437 regionVolumeTypes[surfI].insert
442 regionDict.lookupOrDefault<word>
445 extendedFeatureEdgeMesh::
448 globalVolumeTypes[surfI]
454 readFeatures(regionDict, regionName, featureI);
464 if (unmatchedKeys.size() > 0)
469 ) <<
"Not all entries in conformationSurfaces dictionary were used." 470 <<
" The following entries were not used : " 471 << unmatchedKeys.sortedToc()
481 regionOffset_[surfI] = nRegions;
483 const searchableSurface& surface = allGeometry_[surfaces_[surfI]];
484 nRegions += surface.regions().size();
488 patchInfo_.setSize(nRegions);
489 normalVolumeTypes_.setSize(nRegions);
493 const searchableSurface& surface = allGeometry_[surfaces_[surfI]];
495 label nRegions = surface.regions().size();
498 for (
label i = 0; i < nRegions; i++)
500 label globalRegionI = regionOffset_[surfI] + i;
501 normalVolumeTypes_[globalRegionI] = globalVolumeTypes[surfI];
502 if (globalPatchInfo.set(surfI))
507 globalPatchInfo[surfI].
clone()
514 label globalRegionI = regionOffset_[surfI] + iter.key();
516 normalVolumeTypes_[globalRegionI] =
517 regionVolumeTypes[surfI][iter.key()];
520 const Map<autoPtr<dictionary>>& localInfo = regionPatchInfo[surfI];
523 label globalRegionI = regionOffset_[surfI] + iter.key();
525 patchInfo_.set(globalRegionI, iter()().
clone());
531 if (!additionalFeaturesDict.empty())
533 Info<<
nl <<
"Reading additionalFeatures" <<
endl;
538 word featureName = iter().keyword();
542 const dictionary& featureSubDict
544 additionalFeaturesDict.subDict(featureName)
547 readFeatures(featureSubDict, featureName, featureI);
551 features_.setSize(featureI);
553 globalBounds_ = treeBoundBox
560 vector newSpan = 1
e-4*globalBounds_.span();
561 globalBounds_.min() -= newSpan;
562 globalBounds_.max() += newSpan;
568 referenceVolumeTypes_.setSize
575 <<
"Testing for insidePoint " << insidePoint_ <<
endl;
577 hasBoundedVolume(referenceVolumeTypes_);
581 Info<<
"Names = " << allGeometry_.names() <<
endl;
582 Info<<
"Surfaces = " << surfaces_ <<
endl;
583 Info<<
"AllGeom to Surfaces = " << allGeometryToSurfaces_ <<
endl;
584 Info<<
"Volume types = " << normalVolumeTypes_ <<
endl;
585 Info<<
"Patch names = " << patchNames_ <<
endl;
586 Info<<
"Region Offset = " << regionOffset_ <<
endl;
590 Info<< features_[fI].name() <<
endl;
608 if (allGeometry_[surfaces_[
s]].overlaps(bb))
623 return wellInside(samplePts,
scalarField(samplePts.size(), 0.0));
629 const point& samplePt
641 return wellOutside(samplePts,
scalarField(samplePts.size(), 0.0));
647 const point& samplePt
659 const bool testForInside
662 List<List<volumeType>> surfaceVolumeTests
675 const searchableSurface& surface(allGeometry_[surfaces_[
s]]);
677 const label regionI = regionOffset_[
s];
681 surface.getVolumeType(samplePts, surfaceVolumeTests[
s]);
690 Field<bool> insideOutsidePoint(samplePts.size(), testForInside);
695 List<pointIndexHit> hitInfo;
714 insideOutsidePoint[i] =
false;
721 const label regionI = regionOffset_[
s];
728 const searchableSurface& surface(allGeometry_[surfaces_[
s]]);
732 !surface.hasVolumeType()
738 List<pointIndexHit> info;
740 surface.findNearest(sample, nearestDistSqr, info);
742 vector hitDir = info[0].rawPoint() - samplePts[i];
743 hitDir /=
mag(hitDir) + small;
748 findSurfaceNearestIntersection
751 info[0].rawPoint() - 1
e-3*
mag(hitDir)*hitDir,
756 if (surfHit.hit() && hitSurface != surfaces_[
s])
766 normalVolumeTypes_[regionI]
770 insideOutsidePoint[i] = !testForInside;
778 normalVolumeTypes_[regionI]
782 insideOutsidePoint[i] = !testForInside;
789 return insideOutsidePoint;
799 return wellInOutSide(samplePts, testDistSqr,
true);
805 const point& samplePt,
819 return wellInOutSide(samplePts, testDistSqr,
false);
825 const point& samplePt,
840 List<pointIndexHit> hitInfo;
852 return hitInfo[0].hit();
865 List<pointIndexHit> hitInfo;
877 surfHit = hitInfo[0];
885 hitSurface = surfaces_[hitSurfaces[0]];
894 List<pointIndexHit>& surfHit,
899 List<List<pointIndexHit>> hitInfo;
911 surfHit = hitInfo[0];
913 hitSurface.setSize(hitSurfaces[0].size());
915 forAll(hitSurfaces[0], surfI)
921 hitSurface[surfI] = surfaces_[hitSurfaces[0][surfI]];
935 List<pointIndexHit> hitInfoStart;
937 List<pointIndexHit> hitInfoEnd;
951 surfHit = hitInfoStart[0];
959 hitSurface = surfaces_[hitSurfacesStart[0]];
967 scalar nearestDistSqr,
973 List<pointIndexHit> surfaceHits;
985 surfHit = surfaceHits[0];
993 hitSurface = surfaces_[hitSurfaces[0]];
1002 List<pointIndexHit>& surfaceHits,
1018 if (surfaceHits[i].hit())
1024 hitSurfaces[i] = surfaces_[hitSurfaces[i]];
1032 const point& sample,
1033 scalar nearestDistSqr,
1039 scalar minDistSqr = nearestDistSqr;
1044 features_[testI].nearestFeaturePoint
1053 minDistSqr =
magSqr(hitInfo.hitPoint()- sample);
1063 const point& sample,
1064 scalar nearestDistSqr,
1072 List<pointIndexHit> edgeHits;
1083 edgeHit = edgeHits[0];
1084 featureHit = featuresHit[0];
1092 List<pointIndexHit>& edgeHits,
1097 featuresHit.setSize(samples.size());
1099 edgeHits.setSize(samples.size());
1103 List<pointIndexHit> hitInfo(samples.size());
1107 features_[testI].nearestFeatureEdge
1117 if (hitInfo[pointi].hit())
1119 minDistSqr[pointi] =
magSqr 1121 hitInfo[pointi].hitPoint()
1124 edgeHits[pointi] = hitInfo[pointi];
1125 featuresHit[pointi] = testI;
1134 const point& sample,
1135 scalar nearestDistSqr,
1136 List<pointIndexHit>& edgeHits,
1137 List<label>& featuresHit
1151 features_[testI].nearestFeatureEdgeByType
1161 if (hitInfo[typeI].hit())
1163 minDistSqr[typeI] =
magSqr(hitInfo[typeI].hitPoint() - sample);
1164 edgeHits[typeI] = hitInfo[typeI];
1165 featuresHit[typeI] = testI;
1174 const point& sample,
1175 const scalar searchRadiusSqr,
1176 List<List<pointIndexHit>>& edgeHitsByFeature,
1177 List<label>& featuresHit
1190 features_[testI].allNearestFeatureEdges
1197 bool anyHit =
false;
1200 if (hitInfo[hitI].hit())
1208 edgeHitsByFeature.append(hitInfo);
1209 featuresHit.append(testI);
1217 OFstream ftStr(runTime_.time().path()/prefix +
"_allFeatures.obj");
1219 Pout<<
nl <<
"Writing all features to " << ftStr.name() <<
endl;
1225 const extendedFeatureEdgeMesh& fEM(features_[i]);
1229 ftStr <<
"g " << fEM.name() <<
endl;
1233 const edge&
e = eds[j];
1237 ftStr <<
"l " << verti-1 <<
' ' << verti <<
endl;
1252 findSurfaceAnyIntersection(ptA, ptB, surfHit, hitSurface);
1254 return getPatchID(hitSurface, surfHit);
1263 findSurfaceNearest(pt,
sqr(great), surfHit, hitSurface);
1265 return getPatchID(hitSurface, surfHit);
1271 const label hitSurface,
1282 allGeometry_[hitSurface].getRegion
1284 List<pointIndexHit>(1, surfHit),
1288 const label patchID =
1290 + regionOffset_[allGeometryToSurfaces_[hitSurface]];
1299 const label hitSurface,
1303 const label patchID = getPatchID(hitSurface, surfHit);
1310 return normalVolumeTypes_[patchID];
1316 const label hitSurface,
1317 const List<pointIndexHit>& surfHit,
1321 allGeometry_[hitSurface].getNormal(surfHit, normal);
1323 const label patchID = regionOffset_[allGeometryToSurfaces_[hitSurface]];
List< labelList > labelListList
A List of labelList.
#define forAll(list, i)
Loop across all elements in list.
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
static void findNearest(const PtrList< searchableSurface > &, const labelList &surfacesToTest, const pointField &, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &)
Find nearest. Return -1 (and a miss()) or surface and nearest.
static autoPtr< searchableSurfaceFeatures > New(const searchableSurface &surface, const dictionary &dict)
Return a reference to the selected searchableSurfaceFeatures.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
static const Foam::NamedEnum< sideVolumeType, 4 > sideVolumeTypeNames_
Ostream & endl(Ostream &os)
Add newline and flush stream.
Holds information (coordinate and normal) regarding nearest wall point.
PointIndexHit< point > pointIndexHit
Vector< scalar > vector
A scalar version of the templated Vector.
static void findAllIntersections(const PtrList< searchableSurface > &, const labelList &surfacesToTest, const pointField &start, const pointField &end, labelListList &surfaces, List< List< pointIndexHit >> &surfaceHits)
Find all intersections in order from start to end. Returns for.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
scalarField samples(nIntervals, 0)
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
vectorField pointField
pointField is a vectorField.
stressControl lookup("compactNormalStress") >> compactNormalStress
static void findNearestIntersection(const PtrList< searchableSurface > &allSurfaces, const labelList &surfacesToTest, const pointField &start, const pointField &end, labelList &surface1, List< pointIndexHit > &hit1, labelList &surface2, List< pointIndexHit > &hit2)
Find intersections of edge nearest to both endpoints.
Pre-declare SubField and related Field type.
static label nEdgeTypes
Number of possible feature edge types (i.e. number of slices)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void append(const T &)
Append an element at the end of the list.
sideVolumeType
Normals point to the outside.
List< label > labelList
A List of labels.
static void findAnyIntersection(const PtrList< searchableSurface > &, const labelList &surfacesToTest, const pointField &start, const pointField &end, labelList &surfaces, List< pointIndexHit > &)
Find any intersection. Return hit point information and.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
defineTypeNameAndDebug(combustionModel, 0)
List< word > wordList
A List of words.
vector point
Point is a vector.
#define WarningInFunction
Report a warning using Foam::Warning.
prefixOSstream Pout(cout, "Pout")
dimensioned< scalar > mag(const dimensioned< Type > &)
Field< vector > vectorField
Specialisation of Field<T> for vector.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
const doubleScalar e
Elementary charge.
static const NamedEnum< volumeType, 4 > names
static boundBox bounds(const PtrList< searchableSurface > &allSurfaces, const labelList &surfacesToTest)
Find the boundBox of the selected surfaces.