35 #ifndef unstructuredgridfield_h 36 #define unstructuredgridfield_h 120 return ((cell->
getVertex(i-1))->getCoordinates());
146 this->giveBoundingBox(b);
149 return (this->getInterpolation()->global2local (tmp, coords, cgw));
157 bb1 = bb0 = *(this->getVertex(0)->getCoordinates());
159 for (
int i = 1; i < this->giveNumberOfVertices(); ++i ) {
160 const FloatArray *coordinates = this->getVertex(i)->getCoordinates();
161 bb0.
beMinOf(bb0, * coordinates);
162 bb1.
beMaxOf(bb1, * coordinates);
168 for (
int i =1; i< nsd; i++) size=
max(size, bb1(i));
169 for (
int i=0; i<nsd; i++) mask(i)=1;
170 bb.
init (bb0, size, mask);
186 if (this->itype == EGT_line_1)
return interpTable[0];
187 else if (this->itype == EGT_line_2)
return interpTable[1];
188 else if (this->itype == EGT_triangle_1)
return interpTable[2];
189 else if (this->itype == EGT_triangle_2)
return interpTable[3];
190 else if (this->itype == EGT_quad_1)
return interpTable[4];
191 else if (this->itype == EGT_quad_2)
return interpTable[5];
192 else if (this->itype == EGT_tetra_1)
return interpTable[6];
193 else if (this->itype == EGT_hexa_1)
return interpTable[7];
195 OOFEM_LOG_ERROR (
"UnstructuredGridField.Cell:: Unsupported cell type");
202 int i,j, size = vertexVals[0]->
giveSize();
208 it->
evalN (N, lcoords, cw);
212 for (i=0; i<giveNumberOfVertices(); i++) {
213 for (j=0; j<size; j++) {
214 answer(j)+=
N(i)*vertexVals[i]->
at(j+1);
220 return this->vertices(i);
315 { this->timeStamp = this->octreeTimeStamp = 0;
316 this->vertexList.resize(nvert);
317 this->cellList.resize(ncells);
318 this->valueList.resize(nvert);
319 this->octreeOriginShift = octreeOriginShift;
328 vertexList[num] =
Vertex(coords);
335 cellList[num]=
Cell(type, vertices,
this);
341 std::list<Cell> elist;
342 if ((mode == VM_Total) || (mode == VM_TotalIntrinsic)) {
343 if(this->cellList.size()>0){
348 Cell &c = elist.front();
352 for (
int i=0; i<size; i++) {
361 if(!this->vertexList.size()) {
365 double minDist=0.,dist=0.;
367 int idOfClosestPoint=-1;
368 for(
int i=0;i<(int) this->vertexList.size();i++){
369 const FloatArray *pcoords=this->vertexList[i].getCoordinates();
370 dist=sqrt( pow(coords[0]-pcoords->
at(1),2)+pow(coords[1]-pcoords->
at(2),2)+pow(coords[2]-pcoords->
at(3),2) );
371 if((dist<minDist) || (!i)){
376 answer=this->valueList[idOfClosestPoint];
391 return this->evaluateAt (answer, *coords, mode, tStep);
414 const char *
giveClassName()
const override {
return "UnstructuredGridField"; }
418 if (this->timeStamp != this->octreeTimeStamp) {
420 this->spatialLocalizer.
clear();
422 std::vector<Vertex>::iterator it = vertexList.begin();
424 cmax= cmin = *((*it).getCoordinates());
427 for (; it != vertexList.end(); ++it) {
428 const FloatArray *vc = (*it).getCoordinates();
429 for (
int j=0; j<nsd; j++) {
430 cmax(j)=
max(cmax(j), (*vc)(j));
431 cmin(j)=
min(cmin(j), (*vc)(j));
435 for (
int j=0; j<nsd; j++) {
436 cmin(j) -= octreeOriginShift;
440 for (
int j=0; j<nsd; j++) {
441 size =
max(size, cmax(j)-cmin(j));
445 bb.
init(cmin, size, mask);
446 this->spatialLocalizer.
init (bb);
447 std::vector<Cell>::iterator cit;
450 for (cit=this->cellList.begin(); cit != this->cellList.end(); ++cit) {
463 this->octreeTimeStamp = this->timeStamp;
468 #endif // unstructuredgridfield_h
Class representing implementation of linear hexahedra interpolation class.
void subtract(const FloatArray &src)
Subtracts array src to receiver.
Templated octree cell containing data of T type.
bool isBBXStage1Defined(BoundingBox &BBXStage1)
Stage1 means, we are looking for objects in a distance given by some boundingBox (e.g.
Squared bounding box for templated octree localizer.
Element_Geometry_Type itype
virtual void evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)=0
Evaluates the array of interpolation functions (shape functions) at given point.
#define OOFEM_LOG_ERROR(...)
FieldType
Physical type of field.
Element_Geometry_Type
Enumerative type used to classify element geometry Possible values are: EGT_point - point in space EG...
Vertex * getVertex(int num)
const FloatArray * giveVertexCoordinates(int i) const
const Vertex * getVertex(int i) const
int interpolate(FloatArray &answer, const FloatArray &pos, FloatArray **vertexVals)
std::list< LocalInsertionData< Cell > > * giveInsertionList(Cell &m)
const FloatArray * getCoordinates() const
The purpose of DataStream abstract class is to allow to store/restore context to different streams...
double & at(int i)
Coefficient access function.
int max(int i, int j)
Returns bigger value form two given decimals.
ValueModeType
Type representing the mode of UnknownType or CharType, or similar types.
Class representing a general abstraction for cell geometry.
Class representing implementation of linear tetrahedra interpolation class.
std::vector< Cell > cellList
contextIOResultType restoreContext(DataStream &stream, ContextMode mode) override
Restores the receiver state previously written in stream.
bool evaluate(Cell &c)
Evaluates a triangle upon its circumscribed cricle.
virtual FloatArray * giveCoordinates()
~CellContainingPointFunctor()
Cell(Element_Geometry_Type t, IntArray &v, UnstructuredGridField *m)
long int octreeTimeStamp
octree build time stamp
void init(FloatArray &origin, double size, IntArray &mask)
Sets all BBOx parameters in ince.
Base class for dof managers.
std::vector< FloatArray > valueList
void giveResult(std::list< Cell > &answer)
Gives the triangles containing the node.
void giveDataOnFilter(std::list< T > &answer, SL_Evaluation_Functor< T > &filter)
Evalutes the search accoring used functor a fills the list with results - NOT IN USE.
Class implementing an array of integers.
Wrapper around element definition to provide FEICellGeometry interface.
Class representing a 2d line quadratic interpolation.
void beMaxOf(const FloatArray &a, const FloatArray &b)
Sets receiver to maximum of a or b's respective elements.
Abstract class representing field.
double distance(const FloatArray &x) const
Computes the distance between position represented by receiver and position given as parameter...
Class representing a general abstraction for finite element interpolation class.
UnstructuredGridField * mesh
UnstructuredGridField(int nvert, int ncells, double octreeOriginShift=0.0)
Constructor.
Class representing a 2d triangular linear interpolation based on area coordinates.
FEInterpolation * getInterpolation() const
void beMinOf(const FloatArray &a, const FloatArray &b)
Sets receiver to be minimum of a or b's respective elements.
int evaluateAt(FloatArray &answer, const FloatArray &coords, ValueModeType mode, TimeStep *tStep) override
Evaluates the field at given point.
virtual ~FEICellGeometryWrapper()
virtual bool evaluate(Cell &member, OctantRecT< Cell > *cell)
void addVertex(int num, FloatArray &coords)
Help class for storing pointer to octant cell and position of the member in the data list...
virtual int global2local(FloatArray &answer, const FloatArray &gcoords, const FEICellGeometry &cellgeo)=0
Evaluates local coordinates from given global ones.
std::vector< Vertex > vertexList
Field defined by values fefined on unstructured grid.
Class representing a 2d quadrilateral with quadratic interpolation based on isoparametric coordinates...
void addCell(int num, Element_Geometry_Type type, IntArray &vertices)
int giveNumberOfVertices() const
void setVertexValue(int num, const FloatArray &vv)
Class representing a 2d line with linear interpolation.
void giveBoundingBox(BoundingBox &bb) const
Class representing vector of real numbers.
bool isBBXStage2Defined(BoundingBox &BBXStage2)
Stage2BBX is given by results of a prior search.
contextIOResultType saveContext(DataStream &stream, ContextMode mode) override
Stores receiver state to output stream.
Functor base class responsible for insertion of members into the octree cell.
bool contains(const FloatArray &coords) const
OctantRec::BoundingBoxStatus testBoundingBox(BoundingBox &testedBBX)
Tests the position of a bounding box in relation to the octant cell.
bool containsPoint(const FloatArray &coords) const
const char * giveClassName() const override
void zero()
Zeroes all coefficients of receiver.
int insertMemberIntoOctree(T &memberID, SL_Insertion_Functor< T > &functor)
Inserts member into the octree using functor for the evaluation.
double octreeOriginShift
octree origin shift
long ContextMode
Context mode (mask), defining the type of information written/read to/from context.
Templated octree spatial localizer.
Functor base class for evaluating search tasks on the octree according given condition.
CellContainingPointFunctor(const FloatArray &pos)
Constructor.
int min(int i, int j)
Returns smaller value from two given decimals.
int evaluateAt(FloatArray &answer, DofManager *dman, ValueModeType mode, TimeStep *tStep) override
Implementaton of Field::evaluateAt for DofManager.
int init(BoundingBox &BBX, int initialDivision=0)
Initilizes the octree structure.
long int timeStamp
receiver timestamp
FEICellGeometryWrapper(const Cell *c)
int giveNumberOfVertices() const
Second order triangular interpolation in 2D (6 nodes).
Class representing a 2d isoparametric linear interpolation based on natural coordinates for quadrilat...
int giveSize() const
Returns the size of receiver.
the oofem namespace is to define a context or scope in which all oofem names are defined.
virtual ~UnstructuredGridField()
double giveClosestPoint(FloatArray &lcoords, FloatArray &closest, const FloatArray &gcoords)
void giveStartingPosition(FloatArray &answer)
Gives the starting position of the search.
OctreeSpatialLocalizerT< Cell > spatialLocalizer
Spatial Localizer.
Class representing solution step.
virtual void local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)=0
Evaluates global coordinates from given local ones.
void registerInsertion(Cell &member, LocalInsertionData< Cell > lidata)
void resize(int s)
Resizes receiver towards requested size.