28 static LoggerPtr logger(Logger::getLogger(
"pz.gengrid.tpzgengrid"));
34 fDelx(2), fGeometricProgression(2, 1.), fNumLayers(numl), fRotAngle(rot), fZigZag(false), fTrapeze(false), fDistortion(0.), fRefPattern(false) {
35 fDelx[0] = (x1[0] - x0[0]) / (nx[0]);
36 fDelx[1] = (x1[1] - x0[1]) / (nx[1]);
56 fDelx[0] = (x1[0] - x0[0]) / (nx[0]);
57 fDelx[1] = (x1[1] - x0[1]) / (nx[1]);
101 if (
Read(gridinitial))
110 int64_t i, j, k, nnodestomerge = gridtomerge->
NNodes();
111 int64_t nnodesinitial = gridinitial->
NNodes();
118 for (i = 0; i < nnodestomerge; i++) {
119 nodetomerge = &(gridtomerge->
NodeVec()[i]);
120 if (!nodetomerge)
continue;
122 for (j = 0; j < nnodesinitial; j++) {
123 gridinitial->
NodeVec()[j].GetCoordinates(coordinitial);
135 if (j == nnodesinitial) {
138 gridinitial->
NodeVec()[index].Initialize(coordtomerge, *gridinitial);
139 index = gridinitial->
NodeVec()[index].Id();
140 int64_t oldid = nodetomerge->
Id();
141 for (k = 0; k < gridtomerge->
NElements(); k++) {
144 for (
int p = 0; p < gel->
NNodes(); p++)
153 for (i = 0; i < nnodestomerge; i++) {
154 nodetomerge = &(gridtomerge->
NodeVec()[i]);
155 if (!nodetomerge || nodetomerge->
Id() == -1)
continue;
156 int64_t idnew = nodetomerge->
Id(), idold = (int64_t) (nodetomerge->
Coord(0));
157 for (k = 0; k < gridtomerge->
NElements(); k++) {
160 for (
int p = 0; p < gel->
NNodes(); p++)
167 int64_t nelmerge = gridtomerge->
NElements();
168 for (i = 0; i < nelmerge; i++) {
172 int64_t ngelnodes = gel->
NNodes(), index;
174 for (j = 0; j < ngelnodes; j++)
192 if (
Read(gridinitial, matid))
201 int64_t i, j, k, nnodestomerge = gridtomerge->
NNodes();
202 int64_t nnodesinitial = gridinitial->
NNodes();
209 for (i = 0; i < nnodestomerge; i++) {
210 nodetomerge = &(gridtomerge->
NodeVec()[i]);
211 if (!nodetomerge)
continue;
213 for (j = 0; j < nnodesinitial; j++) {
214 gridinitial->
NodeVec()[j].GetCoordinates(coordinitial);
226 if (j == nnodesinitial) {
229 gridinitial->
NodeVec()[index].Initialize(coordtomerge, *gridinitial);
230 index = gridinitial->
NodeVec()[index].Id();
231 int64_t oldid = nodetomerge->
Id();
232 for (k = 0; k < gridtomerge->
NElements(); k++) {
235 for (
int p = 0; p < gel->
NNodes(); p++)
244 for (i = 0; i < nnodestomerge; i++) {
245 nodetomerge = &(gridtomerge->
NodeVec()[i]);
246 if (!nodetomerge || nodetomerge->
Id() == -1)
continue;
247 int64_t idnew = nodetomerge->
Id(), idold = (int64_t) (nodetomerge->
Coord(0));
248 for (k = 0; k < gridtomerge->
NElements(); k++) {
251 for (
int p = 0; p < gel->
NNodes(); p++)
258 int64_t nelmerge = gridtomerge->
NElements();
259 for (i = 0; i < nelmerge; i++) {
263 int64_t ngelnodes = gel->
NNodes(), index;
265 for (j = 0; j < ngelnodes; j++)
290 int64_t j, k, nnodestomerge = gridtomerge->
NNodes();
291 int64_t nnodesinitial = gridinitial->
NNodes();
297 int64_t newid = -1, oldid = -1;
299 for (int64_t i = 0; i < nnodestomerge; i++) {
300 nodetomerge = &(gridtomerge->
NodeVec()[i]);
301 if (!nodetomerge)
continue;
304 for (j = 0; j < nnodesinitial; j++) {
305 gridinitial->
NodeVec()[j].GetCoordinates(coordinitial);
322 gridinitial->
NodeVec()[newid].Initialize(coordtomerge, *gridinitial);
324 for (k = 0; k < gridtomerge->
NElements(); k++) {
327 for (
int p = 0; p < gel->
NNodes(); p++) {
337 int64_t nelmerge = gridtomerge->
NElements();
338 for (int64_t i = 0; i < nelmerge; i++) {
342 int ngelnodes = gel->
NNodes();
344 for (j = 0; j < ngelnodes; j++){
349 bool found_element_with_all_nodes =
true;
350 for (ii = 0; ii < gridinitial->
NElements(); ii++) {
351 found_element_with_all_nodes =
true;
353 if (!gelinit)
continue;
354 for (kk = 0; kk < nodes.
size(); kk++) {
356 for (jj = 0; jj < gelinit->
NNodes(); jj++) {
357 int64_t nodegelinit = gelinit->
NodeIndex(jj);
358 if (nodes[kk] == nodegelinit){
364 found_element_with_all_nodes =
false;
368 if (found_element_with_all_nodes) {
372 if (found_element_with_all_nodes) {
380 for (int64_t i = 0; i < nelmerge; i++) {
384 int64_t ngelnodes = gel->
NNodes();
386 for (j = 0; j < ngelnodes; j++)
399 switch (gel->
Type()) {
403 if (gel_quadratic_line) {
414 if (gel_quadratic_quad) {
435 if (!grid)
return false;
452 grid->
NodeVec()[i].Initialize(coor, (*grid));
458 if (!grid)
return false;
481 for (i = 0; i < num_rectangles; i++) {
496 std::cout << __PRETTY_FUNCTION__ <<
" - Quadratic interpolation is not available";
506 if (!grid)
return false;
528 for (i = 0; i < num_rectangles; i++) {
550 if (i < (
fNx[0] + 1)*(
fNx[1] + 1)) {
553 ilayer = (i - (
fNx[0] + 1)*(
fNx[1] + 1)) / ((
fNx[0])*(
fNx[1] + 1)) + 1;
556 if (i < (2 *
fNx[0] + 1)*(2 *
fNx[1] + 1)) {
559 ilayer = (i - (2 *
fNx[0] + 1)*(2 *
fNx[1] + 1)) / ((2 *
fNx[0])*(2 *
fNx[1] + 1)) + 1;
564 i -= ((
fNx[0] + 1)*(
fNx[1] + 1))+(ilayer - 1)*((
fNx[0])*(
fNx[1] + 1));
566 i -= ((2 *
fNx[0] + 1)*(2 *
fNx[1] + 1))+(ilayer - 1)*((2 *
fNx[0])*(2 *
fNx[1] + 1));
570 ix = i % (
fNx[0] + 1);
571 iy = i / (
fNx[0] + 1);
573 ix = i % (2 *
fNx[0] + 1);
574 iy = i / (2 *
fNx[0] + 1);
578 ix = i % (
fNx[0]) + 1;
581 ix = i % (2 *
fNx[0]) + 1;
582 iy = i / (2 *
fNx[0]);
587 REAL coorold[2] = {
fX0[0],
fX0[1]};
590 coorold[0] += ix * elsize[0];
592 for (
int i = 0; i < ix; i++) {
593 coorold[0] += elsize[0];
598 coorold[1] += iy * elsize[1];
600 for (
int j = 0; j < iy; j++) {
601 coorold[1] += elsize[1];
607 if (ilayer == 0 && iy % 2) {
612 coor[0] = coorold[0];
613 coor[1] = coorold[1];
617 coor[0] = fX0[0]+(coorold[0] - fX0[0]) *
cos(Rot);
618 coor[2] = fX0[2] + coorold[0] *
sin(Rot);
620 coor[1] = coorold[1];
626 int xel = i % (
fNx[0]);
627 int yel = (i / (
fNx[0])) % (
fNx[1]);
628 int layer = i / (
fNx[0] *
fNx[1]);
632 rectangle_nodes[0] =
GlobalI(xel, yel, layer);
633 rectangle_nodes[1] =
GlobalI(xel + 1, yel, layer);
634 rectangle_nodes[2] =
GlobalI(xel + 1, yel + 1, layer);
635 rectangle_nodes[3] =
GlobalI(xel, yel + 1, layer);
639 rectangle_nodes[0] =
GlobalI(2 * xel, 2 * yel, layer);
640 rectangle_nodes[1] =
GlobalI(2 * xel + 2, 2 * yel, layer);
641 rectangle_nodes[2] =
GlobalI(2 * xel + 2, 2 * yel + 2, layer);
642 rectangle_nodes[3] =
GlobalI(2 * xel, 2 * yel + 2, layer);
643 rectangle_nodes[4] =
GlobalI(2 * xel + 1, 2 * yel, layer);
644 rectangle_nodes[5] =
GlobalI(2 * xel + 2, 2 * yel + 1, layer);
645 rectangle_nodes[6] =
GlobalI(2 * xel + 1, 2 * yel + 2, layer);
646 rectangle_nodes[7] =
GlobalI(2 * xel, 2 * yel + 1, layer);
647 rectangle_nodes[8] =
GlobalI(2 * xel + 1, 2 * yel + 1, layer);
652 int yel = i / (
fNx[0] + 1);
654 int xel = i % (
fNx[0] + 1);
656 if (xel <
fNx[0] - 1) {
657 rectangle_nodes.
resize(4);
658 rectangle_nodes[0] =
GlobalI(xel, yel, layer);
659 rectangle_nodes[1] =
GlobalI(xel + 1, yel, layer);
660 rectangle_nodes[2] =
GlobalI(xel + 1, yel + 1, layer);
661 rectangle_nodes[3] =
GlobalI(xel, yel + 1, layer);
663 rectangle_nodes[2]++;
664 rectangle_nodes[3]++;
666 rectangle_nodes[0]++;
667 rectangle_nodes[1]++;
669 }
else if (xel ==
fNx[0] - 1 && yel % 2 == 0) {
670 rectangle_nodes.
resize(3);
671 rectangle_nodes[0] =
GlobalI(0, yel, layer);
672 rectangle_nodes[2] =
GlobalI(0 + 1, yel + 1, layer);
673 rectangle_nodes[1] =
GlobalI(0, yel + 1, layer);
675 }
else if (xel ==
fNx[0] && yel % 2 == 0) {
676 rectangle_nodes.
resize(3);
678 rectangle_nodes[0] =
GlobalI(xel, yel, layer);
679 rectangle_nodes[1] =
GlobalI(xel + 1, yel, layer);
680 rectangle_nodes[2] =
GlobalI(xel + 1, yel + 1, layer);
682 }
else if (xel ==
fNx[0] - 1 && yel % 2 == 1) {
683 rectangle_nodes.
resize(3);
684 rectangle_nodes[0] =
GlobalI(0, yel, layer);
685 rectangle_nodes[1] =
GlobalI(0 + 1, yel, layer);
686 rectangle_nodes[2] =
GlobalI(0, yel + 1, layer);
688 }
else if (xel ==
fNx[0] && yel % 2 == 1) {
689 rectangle_nodes.
resize(3);
691 rectangle_nodes[0] =
GlobalI(xel + 1, yel, layer);
692 rectangle_nodes[1] =
GlobalI(xel + 1, yel + 1, layer);
693 rectangle_nodes[2] =
GlobalI(xel, yel + 1, layer);
699 out <<
"\n" << name <<
"\n";
701 out <<
"Number of divisions " <<
fNx[0] <<
' ' <<
fNx[1] << endl;
702 out <<
"Corner Coordinates " << endl <<
fX0[0] <<
' ' <<
fX0[1] << endl;
703 out <<
fX1[0] <<
' ' <<
fX1[1] << endl;
710 int64_t ielfirst = 0;
716 int elementside = side;
717 for (layer = 0; layer <
fNumLayers; layer++) {
720 ielfirst = layer *
fNx[0] *
fNx[1];
721 iellast = ielfirst + fNx[0];
725 ielfirst = layer * fNx[0] * fNx[1] + fNx[0] - 1;
726 iellast = (layer + 1) * fNx[0] * fNx[1];
730 ielfirst = layer * fNx[0] * fNx[1] + fNx[0]*(fNx[1] - 1);
732 iellast = (layer + 1) * fNx[0] * fNx[1];
735 ielfirst = layer * fNx[0] * fNx[1];
737 iellast = ielfirst + fNx[1] * ielinc;
740 cout <<
"It is not implemented for side = " << side << endl;
756 for (iel = ielfirst; iel < iellast; iel += ielinc) {
775 for (int64_t el = 0; el <
numel; el++) {
784 if (layer == 0 || ix == 0) {
786 return ix + iy * (
fNx[0] + 1);
788 return ix + iy * (2 *
fNx[0] + 1);
792 return (
fNx[0] + 1)*(
fNx[1] + 1)+(
fNx[0])*(
fNx[1] + 1)*(layer - 1) + ix - 1 + iy * (
fNx[0]);
794 return (2 *
fNx[0] + 1)*(2 *
fNx[1] + 1)+(2 *
fNx[0])*(2 *
fNx[1] + 1)*(layer - 1) + ix - 1 + iy * (2 *
fNx[0]);
809 return (
sqrt(l1 * l1 + l2 * l2 + l3 * l3));
832 REAL progression = 1.;
833 REAL factor = domainsize / minsize;
836 for (
int i = 0; i < numdiv; i++) {
838 nextsize *= progression;
843 while (
fabs(func / factor) >= 1.e-10 && iter < 200) {
847 for (
int i = 0; i < numdiv; i++) {
849 dfunc += i * nextsize / progression;
850 nextsize *= progression;
854 progression -= func / dfunc;
858 for (
int i = 0; i < numdiv; i++) {
860 dfunc += i * nextsize / progression;
861 nextsize *= progression;
867 if (iter == maxiter) {
880 progression.
Resize(2, 1.);
884 for (idim = 0; idim < 2; idim++) {
886 factor[idim] = (
fX1[idim] -
fX0[idim]) / minsizes[idim];
889 for (
int i = 0; i <
fNx[idim]; i++) {
891 nextsize *= progression[idim];
893 func -= factor[idim];
896 while (
fabs(func / factor[idim]) >= 1.e-10 && iter < 200) {
900 for (
int i = 0; i < fNx[idim]; i++) {
902 dfunc += i * nextsize / progression[idim];
903 nextsize *= progression[idim];
905 func -= factor[idim];
907 progression[idim] -= func / dfunc;
910 for (
int i = 0; i < fNx[idim]; i++) {
912 dfunc += i * nextsize / progression[idim];
913 nextsize *= progression[idim];
915 func -= factor[idim];
919 if (iter == maxiter) {
928 for (
int idim = 0; idim < 2; idim++) {
931 for (
int i = 0; i <
fNx[idim]; i++) {
932 totalsize += nextsize;
933 nextsize *= progression[idim];
948 for (iel = 0; iel < nelem; iel++) {
953 for (c = 0; c < nc; c++) {
void ComputeGeometricProgression(TPZVec< REAL > &minsizes, TPZVec< REAL > &progression)
Compute the geometric progression such that the first elements have this size.
void SetPointBC(TPZGeoMesh *gr, TPZVec< REAL > &x, int bc)
Generate a boundary geometric element at the indicated node.
void ElementConnectivityZigZag(int64_t iel, TPZVec< int64_t > &nodes)
compute the nodes of the ith Element
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ fabs
int AllocateNewElement()
Makes more room for new elements.
void SetCoord(const TPZVec< REAL > &x)
Sets all coordinates into the current node. It gets the dim values from x.
const int64_t numel
Number of elements to test.
TPZManVector< REAL > fGeometricProgression
Geometric progression coeficients in the x and y direction.
TPZGeoNode * NodePtr(int i) const
Returns a pointer to the ith node of the element.
bool IsZero(long double a)
Returns if the value a is close Zero as the allowable tolerance.
virtual bool GenerateElements(TPZGeoMesh *grid, int matid)
Creates the geometric element: triangles or quadrilaterals.
Contains definitions to LOGPZ_DEBUG, LOGPZ_INFO, LOGPZ_WARN, LOGPZ_ERROR and LOGPZ_FATAL, and the implementation of the inline InitializePZLOG(string) function using log4cxx library or not. It must to be called out of "#ifdef LOG4CXX" scope.
REAL fRotAngle
Rotation angle between the layers.
bool fRefPattern
Uniform or refpattern elements.
int MaterialId() const
Returns the material index of the element.
clarg::argBool bc("-bc", "binary checkpoints", false)
virtual TPZGeoEl * CreateGeoElement(MElementType type, TPZVec< int64_t > &cornerindexes, int matid, int64_t &index, int reftype=1)
Generic method for creating a geometric element. Putting this method centrally facilitates the modifi...
Contains declaration of TPZGeoNode class which defines a geometrical node.
virtual void resize(const int64_t newsize)
REAL Coord(int i) const
Returns i-th coordinate of the current node.
TPZManVector< REAL > fDelx
Size of the lower left element.
bool MergeGeoMesh(TPZGeoMesh *grid, TPZGeoMesh *grid2, int matid=1)
Merges two geometrical mesh created for TPZGenGrid as separated, both meshes must to exist...
Templated vector implementation.
Contains the TPZQuadraticQuad class which defines a quadrilateral geometric element with quadratic ma...
static REAL Distance(TPZVec< REAL > &x1, TPZVec< REAL > &x2)
Computes the euclidean distance between two points, or the measure of the interval between two points...
virtual int NCornerNodes() const =0
Returns the number of corner nodes of the element.
virtual void SetElementType(MElementType type)
Set the element type.
virtual bool GenerateElementsZigZag(TPZGeoMesh *grid, int matid)
Creates the geometric element: triangles or quadrilaterals.
TPZManVector< REAL > fX0
Coordinate of the lower left point.
int64_t NElements() const
Number of elements of the mesh.
Contains declaration of TPZGeoElBC class, it is a structure to help the construction of geometric ele...
int64_t NElements() const
Access method to query the number of elements of the vector.
virtual int64_t NodeIndex(int i) const =0
Returns the index of the ith node the index is the location of the node in the nodevector of the mesh...
virtual void Print(char *name=NULL, std::ostream &out=std::cout)
Prints the data structure of the class.
void SetDimension(int dim)
Set Dimension.
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object.
virtual int GlobalI(int ix, int iy, int layer)
Returns the geometric node id for the element addressed by the parameters.
TPZGeoNode * FindNode(TPZVec< REAL > &co)
Returns the nearest node to the coordinate. This method is VERY INEFFICIENT.
int64_t size() const
Returns the number of elements of the vector.
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object reallocating the necessary storage, copying the existing objects to the new...
void Resize(const int newsize)
Increase the size of the chunk vector.
int64_t CreateUniqueElementId()
Returns ++fElementMaxId.
Contains declaration of TPZMesh class which defines a geometrical mesh and contains a corresponding l...
TPZManVector< int > fNx
Number of elements in both directions.
virtual void SetNodeIndex(int i, int64_t nodeindex)=0
Initializes the node i of the element.
Implements a generic geometric element which is refined according to a generic refinement pattern...
static REAL GeometricProgression(REAL minsize, REAL size, int numdiv)
Compute the geometric progression such that the first elements have this size.
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
int fNumLayers
Number of meshes which will be generated hinging along an axis.
TPZManVector< REAL > fX1
coordinate of the upper right point
MElementType fElementType
Variable which indicates the type of element that should be generated Only EQuadrilateral or ETriangl...
virtual void SetBC(TPZGeoMesh *gr, int side, int bc)
Generate boundary geometric elements associated with the side of the rectangular domain.
Contains TPZMatrixclass which implements full matrix (using column major representation).
#define DebugStop()
Returns a message to user put a breakpoint in.
int64_t NNodes() const
Number of nodes of the mesh.
#define LOGPZ_DEBUG(A, B)
Define log for debug info.
void SetGeometricProgression(TPZVec< REAL > &progression)
Sets the geometric progression of the mesh to be generated.
Contains declaration of TPZConnect class which represents a set of shape functions associated with a ...
TPZGenGrid(TPZVec< int > &nx, TPZVec< REAL > &x0, TPZVec< REAL > &x1, int numl=1, REAL rot=0.5)
Constructor of the rectangular domain.
virtual MElementType Type() const =0
Returns the element type acording to pzeltype.h.
TPZAdmChunkVector< TPZGeoNode > & NodeVec()
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ sqrt
Contains the TPZGenGrid class which implements the generation of a multilayered geometric grid (two-d...
Contains declaration of TPZGeoElRefPattern class which implements a generic geometric element which i...
virtual void Coord(int i, TPZVec< REAL > &coord)
Computes the coordinates of the ith geometric node generated.
int64_t fNumNodes
Number of nodes of the mesh.
Contains the TPZQuadraticLine class which defines a linear geometric element with quadratic map...
Contains declaration of TPZCompMesh class which is a repository for computational elements...
void SetData(TPZVec< int > &nx, TPZVec< REAL > &x0, TPZVec< REAL > &x1, MElementType eltype=EQuadrilateral, int numl=1, REAL rot=0.5)
Change points and all data to generate geometric mesh.
virtual int HasSubElement() const =0
Return 1 if the element has subelements.
virtual int NNodes() const =0
Returns the number of nodes of the element.
virtual bool IsLinearMapping() const
bool ReadAndMergeGeoMesh(TPZGeoMesh *grid, TPZGeoMesh *grid2)
Merges two geometrical mesh created for TPZGenGrid as separated.
Structure to help the construction of geometric elements along side of a given geometric element...
void GetBoundaryElements(int64_t IndexNodeFrom, int64_t IndexNodeTo, TPZStack< TPZGeoEl *> &ElementVec, TPZStack< int > &Sides)
GetBoundaryElements returns all elements beweeen NodFrom and NodTo counterclock wise this method uses...
void BuildConnectivity()
Build the connectivity of the grid.
bool fZigZag
variable to generate a zigzag grid
Implements a geometric node in the pz environment. Geometry.
int64_t ElemId(int64_t iel, int64_t jel, int layer)
Returns the element id for the element addressed by the parameters.
virtual ~TPZGenGrid()
Default destructor.
virtual bool GenerateNodes(TPZGeoMesh *grid)
Creates the geometric nodes, it depends on fElementType, layer and fRotAngle.
This class implements a geometric mesh for the pz environment. Geometry.
MElementType
Define the element types.
This class implements a stack object. Utility.
void ResetConnectivities()
Reset all connectivities.
int Id() const
Returns the identity of the current node.
int64_t NElements() const
Returns the number of elements of the vector.
void GetCoordinates(TPZVec< REAL > &co)
Fill the coordinates of the node.
TPZFlopCounter cos(const TPZFlopCounter &orig)
Returns the cosine in radians and increments the counter of the Cosine.
void ElementConnectivity(int64_t iel, TPZVec< int64_t > &nodes)
compute the nodes of the ith Element
virtual short Read(TPZGeoMesh *mesh, int matid=1)
Add nodes and elements to the object mesh.
TPZAdmChunkVector< TPZGeoEl * > & ElementVec()
Methods for handling pzlists.