ESyS-Particle
2.2
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
ntable.h
Go to the documentation of this file.
1
2
// //
3
// Copyright (c) 2003-2013 by The University of Queensland //
4
// Earth Systems Science Computational Centre (ESSCC) //
5
// http://www.uq.edu.au/esscc //
6
// //
7
// Primary Business: Brisbane, Queensland, Australia //
8
// Licensed under the Open Software License version 3.0 //
9
// http://www.opensource.org/licenses/osl-3.0.php //
10
// //
12
13
#ifndef __NTABLE_H
14
#define __NTABLE_H
15
16
#include "
Foundation/console.h
"
17
18
//--- project includes ---
19
#include "
Foundation/vec3.h
"
20
#include "
ntable/src/dslice.h
"
21
#include "
ntable/src/handle.h
"
22
#include "
Geometry/Triangle.h
"
23
#include "
Geometry/AEdge.h
"
24
25
26
27
//--- STL includes ---
28
#include <utility>
29
#include <valarray>
30
#include <vector>
31
#include <list>
32
33
#if HAVE_CONFIG_H
34
#include <config.h>
35
#endif
36
37
/* #if HAVE_HASH_MAP */
38
/* #include <hash_map> */
39
/* #else */
40
#include <map>
41
/* #endif */
42
43
using
std::valarray;
44
using
std::vector;
45
using
std::list;
46
using
std::pair;
47
using
std::make_pair;
48
49
//--- IO includes ---
50
#include <iostream>
51
52
//--- forward declarations ---
53
template
<
typename
T>
54
class
NTSlab
;
55
56
template
<
typename
T>
57
class
NTBlock
;
58
59
template
<
typename
T>
60
class
NTSlab_iter
;
61
66
template
<
typename
T>
67
class
NeighborTable
68
{
69
public
:
// types
70
typedef
valarray<vector<typename list<T>::iterator> >
arraytype
;
71
typedef
vector<typename list<T>::iterator>
pointtype
;
72
typedef
pair<int,int>
indextype
;
73
typedef
list<pair<T*,T*> >
pairlist
;
74
typedef
list<T*>
particlelist
;
75
/* #if HAVE_HASH_MAP */
76
/* typedef std::hash_map<int, T*> IdParticleMap; */
77
/* #else */
78
typedef
std::map<int, T*>
IdParticleMap
;
79
/* #endif */
80
typedef
typename
list<T>::iterator
iterator
;
81
82
private
:
83
// member variables
84
list<T>
m_list
;
85
arraytype
m_array
;
86
IdParticleMap
m_idParticleMap
;
87
Vec3
m_p0_global
;
88
double
m_dim
;
89
double
m_alpha
;
90
int
m_global_idx
;
91
int
m_global_idy
;
92
int
m_global_idz
;
93
int
m_xsize
;
94
int
m_ysize
;
95
int
m_zsize
;
96
bool
m_valid
;
97
Vec3
m_min_corner
;
98
Vec3
m_max_corner
;
99
100
101
// private member functions
102
void
clear_search_array
();
103
int
index
(
const
Vec3
&);
// index from position
104
105
void
addPairsToList
(
T_Handle<pairlist>
,
int
,
int
);
106
void
addPairsToListLocal
(
T_Handle<pairlist>
,
int
);
107
void
addPairsToListFlagged
(
T_Handle<pairlist>
,
int
,
int
);
108
void
addPairsToListLocalFlagged
(
T_Handle<pairlist>
,
int
);
109
110
arraytype
*
array
(){
return
&
m_array
;};
111
112
public
:
114
NeighborTable
();
115
NeighborTable
(
int
,
int
,
int
,
double
,
double
,
const
Vec3
&,
int
,
int
,
int
);
116
~NeighborTable
();
117
118
void
insert
(
const
T&);
119
void
insert
(
iterator
i,
const
T& data){
insert
(data);};
120
void
build
();
121
inline
int
index
(
int
,
int
,
int
)
const
;
// total index from x,y,z indices
122
124
iterator
begin
(){
return
m_list
.begin();};
125
iterator
end
(){
return
m_list
.end();};
126
128
unsigned
int
nparts_at_gridpoint
(
unsigned
int
idx)
const
129
{
130
return
(
m_array
[idx]).size();
131
}
132
133
// check in posn. is in inner part
134
bool
isInInner
(
const
Vec3
&);
135
137
int
xsize
(){
return
m_xsize
;};
138
int
ysize
(){
return
m_ysize
;};
139
int
zsize
(){
return
m_zsize
;};
140
int
size
(){
return
m_list
.size();};
141
Vec3
base_point
()
const
{
return
m_p0_global
;};
142
int
base_idx_x
()
const
{
return
m_global_idx
;};
143
int
base_idx_y
()
const
{
return
m_global_idy
;};
144
int
base_idx_z
()
const
{
return
m_global_idz
;};
145
147
NTSlab<T>
xy_slab
(
int
);
148
NTSlab<T>
xz_slab
(
int
);
149
NTSlab<T>
yz_slab
(
int
);
150
NTBlock<T>
block
(
int
,
int
,
int
,
int
,
int
,
int
);
151
NTBlock<T>
block
(
const
Vec3
&,
const
Vec3
&);
152
NTBlock<T>
inner
();
153
154
// access ops
155
T*
ptr
(
NeighborTable<T>::indextype
);
156
T&
ref
(
NeighborTable<T>::indextype
);
157
T*
ptr_by_id
(
int
);
158
T *
getNearestPtr
(
const
Vec3
&);
159
160
// erase particle (not meant to be used directly)
161
void
erase
(
NeighborTable<T>::indextype
);
162
163
// neigbor list creation
164
T_Handle<pairlist>
getFullList
();
165
T_Handle<pairlist>
getNewList
();
166
T_Handle<particlelist>
getParticlesAtPlane
(
const
Vec3
&,
const
Vec3
&);
// distance as parameter ??
167
T_Handle<particlelist>
getParticlesNearTriangle
(
const
Triangle
&);
168
T_Handle<particlelist>
getParticlesNearEdge
(
const
AEdge
*);
169
T_Handle<particlelist>
getParticlesNearPoint
(
const
Vec3
&);
170
T_Handle<particlelist>
getAllParticles
();
171
173
template
<
typename
TT>
174
friend
std::ostream& operator<<(std::ostream &, const NeighborTable<TT> &);
175
};
176
177
#include "
ntable/src/ntable.hpp
"
178
179
#endif // __NTABLE_H
ntable
src
ntable.h
Generated on Mon May 6 2013 23:26:30 for ESyS-Particle by
1.8.3.1