-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBody.h
329 lines (297 loc) · 7.72 KB
/
Body.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
/**
* @file Body.h
* @author Dan R. Lipsa
* @brief A bubble.
* @ingroup data model
*/
#ifndef __BODY_H__
#define __BODY_H__
#include "Comparisons.h"
#include "Element.h"
class AttributesInfo;
class Edge;
class Face;
class OrientedFace;
class OrientedEdge;
class OOBox;
class Vertex;
/**
* @brief A bubble.
*
* A body consists of a list of oriented faces
*/
class Body : public Element
{
public:
typedef vector<boost::shared_ptr<OrientedFace> > OrientedFaces;
/**
* @brief Store the neighbor (m_body) and an eventual translation
* for the periodic domain (m_translation) or a point obtained by
* reflecting against a wall or object m_centerReflection
*/
class Neighbor {
public:
Neighbor ();
Neighbor (G3D::Vector3 centerOfReflection);
Neighbor (boost::shared_ptr<Body> body, G3D::Vector3int16 translation);
boost::shared_ptr<Body> GetBody () const
{
return m_body;
}
G3D::Vector3int16 GetTranslation () const
{
return m_translation;
}
G3D::Vector3 GetCenterReflection () const
{
return m_centerReflection;
}
private:
boost::shared_ptr<Body> m_body;
G3D::Vector3int16 m_translation;
G3D::Vector3 m_centerReflection;
};
public:
/**
* Creates a body for a bubble
*/
Body(const vector<int>& faceIndexes,
const vector< boost::shared_ptr<Face> >& faces,
size_t id,
ElementStatus::Enum duplicateStatus = ElementStatus::ORIGINAL);
/**
* Creates a body determined by a constraint. Usualy this is an
* object interacting with the foam.
*/
Body (boost::shared_ptr<Face> face, size_t id);
const Face& GetFace (size_t i) const;
Face& GetFace (size_t i);
void GetFaceSet (FaceSet* faceSet) const;
const OrientedFace& GetOrientedFace (size_t i) const
{
return *m_orientedFaces[i];
}
boost::shared_ptr<OrientedFace> GetOrientedFacePtr (size_t i) const
{
return m_orientedFaces[i];
}
/**
* Returns the vector of oriented faces this body is made of
* @return a vector of oriented faces
*/
OrientedFaces& GetOrientedFaces ()
{
return m_orientedFaces;
}
const OrientedFaces& GetOrientedFaces () const
{
return m_orientedFaces;
}
bool Is2D () const
{
return m_orientedFaces.size () <= 1;
}
size_t GetFaceCount () const
{
return m_orientedFaces.size ();
}
/**
* Calculates the center
*/
void CalculateCenter ();
void CalculateBoundingBox ();
/**
* Gets the center
* @return the center of the body
*/
const G3D::Vector3 GetCenter () const
{
return m_center;
}
void UpdateAdjacentBody (const boost::shared_ptr<Body>& body);
string ToString () const;
void GetVertexSet (VertexSet* vertexSet) const;
VertexSet GetVertexSet () const
{
VertexSet set;
GetVertexSet (&set);
return set;
}
void GetEdgeSet (EdgeSet* edgeSet) const;
EdgeSet GetEdgeSet () const
{
EdgeSet set;
GetEdgeSet (&set);
return set;
}
float GetScalarValue (BodyScalar::Enum property) const;
bool HasScalarValue (BodyScalar::Enum property, bool* deduced = 0) const;
/**
* BodyAttribute::GetNumberOfComponents (attribute) floats have to
* be alocated in 'value' for scalars, vectors and tensors
*/
void GetAttributeValue (size_t attribute, float* value) const;
G3D::Vector3 GetVelocity () const
{
return m_velocity;
}
void SetPressureValue (double value);
void SetPressureDeduced ()
{
m_pressureDeduced = true;
}
void SetTargetVolumeDeduced ()
{
m_targetVolumeDeduced = true;
}
void SetActualVolumeDeduced ()
{
m_actualVolumeDeduced = true;
}
bool operator< (const Body& other) const;
bool operator< (size_t otherBodyId) const;
void SetVelocity (const G3D::Vector3& velocity)
{
m_velocity = velocity;
}
const G3D::AABox& GetBoundingBox () const
{
return m_boundingBox;
}
size_t GetSidesPerBody () const;
float GetDeformationSimple () const;
float GetArea () const
{
return m_area;
}
void CalculateDeformationSimple ();
static const char* GetAttributeKeywordString (BodyScalar::Enum bp);
void CalculateDeformationTensor (const OOBox& originalDomain);
G3D::Matrix3 GetDeformationTensor (
const G3D::Matrix3& additionalRotation) const;
void GetDeformationTensor (float* value,
const G3D::Matrix3& additionalRotation) const;
float GetDeformationEigenScalar () const;
/**
* The eigen values are sorted decreasing.
*/
float GetDeformationEigenValue (size_t i) const
{
return m_deformationEigenValues[i];
}
G3D::Vector3 GetDeformationEigenValues () const
{
return G3D::Vector3 (
m_deformationEigenValues[0], m_deformationEigenValues[1],
m_deformationEigenValues[2]);
}
G3D::Vector3 GetDeformationEigenVector (size_t i) const
{
return m_deformationEigenVectors[i];
}
/**
* Objects are rigid and they interact with the foam. Objects are
* defined by constraints.
*/
bool IsObject () const
{
return m_object;
}
bool HasConstraints () const
{
return IsObject ();
}
size_t GetConstraintIndex () const;
vtkSmartPointer<vtkPolyData> GetPolyData () const;
/**
* @pre {CalculateNeighborsAndGrowthRate}
*/
const vector<Neighbor>& GetNeighbors () const
{
return m_neighbors;
}
/**
* @pre {CalculateNeighborsAndGrowthRate}
*/
float GetGrowthRate () const
{
return m_growthRate;
}
/**
* @pre {Face::CalculateCentroidAndArea}
* /home/dlipsa/data/foam/wetfoam_100_0002.dmp stores all 200 liquid channels
* in a body.
* @todo Handle this correctly.
*/
void CalculateNeighborsAndGrowthRate (
const OOBox& originalDomain, bool is2D);
/**
* @pre CalculateNeighborsAndGrowthRate
*/
bool HasFreeFace () const
{
return m_hasFreeFace;
}
float CalculateVolume () const;
static float GetBubbleDiameter (float volume, bool is2D);
float GetBubbleDiameter () const;
private:
/**
* Caches edges and vertices
*/
void calculatePhysicalVertices (
vector< boost::shared_ptr<Vertex> >* physicalVertices);
float calculateArea () const;
/**
* Splits a set of vertices in physical and
* tesselation vertices
* @param src source for the objects
* @param destTessellation where we store tessellation objects
* @param destPhysical where we store physical objects
*/
void splitTessellationPhysical (
const VertexSet& src,
vector< boost::shared_ptr<Vertex> >* destTessellation,
vector< boost::shared_ptr<Vertex> >* destPhysical);
void calculateNeighbors2D (const OOBox& originalDomain);
void calculateNeighbors3D (const OOBox& originalDomain);
private:
/**
* Oriented faces that are part of this body.
*/
OrientedFaces m_orientedFaces;
bool m_hasFreeFace;
vector<Neighbor> m_neighbors;
boost::array <G3D::Vector3, 3> m_deformationEigenVectors;
boost::array <float, 3> m_deformationEigenValues;
/**
* Center of the body
*/
G3D::Vector3 m_center;
G3D::AABox m_boundingBox;
G3D::Vector3 m_velocity;
float m_area;
float m_volume;
float m_growthRate;
float m_deformationSimple;
bool m_pressureDeduced;
bool m_targetVolumeDeduced;
bool m_actualVolumeDeduced;
bool m_object;
};
/**
* @brief Functor for getting the deformation eigen value for a body.
*/
template <int index>
class getBodyDeformationEigenValue
{
public:
float operator () (const boost::shared_ptr<Body>& body)
{
return body->GetDeformationEigenValue (index);
}
};
#endif //__BODY_H__
// Local Variables:
// mode: c++
// End: