42 PrimitivePatchInterpolation<Patch>::faceToPointWeights()
const 44 if (!faceToPointWeightsPtr_)
46 makeFaceToPointWeights();
49 return *faceToPointWeightsPtr_;
54 void PrimitivePatchInterpolation<Patch>::makeFaceToPointWeights()
const 56 if (faceToPointWeightsPtr_)
59 <<
"Face-to-edge weights already calculated" 64 const List<typename Patch::face_type>& faces = patch_.localFaces();
67 auto& weights = *faceToPointWeightsPtr_;
74 const labelList& curFaces = pointFaces[pointi];
98 PrimitivePatchInterpolation<Patch>::faceToEdgeWeights()
const 100 if (!faceToEdgeWeightsPtr_)
102 makeFaceToEdgeWeights();
105 return *faceToEdgeWeightsPtr_;
109 template<
class Patch>
110 void PrimitivePatchInterpolation<Patch>::makeFaceToEdgeWeights()
const 112 if (faceToEdgeWeightsPtr_)
115 <<
"Face-to-edge weights already calculated" 120 const List<typename Patch::face_type>& faces = patch_.localFaces();
121 const edgeList& edges = patch_.edges();
124 faceToEdgeWeightsPtr_ =
new scalarList(patch_.nInternalEdges());
125 auto& weights = *faceToEdgeWeightsPtr_;
135 -(((
N - P)^(S - P))&((
N - P)^
e))/(((
N - P)^
e )&((
N - P)^
e));
139 weights[edgei] =
mag(
N - E)/(
mag(
N - E) +
mag(E - P));
144 template<
class Patch>
145 void PrimitivePatchInterpolation<Patch>::clearWeights()
154 template<
class Patch>
158 faceToPointWeightsPtr_(nullptr),
159 faceToEdgeWeightsPtr_(nullptr)
165 template<
class Patch>
174 template<
class Patch>
182 if (
ff.size() != patch_.size())
185 <<
"given field does not correspond to patch. Patch size: " 186 << patch_.size() <<
" field size: " <<
ff.size()
194 patch_.nPoints(),
Zero 203 forAll(pointFaces, pointi)
205 const labelList& curFaces = pointFaces[pointi];
210 result[pointi] += w[facei]*
ff[curFaces[facei]];
218 template<
class Patch>
231 template<
class Patch>
238 if (pf.
size() != patch_.nPoints())
241 <<
"given field does not correspond to patch. Patch size: " 242 << patch_.nPoints() <<
" field size: " << pf.
size()
246 tmp<Field<Type>> tresult
255 Field<Type>& result = tresult.ref();
257 const List<typename Patch::face_type>& localFaces = patch_.localFaces();
261 const labelList& curPoints = localFaces[facei];
265 result[facei] += pf[curPoints[pointi]];
268 result[facei] /= curPoints.
size();
275 template<
class Patch>
288 template<
class Patch>
296 if (pf.
size() != patch_.size())
299 <<
"given field does not correspond to patch. Patch size: " 300 << patch_.size() <<
" field size: " << pf.
size()
304 auto tresult = tmp<Field<Type>>
::New(patch_.nEdges(),
Zero);
305 auto& result = tresult.ref();
307 const edgeList& edges = patch_.edges();
310 const scalarList& weights = faceToEdgeWeights();
312 for (label edgei = 0; edgei < patch_.nInternalEdges(); edgei++)
315 weights[edgei]*pf[edgeFaces[edgei][0]]
316 + (1.0 - weights[edgei])*pf[edgeFaces[edgei][1]];
319 for (label edgei = patch_.nInternalEdges(); edgei < edges.size(); edgei++)
321 result[edgei] = pf[edgeFaces[edgei][0]];
328 template<
class Patch>
341 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...
void size(const label n)
Older name for setAddressableSize.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
tmp< Field< Type > > faceToEdgeInterpolate(const Field< Type > &ff) const
Interpolate from faces to edges.
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
tmp< Field< Type > > pointToFaceInterpolate(const Field< Type > &pf) const
Interpolate from points to faces.
#define forAll(list, i)
Loop across all elements in list.
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
List< edge > edgeList
A List of edges.
Generic templated field type.
List< scalar > scalarList
A List of scalars.
bool movePoints()
Do what is necessary if the mesh has moved.
errorManip< error > abort(error &err)
const Vector< Cmpt > & centre(const Foam::UList< Vector< Cmpt >> &) const noexcept
Return this (for point which is a typedef to Vector<scalar>)
const Vector< label > N(dict.get< Vector< label >>("N"))
Template functions to aid in the implementation of demand driven data.
List< scalarList > scalarListList
A List of scalarList.
List< label > labelList
A List of labels.
A class for managing temporary objects.
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
void deleteDemandDrivenData(DataPtr &dataPtr)
~PrimitivePatchInterpolation()
Destructor.
const FieldField< fvPatchField, Type > & ff(const FieldField< fvPatchField, Type > &bf)
tmp< Field< Type > > faceToPointInterpolate(const Field< Type > &ff) const
Interpolate from faces to points.
static constexpr const zero Zero
Global zero (0)