BasicMeshes.cpp
1 /*---------------------------------------------------------------------------*\
2  *
3  * mimmo
4  *
5  * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6  *
7  * -------------------------------------------------------------------------
8  * License
9  * This file is part of mimmo.
10  *
11  * mimmo is free software: you can redistribute it and/or modify it
12  * under the terms of the GNU Lesser General Public License v3 (LGPL)
13  * as published by the Free Software Foundation.
14  *
15  * mimmo is distributed in the hope that it will be useful, but WITHOUT
16  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18  * License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with mimmo. If not, see <http://www.gnu.org/licenses/>.
22  *
23  \ *---------------------------------------------------------------------------*/
24 
25 #include "BasicMeshes.hpp"
26 #include "customOperators.hpp"
27 #include <Operators.hpp>
28 #include <bitpit_common.hpp>
29 
30 namespace mimmo{
31 
36  m_nx = 0; m_ny=0; m_nz=0;
37  m_dx = 0; m_dy=0; m_dz=0;
38 
39  m_setorigin = false;
40  m_setspan = false;
41  m_setInfLimits = false;
42  m_setRefSys = false;
43  m_isBuild = false;
44  m_origin_temp = {{0.0,0.0,0.0}};
45  m_span_temp = {{1.0,1.0,1.0}};
46  m_inflimits_temp = {{0.0,0.0,0.0}};
47  m_refsystem_temp[0] = {{1.0,0.0,0.0}};
48  m_refsystem_temp[1] = {{0.0,1.0,0.0}};
49  m_refsystem_temp[2] = {{0.0,0.0,1.0}};
50  m_shapetype_temp = ShapeType::CUBE;
51 };
52 
57 
63 
64  // Number of cells
65  m_nx = other.m_nx;
66  m_ny = other.m_ny;
67  m_nz = other.m_nz;
68 
69  // Cell Spacing
70  m_dx = other.m_dx;
71  m_dy = other.m_dy;
72  m_dz = other.m_dz;
73 
74  // Copy cell edges and cell centers ----------------------------------------- //
75  m_xnode = other.m_xnode;
76  m_ynode = other.m_ynode;
77  m_znode = other.m_znode;
78  m_xedge = other.m_xedge;
79  m_yedge = other.m_yedge;
80  m_zedge = other.m_zedge;
81 
82  if(other.m_shape){
83  switch(other.m_shape->getShapeType()){
84  case ShapeType::WEDGE :
85  {
86  const Wedge * pp = dynamic_cast<const Wedge*>(other.m_shape.get());
87  if (pp != nullptr) m_shape = std::unique_ptr<BasicShape>(new Wedge(*(pp)));
88  }
89  break;
90  case ShapeType::CYLINDER :
91  {
92  const Cylinder * pp = dynamic_cast<const Cylinder*>(other.m_shape.get());
93  if (pp != nullptr) m_shape = std::unique_ptr<BasicShape>(new Cylinder(*(pp)));
94  }
95  break;
96  case ShapeType::SPHERE :
97  {
98  const Sphere * pp = dynamic_cast<const Sphere*>(other.m_shape.get());
99  if (pp != nullptr) m_shape = std::unique_ptr<BasicShape>(new Sphere(*(pp)));
100  }
101  break;
102  default://CUBE
103  {
104  const Cube * pp = dynamic_cast<const Cube*>(other.m_shape.get());
105  if (pp != nullptr) m_shape = std::unique_ptr<BasicShape>(new Cube(*(pp)));
106  }
107  break;
108  }
109  }
110 
111  //copy temporary members
112  m_origin_temp = other.m_origin_temp;
113  m_span_temp = other.m_span_temp;
114  m_inflimits_temp = other.m_inflimits_temp;
115  m_refsystem_temp = other.m_refsystem_temp;
116  m_shapetype_temp = other.m_shapetype_temp;
117  m_setorigin = other.m_setorigin;
118  m_setspan = other.m_setspan;
120  m_setRefSys = other.m_setRefSys;
121  m_isBuild = other.m_isBuild;
122 
123 };
124 
129  swap(other);
130  return *this;
131 };
132 
139 void UStructMesh::swap(UStructMesh & x) noexcept
140 {
141  // Number of cells
142  std::swap(m_nx, x.m_nx);
143  std::swap(m_ny, x.m_ny);
144  std::swap(m_nz, x.m_nz);
145 
146  // Cell Spacing
147  std::swap(m_dx, x.m_dx);
148  std::swap(m_dy, x.m_dy);
149  std::swap(m_dz, x.m_dz);
150 
151  // Copy cell edges and cell centers ----------------------------------------- //
152  std::swap(m_xnode, x.m_xnode);
153  std::swap(m_ynode, x.m_ynode);
154  std::swap(m_znode, x.m_znode);
155  std::swap(m_xedge, x.m_xedge);
156  std::swap(m_yedge, x.m_yedge);
157  std::swap(m_zedge, x.m_zedge);
158 
159  std::swap(m_origin_temp,x.m_origin_temp);
160  std::swap(m_span_temp,x.m_span_temp);
161  std::swap(m_inflimits_temp,x.m_inflimits_temp);
162  std::swap(m_refsystem_temp,x.m_refsystem_temp);
163  std::swap(m_shapetype_temp,x.m_shapetype_temp);
164 
165  std::swap(m_setorigin,x.m_setorigin);
166  std::swap(m_setspan,x.m_setspan);
167  std::swap(m_setInfLimits,x.m_setInfLimits);
168  std::swap(m_setRefSys,x.m_setRefSys);
169  std::swap(m_isBuild,x.m_isBuild);
170 
171  if(x.m_shape){
172  std::unique_ptr<BasicShape> tempshape;
173  switch(x.m_shape->getShapeType()){
174  case ShapeType::WEDGE :
175  {
176  const Wedge * pp = dynamic_cast<const Wedge*>(x.m_shape.get());
177  if (pp != nullptr) tempshape = std::unique_ptr<BasicShape>(new Wedge(*(pp)));
178  }
179  break;
180  case ShapeType::CYLINDER :
181  {
182  const Cylinder * pp = dynamic_cast<const Cylinder*>(x.m_shape.get());
183  if (pp != nullptr) tempshape = std::unique_ptr<BasicShape>(new Cylinder(*(pp)));
184  }
185  break;
186  case ShapeType::SPHERE :
187  {
188  const Sphere * pp = dynamic_cast<const Sphere*>(x.m_shape.get());
189  if (pp != nullptr) tempshape = std::unique_ptr<BasicShape>(new Sphere(*(pp)));
190  }
191  break;
192  default://CUBE
193  {
194  const Cube * pp = dynamic_cast<const Cube*>(x.m_shape.get());
195  if (pp != nullptr) tempshape = std::unique_ptr<BasicShape>(new Cube(*(pp)));
196  }
197  break;
198  }
199 
200  x.m_shape = std::move(m_shape);
201  m_shape = std::move(tempshape);
202  }
203 }
204 
205 
210  return(m_shape.get());
211 }
212 
217  return(m_shape.get());
218 }
219 
224  if (getShape() == nullptr) return(m_origin_temp);
225  return(getShape()->getOrigin());
226 }
227 
232  if (getShape() == nullptr) return(m_span_temp);
233  return(getShape()->getSpan());
234 }
235 
240  if (getShape() == nullptr) return(m_inflimits_temp);
241  return(getShape()->getInfLimits());
242 }
243 
248  if (getShape() == nullptr) return(m_refsystem_temp);
249  return(getShape()->getRefSystem());
250 }
251 
256  if (getShape() == nullptr) return(darray3E{{1,1,1}});
257  return(getShape()->getScaling());
258 }
259 
264  if (getShape() == nullptr) return(darray3E{{1,1,1}});
265  return(getShape()->getLocalSpan());
266 }
267 
272  if (getShape() == nullptr) return(m_shapetype_temp);
273  return(getShape()->getShapeType());
274 }
275 
281  if (getShape() == nullptr) return(CoordType::CLAMPED);
282  return(getShape()->getCoordinateType(0));
283 }
284 
290  if (getShape() == nullptr) return(CoordType::CLAMPED);
291  return(getShape()->getCoordinateType(i));
292 }
293 
299  if (getShape() == nullptr) return(CoordType::CLAMPED);
300  return(getShape()->getCoordinateType(1));
301 }
302 
308  if (getShape() == nullptr) return(CoordType::CLAMPED);
309  return(getShape()->getCoordinateType(2));
310 }
311 
316 std::array<CoordType, 3> UStructMesh::getCoordType(){
317  std::array<CoordType, 3> types;
318  for (int i=0; i<3; i++){
319  types[i] = getShape()->getCoordinateType(i);
320  }
321  return(types);
322 }
323 
328  darray3E res;
329  darray3E scale = getScaling();
330  res[0] = m_dx*scale[0]; res[1] =m_dy*scale[1]; res[2] = m_dz*scale[2];
331  return(res);
332 };
333 
338 
339  iarray3E res;
340  res[0] = m_nx + 1;
341  res[1] = m_ny + 1;
342  res[2] = m_nz + 1;
343  return(res);
344 };
345 
352 
353  int i,j,k;
354  accessCellIndex(index, i,j,k);
355  darray3E res = getLocalCCell(i,j,k);
356 
357  return(res);
358 };
359 
367 darray3E UStructMesh::getLocalCCell(int i_, int j_, int k_){
368 
369  darray3E res;
370  res[0] = m_xnode[i_];
371  res[1] = m_ynode[j_];
372  res[2] = m_znode[k_];
373 
374  return(res);
375 };
376 
383 
384  int i,j,k;
385  accessPointIndex(index, i,j,k);
386  darray3E res = getLocalPoint(i,j,k);
387 
388  return(res);
389 };
397 darray3E UStructMesh::getLocalPoint(int i_, int j_, int k_){
398 
399  darray3E res;
400  res[0] = m_xedge[i_];
401  res[1] = m_yedge[j_];
402  res[2] = m_zedge[k_];
403 
404  return(res);
405 };
406 
413 
414  darray3E res = getLocalCCell(index);
415  return(transfToGlobal(res));
416 };
424 darray3E UStructMesh::getGlobalCCell(int i_, int j_, int k_){
425 
426  darray3E res = getLocalCCell(i_,j_,k_);
427  return(transfToGlobal(res));
428 };
429 
436  darray3E res = getLocalPoint(index);
437  return(transfToGlobal(res));
438 };
446 darray3E UStructMesh::getGlobalPoint(int i_, int j_, int k_){
447 
448  darray3E res = getLocalPoint(i_,j_,k_);
449  return(transfToGlobal(res));
450 };
451 
459 ivector1D UStructMesh::getCellNeighs(int i_, int j_, int k_){
460 
461  ivector1D result(8);
462  result[0] = accessPointIndex(i_, j_, k_);
463  result[1] = accessPointIndex(i_+1, j_, k_);
464  result[2] = accessPointIndex(i_+1, j_+1, k_);
465  result[3] = accessPointIndex(i_, j_+1, k_);
466  result[4] = accessPointIndex(i_, j_, k_+1);
467  result[5] = accessPointIndex(i_+1, j_, k_+1);
468  result[6] = accessPointIndex(i_+1, j_+1, k_+1);
469  result[7] = accessPointIndex(i_, j_+1, k_+1);
470  return(result);
471 }
472 
479 
480  ivector1D pp(3,0);
481  accessCellIndex(index, pp[0],pp[1], pp[2]);
482  return(getCellNeighs(pp[0],pp[1],pp[2]));
483 }
484 
489 
490  int np = (m_nx+1)*(m_ny+1)*(m_nz+1);
491  dvecarr3E coords(np);
492  for (int i=0; i<np; i++){
493  coords[i] = getLocalPoint(i);
494  }
495  return coords;
496 };
497 
502  int np = (m_nx+1)*(m_ny+1)*(m_nz+1);
503  dvecarr3E coords(np);
504  for (int i=0; i<np; i++){
505  coords[i] = getGlobalPoint(i);
506  }
507  return coords;
508 };
509 
514 
515  int np = (m_nx)*(m_ny)*(m_nz);
516  dvecarr3E coords(np);
517  for (int i=0; i<np; i++){
518  coords[i] = getLocalCCell(i);
519  }
520  return coords;
521 };
522 
527  int np = (m_nx)*(m_ny)*(m_nz);
528  dvecarr3E coords(np);
529  for (int i=0; i<np; i++){
530  coords[i] = getGlobalCCell(i);
531  }
532  return coords;
533 };
534 
542  if (getShape() == nullptr){
543  m_origin_temp = origin;
544  m_setorigin = true;
545  }else{
546  getShape()->setOrigin(origin);
547  }
548 }
549 
558 void UStructMesh::setSpan(double s0, double s1, double s2){
559 
560  if (getShape() == nullptr){
561  m_span_temp[0] = s0;
562  m_span_temp[1] = s1;
563  m_span_temp[2] = s2;
564  m_setspan = true;
565  }else{
566  getShape()->setSpan( s0, s1,s2);
567  }
568  m_isBuild = false;
569 }
570 
578  setSpan( s[0], s[1], s[2]);
579 }
580 
588 void UStructMesh::setInfLimits(double inflim, int dir){
589  if (getShape() == nullptr){
590  m_inflimits_temp[dir] = inflim;
591  m_setInfLimits = true;
592  }else{
593  getShape()->setInfLimits(inflim, dir);
594  }
595 }
596 
604  setInfLimits(inflim[0], 0);
605  setInfLimits(inflim[1], 1);
606  setInfLimits(inflim[2], 2);
607 }
608 
620 
621  if (getShape() == nullptr){
622  m_refsystem_temp[0] = axis0;
623  m_refsystem_temp[1] = axis1;
624  m_refsystem_temp[2] = axis2;
625  m_setRefSys = true;
626  }else{
627  getShape()->setRefSystem(axis0, axis1, axis2);
628  }
629 }
630 
638 void UStructMesh::setRefSystem(int label, darray3E axis){
639 
640  if(getShape() == nullptr){
641  BasicShape * temp = new Cube();
642  temp->setRefSystem(label, axis);
643  m_refsystem_temp = temp->getRefSystem();
644  delete temp;
645  temp = nullptr;
646  m_setRefSys = true;
647  }else{
648  getShape()->setRefSystem(label,axis);
649  }
650 }
651 
659  if (getShape() == nullptr){
660 
661  m_refsystem_temp[0] = axes[0];
662  m_refsystem_temp[1] = axes[1];
663  m_refsystem_temp[2] = axes[2];
664  m_setRefSys = true;
665  }else{
666  getShape()->setRefSystem(axes);
667  }
668 }
669 
677  m_nx = dim[0] - 1;
678  m_ny = dim[1] - 1;
679  m_nz = dim[2] - 1;
680 
681  m_isBuild = false;
682 };
683 
691  m_nx = dim[0] - 1;
692  m_ny = dim[1] - 1;
693  m_nz = dim[2] - 1;
694 
695  m_isBuild = false;
696  };
697 
703  void UStructMesh::setShape(int itype){
704  ShapeType type = static_cast<ShapeType>(itype);
705  UStructMesh::setShape(type);
706  }
707 
714  //create internal shape using unique_ptr member.
715  // unlink external shape eventually
716  if(m_shape){
717 
718  m_origin_temp = m_shape.get()->getOrigin();
719  m_span_temp = m_shape.get()->getSpan();
720  m_inflimits_temp = m_shape.get()->getInfLimits();
721  m_refsystem_temp = m_shape.get()->getRefSystem();
722  m_setorigin = true;
723  m_setspan = true;
724  m_setInfLimits = true;
725  m_setRefSys = true;
726 
727  m_shape.reset(nullptr);
728  }
729 
730  darray3E origin{{0,0,0}};
731  dmatrix33E spanMat;
732  spanMat[0].fill(1); spanMat[2].fill(1); spanMat[2].fill(1);
733  spanMat[1][1] = spanMat[2][1] = 2*BITPIT_PI;
734  spanMat[2][2] = BITPIT_PI;
735 
736  if(m_setorigin){origin = m_origin_temp; m_setorigin= false;}
737  if(m_setspan){
738  for(int i=0; i<3; ++i) spanMat[i] = m_span_temp;
739  m_setspan = false;
740  }
741 
742  switch(type){
743  case ShapeType::WEDGE :
744  m_shape = std::unique_ptr<BasicShape>(new Wedge(origin,spanMat[0]));
745  break;
746  case ShapeType::CYLINDER :
747  m_shape = std::unique_ptr<BasicShape>(new Cylinder(origin,spanMat[1]));
748  break;
749  case ShapeType::SPHERE :
750  m_shape = std::unique_ptr<BasicShape>(new Sphere(origin, spanMat[2]));
751  break;
752  default://CUBE
753  m_shape = std::unique_ptr<BasicShape>(new Cube(origin, spanMat[0]));
754  break;
755  }
756 
757  if(m_setInfLimits){
758  m_shape.get()->setInfLimits(m_inflimits_temp[0],0);
759  m_shape.get()->setInfLimits(m_inflimits_temp[1],1);
760  m_shape.get()->setInfLimits(m_inflimits_temp[2],2);
761  m_setInfLimits = false;
762  }
763 
764  if(m_setRefSys){
765  m_shape.get()->setRefSystem(m_refsystem_temp);
766  m_setRefSys = false;
767  }
768 
769  m_isBuild = false;
770 }
771 
777 void UStructMesh::setShape(const BasicShape * shape){
778 
779  if(shape == nullptr) return;
780  m_shape.reset(nullptr);
781  m_setorigin = false;
782  m_setspan = false;
783  m_setInfLimits = false;
784  m_setRefSys = false;
785 
786  switch(shape->getShapeType()){
787  case ShapeType::WEDGE :
788  {
789  const Wedge * pp = dynamic_cast<const Wedge*>(shape);
790  if (pp != nullptr) m_shape = std::unique_ptr<BasicShape>(new Wedge(*(pp)));
791  }
792  break;
793  case ShapeType::CYLINDER :
794  {
795  const Cylinder * pp = dynamic_cast<const Cylinder*>(shape);
796  if (pp != nullptr) m_shape = std::unique_ptr<BasicShape>(new Cylinder(*(pp)));
797  }
798  break;
799  case ShapeType::SPHERE :
800  {
801  const Sphere * pp = dynamic_cast<const Sphere*>(shape);
802  if (pp != nullptr) m_shape = std::unique_ptr<BasicShape>(new Sphere(*(pp)));
803  }
804  break;
805  default://CUBE
806  {
807  const Cube * pp = dynamic_cast<const Cube*>(shape);
808  if (pp != nullptr) m_shape = std::unique_ptr<BasicShape>(new Cube(*(pp)));
809  }
810  break;
811  }
812 
813  m_isBuild = false;
814 };
815 
816 
822  if (getShape() == nullptr) return;
823  getShape()->setCoordinateType(type,0);
824 }
825 
833  if (getShape() == nullptr) return;
834  getShape()->setCoordinateType(type,i);
835 }
836 
843  if (getShape() == nullptr) return;
844  getShape()->setCoordinateType(type,1);
845 }
846 
853  if (getShape() == nullptr) return;
854  getShape()->setCoordinateType(type,2);
855 }
856 
861 void UStructMesh::setCoordType(std::array<CoordType, 3> types){
862  for (int i=0; i<3; i++){
863  getShape()->setCoordinateType(types[i],i);
864  }
865 }
866 
874 void UStructMesh::setMesh(darray3E & origin, darray3E &span, ShapeType type, iarray3E & dimensions){
875 
876  if(m_shape){m_shape.reset(nullptr);}
877 
878  setShape(type);
879  setOrigin(origin);
880  setSpan(span);
881  setDimension(dimensions);
882  build();
883 };
884 
885 
893 void UStructMesh::setMesh(darray3E & origin, darray3E &span, ShapeType type, dvector1D & spacing){
894 
895  ivector1D dimLimit(3,2);
896  //create internal shape using unique_ptr member.
897  if(m_shape){m_shape.reset(nullptr);}
898 
899  switch(type){
900  case ShapeType::CYLINDER :
901  dimLimit[1] = 4;
902  break;
903  case ShapeType::SPHERE :
904  dimLimit[1] = 5; dimLimit[2] = 3;
905  break;
906  default://CUBE //WEDGE
907  break;
908  }
909 
910  setShape(type);
911  setOrigin(origin);
912  setSpan(span);
913 
914  darray3E span2 = getSpan();
915  iarray3E dim;
916 
917  for(int i=0; i<3; ++i){
918  if(spacing[i] != 0.0) {
919  dim[i] = (int) std::floor(span2[i]/spacing[i] +0.5) + 1;
920  }else{
921  dim[i] = dimLimit[i];
922  }
923  }
924 
925  setDimension(dim);
926  build();
927 };
928 
934 void UStructMesh::setMesh(BasicShape * shape, iarray3E & dimensions){
935 
936  if(m_shape){m_shape.reset(nullptr);}
937 
938  setShape(shape);
939  setDimension(dimensions);
940  build();
941 };
942 
948 void UStructMesh::setMesh(BasicShape * shape, dvector1D & spacing){
949 
950  ivector1D dimLimit(3,2);
951  //create internal shape using unique_ptr member.
952  if(m_shape){m_shape.reset(nullptr);}
953 
954  switch(shape->getShapeType()){
955  case ShapeType::CYLINDER :
956  dimLimit[1] = 4;
957  break;
958  case ShapeType::SPHERE :
959  dimLimit[1] = 5; dimLimit[2] = 3;
960  break;
961  default://CUBE //WEDGE
962  break;
963  }
964 
965  setShape(shape);
966 
967  darray3E span2 = getSpan();
968  iarray3E dim;
969 
970  for(int i=0; i<3; ++i){
971  if(spacing[i] != 0.0) {
972  dim[i] = (int) std::floor(span2[i]/spacing[i] +0.5) + 1;
973  }else{
974  dim[i] = dimLimit[i];
975  }
976  }
977 
978  setDimension(dim);
979  build();
980 };
981 
982 
988 
989  m_shape.reset(nullptr);
990  m_nx=0; m_ny=0; m_nz=0;
991  m_dx=0.0; m_dy=0.0; m_dz=0.0;
992 
993 
994  m_setorigin = false;
995  m_setspan = false;
996  m_setInfLimits = false;
997  m_setRefSys = false;
998  m_isBuild = false;
999 
1000  m_origin_temp = {{0.0,0.0,0.0}};
1001  m_span_temp = {{1.0,1.0,1.0}};
1002  m_inflimits_temp = {{0.0,0.0,0.0}};
1003  for(int i=0; i<3; ++i){m_refsystem_temp[i].fill(0.0); m_refsystem_temp[i][i] = 1.0;}
1004  m_shapetype_temp = ShapeType::CUBE;
1005 
1007 };
1008 
1009 
1018 void UStructMesh::locateCellByPoint(darray3E & point, int &i, int &j, int &k){
1019 
1020  darray3E P = transfToLocal(point);
1021  darray3E locOr = getShape()->getLocalOrigin();
1022 
1023  i = std::min(m_nx-1, std::max(0, (int) std::floor((P[0]-locOr[0])/m_dx)));
1024  j = std::min(m_ny-1, std::max(0, (int) std::floor((P[1]-locOr[1])/m_dy)));
1025  k = std::min(m_nz-1, std::max(0, (int) std::floor((P[2]-locOr[2])/m_dz)));
1026 };
1027 
1036 void UStructMesh::locateCellByPoint(dvector1D & point, int &i, int &j, int &k){
1037  darray3E temp = conArray<double,3>(point);
1038  locateCellByPoint(temp,i,j,k);
1039 };
1040 
1049 int UStructMesh::accessCellIndex(int i, int j, int k){
1050 
1051  int index = m_ny * m_nz * i + m_nz * j + k;
1052  return(index);
1053 };
1054 
1063 void UStructMesh::accessCellIndex(int N_, int & i, int & j, int & k){
1064  k = N_ % m_nz;
1065  int index = N_ / m_nz;
1066  j = index % m_ny;
1067  i = index / m_ny;
1068 };
1069 
1078 void UStructMesh::accessPointIndex(int N_, int &i, int &j, int &k){
1079 
1080  k = N_ % (m_nz+1);
1081  int index = N_ / (m_nz+1);
1082  j = index % (m_ny+1);
1083  i = index / (m_ny+1);
1084 };
1085 
1091  return(getShape()->toWorldCoord(point));
1092 };
1093 
1099  darray3E temp = conArray<double,3>(point);
1100  darray3E temp2 = getShape()->toWorldCoord(temp);
1101  return(conVect(temp2));
1102 };
1103 
1109  int size = list_points.size();
1110  dvecarr3E result(size);
1111  for(int i=0; i<size; ++i){
1112  result[i] = transfToGlobal(list_points[i]);
1113  }
1114  return(result);
1115 };
1116 
1122  return(getShape()->toLocalCoord(point));
1123 };
1124 
1127  darray3E temp = conArray<double,3>(point);
1128  darray3E temp2 = getShape()->toLocalCoord(temp);
1129  return(conVect(temp2));
1130 
1131 };
1132 
1138  int size = list_points.size();
1139  dvecarr3E result(size);
1140  for(int i=0; i<size; ++i){
1141  result[i] = transfToLocal(list_points[i]);
1142  }
1143  return(result);
1144 
1145 };
1146 
1153 
1154  int i0, j0, k0, ip, jp, kp;
1155  double wx0,wx1,wy0,wy1,wz0,wz1;
1156 
1157  locateCellByPoint(point, i0, j0, k0);
1158  darray3E P = transfToLocal(point);
1159  if (P[0] > m_xnode[i0]) { ip = std::min(i0+1, m_nx-1); }
1160  else { ip = std::max(0, i0-1); }
1161  if (P[1] > m_ynode[j0]) { jp = std::min(j0+1, m_ny-1); }
1162  else { jp = std::max(0, j0-1); }
1163  if (P[2] > m_znode[k0]) { kp = std::min(k0+1, m_nz-1); }
1164  else { kp = std::max(0, k0-1); }
1165 
1166  // Interpolation weights
1167  wx1 = std::max(0.0, std::min(1.0, std::abs((P[0] - m_xnode[i0])/m_dx))); wx0 = 1.0 - wx1;
1168  wy1 = std::max(0.0, std::min(1.0, std::abs((P[1] - m_ynode[j0])/m_dy))); wy0 = 1.0 - wy1;
1169  wz1 = std::max(0.0, std::min(1.0, std::abs((P[2] - m_znode[k0])/m_dz))); wz0 = 1.0 - wz1;
1170 
1171  // Interpolation
1172  double result = wz0 * wx0 * wy0 * celldata[accessCellIndex(i0,j0,k0)]
1173  + wz0 * wx0 * wy1 * celldata[accessCellIndex(i0,jp,k0)]
1174  + wz0 * wx1 * wy0 * celldata[accessCellIndex(ip,j0,k0)]
1175  + wz0 * wx1 * wy1 * celldata[accessCellIndex(ip,jp,k0)]
1176  + wz1 * wx0 * wy0 * celldata[accessCellIndex(i0,j0,kp)]
1177  + wz1 * wx0 * wy1 * celldata[accessCellIndex(i0,jp,kp)]
1178  + wz1 * wx1 * wy0 * celldata[accessCellIndex(ip,j0,kp)]
1179  + wz1 * wx1 * wy1 * celldata[accessCellIndex(ip,jp,kp)];
1180 
1181  return(result);
1182 };
1183 
1191 
1192  int i0, j0, k0, ip, jp, kp;
1193  double wx0,wx1,wy0,wy1,wz0,wz1;
1194 
1195  locateCellByPoint(point, i0, j0, k0);
1196  darray3E P = transfToLocal(point);
1197  if (P[0] > m_xnode[i0]) { ip = std::min(i0+1, m_nx-1); }
1198  else { ip = std::max(0, i0-1); }
1199  if (P[1] > m_ynode[j0]) { jp = std::min(j0+1, m_ny-1); }
1200  else { jp = std::max(0, j0-1); }
1201  if (P[2] > m_znode[k0]) { kp = std::min(k0+1, m_nz-1); }
1202  else { kp = std::max(0, k0-1); }
1203 
1204  // Interpolation weights
1205  wx1 = std::max(0.0, std::min(1.0, std::abs((P[0] - m_xnode[i0])/m_dx))); wx0 = 1.0 - wx1;
1206  wy1 = std::max(0.0, std::min(1.0, std::abs((P[1] - m_ynode[j0])/m_dy))); wy0 = 1.0 - wy1;
1207  wz1 = std::max(0.0, std::min(1.0, std::abs((P[2] - m_znode[k0])/m_dz))); wz0 = 1.0 - wz1;
1208 
1209  // Interpolation
1210  double result = wz0 * wx0 * wy0 * (double)celldata[accessCellIndex(i0,j0,k0)]
1211  + wz0 * wx0 * wy1 * (double)celldata[accessCellIndex(i0,jp,k0)]
1212  + wz0 * wx1 * wy0 *(double) celldata[accessCellIndex(ip,j0,k0)]
1213  + wz0 * wx1 * wy1 *(double) celldata[accessCellIndex(ip,jp,k0)]
1214  + wz1 * wx0 * wy0 *(double) celldata[accessCellIndex(i0,j0,kp)]
1215  + wz1 * wx0 * wy1 *(double) celldata[accessCellIndex(i0,jp,kp)]
1216  + wz1 * wx1 * wy0 *(double) celldata[accessCellIndex(ip,j0,kp)]
1217  + wz1 * wx1 * wy1 *(double) celldata[accessCellIndex(ip,jp,kp)];
1218 
1219  int result2 =std::floor(result+0.5);
1220  return(result2);
1221 };
1222 
1229 
1230  int i0, j0, k0, ip, jp, kp;
1231  double wx0,wx1,wy0,wy1,wz0,wz1;
1232 
1233  locateCellByPoint(point, i0, j0, k0);
1234  darray3E P = transfToLocal(point);
1235 
1236  if (P[0] > m_xnode[i0]) { ip = std::min(i0+1, m_nx-1); }
1237  else { ip = std::max(0, i0-1); }
1238  if (P[1] > m_ynode[j0]) { jp = std::min(j0+1, m_ny-1); }
1239  else { jp = std::max(0, j0-1); }
1240  if (P[2] > m_znode[k0]) { kp = std::min(k0+1, m_nz-1); }
1241  else { kp = std::max(0, k0-1); }
1242 
1243  // Interpolation weights
1244  wx1 = std::max(0.0, std::min(1.0, std::abs((P[0] - m_xnode[i0])/m_dx))); wx0 = 1.0 - wx1;
1245  wy1 = std::max(0.0, std::min(1.0, std::abs((P[1] - m_ynode[j0])/m_dy))); wy0 = 1.0 - wy1;
1246  wz1 = std::max(0.0, std::min(1.0, std::abs((P[2] - m_znode[k0])/m_dz))); wz0 = 1.0 - wz1;
1247 
1248  // Interpolation
1249  darray3E result = wz0 * wx0 * wy0 * celldata[accessCellIndex(i0,j0,k0)]
1250  + wz0 * wx0 * wy1 * celldata[accessCellIndex(i0,jp,k0)]
1251  + wz0 * wx1 * wy0 * celldata[accessCellIndex(ip,j0,k0)]
1252  + wz0 * wx1 * wy1 * celldata[accessCellIndex(ip,jp,k0)]
1253  + wz1 * wx0 * wy0 * celldata[accessCellIndex(i0,j0,kp)]
1254  + wz1 * wx0 * wy1 * celldata[accessCellIndex(i0,jp,kp)]
1255  + wz1 * wx1 * wy0 * celldata[accessCellIndex(ip,j0,kp)]
1256  + wz1 * wx1 * wy1 * celldata[accessCellIndex(ip,jp,kp)];
1257 
1258  return(result);
1259 };
1260 
1267 
1268  int i0, j0, k0, ip, jp, kp;
1269  double wx0,wx1,wy0,wy1,wz0,wz1;
1270 
1271  darray3E P = transfToLocal(point);
1272  darray3E locOr = getShape()->getLocalOrigin();
1273  i0 = std::max(0, std::min(m_nx, (int) std::floor((P[0]-locOr[0])/m_dx)));
1274  j0 = std::max(0, std::min(m_ny, (int) std::floor((P[1]-locOr[1])/m_dy)));
1275  k0 = std::max(0, std::min(m_nz, (int) std::floor((P[2]-locOr[2])/m_dz)));
1276 
1277  if (P[0] >= m_xedge[i0]) { ip = std::min(i0+1, m_nx); }
1278  else { ip = std::max(0, i0-1); }
1279  if (P[1] >= m_yedge[j0]) { jp = std::min(j0+1, m_ny); }
1280  else { jp = std::max(0, j0-1); }
1281  if (P[2] >= m_zedge[k0]) { kp = std::min(k0+1, m_nz); }
1282  else { kp = std::max(0, k0-1); }
1283 
1284  // Interpolation weights
1285  wx1 = std::max(0.0, std::min(1.0, std::abs((P[0] - m_xedge[i0])/m_dx))); wx0 = 1.0 - wx1;
1286  wy1 = std::max(0.0, std::min(1.0, std::abs((P[1] - m_yedge[j0])/m_dy))); wy0 = 1.0 - wy1;
1287  wz1 = std::max(0.0, std::min(1.0, std::abs((P[2] - m_zedge[k0])/m_dz))); wz0 = 1.0 - wz1;
1288 
1289  // Interpolation
1290  double result = wz0 * wx0 * wy0 * pointdata[accessPointIndex(i0,j0,k0)]
1291  + wz0 * wx0 * wy1 * pointdata[accessPointIndex(i0,jp,k0)]
1292  + wz0 * wx1 * wy0 * pointdata[accessPointIndex(ip,j0,k0)]
1293  + wz0 * wx1 * wy1 * pointdata[accessPointIndex(ip,jp,k0)]
1294  + wz1 * wx0 * wy0 * pointdata[accessPointIndex(i0,j0,kp)]
1295  + wz1 * wx0 * wy1 * pointdata[accessPointIndex(i0,jp,kp)]
1296  + wz1 * wx1 * wy0 * pointdata[accessPointIndex(ip,j0,kp)]
1297  + wz1 * wx1 * wy1 * pointdata[accessPointIndex(ip,jp,kp)];
1298  return(result);
1299 };
1300 
1307 
1308  int i0, j0, k0, ip, jp, kp;
1309  double wx0,wx1,wy0,wy1,wz0,wz1;
1310 
1311  darray3E P = transfToLocal(point);
1312  darray3E locOr = getShape()->getLocalOrigin();
1313  i0 = std::max(0, std::min(m_nx, (int) std::floor((P[0]-locOr[0])/m_dx)));
1314  j0 = std::max(0, std::min(m_ny, (int) std::floor((P[1]-locOr[1])/m_dy)));
1315  k0 = std::max(0, std::min(m_nz, (int) std::floor((P[2]-locOr[2])/m_dz)));
1316 
1317  if (P[0] >= m_xedge[i0]) { ip = std::min(i0+1, m_nx); }
1318  else { ip = std::max(0, i0-1); }
1319  if (P[1] >= m_yedge[j0]) { jp = std::min(j0+1, m_ny); }
1320  else { jp = std::max(0, j0-1); }
1321  if (P[2] >= m_zedge[k0]) { kp = std::min(k0+1, m_nz); }
1322  else { kp = std::max(0, k0-1); }
1323 
1324  // Interpolation weights
1325  wx1 = std::max(0.0, std::min(1.0, std::abs((P[0] - m_xedge[i0])/m_dx))); wx0 = 1.0 - wx1;
1326  wy1 = std::max(0.0, std::min(1.0, std::abs((P[1] - m_yedge[j0])/m_dy))); wy0 = 1.0 - wy1;
1327  wz1 = std::max(0.0, std::min(1.0, std::abs((P[2] - m_zedge[k0])/m_dz))); wz0 = 1.0 - wz1;
1328 
1329  // Interpolation
1330  double result = wz0 * wx0 * wy0 * (double)pointdata[accessPointIndex(i0,j0,k0)]
1331  + wz0 * wx0 * wy1 * (double)pointdata[accessPointIndex(i0,jp,k0)]
1332  + wz0 * wx1 * wy0 *(double) pointdata[accessPointIndex(ip,j0,k0)]
1333  + wz0 * wx1 * wy1 *(double) pointdata[accessPointIndex(ip,jp,k0)]
1334  + wz1 * wx0 * wy0 *(double) pointdata[accessPointIndex(i0,j0,kp)]
1335  + wz1 * wx0 * wy1 *(double) pointdata[accessPointIndex(i0,jp,kp)]
1336  + wz1 * wx1 * wy0 *(double) pointdata[accessPointIndex(ip,j0,kp)]
1337  + wz1 * wx1 * wy1 *(double) pointdata[accessPointIndex(ip,jp,kp)];
1338 
1339  int result2 = std::floor(result+0.5);
1340  return(result2);
1341 };
1342 
1349 
1350  int i0, j0, k0, ip, jp, kp;
1351  double wx0,wx1,wy0,wy1,wz0,wz1;
1352 
1353  darray3E P = transfToLocal(point);
1354  darray3E locOr = getShape()->getLocalOrigin();
1355  i0 = std::max(0, std::min(m_nx, (int) std::floor((P[0]-locOr[0])/m_dx)));
1356  j0 = std::max(0, std::min(m_ny, (int) std::floor((P[1]-locOr[1])/m_dy)));
1357  k0 = std::max(0, std::min(m_nz, (int) std::floor((P[2]-locOr[2])/m_dz)));
1358 
1359 
1360  if (P[0] >= m_xedge[i0]) { ip = std::min(i0+1, m_nx); }
1361  else { ip = std::max(0, i0-1); }
1362  if (P[1] >= m_yedge[j0]) { jp = std::min(j0+1, m_ny); }
1363  else { jp = std::max(0, j0-1); }
1364  if (P[2] >= m_zedge[k0]) { kp = std::min(k0+1, m_nz); }
1365  else { kp = std::max(0, k0-1); }
1366 
1367  // Interpolation weights
1368  wx1 = std::max(0.0, std::min(1.0, std::abs((P[0] - m_xedge[i0])/m_dx))); wx0 = 1.0 - wx1;
1369  wy1 = std::max(0.0, std::min(1.0, std::abs((P[1] - m_yedge[j0])/m_dy))); wy0 = 1.0 - wy1;
1370  wz1 = std::max(0.0, std::min(1.0, std::abs((P[2] - m_zedge[k0])/m_dz))); wz0 = 1.0 - wz1;
1371 
1372  // Interpolation
1373  darray3E result = wz0 * wx0 * wy0 * pointdata[accessPointIndex(i0,j0,k0)]
1374  + wz0 * wx0 * wy1 * pointdata[accessPointIndex(i0,jp,k0)]
1375  + wz0 * wx1 * wy0 * pointdata[accessPointIndex(ip,j0,k0)]
1376  + wz0 * wx1 * wy1 * pointdata[accessPointIndex(ip,jp,k0)]
1377  + wz1 * wx0 * wy0 * pointdata[accessPointIndex(i0,j0,kp)]
1378  + wz1 * wx0 * wy1 * pointdata[accessPointIndex(i0,jp,kp)]
1379  + wz1 * wx1 * wy0 * pointdata[accessPointIndex(ip,j0,kp)]
1380  + wz1 * wx1 * wy1 * pointdata[accessPointIndex(ip,jp,kp)];
1381 
1382  return(result);
1383 };
1384 
1385 
1396 void UStructMesh::plotCloud( std::string & folder , std::string outfile,
1397  int counterFile, bool codexFlag,
1398  const ivector1D & labels,
1399  dvecarr3E * extPoints){
1400 
1401  bitpit::VTKFormat codex = bitpit::VTKFormat::ASCII;
1402  if(codexFlag){codex=bitpit::VTKFormat::APPENDED;}
1403 
1404  iarray3E dim = getDimension();
1405  int sizeTot = dim[0]*dim[1]*dim[2];
1406 
1407  dvecarr3E activeP;
1408  if(extPoints != nullptr && (int)extPoints->size() == sizeTot){
1409  activeP = *extPoints;
1410  }else{
1411  activeP.resize(sizeTot);
1412  for(int i=0; i<sizeTot; i++){
1413  activeP[i] = getGlobalPoint(i);
1414  }
1415  }
1416 
1417  ivector1D conn(activeP.size());
1418  {
1419  int counter = 0;
1420  for(auto & val: conn){
1421  val = counter;
1422  ++counter;
1423  }
1424  }
1425  ivector1D datalab = labels;
1426  datalab.resize(activeP.size(), -1);
1427 
1428  bitpit::VTKUnstructuredGrid vtk(folder, outfile, bitpit::VTKElementType::VERTEX);
1429  vtk.setGeomData( bitpit::VTKUnstructuredField::POINTS, activeP) ;
1430  vtk.setGeomData( bitpit::VTKUnstructuredField::CONNECTIVITY, conn) ;
1431  vtk.setDimensions(conn.size(), activeP.size());
1432  vtk.addData("labels",bitpit::VTKFieldType::SCALAR, bitpit::VTKLocation::POINT, datalab) ;
1433  vtk.setCodex(codex);
1434  if(counterFile>=0){vtk.setCounter(counterFile);}
1435 
1436  vtk.write();
1437 
1438 };
1439 
1448 void UStructMesh::plotCloudScalar( std::string folder , std::string outfile, int counterFile, bool codexFlag, dvector1D & data){
1449 
1450  bitpit::VTKFormat codex = bitpit::VTKFormat::ASCII;
1451  if(codexFlag){codex=bitpit::VTKFormat::APPENDED;}
1452 
1453  iarray3E dim = getDimension();
1454  int sizeTot = dim[0]*dim[1]*dim[2];
1455 
1456  dvecarr3E activeP(sizeTot);
1457  for(int i=0; i<sizeTot; i++){
1458  activeP[i] = getGlobalPoint(i);
1459  }
1460 
1461  ivector1D conn(activeP.size());
1462  {
1463  int counter = 0;
1464  for(auto & val: conn){
1465  val = counter;
1466  ++counter;
1467  }
1468  }
1469 
1470  bitpit::VTKUnstructuredGrid vtk(folder, outfile, bitpit::VTKElementType::VERTEX);
1471  vtk.setGeomData( bitpit::VTKUnstructuredField::POINTS, activeP) ;
1472  vtk.setGeomData( bitpit::VTKUnstructuredField::CONNECTIVITY, conn) ;
1473  vtk.setDimensions(conn.size(), activeP.size());
1474  vtk.setCodex(codex);
1475  if(counterFile>=0){vtk.setCounter(counterFile);}
1476 
1477  bitpit::VTKLocation loc = bitpit::VTKLocation::POINT;
1478  vtk.addData("field",bitpit::VTKFieldType::SCALAR, loc, data) ;
1479  vtk.write();
1480 };
1481 
1492 void UStructMesh::plotGrid(std::string & folder, std::string outfile ,
1493  int counterFile, bool codexFlag,
1494  const ivector1D & labels,
1495  dvecarr3E * extPoints)
1496 {
1497  bitpit::VTKFormat codex = bitpit::VTKFormat::ASCII;
1498  if(codexFlag){codex=bitpit::VTKFormat::APPENDED;}
1499 
1500  iarray3E dim = getDimension();
1501  int sizePt = dim[0]*dim[1]*dim[2];
1502  int sizeCl = (dim[0]-1)*(dim[1]-1)*(dim[2]-1);
1503 
1504  dvecarr3E activeP(sizePt);
1505  ivector2D activeConn(sizeCl, ivector1D(8,0));
1506 
1507  if(extPoints != nullptr && (int)extPoints->size() == sizePt){
1508  activeP = *extPoints;
1509  }
1510  else{
1511  for(int i=0; i<sizePt; i++){
1512  activeP[i] = getGlobalPoint(i);
1513  }
1514  }
1515 
1516  for(int i=0; i<sizeCl; ++i){
1517  activeConn[i] = getCellNeighs(i);
1518  }
1519 
1520  ivector1D datalab = labels;
1521  datalab.resize(activeP.size(),-1);
1522 
1523  bitpit::VTKElementType elDM = bitpit::VTKElementType::HEXAHEDRON;
1524  bitpit::VTKUnstructuredGrid vtk(folder, outfile, elDM);
1525  vtk.setGeomData( bitpit::VTKUnstructuredField::POINTS, activeP) ;
1526  vtk.setGeomData( bitpit::VTKUnstructuredField::CONNECTIVITY, activeConn) ;
1527  vtk.setDimensions(sizeCl, sizePt);
1528  vtk.addData("labels",bitpit::VTKFieldType::SCALAR, bitpit::VTKLocation::POINT, datalab) ;
1529  vtk.setCodex(codex);
1530  if(counterFile>=0){vtk.setCounter(counterFile);}
1531 
1532  vtk.write();
1533 
1534 };
1535 
1544 void UStructMesh::plotGridScalar(std::string folder, std::string outfile , int counterFile, bool codexFlag, dvector1D & data){
1545 
1546  bitpit::VTKFormat codex = bitpit::VTKFormat::ASCII;
1547  if(codexFlag){codex=bitpit::VTKFormat::APPENDED;}
1548 
1549  iarray3E dim = getDimension();
1550  int sizePt = dim[0]*dim[1]*dim[2];
1551  int sizeCl = (dim[0]-1)*(dim[1]-1)*(dim[2]-1);
1552 
1553  dvecarr3E activeP(sizePt);
1554  ivector2D activeConn(sizeCl, ivector1D(8,0));
1555 
1556  for(int i=0; i<sizePt; i++){
1557  activeP[i] = getGlobalPoint(i);
1558  }
1559 
1560  for(int i=0; i<sizeCl; ++i){
1561  activeConn[i] = getCellNeighs(i);
1562  }
1563 
1564  bitpit::VTKElementType elDM = bitpit::VTKElementType::HEXAHEDRON;
1565  bitpit::VTKUnstructuredGrid vtk(folder, outfile, elDM);
1566  vtk.setGeomData( bitpit::VTKUnstructuredField::POINTS, activeP) ;
1567  vtk.setGeomData( bitpit::VTKUnstructuredField::CONNECTIVITY, activeConn) ;
1568  vtk.setDimensions(sizeCl, sizePt);
1569 
1570  vtk.setCodex(codex);
1571  if(counterFile>=0){vtk.setCounter(counterFile);}
1572 
1573  bitpit::VTKLocation loc = bitpit::VTKLocation::POINT;
1574  if ((int)data.size() == sizeCl) loc = bitpit::VTKLocation::CELL;
1575 
1576  vtk.addData("field",bitpit::VTKFieldType::SCALAR, loc, data) ;
1577  vtk.write();
1578 
1579 };
1580 
1581 
1586  m_xnode.clear();
1587  m_ynode.clear();
1588  m_znode.clear();
1589  m_xedge.clear();
1590  m_yedge.clear();
1591  m_zedge.clear();
1592 };
1593 
1600  resizeMesh();
1601 };
1602 
1607  // Cell centers
1608  m_xnode.resize(m_nx, 0.0);
1609  m_ynode.resize(m_ny, 0.0);
1610  m_znode.resize(m_nz, 0.0);
1611 
1612  // Points
1613  m_xedge.resize(m_nx+1, 0.0);
1614  m_yedge.resize(m_ny+1, 0.0);
1615  m_zedge.resize(m_nz+1, 0.0);
1616 };
1617 
1623 
1624  if(getShape() == nullptr){return false;}
1625 
1626  ivector1D dimLimit(3,2);
1627  //create internal shape using unique_ptr member.
1628  // unlink external shape eventually
1629  switch(getShapeType()){
1630  case ShapeType::CYLINDER :
1631  dimLimit[1] = 4;
1632  break;
1633  case ShapeType::SPHERE :
1634  dimLimit[1] = 5; dimLimit[2] = 3;
1635  break;
1636  default://CUBE //WEDGE
1637  break;
1638  }
1639 
1640  //check on dimensions and eventual closed loops on coordinates.
1641  m_nx = std::max(m_nx, dimLimit[0]-1);
1642  m_ny = std::max(m_ny, dimLimit[1]-1);
1643  m_nz = std::max(m_nz, dimLimit[2]-1);
1644 
1645  darray3E spanEff = getLocalSpan();
1646 
1648 
1649  m_dx = spanEff[0]/m_nx;
1650  m_dy = spanEff[1]/m_ny;
1651  m_dz = spanEff[2]/m_nz;
1652  darray3E locOr = getShape()->getLocalOrigin();
1653  // get point distro;
1654  for (int i = 0; i < m_nx+1; i++) {m_xedge[i] = locOr[0] + ((double) i) * m_dx;}
1655  for (int i = 0; i < m_ny+1; i++) {m_yedge[i] = locOr[1] + ((double) i) * m_dy;}
1656  for (int i = 0; i < m_nz+1; i++) {m_zedge[i] = locOr[2] + ((double) i) * m_dz;}
1657  // get cell distro
1658  for (int i = 0; i < m_nx; i++) {m_xnode[i] = m_xedge[i] + 0.5 * m_dx;}
1659  for (int i = 0; i < m_ny; i++) {m_ynode[i] = m_yedge[i] + 0.5 * m_dy;}
1660  for (int i = 0; i < m_nz; i++) {m_znode[i] = m_zedge[i] + 0.5 * m_dz;}
1661 
1662  m_isBuild = true;
1663  return true;
1664 };
1665 
1666 
1671  build();
1672 }
1673 
1678  return(m_isBuild);
1679 }
1680 
1681 };
void setOrigin(darray3E)
CoordType getCoordTypey()
Abstract Interface class for Elementary Shape Representation.
Definition: BasicShapes.hpp:91
void setCoordTypey(CoordType)
void plotCloudScalar(std::string, std::string, int, bool, dvector1D &data)
void setInfLimits(double val, int dir)
darray3E getLocalSpan()
std::array< int, 3 > iarray3E
darray3E getLocalCCell(int)
darray3E getGlobalCCell(int)
void setDimension(ivector1D dim)
dvecarr3E getGlobalCellCentroids()
darray3E getGlobalPoint(int)
virtual bool build()
darray3E getLocalPoint(int)
virtual darray3E toWorldCoord(const darray3E &point)=0
CoordType
Specify type of conditions to distribute NURBS nodes in a given coordinate of the shape.
Definition: BasicShapes.hpp:49
void setRefSystem(darray3E, darray3E, darray3E)
Elementary Shape Representation of a Prism with triangular basis.
int accessCellIndex(int i, int j, int k)
dvecarr3E getLocalCellCentroids()
void setCoordTypez(CoordType)
ivector1D getCellNeighs(int)
std::vector< darray3E > dvecarr3E
std::vector< T > conVect(std::array< T, d > &origin)
void setCoordType(CoordType, int)
void locateCellByPoint(darray3E &point, int &i, int &j, int &k)
std::unique_ptr< BasicShape > m_shape
Definition: BasicMeshes.hpp:47
void setOrigin(darray3E origin)
int accessPointIndex(int i, int j, int k)
ShapeType getShapeType()
const BasicShape * getShape() const
Elementary Shape Representation of a Sphere or portion of it.
CoordType getCoordTypex()
virtual darray3E toLocalCoord(const darray3E &point)=0
Elementary Shape Representation of a Cylinder or portion of it.
void setShape(ShapeType type=ShapeType::CUBE)
std::array< CoordType, 3 > getCoordType()
void setRefSystem(darray3E, darray3E, darray3E)
std::vector< int > ivector1D
Elementary Shape Representation of a Cube.
std::array< darray3E, 3 > dmatrix33E
void setMesh(darray3E &origin, darray3E &span, ShapeType, iarray3E &dimensions)
dvecarr3E getLocalCoords()
darray3E transfToLocal(darray3E &point)
std::vector< double > dvector1D
darray3E getSpacing()
darray3E transfToGlobal(darray3E &point)
virtual ~UStructMesh()
Definition: BasicMeshes.cpp:56
darray3E getScaling()
iarray3E getDimension()
void plotGridScalar(std::string, std::string, int, bool, dvector1D &data)
ShapeType
Identifies the type of elemental shape supported by BasicShape class.
Definition: BasicShapes.hpp:38
double interpolateCellData(darray3E &point, dvector1D &celldata)
double interpolatePointData(darray3E &point, dvector1D &pointdata)
void setCoordTypex(CoordType)
std::vector< ivector1D > ivector2D
void plotCloud(std::string &, std::string, int, bool, const ivector1D &labels, dvecarr3E *extPoints=nullptr)
ShapeType getShapeType()
Class for 3D uniform structured mesh.
Definition: BasicMeshes.hpp:44
std::array< double, 3 > darray3E
void setSpan(double, double, double)
dmatrix33E getRefSystem()
UStructMesh & operator=(UStructMesh other)
void swap(UStructMesh &x) noexcept
void setSpan(double, double, double)
dvecarr3E getGlobalCoords()
virtual darray3E getLocalOrigin()=0
darray3E getOrigin()
void setCoordinateType(CoordType, int dir)
darray3E getInfLimits()
void plotGrid(std::string &, std::string, int, bool, const ivector1D &labels, dvecarr3E *extPoints=nullptr)
void setInfLimits(double val, int dir)
CoordType getCoordinateType(int dir)
dmatrix33E getRefSystem()
CoordType getCoordTypez()