Ice Sheet System Model  4.18
Code documentation
Public Member Functions | Private Attributes
bamg::SetOfEdges4 Class Reference

#include <SetOfE4.h>

Public Member Functions

 SetOfEdges4 (long, long)
 
 ~SetOfEdges4 ()
 
IntEdgeoperator[] (long k)
 
long add (long ii, long jj)
 
long SortAndAdd (long ii, long jj)
 
long nb ()
 
long find (long ii, long jj)
 
long SortAndFind (long ii, long jj)
 
long i (long k)
 
long j (long k)
 

Private Attributes

long nx
 
long nbax
 
long NbOfEdges
 
long * head
 
IntEdgeEdges
 

Detailed Description

Definition at line 15 of file SetOfE4.h.

Constructor & Destructor Documentation

◆ SetOfEdges4()

bamg::SetOfEdges4::SetOfEdges4 ( long  mmx,
long  nnx 
)

Definition at line 7 of file SetOfE4.cpp.

7  {/*{{{*/
8  /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, SetOfEdges4.cpp/SetOfEdges4)*/
9 
10  /*Intermediary*/
11  int i;
12 
13  //initialize fields
14  nx =nnx; //number of vertices
15  nbax =mmx; // 3 * number of triangles
16  NbOfEdges=0;
17  head = new long [nx];
18  Edges= new IntEdge[nbax];
19 
20  //initialize head (-1 everywhere)
21  i=nx;
22  while(i--) head[i]=-1;
23  }

◆ ~SetOfEdges4()

bamg::SetOfEdges4::~SetOfEdges4 ( )
inline

Definition at line 26 of file SetOfE4.h.

26 {delete [] head; delete [] Edges;}

Member Function Documentation

◆ operator[]()

IntEdge& bamg::SetOfEdges4::operator[] ( long  k)
inline

Definition at line 29 of file SetOfE4.h.

29 {return Edges[k];}

◆ add()

long bamg::SetOfEdges4::add ( long  ii,
long  jj 
)

Definition at line 27 of file SetOfE4.cpp.

27  {/*{{{*/
28  /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, SetOfEdges4.cpp/add)*/
29 
30  /*Intermediary*/
31  int h,n;
32 
33  //get n from h (usually h=ii)
34  _assert_(head);
35  n=head[h=Abs(ii)%nx];
36 
37  //go through the existing edges that holds h (=ii) and check that
38  //the edge ii jj is not already in Edge
39  while (n >= 0){
40 
41  //if the edge ii jj is already in Edges, return n
42  if (ii == Edges[n].i && jj == Edges[n].j) return n;
43 
44  //else go to next edge that holds ii
45  else n = Edges[n].next;
46  }
47 
48  //check that nbax <=NbOfEdges
49  if (nbax <=NbOfEdges ) {
50  _error_("SetOfEdges4::add overflow: NbOfEdges=" << NbOfEdges << " > nbax=" << nbax);
51  }
52 
53  //update chain
54  Edges[NbOfEdges].i=ii;
55  Edges[NbOfEdges].j=jj;
56  Edges[NbOfEdges].next= head[h];
57  head[h] = NbOfEdges;
58  return NbOfEdges ++;
59  }

◆ SortAndAdd()

long bamg::SetOfEdges4::SortAndAdd ( long  ii,
long  jj 
)

Definition at line 99 of file SetOfE4.cpp.

99  {/*{{{*/
100  return ii <=jj ? add (ii,jj) : add (jj,ii) ;
101  }

◆ nb()

long bamg::SetOfEdges4::nb ( )

Definition at line 95 of file SetOfE4.cpp.

95  {/*{{{*/
96  return NbOfEdges;
97  }

◆ find()

long bamg::SetOfEdges4::find ( long  ii,
long  jj 
)

Definition at line 61 of file SetOfE4.cpp.

61  { /*{{{*/
62  /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, SetOfEdges4.cpp/find)*/
63 
64  /*Intermediary*/
65  int n;
66 
67  //check that head is not empty
68  _assert_(head);
69 
70  //get n from h (usually h=ii)
71  n=head[Abs(ii)%nx];
72 
73  //go through the existing edges that holds h (=ii) and return position in Edge
74  while (n >= 0){
75 
76  //if the edge ii jj is already in Edges, return n
77  if (ii == Edges[n].i && jj == Edges[n].j) return n;
78 
79  //else go to next edge that holds ii
80  else n = Edges[n].next;
81  }
82 
83  //if we reach this point, the edge does not exist return -1
84  return -1;
85  }

◆ SortAndFind()

long bamg::SetOfEdges4::SortAndFind ( long  ii,
long  jj 
)

Definition at line 103 of file SetOfE4.cpp.

103  {/*{{{*/
104  return ii <=jj ? find (ii,jj) : find (jj,ii) ;
105  }

◆ i()

long bamg::SetOfEdges4::i ( long  k)

Definition at line 87 of file SetOfE4.cpp.

87  {/*{{{*/
88  return Edges[k].i;
89  }

◆ j()

long bamg::SetOfEdges4::j ( long  k)

Definition at line 91 of file SetOfE4.cpp.

91  {/*{{{*/
92  return Edges[k].j;
93  }

Field Documentation

◆ nx

long bamg::SetOfEdges4::nx
private

Definition at line 18 of file SetOfE4.h.

◆ nbax

long bamg::SetOfEdges4::nbax
private

Definition at line 18 of file SetOfE4.h.

◆ NbOfEdges

long bamg::SetOfEdges4::NbOfEdges
private

Definition at line 18 of file SetOfE4.h.

◆ head

long* bamg::SetOfEdges4::head
private

Definition at line 19 of file SetOfE4.h.

◆ Edges

IntEdge* bamg::SetOfEdges4::Edges
private

Definition at line 20 of file SetOfE4.h.


The documentation for this class was generated from the following files:
_assert_
#define _assert_(ignore)
Definition: exceptions.h:37
bamg::SetOfEdges4::nx
long nx
Definition: SetOfE4.h:18
bamg::SetOfEdges4::NbOfEdges
long NbOfEdges
Definition: SetOfE4.h:18
bamg::SetOfEdges4::add
long add(long ii, long jj)
Definition: SetOfE4.cpp:27
bamg::IntEdge::next
long next
Definition: SetOfE4.h:12
bamg::SetOfEdges4::j
long j(long k)
Definition: SetOfE4.cpp:91
bamg::IntEdge::i
long i
Definition: SetOfE4.h:11
bamg::IntEdge::j
long j
Definition: SetOfE4.h:11
bamg::SetOfEdges4::find
long find(long ii, long jj)
Definition: SetOfE4.cpp:61
bamg::SetOfEdges4::nbax
long nbax
Definition: SetOfE4.h:18
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
bamg::SetOfEdges4::head
long * head
Definition: SetOfE4.h:19
bamg::SetOfEdges4::i
long i(long k)
Definition: SetOfE4.cpp:87
bamg::Abs
T Abs(const T &a)
Definition: Abs.h:5
bamg::SetOfEdges4::Edges
IntEdge * Edges
Definition: SetOfE4.h:20