13 #include "apfDynamicArray.h"
43 template <
class T>
class ReductionSum;
57 virtual T apply(T val1, T val2)
const = 0;
60 virtual T getNeutralElement()
const = 0;
66 T apply(T val1, T val2)
const {
return val1 + val2; };
67 T getNeutralElement()
const {
return 0; };
71 class ReductionMin :
public ReductionOp<T>
73 T apply(T val1, T val2)
const {
return ( (val1 < val2) ? val1 : val2 ); };
74 T getNeutralElement()
const {
return std::numeric_limits<T>::max(); };
78 class ReductionMax :
public ReductionOp<T>
80 T apply(T val1, T val2)
const {
return ( (val1 < val2) ? val2 : val1 ); };
81 T getNeutralElement()
const {
return std::numeric_limits<T>::min(); };
172 Field*
createField(
Mesh* m,
const char* name,
int valueType, FieldShape* shape);
231 void setScalar(Field* f, MeshEntity* e,
int node,
double value);
237 double getScalar(Field* f, MeshEntity* e,
int node);
243 void setVector(Field* f, MeshEntity* e,
int node, Vector3
const& value);
247 void getVector(Field* f, MeshEntity* e,
int node, Vector3& value);
253 void setMatrix(Field* f, MeshEntity* e,
int node, Matrix3x3
const& value);
257 void getMatrix(Field* f, MeshEntity* e,
int node, Matrix3x3& value);
260 void setComponents(Field* f, MeshEntity* e,
int node,
double const* components);
266 void getComponents(Field* f, MeshEntity* e,
int node,
double* components);
307 double getScalar(Element* e, Vector3
const& param);
314 void getGrad(Element* e, Vector3
const& param, Vector3& grad);
321 void getVector(Element* e, Vector3
const& param, Vector3& value);
328 double getDiv(Element* e, Vector3
const& param);
335 void getCurl(Element* e, Vector3
const& param, Vector3& curl);
346 void getVectorGrad(Element* e, Vector3
const& param, Matrix3x3& deriv);
353 void getMatrix(Element* e, Vector3
const& param, Matrix3x3& value);
360 void getMatrixGrad(Element* e, Vector3
const& param, Vector<27>& value);
363 void getComponents(Element* e, Vector3
const& param,
double* components);
518 double computeCosAngleInTri(
Mesh* m, MeshEntity* tri,
519 MeshEntity* e1, MeshEntity* e2,
const Matrix3x3& Q);
521 double computeCosAngleInTet(
Mesh* m, MeshEntity* tet,
522 MeshEntity* e1, MeshEntity* e2,
const Matrix3x3& Q);
524 Vector3 computeFaceNormalAtEdgeInTet(
Mesh* m, MeshEntity* tet,
525 MeshEntity* face, MeshEntity* edge,
Matrix3x3 Q);
527 Vector3 computeFaceNormalAtVertex(
Mesh* m, MeshEntity* face,
530 Vector3 computeEdgeTangentAtVertex(
Mesh* m, MeshEntity* edge,
597 NewArray<double>& values);
604 NewArray<Vector3>& grads);
623 #define APF_ITERATE(t,w,i) \
624 for (t::iterator i = (w).begin(); \
625 (i) != (w).end(); ++(i))
628 #define APF_CONST_ITERATE(t,w,i) \
629 for (t::const_iterator i = (w).begin(); \
630 (i) != (w).end(); ++(i))
646 std::vector<std::string> writeFields,
int cellDim = -1);
667 std::vector<std::string> writeFields);
675 void getGaussPoint(
int type,
int order,
int point, Vector3& param);
705 void accumulate(Field* f, Sharing* shr = 0,
bool delete_shr =
false);
714 const ReductionOp<double>& sum = ReductionSum<double>());
727 void fail(
const char* why) __attribute__((noreturn));
759 virtual void eval(MeshEntity* e,
double* result) = 0;
770 Field* createUserField(
Mesh* m,
const char* name,
int valueType,
FieldShape* s,
776 void updateUserField(Field* field,
Function* newFunc);
784 void copyData(Field* to, Field* from);
789 void axpy(
double a, Field* x, Field* y);
791 void renameField(Field* f,
const char* name);
801 NewArray<double>& BF);
808 NewArray<Vector3>& gradBF);
bool isFrozen(Field *f)
Returns true iff the Field uses array storage.
virtual void eval(MeshEntity *e, double *result)=0
The user's analytic function call.
double * getArrayData(Field *f)
Return the contiguous array storing this field.
User-defined Analytic Function.
void destroyElement(Element *e)
Destroy a Field Element.
void accumulate(Field *f, Sharing *shr=0, bool delete_shr=false)
Add field values along partition boundary.
ValueType
The type of value the field stores.
void getComponents(Field *f, MeshEntity *e, int node, double *components)
Copy the nodal value into an array of component values.
void setScalar(Field *f, MeshEntity *e, int node, double value)
Set a nodal value of a scalar field.
void getIntPoint(MeshElement *e, int order, int point, Vector3 ¶m)
Get an integration point in an element.
Field * createPackedField(Mesh *m, const char *name, int components, apf::FieldShape *shape=0)
Create a field of N components without a tensor type.
double getIntWeight(MeshElement *e, int order, int point)
Get the weight of an integration point in an element.
Field * createLagrangeField(Mesh *m, const char *name, int valueType, int order)
Create an apf::Field using a Lagrange distribution.
void getJacobianInv(MeshElement *e, Vector3 const &local, Matrix3x3 &jinv)
Returns the Jacobian inverse at a local point.
Element * createElement(Field *f, MeshElement *e)
Create a Field Element from a Mesh Element.
Field * cloneField(Field *f, Mesh *onto)
Declare a copy of a field on another apf::Mesh.
virtual void parallelReduce()
User callback: parallel reduction.
void setMatrix(Field *f, MeshEntity *e, int node, Matrix3x3 const &value)
Set the nodal value of a matrix field.
bool isPrintable(Field *f)
Checks whether a Field/Numbering/GlobalNumbering is complete and therefore printable to visualization...
Describes field distribution and shape functions.
int countIntPoints(MeshElement *e, int order)
Get the number of integration points for an element.
int getDimension(Mesh *m, MeshEntity *e)
get the dimension of a mesh entity
void synchronize(Field *f, Sharing *shr=0)
Synchronize field values along partition boundary.
double computeLargestHeightInTet(Mesh *m, MeshEntity *tet, const Matrix3x3 &Q=Matrix3x3(1., 0., 0., 0., 1., 0., 0., 0., 1.))
Returns the largest height in a tet.
void destroyMesh(Mesh *m)
Destroys an apf::Mesh.
virtual void atPoint(Vector3 const &p, double w, double dV)=0
User callback: accumulation.
double computeShortestHeightInTet(Mesh *m, MeshEntity *tet, const Matrix3x3 &Q=Matrix3x3(1., 0., 0., 0., 1., 0., 0., 0., 1.))
Returns the shortest height in a tet.
The APF linear algebra matrix interface.
void mapLocalToGlobal(MeshElement *e, Vector3 const &local, Vector3 &global)
Map a local coordinate to a global coordinate.
void getBF(FieldShape *s, MeshElement *e, Vector3 const &p, NewArray< double > &BF)
Get the basis functions over a mesh element.
void zeroField(Field *f)
Initialize all nodal values with all-zero components.
Field * createIPField(Mesh *m, const char *name, int valueType, int order)
Create an apf::Field of integration point data.
Field * recoverGradientByVolume(Field *f)
Compute a nodal gradient field from a nodal input field.
void getShapeValues(Element *e, Vector3 const &local, NewArray< double > &values)
Returns the shape function values at a point.
void getCurl(Element *e, Vector3 const ¶m, Vector3 &curl)
Evaluate the curl of a vector field at a point.
void writeVtkFiles(const char *prefix, Mesh *m, int cellDim=-1)
Write a set of parallel VTK Unstructured Mesh files from an apf::Mesh with binary (base64) encoding a...
int countGaussPoints(int type, int order)
Return the number of Gaussian integration points.
Base class for applying operations to make a Field consistent in parallel.
Field * createGeneralField(Mesh *m, const char *name, int valueType, int components, FieldShape *shape)
Encompasses both packed and typed fields.
void setVector(Field *f, MeshEntity *e, int node, Vector3 const &value)
Set the nodal value of a vector field.
convenience wrapper over apf::Matrix<3,3>
void getVectorNodes(Element *e, NewArray< Vector3 > &values)
Returns the element nodal values for a vector field.
double computeCosAngle(Mesh *m, MeshEntity *pe, MeshEntity *e1, MeshEntity *e2, const Matrix3x3 &Q)
Returns the cosine of the angle between 2 entities of the parent entity.
void process(Mesh *m, int dim=-1)
Run the Integrator over the local Mesh.
placeholder used to set array sizes
double measure(MeshElement *e)
Measures the volume, area, or length of a Mesh Element.
double getDV(MeshElement *e, Vector3 const ¶m)
Get the differential volume at a point.
void writeOneVtkFile(const char *prefix, Mesh *m)
Output just the .vtu file with ASCII encoding for this part.
Field * createStepField(Mesh *m, const char *name, int valueType)
Create an apf::Field using a step distribution.
MeshElement * createMeshElement(Mesh *m, MeshEntity *e)
Creates a Mesh Element over an entity.
void getVector(Field *f, MeshEntity *e, int node, Vector3 &value)
Get the nodal value of a vector field.
virtual void outElement()
User callback: element exit.
double computeLargestHeightInTri(Mesh *m, MeshEntity *tri, const Matrix3x3 &Q=Matrix3x3(1., 0., 0., 0., 1., 0., 0., 0., 1.))
Returns the largest height in a tri.
Interface to a mesh part.
int countNodes(Element *e)
Returns the number of element nodes.
void getVectorGrad(Element *e, Vector3 const ¶m, Matrix3x3 &deriv)
Get the gradient of a vector field w.r.t. global coordinates.
virtual ~Function()
Possible user-defined cleanup.
FieldShape * getShape(Field *f)
Retrieve the apf::FieldShape used by a field.
void getMatrix(Field *f, MeshEntity *e, int node, Matrix3x3 &value)
Get the nodal value of a matrix field.
void getGradBF(FieldShape *s, MeshElement *e, Vector3 const &p, NewArray< Vector3 > &gradBF)
Get global gradients of basis functions over a mesh element.
void fail(const char *why) __attribute__((noreturn))
Declare failure of code inside APF.
void getMatrixGrad(Element *e, Vector3 const ¶m, Vector< 27 > &value)
get the gradient of a matrix field
void projectField(Field *to, Field *from)
Project a field from an existing field.
apf::Mesh2 Mesh
convenient mesh name
abstract description of entity copy sharing
void setComponents(Field *f, MeshEntity *e, int node, double const *components)
Set the nodal value from an array of component values.
void getScalarNodes(Element *e, NewArray< double > &values)
Returns the element nodal values for a scalar field.
Integrator(int o)
Construct an Integrator given an order of accuracy.
void sharedReduction(Field *f, Sharing *shr, bool delete_shr, const ReductionOp< double > &sum=ReductionSum< double >())
Apply a reudction operator along partition boundaries.
convenience wrapper over apf::Vector<3>
MeshEntity * getMeshEntity(MeshElement *me)
Retrieve the mesh entity associated with an apf::MeshElement.
void freeze(Field *f)
Convert a Field from Tag to array storage.
virtual void inElement(MeshElement *)
User callback: element entry.
Field * createFieldOn(Mesh *m, const char *name, int valueType)
Create a field using the mesh's coordinate nodal distribution.
double getScalar(Field *f, MeshEntity *e, int node)
Get the node value of a scalar field.
void getGaussPoint(int type, int order, int point, Vector3 ¶m)
Return the location of a gaussian integration point.
void writeASCIIVtkFiles(const char *prefix, Mesh *m)
Write a set of parallel VTK Unstructured Mesh files from an apf::Mesh with ASCII encoding.
void destroyField(Field *f)
Destroy an apf::Field.
Field * createField(Mesh *m, const char *name, int valueType, FieldShape *shape)
Create a Field from any builtin or user defined FieldShape.
Mesh * getMesh(Field *f)
Retrieve the Mesh over which a Field is defined.
int countComponents(Field *f)
Count the number of scalar components in the field's value type.
void getMatrixNodes(Element *e, NewArray< Matrix3x3 > &values)
Returns the element nodal values for a matrix field.
int getValueType(Field *f)
Retrieve the type of value a field distributes.
double getDiv(Element *e, Vector3 const ¶m)
Evaluate the divergence of a vector field at a point.
int getOrder(MeshElement *e)
Returns the polynomial order of the coordinate field.
bool hasEntity(Field *f, MeshEntity *e)
Returns true iff an entity has data associate with a field.
a user-defined set of components
void unfreeze(Field *f)
Convert a Field from array to Tag storage.
void getGrad(Element *e, Vector3 const ¶m, Vector3 &grad)
Get the gradient of a scalar field w.r.t. global coordinates.
double getJacobianDeterminant(Matrix3x3 const &J, int dimension)
Return the Jacobian determinant or dimensional equivalent.
double computeShortestHeightInTri(Mesh *m, MeshEntity *tri, const Matrix3x3 &Q=Matrix3x3(1., 0., 0., 0., 1., 0., 0., 0., 1.))
Returns the shortest height in a tri.
VectorElement MeshElement
Mesh Elements represent the mesh coordinate vector field.
void getJacobian(MeshElement *e, Vector3 const &local, Matrix3x3 &j)
Returns the Jacobian at a local point.
void destroyMeshElement(MeshElement *e)
Destroys a Mesh Element.
const char * getName(Field *f)
Get the name of a Field.
A virtual base for user-defined integrators.
void getShapeGrads(Element *e, Vector3 const &local, NewArray< Vector3 > &grads)
Returns the shape function gradients at a point.
MeshElement * getMeshElement(Element *e)
Get the Mesh Element of a Field Element.