195 inline static SP::EMM_Grid3D
New() {
231 mSegmentsNumber[0]=nx;
232 mSegmentsNumber[1]=ny;
233 mSegmentsNumber[2]=nz;
234 mElementsNumber=nx*ny*nz;
235 mNeighborsIndicators->setSize(mElementsNumber);
245 nx=mSegmentsNumber[0];
246 ny=mSegmentsNumber[1];
247 nz=mSegmentsNumber[2];
262 return mSegmentsNumber[d];
273 return i+mSegmentsNumber[0]*(j+mSegmentsNumber[1]*k);
283 i=index%mSegmentsNumber[0];
284 mWorkIndex=index/mSegmentsNumber[0];
285 j=mWorkIndex%mSegmentsNumber[1];
286 k=mWorkIndex/mSegmentsNumber[1];
296 return index%mSegmentsNumber[0];
298 return (index/mSegmentsNumber[0])%mSegmentsNumber[1];
301 return (index/mSegmentsNumber[0])/mSegmentsNumber[1];
310 return mSegmentsNumber[0]*mSegmentsNumber[1]*mSegmentsNumber[2];
317 return (mSegmentsNumber[0]+1)*(mSegmentsNumber[1]+1)*(mSegmentsNumber[2]+1);
352 return mSegmentsSize[d];
358 tReal dx=mSegmentsSize[0];
359 for (
tUSInt i=1;i<3;i++) dx=(dx<mSegmentsSize[i])?dx:mSegmentsSize[i];
366 tReal dx=mSegmentsSize[0];
367 for (
tUSInt i=1;i<3;i++) dx=(dx>mSegmentsSize[i])?dx:mSegmentsSize[i];
404 const tReal *l =&mAdimensionizedSegmentsSize[2];
406 for (
tUSInt k=0;k<2;k++) {
407 ok=ok && (fabs(1.-(*lk)/(*l))<CORE_Object::computeEpsilon<tReal>());
421 mLmax=mSegmentsSize[0];
423 mLmin=mSegmentsSize[0];
425 if (mSegmentsSize[k]>mLmax) {
426 mLmax=mSegmentsSize[k];
428 if (mSegmentsSize[k]<mLmin) {
429 mLmin=mSegmentsSize[k];
436 mAdimensionizedVolume=1.;
438 mAdimensionizedSegmentsSize[k]=mSegmentsSize[k]/
mL;
439 mAdimensionizedVolume*=mAdimensionizedSegmentsSize[k];
470 for (
tUSInt i=0;i<3;i++) {
471 mIsPeriodic=mIsPeriodic || v[i];
472 mIsDirectionPeriodic[i]=v[i];
478 mIsDirectionPeriodic[k]=v;
480 for (
tUSInt i=0;i<3;i++) {
481 mIsPeriodic=mIsPeriodic || mIsDirectionPeriodic[i];
497 return mIsDirectionPeriodic[d];
515 return 3*periodicity[0]+4*periodicity[1]+16*periodicity[2];
536 return ((*mNeighborsIndicators.get())[index]>=MAGNETIZED_ELEMENT_MIN_INDICATOR);
555 return ((*mNeighborsIndicators.get())[index]==MAGNETIZED_DOMAIN_INTERIOR_INDICATOR);
578 const tUSInt& iFace)
const {
579 if (iFace>=FACES_NUMBER_PER_ELEMENT)
581 "index of local face is greater than the max faces number in elements");
583 return (
iand((*mNeighborsIndicators.get())[iElement],p)==p);
633 return *mNeighborsIndicators.
get();
643 return *mNeighborsIndicators.
get();
652 return (*mNeighborsIndicators.get())[index];
742 if ((periodicity&3)!=0) {
751 if ((periodicity&12)!=0) {
760 if ((periodicity&48)!=0) {
793 3*((*periodicity)+4*periodicity[1]+16*periodicity[2]));
810 return ((X&((~N)&(~P)))!=0);
832 3*((*periodicity)+4*(periodicity[1]+4*periodicity[2])));
847 return ((X&((~N)&(P)))!=0);
866 3*((*periodicity)+4*(periodicity[1]+4*periodicity[2])));
884 return ((X&((~N)&(P))&(42))!=0);
static const tFlag POINT
Definition: EMM_Grid3D.h:66
This class is a base class of E-MicromM core package.
Definition: EMM_Object.h:21
static tBoolean IS_POINT_IN_PERIODIC_BOUNDARY(const tCellFlag &X, const tCellFlag &N, const tCellFlag &P)
test if the local point is in periodical boundary
Definition: EMM_Grid3D.h:844
tIndex mNextElementTranslation[FACES_NUMBER_PER_ELEMENT]
get the index translation in each direction to have the previous or next element
Definition: EMM_Grid3D.h:150
This class describes a grid3d mesh.
Definition: EMM_Grid3D.h:48
const tReal & getMaxElementSize() const
get the max length of the cell
Definition: EMM_Grid3D.h:384
tReal mL
reference length
Definition: EMM_Grid3D.h:142
tBoolean saveToFile(const tString &fileName) const
save to a file
Definition: EMM_Grid3D.cpp:1095
#define iand(a, b)
Definition: types.h:159
static const tUCInt FACES_NUMBER_PER_ELEMENT
Definition: EMM_Grid3D.h:80
static const tLimitCondition DIRICHLET_LIMIT_CONDITION
Definition: EMM_Grid3D.h:59
static const tLimitCondition NEUMANN_LIMIT_CONDITION
Definition: EMM_Grid3D.h:60
tReal getMaxStepSize() const
get the max step size
Definition: EMM_Grid3D.h:365
#define tLimitCondition
Definition: EMM_Types.h:19
const tUInteger * getSegmentsNumber() const
get the segments number in all directions
Definition: EMM_Grid3D.h:253
static tBoolean GET_MASTER_PERIODIC_POINT(const tCellFlag &periodicity, const tUIndex &Nx, const tUIndex &Ny, const tUIndex &Nz, tUIndex &iQ, tUIndex &jQ, tUIndex &kQ)
get the index of master point in [0,pointsNumber[. The master point is the point in pair face in the ...
Definition: EMM_Grid3D.h:738
tBoolean saveToGEOFile(const tString &fileName) const
save to a geo file
Definition: EMM_Grid3D.cpp:1108
static tBoolean IS_POINT_IN_PERIODIC_BOUNDARY(const tBoolean x[], const tCellFlag &N, const tBoolean periodicity[])
test if the local point is in a periodical boundary
Definition: EMM_Grid3D.h:823
tReal mSegmentsSize[3]
segments size
Definition: EMM_Grid3D.h:125
#define tUInteger
Definition: types.h:91
static const tUIndex UNMAGNETIZED_ELEMENT
return the index of the unmagnetized element
Definition: EMM_Grid3D.h:56
tReal getMinStepSize() const
get the min step size
Definition: EMM_Grid3D.h:357
static const tDimension X
Definition: EMM_Object.h:33
static tBoolean IS_POINT_IN_BOUNDARY(const tBoolean x[], const tCellFlag &N, const tBoolean periodicity[])
test if the local point is in magnetized boundary.
Definition: EMM_Grid3D.h:788
tIndex mPeriodicElementTranslation[FACES_NUMBER_PER_ELEMENT]
get the index translation in each direction to have the periodic element
Definition: EMM_Grid3D.h:154
This class describes a general morse array of size N. A morse array is composed by.
Definition: CORE_MorseArray.h:31
virtual tString toString() const
turn the mesh into string
Definition: EMM_Grid3D.cpp:1158
tUIndex mElementsNumber
number of elements
Definition: EMM_Grid3D.h:167
tReal adimensionize()
compute the adimensionized constants
Definition: EMM_Grid3D.h:418
static const tUCInt FACE_POINTS[]
points index of elements get the local index of the points in face : FACE_POINTS[f*POINTS_NUMBER_PER_...
Definition: EMM_Grid3D.h:96
T & get(const tUIndex &i)
get the value of the array at index i
Definition: CORE_Array.h:555
static SP::EMM_Grid3D New()
create a Grid3D object
Definition: EMM_Grid3D.h:195
const tReal & getReferenceLength() const
get the reference length
Definition: EMM_Grid3D.h:379
void updateElementTranslations()
update the values of private arrays depending on the discretization of the domain : ...
Definition: EMM_Grid3D.cpp:93
#define tUCInt
Definition: types.h:21
#define tUSInt
Definition: types.h:28
SP::EMM_CellFlagArray mNeighborsIndicators
mNeigbor indicator for each element
Definition: EMM_Grid3D.h:159
#define tBoolean
Definition: types.h:139
tBoolean mIsPeriodic
true if the mesh is periodic in one direction
Definition: EMM_Grid3D.h:117
const tReal & getAdimensionizedVolume() const
get the adimensionized element volume <=1
Definition: EMM_Grid3D.h:448
void setStepsSize(const tReal &lx, const tReal &ly, const tReal &lz)
set the step size in the direction x,y,z : length of segment in each direction
Definition: EMM_Grid3D.h:329
const tReal & getStepSize(const tUSInt &d) const
get the step size in the direction d
Definition: EMM_Grid3D.h:351
tBoolean isCubicVolume() const
return true if the element is cubic
Definition: EMM_Grid3D.h:402
static tBoolean isFaceOnNeumannBoundary(const tCellFlag &periodicity, const tUInteger &xCell, const tUInteger &yCell, const tUInteger &zCell, const tUCInt &f, const tUInteger &nPx, const tUInteger &nPy, const tUInteger &nPz, const tLimitCondition *dirichletPoints)
return tue if the face f of the magnetized cell (xCell,yCell,zCell) is on Neumann boundary ...
Definition: EMM_Grid3D.cpp:577
static const tCellFlag MAGNETIZED_DOMAIN_INTERIOR_INDICATOR
Definition: EMM_Grid3D.h:73
static tBoolean IS_POINT_IN_SLAVE_PERIODIC_BOUNDARY(const tCellFlag &X, const tCellFlag &N, const tCellFlag &P)
test if the local point is in slave periodical boundary
Definition: EMM_Grid3D.h:881
static tCellFlag getPeriodicIndicator(const tBoolean periodicity[])
get the periodic indicator by face with if face f is periodic
Definition: EMM_Grid3D.h:514
static const tFlag ELEMENT
Definition: EMM_Grid3D.h:69
static const tCellFlag MAGNETIZED_ELEMENT_MIN_INDICATOR
Definition: EMM_Grid3D.h:76
static tBoolean IS_POINT_IN_BOUNDARY(const tCellFlag &X, const tCellFlag &N, const tCellFlag &P)
test if the local point is in magnetized boundary
Definition: EMM_Grid3D.h:807
void getSegmentsNumber(tUInteger &nx, tUInteger &ny, tUInteger &nz) const
get the segments number in all directions
Definition: EMM_Grid3D.h:244
EMM_Array< tCellFlag > EMM_CellFlagArray
Definition: EMM_Array.h:278
tBoolean isElementMagnetized(const tUIndex &index) const
Definition: EMM_Grid3D.h:535
void setIsDirectionPeriodic(const tUSInt &k, const tBoolean &v)
set if the mesh is periodic on all directions
Definition: EMM_Grid3D.h:477
static const tCellFlag TWO_POWER_FACES[]
Definition: EMM_Grid3D.h:109
static tBoolean isFaceOnDirichletBoundary(const tCellFlag &periodicity, const tUInteger &xCell, const tUInteger &yCell, const tUInteger &zCell, const tUCInt &f, const tUInteger &nPx, const tUInteger &nPy, const tUInteger &nPz, const tLimitCondition *dirichletPoints)
return tue if the face f of the magnetized cell (xCell,yCell,zCell) is on Dirichlet boundary ...
Definition: EMM_Grid3D.cpp:504
static tBoolean IS_ELEMENT_MAGNETIZED(const tCellFlag &v)
test if the element woth neighbor indicator v is magnetized
Definition: EMM_Grid3D.h:546
void updateLimitConditionOnPoints(EMM_LimitConditionArray &lc) const
update the limit condition of each point.
Definition: EMM_Grid3D.cpp:656
static const tLimitCondition NO_LIMIT_CONDITION
Definition: EMM_Grid3D.h:61
const tReal * getAdimensionizedSegmentsSize() const
return the adimensionized segments size
Definition: EMM_Grid3D.h:373
tBoolean loadFromFile(const tString &fileName)
load from a file
Definition: EMM_Grid3D.cpp:884
void buildMagnetizedNeighborsIndices(const EMM_MatterField &matters, CORE_UIndexMorseArray &neighbors) const
build the neighbors : for each element i build all the magnetized neighbors of element i ...
Definition: EMM_Grid3D.cpp:399
tUInteger mSegmentsNumber[3]
segments number
Definition: EMM_Grid3D.h:121
#define tCellFlag
Definition: EMM_Types.h:16
tUIndex getVerticesNumber() const
get the vertices number of the grid
Definition: EMM_Grid3D.h:316
#define tIndex
Definition: types.h:129
static const tBoolean ELEMENT_POINTS[]
points coordinate of elements get the local coodinates of the points in {0,1} : ELEMENT_POINTS[i*3] i...
Definition: EMM_Grid3D.h:91
const tBoolean & isDirectionPeriodic(const tFlag &d) const
get if the mesh is periodic on direction d
Definition: EMM_Grid3D.h:495
static const tUCInt POINTS_NUMBER_PER_FACE
Definition: EMM_Grid3D.h:86
tUIndex getElementIndex(const tUIndex &i, const tUIndex &j, const tUIndex &k) const
return the element index of the element located at (i,j,k) coordinates on segments number ...
Definition: EMM_Grid3D.h:272
tBoolean loadFromGEOStream(ifstream &f, tUInteger &nReadLines)
load the neighbors from geo stream
Definition: EMM_Grid3D.cpp:1040
tUIndex mWorkIndex
Definition: EMM_Grid3D.h:171
tUIndex mBoundElement[FACES_NUMBER_PER_ELEMENT]
get the index in [0,mSegmentsNumber[k][ of the 2 bound elements at each direction ...
Definition: EMM_Grid3D.h:146
tUIndex getElementSegmentIndex(const tUIndex &index, const tUSInt &d) const
return the element coordinates on segment number on d direction
Definition: EMM_Grid3D.h:293
#define tCInt
Definition: types.h:24
tBoolean loadFromGEOFile(const tString &fileName)
load from a geo file
Definition: EMM_Grid3D.cpp:894
This class describes the field of matters.
Definition: EMM_MatterField.h:34
tBoolean mIsDirectionPeriodic[3]
priodicity of direction the mesh
Definition: EMM_Grid3D.h:113
const tReal * getSegmentsSize() const
return the segments size
Definition: EMM_Grid3D.h:395
tCellFlag getPeriodicIndicator() const
get the periodic indicator by face with if face f is periodic
Definition: EMM_Grid3D.h:508
virtual ~EMM_Grid3D(void)
destroy a Grid3D
Definition: EMM_Grid3D.cpp:88
void setIsPeriodic(const tBoolean v[3])
set if the mesh is periodic on all directions
Definition: EMM_Grid3D.h:468
tUIndex getElementsNumber() const
get the elements number of the grid
Definition: EMM_Grid3D.h:309
#define tUIndex
Definition: types.h:126
tUIndex getNeighborElement(const tUIndex &index, const tUCInt &iFace) const
return the index of the element which is next to the element iElement with iFace in common ...
Definition: EMM_Grid3D.cpp:267
void computeNormalFaceAdimensionizedLength(tReal *L2) const
build the adimensionized length for each face in its normal direction
Definition: EMM_Grid3D.cpp:135
void setStepSize(const tReal &l)
set the step size in the direction x,y,z when it's the same for the 3 directions
Definition: EMM_Grid3D.h:339
EMM_Grid3D(void)
create a grid 3D
Definition: EMM_Grid3D.cpp:70
#define tString
Definition: types.h:135
tBoolean loadFooterFromGEOStream(ifstream &f, tUInteger &nReadLines, tUInteger &nReadProperties)
load header from geo stream
Definition: EMM_Grid3D.cpp:1091
static const tUCInt POINTS_NUMBER_PER_ELEMENT
Definition: EMM_Grid3D.h:83
const tReal & getMinElementSize() const
get the min length of the cell
Definition: EMM_Grid3D.h:389
tReal mLmax
max size of the cell
Definition: EMM_Grid3D.h:139
static const tCInt EDGE_POINTS[]
points index of edge get the local index of the points in edge between face l & r (r>l...
Definition: EMM_Grid3D.h:101
const tBoolean * isDirectionPeriodic() const
get if the mesh is periodic
Definition: EMM_Grid3D.h:488
void buildMagnetizedElements(const EMM_MatterField &matters, CORE_BooleanMorseArray &magnetizedElements) const
build the magnetized element morse array
Definition: EMM_Grid3D.cpp:167
static const tLimitCondition SLAVE_LIMIT_CONDITION
Definition: EMM_Grid3D.h:62
const tUInteger & getSegmentsNumber(const tUSInt &d) const
get the segments number in direction d
Definition: EMM_Grid3D.h:261
const tBoolean & isPeriodic() const
get if the mesh is periodic in one direction
Definition: EMM_Grid3D.h:501
this class describes the exceptions raised for E-MicromM package
Definition: EMM_Exception.h:14
EMM_CellFlagArray & getNeighborsIndicators()
get the neighbor elements for writing
Definition: EMM_Grid3D.h:642
tReal mAdimensionizedSegmentsSize[3]
adimensionized segments size
Definition: EMM_Grid3D.h:128
void buildNeighborsIndices(const EMM_MatterField &matters, CORE_UIndexMorseArray &neighbors) const
build the neighbors index: for each element i build all the (magnetized or not) neighbors of element ...
Definition: EMM_Grid3D.cpp:307
tReal mAdimensionizedVolume
the adimensionized volume
Definition: EMM_Grid3D.h:132
const EMM_CellFlagArray & getNeighborsIndicators() const
get the neighbors indicator for each element for reading
Definition: EMM_Grid3D.h:632
tBoolean loadHeaderFromGEOStream(ifstream &f, tUInteger &nReadLines, tUInteger &nReadProperties)
load header from geo stream
Definition: EMM_Grid3D.cpp:932
const tCellFlag & getNeighborIndicator(const tUIndex &index) const
get the neighbor indicator of the element at index
Definition: EMM_Grid3D.h:651
tBoolean hasNeighborToFace(const tUIndex &iElement, const tUSInt &iFace) const
return true if the element at index iElement have a magnetized neighbor with common face iFace in [0...
Definition: EMM_Grid3D.h:577
const tUIndex & getMagnetizedElementsNumber() const
get the number of magnetized elements
Definition: EMM_Grid3D.h:527
static tBoolean IS_POINT_IN_SLAVE_PERIODIC_BOUNDARY(const tBoolean x[], const tCellFlag &N, const tBoolean periodicity[])
test if the local point is in slave periodical boundary
Definition: EMM_Grid3D.h:860
#define tReal
Definition: types.h:118
void updateMagnetizedElementsNumber()
compute the magnetized elements number form neighbors array the number of magnetized elements is retu...
Definition: EMM_Grid3D.cpp:117
SPC::EMM_CellFlagArray getNeighborsIndicatorsByReference() const
get the neighbor elements for reading
Definition: EMM_Grid3D.h:622
tUIndex mMagnetizedElementsNumber
number of magnetized element
Definition: EMM_Grid3D.h:163
void setSegmentsNumber(const tUInteger &nx, const tUInteger &ny, const tUInteger &nz)
set the segments number in all directions
Definition: EMM_Grid3D.h:230
void getElementSegmentIndices(const tUIndex &index, tUIndex &i, tUIndex &j, tUIndex &k) const
return the element coordinates on segments number
Definition: EMM_Grid3D.h:282
const tReal * getStepsSize() const
get the step size in all directions
Definition: EMM_Grid3D.h:345
tReal mLmin
min size of the cell
Definition: EMM_Grid3D.h:136
#define ASSERT_IN(a)
Definition: types.h:196
tBoolean isInMagnetizedDomainInterior(const tUIndex &index) const
Definition: EMM_Grid3D.h:554
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:141
#define tFlag
Definition: types.h:74