35#ifndef unstructuredgridfield_h
36#define unstructuredgridfield_h
117 return ( (
cell->getVertex(i) )->getCoordinates() );
157 bb1 = bb0 = this->
getVertex(1)->getCoordinates();
160 const auto &coordinates = this->
getVertex(i)->getCoordinates();
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 ]; }
else if ( this->itype == EGT_line_2 ) {
return interpTable [ 1 ]; }
else if ( this->itype == EGT_triangle_1 ) {
return interpTable [ 2 ]; }
else if ( this->itype == EGT_triangle_2 ) {
return interpTable [ 3 ]; }
else if ( this->itype == EGT_quad_1 ) {
return interpTable [ 4 ]; }
else if ( this->itype == EGT_quad_2 ) {
return interpTable [ 5 ]; }
else if ( this->itype == EGT_tetra_1 ) {
return interpTable [ 6 ]; }
else if ( this->itype == EGT_hexa_1 ) {
return interpTable [ 7 ]; }
else {
196 int i, j, size = vertexVals [ 0 ]->
giveSize();
202 it->
evalN(
N, lcoords, cw);
207 for ( j = 0; j < size; j++ ) {
208 answer(j) +=
N(i) * vertexVals [ i ]->
at(j + 1);
215 return this->vertices [ i - 1 ];
310 this->timeStamp = this->octreeTimeStamp = 0;
311 this->vertexList.resize(nvert);
312 this->cellList.resize(ncells);
313 this->valueList.resize(nvert);
318 void initialize(
int nvert,
int ncells,
double _octreeOriginShift = 0.0)
320 this->timeStamp = this->octreeTimeStamp = 0;
321 this->vertexList.resize(nvert);
322 this->cellList.resize(ncells);
323 this->valueList.resize(nvert);
324 this->octreeOriginShift = _octreeOriginShift;
340 return ( this->vertexList [ num - 1 ].getCoordinates() );
344 return & this->vertexList [ num - 1 ];
353 ValueModeType mode,
TimeStep *tStep)
override {
354 std::list< Cell >elist;
355 if ( ( mode == VM_Total ) || ( mode == VM_TotalIntrinsic ) ) {
356 if ( this->cellList.size() > 0 ) {
360 if ( elist.size() ) {
361 Cell &c = elist.front();
365 for (
int i = 0; i < size; i++ ) {
366 vertexValues [ i ] = & ( this->valueList [ c.
getVertexNum(i + 1) - 1 ] );
377 if ( !this->vertexList.size() ) {
382 double minDist = 0., dist = 0.;
384 int idOfClosestPoint = -1;
385 for (
int i = 0; i < ( int ) this->vertexList.size(); i++ ) {
386 const auto &pcoords = this->vertexList [ i ].getCoordinates();
387 dist = sqrt(pow(coords [ 0 ] - pcoords.
at(1), 2) + pow(coords [ 1 ] - pcoords.
at(2), 2) + pow(coords [ 2 ] - pcoords.
at(3), 2) );
388 if ( ( dist < minDist ) || ( !i ) ) {
390 idOfClosestPoint = i;
393 answer = this->valueList [ idOfClosestPoint ];
406 ValueModeType mode,
TimeStep *tStep)
override {
408 return this->
evaluateAt(answer, coords, mode, tStep);
415 const char *
giveClassName()
const override {
return "UnstructuredGridField"; }
419 if ( this->timeStamp != this->octreeTimeStamp ) {
421 this->spatialLocalizer.
clear();
423 std::vector< Vertex >::iterator it =
vertexList.begin();
425 cmax = cmin = ( * it ).getCoordinates();
429 const auto &vc = ( * it ).getCoordinates();
430 for (
int j = 0; j < nsd; j++ ) {
431 cmax(j) =
max(cmax(j), vc(j) );
432 cmin(j) =
min(cmin(j), vc(j) );
436 for (
int j = 0; j < nsd; j++ ) {
441 for (
int j = 0; j < nsd; j++ ) {
442 size =
max(size, cmax(j) - cmin(j) );
446 bb.
init(cmin, size, mask);
447 this->spatialLocalizer.
init(bb);
448 std::vector< Cell >::iterator cit;
451 for ( cit = this->cellList.begin(); cit != this->cellList.end(); ++cit ) {
464 this->octreeTimeStamp = this->timeStamp;
void init(FloatArray &_origin, double _size, IntArray &mask)
bool contains(const FloatArray &coords) const
const FloatArray & giveCoordinates() const
virtual int global2local(FloatArray &answer, const FloatArray &gcoords, const FEICellGeometry &cellgeo) const =0
virtual void evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const =0
virtual void local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const =0
Field(FieldType b=FieldType::FT_Unknown)
Index giveSize() const
Returns the size of receiver.
virtual void printYourself() const
void beMinOf(const FloatArray &a, const FloatArray &b)
void zero()
Zeroes all coefficients of receiver.
void beMaxOf(const FloatArray &a, const FloatArray &b)
void subtract(const FloatArray &src)
OctantRec::BoundingBoxStatus testBoundingBox(BoundingBox &A)
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.
int insertMemberIntoOctree(T &memberID, SL_Insertion_Functor< T > &functor)
Inserts member into the octree using functor for the evaluation.
int init(BoundingBox &BBX, int initialDivision=0)
Initilizes the octree structure.
void giveStartingPosition(FloatArray &answer) override
void giveResult(std::list< Cell > &answer) override
CellContainingPointFunctor(const FloatArray &pos)
bool isBBXStage1Defined(BoundingBox &BBXStage1) override
bool isBBXStage2Defined(BoundingBox &BBXStage2) override
~CellContainingPointFunctor()
bool evaluate(Cell &c) override
void registerInsertion(Cell &member, LocalInsertionData< Cell >lidata) override
bool evaluate(Cell &member, OctantRecT< Cell > *cell) override
std::list< LocalInsertionData< Cell > > * giveInsertionList(Cell &m) override
FEICellGeometryWrapper(const Cell *c)
int giveNumberOfVertices() const override
const Element_Geometry_Type giveGeometryType() const override
virtual ~FEICellGeometryWrapper()
const FloatArray giveVertexCoordinates(int i) const override
Cell(const Element_Geometry_Type t, IntArray &v, UnstructuredGridField *m)
void giveBoundingBox(BoundingBox &bb) const
const Vertex * getVertex(int i) const
int interpolate(FloatArray &answer, const FloatArray &pos, FloatArray **vertexVals)
Element_Geometry_Type itype
bool containsPoint(const FloatArray &coords) const
static FEInterpolation * interpTable[]
FEInterpolation * getInterpolation() const
Cell & operator=(const Cell &c)
int giveNumberOfVertices() const
UnstructuredGridField * mesh
double giveClosestPoint(FloatArray &lcoords, FloatArray &closest, const FloatArray &gcoords)
const FloatArray & getCoordinates() const
Vertex & operator=(const Vertex &v)
void addVertex(int num, FloatArray &coords)
int evaluateAt(FloatArray &answer, const FloatArray &coords, ValueModeType mode, TimeStep *tStep) override
int giveNumberOfVertices() const
void saveContext(DataStream &stream) override
const char * giveClassName() const override
void setVertexValue(int num, const FloatArray &vv)
std::vector< Cell > cellList
int evaluateAt(FloatArray &answer, DofManager *dman, ValueModeType mode, TimeStep *tStep) override
std::vector< Vertex > vertexList
double octreeOriginShift
octree origin shift
void restoreContext(DataStream &stream) override
Vertex * getVertex(int num)
void addCell(int num, const Element_Geometry_Type type, IntArray &vertices)
OctreeSpatialLocalizerT< Cell > spatialLocalizer
const FloatArray & getVertexCoordinates(int num) const
long int octreeTimeStamp
octree build time stamp
UnstructuredGridField(int nvert, int ncells, double octreeOriginShift=0.0)
int giveNumberOfCells() const
std::vector< FloatArray > valueList
virtual ~UnstructuredGridField()
long int timeStamp
receiver timestamp
void initialize(int nvert, int ncells, double _octreeOriginShift=0.0)
#define OOFEM_LOG_ERROR(...)
FloatArrayF< N > min(const FloatArrayF< N > &a, const FloatArrayF< N > &b)
FieldType
Physical type of field.
FloatArrayF< N > max(const FloatArrayF< N > &a, const FloatArrayF< N > &b)
double distance(const FloatArray &x, const FloatArray &y)