40Foam::isoSurfacePoint::adaptPatchFields
59 auto& sliceFld = tslice.ref();
65 auto& sliceFldBf = sliceFld.boundaryFieldRef();
74 &&
pp.size() != sliceFldBf[patchi].size()
80 sliceFldBf.release(patchi);
86 mesh.boundary()[patchi],
94 mesh.boundary()[patchi].patch().faceCells();
118 mesh.weights().boundaryField()[patchi]
128 if (!isCollocated[i])
140Type Foam::isoSurfacePoint::generatePoint
153 const scalar d = s1-s0;
157 const scalar
s = (iso_-s0)/d;
159 if (hasSnap1 &&
s >= 0.5 &&
s <= 1)
163 else if (hasSnap0 &&
s >= 0.0 &&
s <= 0.5)
169 return s*p1 + (1.0-
s)*
p0;
174 constexpr scalar
s = 0.4999;
176 return s*p1 + (1.0-
s)*
p0;
182void Foam::isoSurfacePoint::generateTriPoints
240 generatePoint(s0,
p0,hasSnap0,snapP0,s1,p1,hasSnap1,snapP1)
244 generatePoint(s0,
p0,hasSnap0,snapP0,s2,p2,hasSnap2,snapP2)
248 generatePoint(s0,
p0,hasSnap0,snapP0,s3,p3,hasSnap3,snapP3)
250 if (triIndex == 0x0E)
254 std::swap(
pts[sz-2],
pts[sz-1]);
264 generatePoint(s1,p1,hasSnap1,snapP1,s0,
p0,hasSnap0,snapP0)
268 generatePoint(s1,p1,hasSnap1,snapP1,s3,p3,hasSnap3,snapP3)
272 generatePoint(s1,p1,hasSnap1,snapP1,s2,p2,hasSnap2,snapP2)
274 if (triIndex == 0x0D)
278 std::swap(
pts[sz-2],
pts[sz-1]);
287 generatePoint(s0,
p0,hasSnap0,snapP0,s2,p2,hasSnap2,snapP2);
289 generatePoint(s1,p1,hasSnap1,snapP1,s3,p3,hasSnap3,snapP3);
293 generatePoint(s0,
p0,hasSnap0,snapP0,s3,p3,hasSnap3,snapP3)
301 generatePoint(s1,p1,hasSnap1,snapP1,s2,p2,hasSnap2,snapP2)
305 if (triIndex == 0x0C)
309 std::swap(
pts[sz-5],
pts[sz-4]);
310 std::swap(
pts[sz-2],
pts[sz-1]);
320 generatePoint(s2,p2,hasSnap2,snapP2,s0,
p0,hasSnap0,snapP0)
324 generatePoint(s2,p2,hasSnap2,snapP2,s1,p1,hasSnap1,snapP1)
328 generatePoint(s2,p2,hasSnap2,snapP2,s3,p3,hasSnap3,snapP3)
331 if (triIndex == 0x0B)
335 std::swap(
pts[sz-2],
pts[sz-1]);
344 generatePoint(s0,
p0,hasSnap0,snapP0,s1,p1,hasSnap1,snapP1);
346 generatePoint(s2,p2,hasSnap2,snapP2,s3,p3,hasSnap3,snapP3);
352 generatePoint(s0,
p0,hasSnap0,snapP0,s3,p3,hasSnap3,snapP3)
358 generatePoint(s1,p1,hasSnap1,snapP1,s2,p2,hasSnap2,snapP2)
362 if (triIndex == 0x0A)
366 std::swap(
pts[sz-5],
pts[sz-4]);
367 std::swap(
pts[sz-2],
pts[sz-1]);
376 generatePoint(s0,
p0,hasSnap0,snapP0,s1,p1,hasSnap1,snapP1);
378 generatePoint(s2,p2,hasSnap2,snapP2,s3,p3,hasSnap3,snapP3);
383 generatePoint(s1,p1,hasSnap1,snapP1,s3,p3,hasSnap3,snapP3)
391 generatePoint(s0,
p0,hasSnap0,snapP0,s2,p2,hasSnap2,snapP2)
394 if (triIndex == 0x09)
398 std::swap(
pts[sz-5],
pts[sz-4]);
399 std::swap(
pts[sz-2],
pts[sz-1]);
409 generatePoint(s3,p3,hasSnap3,snapP3,s0,
p0,hasSnap0,snapP0)
413 generatePoint(s3,p3,hasSnap3,snapP3,s2,p2,hasSnap2,snapP2)
417 generatePoint(s3,p3,hasSnap3,snapP3,s1,p1,hasSnap1,snapP1)
420 if (triIndex == 0x07)
424 std::swap(
pts[sz-2],
pts[sz-1]);
433Foam::label Foam::isoSurfacePoint::generateFaceTriPoints
448 const bool hasNeiSnap,
449 const Type& neiSnapPt,
455 const label own = mesh_.faceOwner()[facei];
459 const face&
f = mesh_.faces()[facei];
463 label pointi =
f[fp];
470 snappedPoint[pointi] != -1,
472 snappedPoint[pointi] != -1
473 ? snappedPoints[snappedPoint[pointi]]
479 snappedPoint[nextPointi] != -1,
481 snappedPoint[nextPointi] != -1
482 ? snappedPoints[snappedPoint[nextPointi]]
488 snappedCc[own] != -1,
491 ? snappedPoints[snappedCc[own]]
506 for (label i = 0; i < nTris; i++)
508 triMeshCells.append(own);
516void Foam::isoSurfacePoint::generateTriPoints
533 const labelList& own = mesh_.faceOwner();
534 const labelList& nei = mesh_.faceNeighbour();
538 (cVals.size() != mesh_.nCells())
539 || (pVals.size() != mesh_.nPoints())
540 || (cCoords.size() != mesh_.nCells())
541 || (pCoords.size() != mesh_.nPoints())
542 || (snappedCc.size() != mesh_.nCells())
543 || (snappedPoint.size() != mesh_.nPoints())
547 <<
"Incorrect size." <<
endl
548 <<
"mesh: nCells:" << mesh_.nCells()
549 <<
" points:" << mesh_.nPoints() <<
endl
550 <<
"cVals:" << cVals.size() <<
endl
551 <<
"cCoords:" << cCoords.size() <<
endl
552 <<
"snappedCc:" << snappedCc.size() <<
endl
553 <<
"pVals:" << pVals.size() <<
endl
554 <<
"pCoords:" << pCoords.size() <<
endl
555 <<
"snappedPoint:" << snappedPoint.size() <<
endl
563 triMeshCells.clear();
565 for (label facei = 0; facei < mesh_.nInternalFaces(); ++facei)
567 if ((faceCutType_[facei] & cutType::ANYCUT) != 0)
569 generateFaceTriPoints
584 snappedCc[nei[facei]] != -1,
586 snappedCc[nei[facei]] != -1
587 ? snappedPoints[snappedCc[nei[facei]]]
599 boolList neiSnapped(mesh_.nBoundaryFaces(),
false);
605 label facei =
pp.start();
608 label bFacei = facei-mesh_.nInternalFaces();
609 label snappedIndex = snappedCc[own[facei]];
611 if (snappedIndex != -1)
613 neiSnapped[bFacei] =
true;
614 neiSnappedPoint[bFacei] = snappedPoints[snappedIndex];
633 bitSet isCollocated(collocatedFaces(cpp));
637 const label facei =
pp.start()+i;
639 if ((faceCutType_[facei] & cutType::ANYCUT) != 0)
643 generateFaceTriPoints
656 cVals.boundaryField()[patchi][i],
657 cCoords.boundaryField()[patchi][i],
658 neiSnapped[facei-mesh_.nInternalFaces()],
659 neiSnappedPoint[facei-mesh_.nInternalFaces()],
667 generateFaceTriPoints
680 cVals.boundaryField()[patchi][i],
681 cCoords.boundaryField()[patchi][i],
694 label facei =
pp.start();
698 if ((faceCutType_[facei] & cutType::ANYCUT) != 0)
700 generateFaceTriPoints
713 cVals.boundaryField()[patchi][i],
714 cCoords.boundaryField()[patchi][i],
728 triMeshCells.shrink();
734Foam::isoSurfacePoint::interpolate
746 auto& values = tvalues.ref();
755 label mergedPointi = triPointMergeMap[i];
757 if (mergedPointi >= 0)
759 values[mergedPointi] += unmergedValues[i];
760 nValues[mergedPointi]++;
768 values[i] /= scalar(nValues[i]);
776 forAll(interpolatedPoints, i)
778 label pointi = interpolatedPoints[i];
779 const FixedList<label, 3>& oldPoints = interpolatedOldPoints[i];
780 const FixedList<scalar, 3>& w = interpolationWeights[i];
784 values[pointi] = Type(
Zero);
787 values[pointi] = w[j]*unmergedValues[oldPoints[j]];
797Foam::isoSurfacePoint::interpolateTemplate
813 labelList snappedPoint(mesh_.nPoints(), -1);
836 interpolatedOldPoints_,
837 interpolationWeights_,
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void append(const T &val)
Copy append an element to the end of this list.
DynamicList< T, SizeMin > & shrink()
Calls shrink_to_fit() and returns a reference to the DynamicList.
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
A 1D vector of objects of type <T> with a fixed length <N>.
static constexpr label size() noexcept
Return the number of elements in the FixedList.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
@ NO_REGISTER
Do not request registration (bool: false).
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void append(const T &val)
Append an element at the end of the list.
void setSize(label n)
Alias for resize().
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void size(const label n)
Older name for setAddressableSize.
label fcIndex(const label i) const noexcept
The forward circular index. The next index in the list which returns to the first at the end of the l...
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
This boundary condition is not designed to be evaluated; it is assumed that the value is assigned via...
Smooth ATC in cells next to a set of patches supplied by type.
A face is a list of labels corresponding to mesh vertices.
Mesh data needed to do the Finite Volume discretisation.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
virtual tmp< Field< Type > > patchNeighbourField() const
Return patchField on the opposite patch of a coupled patch.
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch.
Abstract base class for interpolating in 1D.
static autoPtr< isoSurfaceBase > New(const isoSurfaceParams ¶ms, const volScalarField &cellValues, const scalarField &pointValues, const scalar iso, const bitSet &ignoreCells=bitSet())
Create for specified algorithm type.
const scalarField & pVals_
Point values.
const polyMesh & mesh() const noexcept
The mesh for which the iso-surface is associated.
const polyMesh & mesh_
Reference to mesh.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
A patch is a list of labels that address the faces in the global face list.
Neighbour processor patch.
A class for managing temporary objects.
Triangle point storage. Default constructable (triangle is not).
const volScalarField & p0
const polyBoundaryMesh & patches
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.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))
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
GeometricField< Type, fvPatchField, volMesh > VolumeField
A volume field for a given type.
List< label > labelList
A List of labels.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
errorManip< error > abort(error &err)
List< bool > boolList
A List of bools.
static constexpr const zero Zero
Global zero (0).
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
UList< label > labelUList
A UList of labels.
dimensioned< Type > lerp(const dimensioned< Type > &a, const dimensioned< Type > &b, const scalar t)
#define forAll(list, i)
Loop across all elements in list.