23#ifndef _GEMA_GAUSSINDEX_H_
24#define _GEMA_GAUSSINDEX_H_
28#include <QVarLengthArray>
66 virtual int cellIp(
int gpIndex,
int* ip)
const = 0;
87 virtual int pointIndex(
int cellId,
int ip)
const {
return _proxy->pointIndex(cellId, ip); }
88 virtual int cellIp(
int gpIndex,
int* ip)
const {
return _proxy->cellIp(gpIndex, ip); }
110 int numPoints()
const {
return _numIp ? _numCells * _numIp : _cellOffset.last(); }
118 assert(cellId >= 0 && cellId < _numCells);
119 return _numIp ? _numIp : _cellOffset[cellId + 1] - _cellOffset[cellId];
127 assert(cellId >= 0 && cellId < _numCells);
128 assert(ip >= 0 && ip < numPoints(cellId));
129 return ip + (_numIp ? cellId * _numIp : _cellOffset[cellId]);
137 assert(gpIndex >= 0 && gpIndex < numPoints());
142 *ip = gpIndex % _numIp;
143 return gpIndex / _numIp;
146 int pos = qUpperBound(_cellOffset, gpIndex) - _cellOffset.data();
147 assert(pos >= 0 && pos < _cellOffset.size());
149 if(gpIndex < _cellOffset[pos])
152 *ip = gpIndex - _cellOffset[pos];
157 void clear() { _numIp = _numCells = 0; _cellOffset.clear(); _cellOffset.append(0); }
160 size_t usedMemory()
const {
return _numIp ? 0 : _cellOffset.capacity() *
sizeof(int); }
162#if defined ENABLE_TESTS || defined ENABLE_VALUESET_TESTS
163 void validateInternalStructure()
const;
196 virtual int numPoints()
const {
return _cellOffset.last(); }
204 assert(cellId >= 0 && cellId < _cellOffset.size()-1);
205 return _cellOffset[cellId + 1] - _cellOffset[cellId];
215 assert(cellId >= 0 && cellId < _cellOffset.size()-1);
216 assert((ip >= 0 && ip < numPoints(cellId)) || (_cellOffset[cellId + 1] == _cellOffset[cellId]));
217 return (_cellOffset[cellId + 1] != _cellOffset[cellId]) ? ip + _cellOffset[cellId] : -1;
224 virtual int cellIp(
int gpIndex,
int* ip)
const
226 assert(gpIndex >= 0 && gpIndex < numPoints());
229 int pos = qUpperBound(_cellOffset, gpIndex) - _cellOffset.data();
230 assert(pos >= 0 && pos < _cellOffset.size());
232 if(gpIndex < _cellOffset[pos])
235 *ip = gpIndex - _cellOffset[pos];
240 void clear() { _numCells = 0; _cellOffset.clear(); _cellOffset.append(0); }
243 size_t usedMemory()
const {
return _cellOffset.capacity() *
sizeof(int); }
245#if defined ENABLE_TESTS || defined ENABLE_VALUESET_TESTS
246 void validateInternalStructure()
const;
281 bool addValues(
const int* numAddedValues);
282 bool addValues(
int firstAddedElement);
284 void restoreSize(
int oldNumCells);
290 bool addValuesWorker(
const int* numAddedValues,
int firstAddedElement);
292 int numAddedGaussPoints(
const int* numTypes,
int* pointsPerCell,
int* numElem);
293 int numAddedGaussPoints(
int firstElement,
int* pointsPerCell,
int* numElem);
295 int fixedAddedElements(
const int* numTypes,
int firstElement,
int* numElem)
const;
297 void fillOffsetVectorFromMesh (
int firstCell = 0);
298 void fillOffsetVectorFromTypes(
int firstCell,
const int* numTypes,
int newFixed);
Interface for helping managing mesh cell groups and returning the elements in their union.
Definition gmCellGroupSet.h:35
Base interface for FEM (finite element) meshes.
Definition gmElementMesh.h:42
A Gauss index interface indexing a filtered set of mesh elements.
Definition gmGaussIndex.h:326
int _rule
The indexed rule set.
Definition gmGaussIndex.h:335
bool _activeOnly
Should we index active cells only?
Definition gmGaussIndex.h:334
const GmCellGroupSet * _group
The group set object listing the set of mesh cells.
Definition gmGaussIndex.h:333
A helper class that implements a GaussIndex like interface for the case where the index can filter ce...
Definition gmGaussIndex.h:193
void clear()
Clears the index.
Definition gmGaussIndex.h:240
virtual int numPoints(int cellId) const
Returns the number of Gauss points for the given Cell. Returns 0 if the cell does not belongs to the ...
Definition gmGaussIndex.h:202
virtual int cellIp(int gpIndex, int *ip) const
Given a Gauss point "linear" index (a value from 0 to numPoints()-1), returns the mesh cell index + i...
Definition gmGaussIndex.h:224
virtual int numCells() const
Returns the number of cells in the index.
Definition gmGaussIndex.h:199
int _numCells
The number of cells in the index set (might be less than the number of cells in the offset vector)
Definition gmGaussIndex.h:254
size_t usedMemory() const
Returns the size of the used memory.
Definition gmGaussIndex.h:243
QVarLengthArray< int, 2 > _cellOffset
Definition gmGaussIndex.h:266
virtual int numPoints() const
Returns the number of Gauss points in the index.
Definition gmGaussIndex.h:196
GmFilteredGaussIndexBase()
Default empty index constructor.
Definition gmGaussIndex.h:251
virtual int pointIndex(int cellId, int ip) const
Given a mesh cell index and an integration point index, returns the Gauss point "linear" index,...
Definition gmGaussIndex.h:213
A Gauss index interface always indexing ALL the elements in either the full mesh or in the given mesh...
Definition gmGaussIndex.h:312
const GmElementMesh * _mesh
The mesh object to which this index is tied to.
Definition gmGaussIndex.h:319
const int * _cells
The cell subset. If NULL the whole mesh will be used.
Definition gmGaussIndex.h:320
int _rule
The indexed rule set.
Definition gmGaussIndex.h:321
A class storing an index capable of determining the number of integration points belonging to a mesh,...
Definition gmGaussIndex.h:42
virtual int pointIndex(int cellId, int ip) const =0
Given a mesh cell index and an integration point index, returns the Gauss point "linear" index,...
virtual int cellIp(int gpIndex, int *ip) const =0
Given a Gauss point "linear" index (a value from 0 to numPoints()-1), returns the mesh cell index + i...
virtual ~GmGaussIndex()
Virtual destructor.
Definition gmGaussIndex.h:45
virtual int numPoints(int cellId) const =0
Returns the number of Gauss points for the given Cell. Returns 0 if the cell does not belongs to the ...
virtual int numPoints() const =0
Returns the number of Gauss points in the index.
virtual int numCells() const =0
Returns the number of cells in the index.
A helper class that implements a GmGaussIndex interface from a proxy object that includes all the nee...
Definition gmGaussIndex.h:75
virtual int cellIp(int gpIndex, int *ip) const
Given a Gauss point "linear" index (a value from 0 to numPoints()-1), returns the mesh cell index + i...
Definition gmGaussIndex.h:88
virtual int numPoints(int cellId) const
Returns the number of Gauss points for the given Cell. Returns 0 if the cell does not belongs to the ...
Definition gmGaussIndex.h:86
GmGaussIndexProxy(T *proxy, bool ownership)
Constructor. Takes ownership of the received object if ownership is true.
Definition gmGaussIndex.h:78
virtual int numPoints() const
Returns the number of Gauss points in the index.
Definition gmGaussIndex.h:84
bool _ownsProxy
Do we own the proxy object?
Definition gmGaussIndex.h:92
virtual ~GmGaussIndexProxy()
Destructor. Deletes the proxy if we have its ownership.
Definition gmGaussIndex.h:81
T * _proxy
The proxy object.
Definition gmGaussIndex.h:91
virtual int numCells() const
Returns the number of cells in the index.
Definition gmGaussIndex.h:85
virtual int pointIndex(int cellId, int ip) const
Given a mesh cell index and an integration point index, returns the Gauss point "linear" index,...
Definition gmGaussIndex.h:87
A Gauss index interface always indexing ALL the elements of a mesh, with support for mesh growing.
Definition gmGaussIndex.h:275
const GmElementMesh * mesh() const
Returns the associated mesh.
Definition gmGaussIndex.h:287
const GmElementMesh * _mesh
The mesh object to which this index is tied to.
Definition gmGaussIndex.h:300
int _rule
The indexed rule set.
Definition gmGaussIndex.h:301
A helper class that implements a GaussIndex like interface for the basic case where the ENTIRE mesh i...
Definition gmGaussIndex.h:107
int pointIndex(int cellId, int ip) const
Given a mesh cell index and an integration point index, returns the Gauss point "linear" index,...
Definition gmGaussIndex.h:125
int numCells() const
Returns the number of cells in the index.
Definition gmGaussIndex.h:113
QVarLengthArray< int, 2 > _cellOffset
Definition gmGaussIndex.h:177
int numPoints(int cellId) const
Returns the number of Gauss points for the given Cell.
Definition gmGaussIndex.h:116
GmUnfilteredGaussIndexBase()
Default empty index constructor.
Definition gmGaussIndex.h:168
int _numCells
The number of cells in the index set.
Definition gmGaussIndex.h:171
int _numIp
The fixed number of integration points per cell or 0 if index based.
Definition gmGaussIndex.h:170
int cellIp(int gpIndex, int *ip) const
Given a Gauss point "linear" index (a value from 0 to numPoints()-1), returns the mesh cell index + i...
Definition gmGaussIndex.h:135
int numPoints() const
Returns the number of Gauss points in the index.
Definition gmGaussIndex.h:110
void clear()
Clears the index.
Definition gmGaussIndex.h:157
size_t usedMemory() const
Returns the size of the used memory.
Definition gmGaussIndex.h:160
Declaration of useful configuration definitions for the Core library.
#define GMC_API_EXPORT
Macro for controlling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_L...
Definition gmCoreConfig.h:35