43 surfaceOffsetLinearDistance,
52 const dictionary& initialPointsDict,
53 const searchableSurface& surface,
54 const scalar& defaultCellSize,
55 const labelList regionIndices
68 coeffsDict().
get<scalar>(
"distanceCellSizeCoeff") * defaultCellSize
72 coeffsDict().
get<scalar>(
"surfaceOffsetCoeff") * defaultCellSize
77 if (coeffsDict().
readIfPresent(
"totalDistanceCoeff", totalDistance_))
79 totalDistance_ *= defaultCellSize;
81 if (coeffsDict().
found(
"linearDistanceCoeff"))
84 <<
"totalDistanceCoeff and linearDistanceCoeff found, "
85 <<
"specify one or other, not both."
89 else if (coeffsDict().
readIfPresent(
"linearDistanceCoeff", totalDistance_))
91 totalDistance_ *= defaultCellSize;
92 totalDistance_ += surfaceOffset_;
97 <<
"totalDistanceCoeff or linearDistanceCoeff not found."
101 totalDistanceSqr_ =
sqr(totalDistance_);
107Foam::scalar Foam::surfaceOffsetLinearDistance::sizeFunction
114 const scalar interpolatedSize
117 if (d <= surfaceOffset_)
119 return interpolatedSize;
123 (distanceCellSize_ - interpolatedSize)
124 /(totalDistance_ - surfaceOffset_);
126 scalar intercept = interpolatedSize - gradient*surfaceOffset_;
128 return gradient*d + intercept;
144 const scalar offsetCellSize =
145 surfaceCellSizeFunction_().interpolate(pt, hitPt.index());
147 if (sideMode_ == rmBothsides)
150 shapeSizes.resize(4);
152 shapePts[0] = pt -
n*surfaceOffset_;
153 shapeSizes[0] = offsetCellSize;
154 shapePts[1] = pt -
n*totalDistance_;
155 shapeSizes[1] = distanceCellSize_;
157 shapePts[2] = pt +
n*surfaceOffset_;
158 shapeSizes[2] = offsetCellSize;
159 shapePts[3] = pt +
n*totalDistance_;
160 shapeSizes[3] = distanceCellSize_;
162 else if (sideMode_ == smInside)
165 shapeSizes.resize(2);
167 shapePts[0] = pt -
n*surfaceOffset_;
168 shapeSizes[0] = offsetCellSize;
169 shapePts[1] = pt -
n*totalDistance_;
170 shapeSizes[1] = distanceCellSize_;
172 else if (sideMode_ == smOutside)
175 shapeSizes.resize(2);
177 shapePts[0] = pt +
n*surfaceOffset_;
178 shapeSizes[0] = offsetCellSize;
179 shapePts[1] = pt +
n*totalDistance_;
180 shapeSizes[1] = distanceCellSize_;
195 List<pointIndexHit> hits;
209 const point& hitPt = hitInfo.hitPoint();
210 const label hitIndex = hitInfo.index();
212 const scalar dist =
mag(pt - hitPt);
214 if (sideMode_ == rmBothsides)
216 size = sizeFunction(hitPt, dist, hitIndex);
223 if (
mag(pt - hitInfo.hitPoint()) < snapToSurfaceTol_)
225 size = sizeFunction(hitPt, 0, hitIndex);
231 List<volumeType> vTL;
233 surface_.getVolumeType(ptF, vTL);
235 bool functionApplied =
false;
239 sideMode_ == smInside
243 size = sizeFunction(hitPt, dist, hitIndex);
245 functionApplied =
true;
249 sideMode_ == smOutside
253 size = sizeFunction(hitPt, dist, hitIndex);
255 functionApplied =
true;
258 return functionApplied;
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
autoPtr< surfaceCellSizeFunction > surfaceCellSizeFunction_
virtual bool sizeLocations(const pointIndexHit &hitPt, const vector &n, pointField &shapePts, scalarField &shapeSizes) const
virtual bool cellSize(const point &pt, scalar &size) const
Modify scalar argument to the cell size specified by function.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
@ OUTSIDE
A location outside the volume.
@ INSIDE
A location inside the volume.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
const wordList surface
Standard surface field types (scalar, vector, tensor, etc)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
PointIndexHit< point > pointIndexHit
A PointIndexHit for 3D points.
vectorField pointField
pointField is a vectorField.
vector point
Point is a vector.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
propsDict readIfPresent("fields", acceptFields)