openCARP
Doxygen code documentation for the open cardiac electrophysiology simulator openCARP
SF_container.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // openCARP is an open cardiac electrophysiology simulator.
3 //
4 // Copyright (C) 2020 openCARP project
5 //
6 // This program is licensed under the openCARP Academic Public License (APL)
7 // v1.0: You can use and redistribute it and/or modify it in non-commercial
8 // academic environments under the terms of APL as published by the openCARP
9 // project v1.0, or (at your option) any later version. Commercial use requires
10 // a commercial license (info@opencarp.org).
11 //
12 // This program is distributed without any warranty; see the openCARP APL for
13 // more details.
14 //
15 // You should have received a copy of the openCARP APL along with this program
16 // and can find it online: http://www.opencarp.org/license
17 // ----------------------------------------------------------------------------
18 
27 #ifndef _SF_CONTAINER_H
28 #define _SF_CONTAINER_H
29 
30 #include <cstring>
31 #include <mpi.h>
32 #include <map>
33 #include <math.h>
34 #include <set>
35 
36 #include "dense_mat.hpp"
37 #include "SF_globals.h"
38 #include "SF_vector.h"
39 #include "SF_linalg_utils.h"
40 #include "hashmap.hpp"
41 
42 // This datatypes will be used in conjunction with mesh data. We might want to
43 // have increased / reduced precision when storing meshes, mesh related numberings, etc.
44 // Therefore, we will use (mesh_int_t,mesh_real_t) for data fields that scale with the mesh size,
45 // to be able to tweak the used datatype later. -Aurel
46 typedef int mesh_int_t;
47 typedef float mesh_real_t;
48 
49 namespace SF {
50 
52 enum elem_t
53 {
54  Tetra = 0,
60  Tri,
61  Line
62 };
63 
65 struct Point {
66  double x;
67  double y;
68  double z;
69 };
70 
71 template<class V>
72 inline Point arr_to_point(V* arr)
73 {
74  return {arr[0], arr[1], arr[2]};
75 }
76 
77 template<class V>
78 inline void point_to_arr(Point & p, V* arr)
79 {
80  arr[0] = p.x, arr[1] = p.y, arr[2] = p.z;
81 }
82 
84 inline Point cross(const Point & a, const Point & b)
85 {
86  Point c = {a.y*b.z - b.y*a.z, b.x*a.z - a.x*b.z, a.x*b.y - a.y*b.x};
87  return c;
88 }
89 
90 inline double inner_prod(const Point & a, const Point & b)
91 {
92  return a.x*b.x + a.y*b.y + a.z*b.z;
93 }
94 
95 inline void outer_prod(const Point & a, const Point & b, const double s, double* buff, const bool add = false)
96 {
97  if(add == false)
98  memset(buff, 0, 9*sizeof(double));
99 
100  buff[0] += a.x*b.x*s, buff[1] += a.x*b.y*s, buff[2] += a.x*b.z*s;
101  buff[3] += a.y*b.x*s, buff[4] += a.y*b.y*s, buff[5] += a.y*b.z*s;
102  buff[6] += a.z*b.x*s, buff[7] += a.z*b.y*s, buff[8] += a.z*b.z*s;
103 }
104 
105 inline void outer_prod(const Point & a, const Point & b, double* buff)
106 {
107  outer_prod(a, b, 1.0, buff);
108 }
109 
111 inline double mag(const Point & vect)
112 {
113  return sqrt(inner_prod(vect, vect));
114 }
115 
116 inline Point normalize(const Point & vect)
117 {
118  double norm = mag(vect);
119  return {vect.x / norm, vect.y / norm, vect.z / norm};
120 }
121 
122 inline Point operator-(const Point & a, const Point & b)
123 {
124  return {a.x - b.x, a.y - b.y, a.z - b.z};
125 }
126 
127 inline Point operator+(const Point & a, const Point & b)
128 {
129  return {a.x + b.x, a.y + b.y, a.z + b.z};
130 }
131 
132 inline Point operator*(const Point & a, const double & s)
133 {
134  return {a.x * s, a.y * s, a.z * s};
135 }
136 
137 inline Point operator*(const double & s, const Point & a)
138 {
139  return {s * a.x, s * a.y, s * a.z};
140 }
141 
142 inline Point operator*(const dmat<double>& A, const Point& b)
143 {
144  return {A[0][0] * b.x + A[0][1] * b.y + A[0][2] * b.z,
145  A[1][0] * b.x + A[1][1] * b.y + A[1][2] * b.z,
146  A[2][0] * b.x + A[2][1] * b.y + A[2][2] * b.z};
147 }
148 
150 inline Point project(const Point & a, const Point & b)
151 {
152  return a * inner_prod(normalize(a), normalize(b));
153 }
154 
155 inline Point orthogonalize(const Point & a, const Point & b)
156 {
157  return a - project(a, b);
158 }
159 
160 
161 inline double distance(const Point & a, const Point & b)
162 {
163  return mag(a - b);
164 }
165 
167 inline elem_t getElemTypeID(char *eletype)
168 {
169  elem_t ret;
170 
171  if ( !strcmp( eletype, "Tt" ) ) {
172  ret = Tetra;
173  } else if ( !strcmp( eletype, "Hx" ) ) {
174  ret = Hexa;
175  } else if ( !strcmp( eletype, "Oc" ) ) {
176  ret = Octa;
177  } else if ( !strcmp( eletype, "Py" ) ) {
178  ret = Pyramid;
179  } else if ( !strcmp( eletype, "Pr" ) ) {
180  ret = Prism;
181  } else if ( !strcmp( eletype, "Qd" ) ) {
182  ret = Quad;
183  } else if ( !strcmp( eletype, "Tr" ) ) {
184  ret = Tri;
185  } else {
186  ret = Line;
187  }
188  return ret;
189 }
190 
191 template<class S, class POINT> inline
192 void array_to_points(const vector<S> & arr, vector<POINT> & pts)
193 {
194  pts.resize(arr.size() / 3);
195  for(size_t i=0; i<pts.size(); i++)
196  pts[i] = {arr[i*3+0], arr[i*3+1], arr[i*3+2]};
197 }
198 
200 typedef enum {
207 
208 // forward declaration of parallel layouts since they are used in mesh.
209 template<class T> class overlapping_layout;
210 template<class T> class non_overlapping_layout;
211 
218 template<class T>
220 {
221  private:
224 
225  public:
228  {}
229 
236  index_mapping(const vector<T> & a, const vector<T> & b)
237  {
238  this->assign(a, b);
239  }
240 
247  inline void assign(const vector<T> & a, const vector<T> & b)
248  {
249  // a 1:1 mapping between old and new indices is required
250  assert( a.size() == b.size() );
251 
252  _fwd.clear();
253  _bwd.clear();
254 
255  for(size_t i=0; i<a.size(); i++)
256  {
257  T aidx = a[i], bidx = b[i];
258  _fwd[aidx] = bidx;
259  _bwd[bidx] = aidx;
260  }
261  }
262 
264  inline T forward_map(T idx) const
265  {
266  typename hashmap::unordered_map<T, T>::const_iterator it = _fwd.find(idx);
267  if(it != _fwd.end())
268  return it->second;
269  else
270  return T(-1);
271  }
272 
274  inline T backward_map(T idx) const
275  {
276  typename hashmap::unordered_map<T, T>::const_iterator it = _bwd.find(idx);
277  if(it != _bwd.end())
278  return it->second;
279  else
280  return T(-1);
281  }
282 
283 
292  inline void forward_map(vector<T> & idx) const
293  {
294  size_t lsize = idx.size();
295  vector<T> perm(lsize);
296  interval(perm, 0, lsize);
297 
298  binary_sort_copy(idx, perm);
299 
300  size_t c = 0;
302 
303  while(c < lsize)
304  {
305  T cc = idx[c];
306  it = _fwd.find(cc);
307 
308  T val = it != _fwd.end() ? it->second : T(-1);
309 
310  while( (c < lsize) && (cc == idx[c]) )
311  {
312  idx[c] = val;
313  c++;
314  }
315  }
316 
317  binary_sort_copy(perm, idx);
318  }
319 
328  inline void backward_map(vector<T> & idx) const
329  {
330  size_t lsize = idx.size();
331  vector<T> perm(lsize);
332  interval(perm, 0, lsize);
333 
334  binary_sort_copy(idx, perm);
335 
336  size_t c = 0;
338 
339  while(c < lsize)
340  {
341  T cc = idx[c];
342  it = _bwd.find(cc);
343 
344  T val = it != _bwd.end() ? *it : T(-1);
345 
346  while( (c < lsize) && (cc == idx[c]) )
347  {
348  idx[c] = val;
349  c++;
350  }
351  }
352 
353  binary_sort_copy(perm, idx);
354  }
355 
357  size_t size() const
358  {
359  return _fwd.size();
360  }
362  bool in_a(const T idx) {
363  return _fwd.count(idx) == 1;
364  }
366  bool in_b(const T idx) {
367  return _bwd.count(idx) == 1;
368  }
369 
371  {
372  return _fwd;
373  }
374 
376  {
377  return _bwd;
378  }
379 
381  {
382  return _fwd;
383  }
384 
386  {
387  return _bwd;
388  }
389 };
390 
394 template<class T, class S>
395 class meshdata
396 {
397 public:
398  size_t g_numelem;
399  size_t l_numelem;
400  size_t g_numpts;
401  size_t l_numpts;
402 
404  MPI_Comm comm;
405 
407  std::string name;
408 
409  // element connectivity : the nodes forming the elements
413 
414  // element data
415  // one value per element
419  // multiple values per element
422 
425 
426  std::map< SF_nbr, vector<T> > nbr;
428 
431 
434  comm(SF_COMM), name("unnamed")
435  {}
436 
445  {
446  if(nbr.count(nbr_type) == 0)
447  nbr[nbr_type] = vector<T>();
448 
449  return nbr[nbr_type];
450  }
451 
464  inline vector<T> & get_numbering(SF_nbr nbr_type)
465  {
466  typename std::map< SF_nbr, vector<T> >::iterator it = nbr.find(nbr_type);
467  assert(it != nbr.end());
468  return it->second;
469  }
482  inline const vector<T> & get_numbering(SF_nbr nbr_type) const
483  {
484  typename std::map< SF_nbr, vector<T> >::const_iterator it = nbr.find(nbr_type);
485  assert(it != nbr.end());
486  return it->second;
487  }
488 
496  inline void localize(SF_nbr nbr_type)
497  {
498  // register numbering
499  vector<T> & nod = this->register_numbering(nbr_type);
500 
502  for(const T & c : this->con) g2l[c] = 0;
503  g2l.sort();
504 
505  // compute numbering
506  nod.resize(g2l.size());
507 
508  size_t widx = 0;
509  for(auto it = g2l.begin(); it != g2l.end(); ++it, widx++) {
510  nod[widx] = it->first;
511  it->second = widx;
512  }
513 
514  global_to_local(g2l, this->con, true);
515  this->l_numpts = nod.size();
516  }
517 
525  inline void globalize(SF_nbr nbr_type)
526  {
527  // register numbering
528  vector<T> & nod = this->get_numbering(nbr_type);
529  for(T & c : con) c = nod[c];
530  }
531 
532 
538  inline void generate_par_layout()
539  {
540  const vector<T> & rnod = this->get_numbering(NBR_REF);
541  const vector<T> & reidx = this->get_numbering(NBR_ELEM_REF);
542 
543  pl.assign(rnod, comm);
544  g_numpts = pl.num_global_idx();
545 
546  epl.assign(reidx, comm);
547  }
548 
552  inline void clear_data()
553  {
554  g_numelem = 0;
555  g_numpts = 0;
556  l_numelem = 0;
557  l_numpts = 0;
558 
559  con.resize(0); con.reallocate();
560  dsp.resize(0); dsp.reallocate();
561  tag.resize(0); tag.reallocate();
562  type.resize(0); type.reallocate();
563 
564  fib.resize(0); fib.reallocate();
565  she.resize(0); she.reallocate();
566  xyz.resize(0); xyz.reallocate();
567 
568  extr_tag.clear();
569  nbr.clear();
570  }
571 
572 
573 };
574 
582 template<class T, class S>
583 inline void nodal_connectivity_graph(const meshdata<T, S> & mesh,
584  vector<T> & n2n_cnt,
585  vector<T> & n2n_con)
586 {
587  vector<T> e2n_cnt, n2e_cnt, n2e_con;
588  const vector<T> & e2n_con = mesh.con;
589 
590  cnt_from_dsp(mesh.dsp, e2n_cnt);
591 
592  transpose_connectivity(e2n_cnt, e2n_con, n2e_cnt, n2e_con);
593  multiply_connectivities(n2e_cnt, n2e_con,
594  e2n_cnt, e2n_con,
595  n2n_cnt, n2n_con);
596 }
597 
607 template<class T, class S>
609 {
610  vector<T> n2n_cnt, n2n_con;
611  nodal_connectivity_graph(mesh, n2n_cnt, n2n_con);
612 
613  int nmax = 0;
614  for(size_t nidx=0; nidx < n2n_cnt.size(); nidx++)
615  if(nmax < n2n_cnt[nidx]) nmax = n2n_cnt[nidx];
616 
617  MPI_Allreduce(MPI_IN_PLACE, &nmax, 1, MPI_INT, MPI_MAX, mesh.comm);
618 
619  return nmax;
620 }
621 
622 template<class T, class S>
623 void get_alg_mask(const meshdata<T,S> & mesh, vector<bool> & alg_mask)
624 {
625  const vector<T> & alg_nod = mesh.pl.algebraic_nodes();
626 
627  alg_mask.assign(mesh.l_numpts, false);
628  for(const T & n : alg_nod) alg_mask[n] = true;
629 }
630 
631 
636 template<class T>
638 {
639  public:
644 
646  inline void resize(size_t size)
647  {
648  scnt.assign(size, T()), rcnt.assign(size, T()), sdsp.assign(size+1, T()), rdsp.assign(size+1, T());
649  }
650 
652  template<class V>
653  inline void scale(V fac)
654  {
655  for(size_t i=0; i<scnt.size(); i++)
656  scnt[i] *= fac, rcnt[i] *= fac;
657 
658  for(size_t i=0; i<sdsp.size(); i++)
659  sdsp[i] *= fac, rdsp[i] *= fac;
660  }
661 
663  inline void transpose()
664  {
665  vector<T> tcnt(scnt), tdsp(sdsp);
666  scnt = rcnt, sdsp = rdsp;
667  rcnt = tcnt, rdsp = tdsp;
668  }
669 
678  template<class V>
679  inline void configure(const vector<V> & dest, MPI_Comm comm)
680  {
681  int size, rank;
682  MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank);
683 
684  this->resize(size);
685 
686  count(dest, scnt);
687  MPI_Alltoall(scnt.data(), sizeof(T), MPI_BYTE, rcnt.data(), sizeof(T), MPI_BYTE, comm);
690  }
700  template<class V>
701  inline void configure(const vector<V> & dest, const vector<T> & cnt, MPI_Comm comm)
702  {
703  int size, rank;
704  MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank);
705 
706  this->resize(size);
707 
708  scnt.zero();
709  for(size_t i=0; i<dest.size(); i++) scnt[dest[i]] += cnt[i];
710 
711  MPI_Alltoall(scnt.data(), sizeof(T), MPI_BYTE, rcnt.data(), sizeof(T), MPI_BYTE, comm);
712 
715  }
725  template<class V>
726  inline void source_ranks(vector<V> & source)
727  {
728  size_t size = rcnt.size();
729  source.resize(sum(rcnt));
730 
731  for(size_t i=0, widx=0; i<size; i++)
732  for(T j=0; j<rcnt[i]; j++, widx++)
733  source[widx] = i;
734  }
735 };
736 
737 template<class T>
738 struct tuple {
739  T v1;
740  T v2;
741 };
742 
743 template<class T, class S>
745 {
746  T v1;
747  S v2;
748 };
749 
750 template<class T>
751 struct triple {
752  T v1;
753  T v2;
754  T v3;
755 };
756 
757 template<class T, class S, class V>
758 struct mixed_triple {
759  T v1;
760  S v2;
761  V v3;
762 };
763 
764 template<class T>
765 struct quadruple {
766  T v1;
767  T v2;
768  T v3;
769  T v4;
770 };
771 
772 template<class T>
773 bool operator<(const struct tuple<T> & lhs, const struct tuple<T> & rhs)
774 {
775  if(lhs.v1 != rhs.v1)
776  return lhs.v1 < rhs.v1;
777  else
778  return lhs.v2 < rhs.v2;
779 }
780 template<class T, class S>
781 bool operator<(const struct mixed_tuple<T, S> & lhs, const struct mixed_tuple<T, S> & rhs)
782 {
783  if(lhs.v1 != rhs.v1)
784  return lhs.v1 < rhs.v1;
785  else
786  return lhs.v2 < rhs.v2;
787 }
788 
789 template<class T>
790 bool operator<(const struct triple<T> & lhs, const struct triple<T> & rhs)
791 {
792  if(lhs.v1 != rhs.v1)
793  return lhs.v1 < rhs.v1;
794  else if(lhs.v2 != rhs.v2)
795  return lhs.v2 < rhs.v2;
796  else
797  return lhs.v3 < rhs.v3;
798 }
799 
800 template<class T>
801 bool operator<(const struct quadruple<T> & lhs, const struct quadruple<T> & rhs)
802 {
803  if(lhs.v1 != rhs.v1)
804  return lhs.v1 < rhs.v1;
805  else if(lhs.v2 != rhs.v2)
806  return lhs.v2 < rhs.v2;
807  else if(lhs.v3 != rhs.v3)
808  return lhs.v3 < rhs.v3;
809  else
810  return lhs.v4 < rhs.v4;
811 }
812 
813 // expand hashing for custom triple struct
814 
815 }
816 
817 namespace hashmap {
818 
819 template<typename T>
820 struct hash_ops< SF::tuple<T> >
821 {
822  static inline
824  return a.v1 == b.v1 && a.v2 == b.v2;
825  }
826 
827  static inline
832  return h;
833  }
834 };
835 
836 template<typename T>
837 struct hash_ops< SF::triple<T> >
838 {
839  static inline
841  return a.v1 == b.v1 && a.v2 == b.v2 && a.v3 == b.v3;
842  }
843 
844  static inline
846  hm_uint h = mkhash_init;
850  return h;
851  }
852 };
853 
854 template<typename T>
855 struct hash_ops< SF::quadruple<T> >
856 {
857  static inline
859  return a.v1 == b.v1 && a.v2 == b.v2 && a.v3 == b.v3 && a.v4 == b.v4;
860  }
861 
862  static inline
864  hm_uint h = mkhash_init;
869  return h;
870  }
871 };
872 }
873 
874 template<class T>
875 struct tri_sele {
876  T v1;
877  T v2;
878  T v3;
879  T eidx;
880 };
881 
882 template<class T>
883 struct quad_sele {
884  T v1;
885  T v2;
886  T v3;
887  T v4;
888  T eidx;
889 };
890 
892 template<class T>
893 void sort_triple(const T in1, const T in2, const T in3, T & out1, T & out2, T & out3)
894 {
895  bool t12 = in1 < in2;
896  bool t13 = in1 < in3;
897  bool t23 = in2 < in3;
898 
899  if(t12) {
900  //(123),(312),(132)
901  if(t23) {
902  //123
903  out1=in1; out2=in2; out3=in3;
904  }
905  else {
906  //(312),(132)
907  if(t13) {
908  //132
909  out1=in1; out2=in3; out3=in2;
910  }
911  else {
912  //312
913  out1=in3; out2=in1; out3=in2;
914  }
915  }
916  }
917  else {
918  //(213),(231),(321)
919  if(t23) {
920  //(213),(231)
921  if(t13) {
922  //213
923  out1=in2; out2=in1; out3=in3;
924  }
925  else {
926  //231
927  out1=in2; out2=in3; out3=in1;
928  }
929  }
930  else {
931  //321
932  out1=in3; out2=in2; out3=in1;
933  }
934  }
935 }
936 
937 #endif
938 
void sort_triple(const T in1, const T in2, const T in3, T &out1, T &out2, T &out3)
sort the "in" triple into the "out" triple
Definition: SF_container.h:893
int mesh_int_t
Definition: SF_container.h:46
float mesh_real_t
Definition: SF_container.h:47
#define SF_COMM
the default SlimFem MPI communicator
Definition: SF_globals.h:27
Sequential linear algebra kernels.
The vector class and related algorithms.
Definition: mesher.cc:237
The class holds the communication graph for a MPI_Exchange() call.
Definition: SF_container.h:638
vector< T > rcnt
Number of elements received from each rank.
Definition: SF_container.h:642
vector< T > scnt
Number of elements sent to each rank.
Definition: SF_container.h:640
void resize(size_t size)
Resize all vectors to size.
Definition: SF_container.h:646
void configure(const vector< V > &dest, MPI_Comm comm)
Set up the communication graph.
Definition: SF_container.h:679
void configure(const vector< V > &dest, const vector< T > &cnt, MPI_Comm comm)
Set up the communication graph.
Definition: SF_container.h:701
vector< T > sdsp
Displacements w.r.t. scnt.
Definition: SF_container.h:641
vector< T > rdsp
Displacements w.r.t. rcnt.
Definition: SF_container.h:643
void source_ranks(vector< V > &source)
For every received data element, get the rank indices it was receive from.
Definition: SF_container.h:726
void transpose()
transpose comm graph (receive becomes send, and vice versa)
Definition: SF_container.h:663
void scale(V fac)
scale comm graph layout data
Definition: SF_container.h:653
Index mapping class. This is a bijective mapping.
Definition: SF_container.h:220
void assign(const vector< T > &a, const vector< T > &b)
Set up the index mapping between a and b.
Definition: SF_container.h:247
const hashmap::unordered_map< T, T > & get_fwd_map() const
Definition: SF_container.h:370
void backward_map(vector< T > &idx) const
Map a whole array of indices in b to indices in a.
Definition: SF_container.h:328
hashmap::unordered_map< T, T > & get_bwd_map()
Definition: SF_container.h:385
index_mapping(const vector< T > &a, const vector< T > &b)
Constructor that uses assign() to set up the index mapping.
Definition: SF_container.h:236
size_t size() const
number of entries in bijective map
Definition: SF_container.h:357
void forward_map(vector< T > &idx) const
Map a whole array of indices in a to indices in b.
Definition: SF_container.h:292
hashmap::unordered_map< T, T > & get_fwd_map()
Definition: SF_container.h:380
const hashmap::unordered_map< T, T > & get_bwd_map() const
Definition: SF_container.h:375
T forward_map(T idx) const
Map one index from a to b.
Definition: SF_container.h:264
bool in_a(const T idx)
return whether idx is in set A
Definition: SF_container.h:362
bool in_b(const T idx)
return whether idx is in set B
Definition: SF_container.h:366
T backward_map(T idx) const
Map one index from b to a.
Definition: SF_container.h:274
index_mapping()
empty constructor.
Definition: SF_container.h:227
The mesh storage class. It contains both element and vertex data.
Definition: SF_container.h:396
void globalize(SF_nbr nbr_type)
Localize the connectivity data w.r.t. a given numbering.
Definition: SF_container.h:525
void clear_data()
Clear the mesh data from memory.
Definition: SF_container.h:552
overlapping_layout< T > pl
nodal parallel layout
Definition: SF_container.h:429
size_t g_numpts
global number of points
Definition: SF_container.h:400
meshdata()
construct empty mesh
Definition: SF_container.h:433
vector< T > dsp
connectivity starting index of each element
Definition: SF_container.h:416
vector< S > she
sheet direction
Definition: SF_container.h:421
vector< S > fib
fiber direction
Definition: SF_container.h:420
size_t l_numelem
local number of elements
Definition: SF_container.h:399
vector< elem_t > type
element type
Definition: SF_container.h:418
std::map< SF_nbr, vector< T > > nbr
container for different numberings
Definition: SF_container.h:426
std::string name
the mesh name
Definition: SF_container.h:407
void generate_par_layout()
Set up the parallel layout.
Definition: SF_container.h:538
vector< T > & register_numbering(SF_nbr nbr_type)
Register a new numbering to the mesh and return the associated index vector.
Definition: SF_container.h:444
vector< T > con
Definition: SF_container.h:412
vector< S > xyz
node cooridnates
Definition: SF_container.h:427
const vector< T > & get_numbering(SF_nbr nbr_type) const
Get the vector defining a certain numbering.
Definition: SF_container.h:482
size_t l_numpts
local number of points
Definition: SF_container.h:401
size_t g_numelem
global number of elements
Definition: SF_container.h:398
void localize(SF_nbr nbr_type)
Localize the connectivity data w.r.t. a given numbering.
Definition: SF_container.h:496
MPI_Comm comm
the parallel mesh is defined on a MPI world
Definition: SF_container.h:404
vector< T > & get_numbering(SF_nbr nbr_type)
Get the vector defining a certain numbering.
Definition: SF_container.h:464
vector< T > tag
element tag
Definition: SF_container.h:417
hashmap::unordered_set< int > extr_tag
the element tags based on which the mesh has been extracted
Definition: SF_container.h:424
non_overlapping_layout< T > epl
element parallel layout
Definition: SF_container.h:430
The parallel layout of non overlapping indices.
The overlapping_layout class contains the algorithms related to managing overlapping parallel index s...
void assign(const vector< T > &idx, MPI_Comm comm)
Initialization function.
size_t size() const
The current size of the vector.
Definition: SF_vector.h:104
void resize(size_t n)
Resize a vector.
Definition: SF_vector.h:209
void assign(InputIterator s, InputIterator e)
Assign a memory range.
Definition: SF_vector.h:161
void reallocate()
Definition: SF_vector.h:257
iterator find(const K &key)
Search for key. Return iterator.
Definition: hashmap.hpp:593
hm_int count(const K &key) const
Check if key exists.
Definition: hashmap.hpp:579
void sort(Compare comp=Compare())
Sort data entries.
Definition: hashmap.hpp:659
size_t size() const
Definition: hashmap.hpp:687
Dense matrix class and associated funcs.
Classes similar to unordered_set and unordered_map, but with better performance.
unsigned long int hm_uint
Definition: hashmap.hpp:43
Definition: dense_mat.hpp:34
double mag(const Point &vect)
vector magnitude
Definition: SF_container.h:111
void cnt_from_dsp(const vector< T > &dsp, vector< T > &cnt)
Compute counts from displacements.
Definition: SF_vector.h:319
Point arr_to_point(V *arr)
Definition: SF_container.h:72
void dsp_from_cnt(const vector< T > &cnt, vector< T > &dsp)
Compute displacements from counts.
Definition: SF_vector.h:310
void transpose_connectivity(const vector< T > &a_cnt, const vector< T > &a_con, vector< T > &b_cnt, vector< T > &b_con)
Transpose CRS matrix graph A into B.
bool operator<(const struct tuple< T > &lhs, const struct tuple< T > &rhs)
Definition: SF_container.h:773
dmat< S > operator-(const dmat< S > &a, const dmat< S > &b)
Definition: dense_mat.hpp:421
void interval(vector< T > &vec, size_t start, size_t end)
Create an integer interval between start and end.
Definition: SF_vector.h:350
void get_alg_mask(const meshdata< T, S > &mesh, vector< bool > &alg_mask)
Definition: SF_container.h:623
double inner_prod(const Point &a, const Point &b)
Definition: SF_container.h:90
void binary_sort_copy(vector< T > &_V, vector< S > &_W)
Definition: SF_sort.h:296
T sum(const vector< T > &vec)
Compute sum of a vector's entries.
Definition: SF_vector.h:340
void count(const vector< T > &data, vector< S > &cnt)
Count number of occurrences of indices.
Definition: SF_vector.h:332
void point_to_arr(Point &p, V *arr)
Definition: SF_container.h:78
Point project(const Point &a, const Point &b)
project b onto a
Definition: SF_container.h:150
void outer_prod(const Point &a, const Point &b, const double s, double *buff, const bool add=false)
Definition: SF_container.h:95
void multiply_connectivities(const vector< T > &a_cnt, const vector< T > &a_con, const vector< T > &b_cnt, const vector< T > &b_con, vector< T > &c_cnt, vector< T > &c_con)
int max_nodal_edgecount(const meshdata< T, S > &mesh)
Compute the maximum number of node-to-node edges for a mesh.
Definition: SF_container.h:608
dmat< S > operator*(const dmat< S > &a, const dmat< S > &b)
Definition: dense_mat.hpp:373
Point normalize(const Point &vect)
Definition: SF_container.h:116
void array_to_points(const vector< S > &arr, vector< POINT > &pts)
Definition: SF_container.h:192
Point orthogonalize(const Point &a, const Point &b)
Definition: SF_container.h:155
void global_to_local(const vector< T > &glob, vector< T > &data, bool sortedData, bool doWarn)
Definition: SF_sort.h:540
elem_t getElemTypeID(char *eletype)
Generate element type enum from string.
Definition: SF_container.h:167
double distance(const Point &a, const Point &b)
Definition: SF_container.h:161
dmat< S > operator+(const dmat< S > &a, const dmat< S > &b)
Definition: dense_mat.hpp:413
Point cross(const Point &a, const Point &b)
cross product
Definition: SF_container.h:84
elem_t
element type enum
Definition: SF_container.h:53
@ Line
Definition: SF_container.h:61
@ Tri
Definition: SF_container.h:60
@ Prism
Definition: SF_container.h:58
@ Pyramid
Definition: SF_container.h:57
@ Tetra
Definition: SF_container.h:54
@ Quad
Definition: SF_container.h:59
@ Octa
Definition: SF_container.h:56
@ Hexa
Definition: SF_container.h:55
void nodal_connectivity_graph(const meshdata< T, S > &mesh, vector< T > &n2n_cnt, vector< T > &n2n_con)
Compute the node-to-node connectivity.
Definition: SF_container.h:583
SF_nbr
Enumeration encoding the different supported numberings.
Definition: SF_container.h:200
@ NBR_PETSC
PETSc numbering of nodes.
Definition: SF_container.h:203
@ NBR_ELEM_REF
The element numbering of the reference mesh (the one stored on HD).
Definition: SF_container.h:204
@ NBR_REF
The nodal numbering of the reference mesh (the one stored on HD).
Definition: SF_container.h:201
@ NBR_SUBMESH
Submesh nodal numbering: The globally ascending sorted reference indices are reindexed.
Definition: SF_container.h:202
@ NBR_ELEM_SUBMESH
Submesh element numbering: The globally ascending sorted reference indices are reindexed.
Definition: SF_container.h:205
const hm_uint mkhash_init
Definition: hashmap.hpp:57
hm_uint mkhash(hm_uint a, hm_uint b)
Definition: hashmap.hpp:52
Point and vector struct.
Definition: SF_container.h:65
double y
Definition: SF_container.h:67
double z
Definition: SF_container.h:68
double x
Definition: SF_container.h:66
static hm_uint hash(SF::quadruple< T > a)
Definition: SF_container.h:863
static bool cmp(SF::quadruple< T > a, SF::quadruple< T > b)
Definition: SF_container.h:858
static bool cmp(SF::triple< T > a, SF::triple< T > b)
Definition: SF_container.h:840
static hm_uint hash(SF::triple< T > a)
Definition: SF_container.h:845
static hm_uint hash(SF::tuple< T > a)
Definition: SF_container.h:828
static bool cmp(SF::tuple< T > a, SF::tuple< T > b)
Definition: SF_container.h:823
Base hashing class.
Definition: hashmap.hpp:88