30#include "surfaceInterpolate.H"
69 resultField_.reset(
nullptr);
77 if (hasDimensions_ && !logical)
96 resultField_.reset(
nullptr);
100 isLogical_ = logical;
104 if (hasDimensions_ && !logical)
123 resultField_.reset(
nullptr);
127 isLogical_ = logical;
131 if (hasDimensions_ && !logical)
143template<
class GeomField>
147 return dynamic_cast<const GeomField*
>(
resultField_.get());
151template<
class GeomField>
161 if (dieOnNull && !ptr)
164 <<
"No result available. Requested "
169 if (isLogical_ == logical)
171 return dynamic_cast<const GeomField*
>(ptr);
186 return this->getOrReadField<VolumeField<Type>>
203 return this->getOrReadField<SurfaceField<Type>>
220 return this->getOrReadPointField<PointField<Type>>
296 return interp.interpolate(
field);
307 auto tresult = newVolField<Type>();
308 auto& result = tresult.ref();
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))
const dimensionSet & dimensions() const noexcept
Return dimensions.
static const char *const typeName
Typename for Field.
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
static tmp< GeometricField< Type, fvPatchField, volMesh > > New(const word &name, IOobjectOption::registerOption regOpt, const Mesh &mesh, const dimensionSet &dims, const word &patchFieldType=fvPatchField< Type >::calculatedType())
const Internal::FieldType & primitiveField() const noexcept
Return a const-reference to the internal field values.
static FOAM_NO_DANGLING_REFERENCE const pointMesh & New(const polyMesh &mesh, Args &&... args)
bool get(const label i) const
Return bool value at specified position, always false for out-of-range access.
void reset(const dimensionSet &ds)
Copy assign the exponents from the dimensionSet.
Generic dimensioned Type class.
const exprResult & result() const noexcept
Const access to expression result.
void setResult(Field< Type > *, bool wantPointData=false)
Set result field, taking ownership of the pointer.
tmp< GeomField > getOrReadPointField(const word &name, const bool mandatory=true, const bool getOldTime=false)
Retrieve point field from memory or disk.
tmp< GeomField > getOrReadField(const word &name, const bool mandatory=true, const bool getOldTime=false)
Retrieve field from memory or disk.
tmp< VolumeField< Type > > newVolField(const Type &val=pTraits< Type >::zero) const
Return a new volume field with the mesh size.
expressions::FieldAssociation fieldGeoType_
A volume/surface/point field.
bool isPointData() const noexcept
A point field.
tmp< VolumeField< Type > > pointToCell(const PointField< Type > &field) const
Interpolate point to cell values.
tmp< PointField< Type > > getPointField(const word &fldName, bool getOldTime=false)
Retrieve field (surface field).
tmp< PointField< Type > > newPointField(const Type &val=pTraits< Type >::zero) const
Return a new point field with the mesh nPoints size.
const GeoField * isResultType() const
Test if stored result pointer is the specified type.
tmp< VolumeField< Type > > getVolField(const word &fldName, bool getOldTime=false)
Retrieve field (vol field).
tmp< SurfaceField< Type > > cellToFace(const VolumeField< Type > &field) const
Interpolate cell to face values.
bool hasDimensions_
Requested use of dimensions.
tmp< SurfaceField< Type > > newSurfaceField(const Type &val=pTraits< Type >::zero) const
Return a new surface field with the mesh nInternalFaces size.
tmp< PointField< Type > > cellToPoint(const VolumeField< Type > &field) const
Interpolate cell to point values.
tmp< SurfaceField< Type > > getSurfaceField(const word &fldName, bool getOldTime=false)
Retrieve field (surface field).
void setInternalFieldResult(const Field< Type > &fld)
Deep-copy the internalField as a result.
word resultType_
The result type-name.
autoPtr< regIOobject > resultField_
The results (volume, surface, point).
bool isLogical_
A logical (bool-like) field (but actually a scalar).
void setResult(VolumeField< Type > *ptr, bool logical=false)
Set result (vol field).
dimensionSet resultDimensions_
The result dimensions.
A traits class, which is primarily used for primitives and vector-space.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
A class for managing temporary objects.
Interpolate from cell centres to points (vertices) using inverse distance weighting.
tmp< GeometricField< Type, pointPatchField, pointMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &) const
Interpolate volField using inverse distance weighting.
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Operations involving expressions.
Interpolates (averages) the vertex values to the cell center.
void assign(Field< Tout > &result, const Field< T1 > &a, const UnaryOp &op)
Populate a field as the result of a unary operation on an input.
@ VOLUME_DATA
Volume data.
static tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
const dimensionSet dimless
Dimensionless.
GeometricField< Type, fvPatchField, volMesh > VolumeField
A volume field for a given type.
Type interpolatePointToCell(const GeometricField< Type, pointPatchField, pointMesh > &ptf, const label celli)
GeometricField< Type, pointPatchField, pointMesh > PointField
A point field for a given type.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
GeometricField< Type, fvsPatchField, surfaceMesh > SurfaceField
A (volume) surface field for a given type.
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.
Convert [0-1] values (usually scalars) as false/true.