35Foam::PrimitivePatchInterpolation<Patch>::faceToPointWeights()
const
37 if (!faceToPointWeightsPtr_)
39 makeFaceToPointWeights();
42 return *faceToPointWeightsPtr_;
47void Foam::PrimitivePatchInterpolation<Patch>::makeFaceToPointWeights()
const
49 if (faceToPointWeightsPtr_)
52 <<
"Face-to-edge weights already calculated"
56 const auto&
points = patch_.localPoints();
57 const auto& faces = patch_.localFaces();
60 auto& weights = *faceToPointWeightsPtr_;
67 const labelList& curFaces = pointFaces[pointi];
91Foam::PrimitivePatchInterpolation<Patch>::faceToEdgeWeights()
const
93 if (!faceToEdgeWeightsPtr_)
95 makeFaceToEdgeWeights();
98 return *faceToEdgeWeightsPtr_;
103void Foam::PrimitivePatchInterpolation<Patch>::makeFaceToEdgeWeights()
const
105 if (faceToEdgeWeightsPtr_)
108 <<
"Face-to-edge weights already calculated"
109 <<
abort(FatalError);
112 const auto&
points = patch_.localPoints();
113 const auto& faces = patch_.localFaces();
114 const edgeList& edges = patch_.edges();
117 faceToEdgeWeightsPtr_.reset(
new scalarList(patch_.nInternalEdges()));
118 auto& weights = *faceToEdgeWeightsPtr_;
128 -(((
N - P)^(S - P))&((
N - P)^
e))/(((
N - P)^
e )&((
N - P)^
e));
132 weights[edgei] =
mag(
N - E)/(
mag(
N - E) +
mag(E - P));
138void Foam::PrimitivePatchInterpolation<Patch>::clearWeights()
140 faceToPointWeightsPtr_.reset(
nullptr);
141 faceToEdgeWeightsPtr_.reset(
nullptr);
148Foam::PrimitivePatchInterpolation<Patch>::PrimitivePatchInterpolation
168 if (ff.size() != patch_.size())
171 <<
"given field does not correspond to patch. Patch size: "
172 << patch_.size() <<
" field size: " << ff.size()
177 auto& result = tresult.ref();
182 forAll(pointFaces, pointi)
189 result[pointi] += w[facei]*ff[curFaces[facei]];
219 if (pf.
size() != patch_.nPoints())
222 <<
"given field does not correspond to patch. Patch size: "
223 << patch_.nPoints() <<
" field size: " << pf.
size()
227 auto tresult = tmp<Field<Type>>
::New(patch_.size(),
Zero);
228 auto& result = tresult.ref();
230 const auto& localFaces = patch_.localFaces();
234 const labelList& curPoints = localFaces[facei];
238 result[facei] += pf[curPoints[pointi]];
241 result[facei] /= curPoints.
size();
271 if (pf.
size() != patch_.size())
274 <<
"given field does not correspond to patch. Patch size: "
275 << patch_.size() <<
" field size: " << pf.
size()
279 auto tresult = tmp<Field<Type>>
::New(patch_.nEdges(),
Zero);
280 auto& result = tresult.ref();
282 const edgeList& edges = patch_.edges();
285 const scalarList& weights = faceToEdgeWeights();
287 for (label edgei = 0; edgei < patch_.nInternalEdges(); edgei++)
290 weights[edgei]*pf[edgeFaces[edgei][0]]
291 + (1.0 - weights[edgei])*pf[edgeFaces[edgei][1]];
294 for (label edgei = patch_.nInternalEdges(); edgei < edges.size(); edgei++)
296 result[edgei] = pf[edgeFaces[edgei][0]];
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
void setSize(label n)
Alias for resize().
bool movePoints()
Do what is necessary if the mesh has moved.
tmp< Field< Type > > faceToPointInterpolate(const Field< Type > &ff) const
Interpolate from faces to points.
tmp< Field< Type > > faceToEdgeInterpolate(const Field< Type > &ff) const
Interpolate from faces to edges.
tmp< Field< Type > > pointToFaceInterpolate(const Field< Type > &pf) const
Interpolate from points to faces.
void size(const label n)
Older name for setAddressableSize.
A class for managing temporary objects.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< scalarList > scalarListList
List of scalarList.
List< edge > edgeList
List of edge.
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.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
errorManip< error > abort(error &err)
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
List< scalar > scalarList
List of scalar.
#define forAll(list, i)
Loop across all elements in list.
const Vector< label > N(dict.get< Vector< label > >("N"))