39 PrimitivePatchInterpolation<Patch>::faceToPointWeights()
const 41 if (!faceToPointWeightsPtr_)
43 makeFaceToPointWeights();
46 return *faceToPointWeightsPtr_;
51 void PrimitivePatchInterpolation<Patch>::makeFaceToPointWeights()
const 53 if (faceToPointWeightsPtr_)
56 <<
"Face-to-edge weights already calculated" 60 const pointField& points = patch_.localPoints();
61 const List<typename Patch::FaceType>& faces = patch_.localFaces();
71 const labelList& curFaces = pointFaces[pointi];
81 1.0/
mag(faces[curFaces[facei]].centre(points) - points[pointi]);
95 PrimitivePatchInterpolation<Patch>::faceToEdgeWeights()
const 97 if (!faceToEdgeWeightsPtr_)
99 makeFaceToEdgeWeights();
102 return *faceToEdgeWeightsPtr_;
106 template<
class Patch>
107 void PrimitivePatchInterpolation<Patch>::makeFaceToEdgeWeights()
const 109 if (faceToEdgeWeightsPtr_)
112 <<
"Face-to-edge weights already calculated" 116 const pointField& points = patch_.localPoints();
117 const List<typename Patch::FaceType>& faces = patch_.localFaces();
118 const edgeList& edges = patch_.edges();
121 faceToEdgeWeightsPtr_ =
new scalarList(patch_.nInternalEdges());
128 vector S = points[edges[edgei].start()];
129 vector e = edges[edgei].vec(points);
132 -(((N - P)^(S - P))&((N - P)^
e))/(((N - P)^e )&((N - P)^e));
136 weights[edgei] =
mag(N - E)/(
mag(N - E) +
mag(E - P));
141 template<
class Patch>
142 void PrimitivePatchInterpolation<Patch>::clearWeights()
151 template<
class Patch>
155 faceToPointWeightsPtr_(nullptr),
156 faceToEdgeWeightsPtr_(nullptr)
162 template<
class Patch>
171 template<
class Patch>
179 if (ff.
size() != patch_.size())
182 <<
"given field does not correspond to patch. Patch size: " 183 << patch_.size() <<
" field size: " << ff.
size()
191 patch_.nPoints(),
Zero 200 forAll(pointFaces, pointi)
202 const labelList& curFaces = pointFaces[pointi];
207 result[pointi] += w[facei]*ff[curFaces[facei]];
215 template<
class Patch>
228 template<
class Patch>
235 if (pf.
size() != patch_.nPoints())
238 <<
"given field does not correspond to patch. Patch size: " 239 << patch_.nPoints() <<
" field size: " << pf.
size()
258 const labelList& curPoints = localFaces[facei];
262 result[facei] += pf[curPoints[pointi]];
265 result[facei] /= curPoints.
size();
272 template<
class Patch>
285 template<
class Patch>
293 if (pf.
size() != patch_.size())
296 <<
"given field does not correspond to patch. Patch size: " 297 << patch_.size() <<
" field size: " << pf.
size()
308 const edgeList& edges = patch_.edges();
311 const scalarList& weights = faceToEdgeWeights();
313 for (
label edgei = 0; edgei < patch_.nInternalEdges(); edgei++)
316 weights[edgei]*pf[edgeFaces[edgei][0]]
317 + (1.0 - weights[edgei])*pf[edgeFaces[edgei][1]];
320 for (
label edgei = patch_.nInternalEdges(); edgei < edges.
size(); edgei++)
322 result[edgei] = pf[edgeFaces[edgei][0]];
329 template<
class Patch>
342 template<
class Patch>
List< labelList > labelListList
A List of labelList.
Interpolation class within a primitive patch. Allows interpolation from points to faces and vice vers...
#define forAll(list, i)
Loop across all elements in list.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
T & ref() const
Return non-const reference or generate a fatal error.
void size(const label)
Override size to be inconsistent with allocated storage.
Vector< scalar > vector
A scalar version of the templated Vector.
const Vector< Cmpt > & centre(const Foam::List< Vector< Cmpt >> &) const
Return *this (used for point which is a typedef to Vector<scalar>.
vectorField pointField
pointField is a vectorField.
PrimitivePatchInterpolation(const Patch &p)
Construct from PrimitivePatch.
Pre-declare SubField and related Field type.
List< scalarList > scalarListList
List< scalar > scalarList
A List of scalars.
List< label > labelList
A List of labels.
errorManip< error > abort(error &err)
void setSize(const label)
Reset size of List.
Template functions to aid in the implementation of demand driven data.
dimensioned< scalar > mag(const dimensioned< Type > &)
const doubleScalar e
Elementary charge.
A class for managing temporary objects.
void deleteDemandDrivenData(DataPtr &dataPtr)