OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
olb::SimpleReflectBoundary3D< T, PARTICLETYPE > Class Template Reference

#include <boundarySimpleReflection3D.h>

+ Inheritance diagram for olb::SimpleReflectBoundary3D< T, PARTICLETYPE >:
+ Collaboration diagram for olb::SimpleReflectBoundary3D< T, PARTICLETYPE >:

Public Member Functions

 SimpleReflectBoundary3D (T dT, SuperGeometry< T, 3 > &sg, std::set< int > materials)
 
 ~SimpleReflectBoundary3D () override
 
void applyBoundary (typename std::deque< PARTICLETYPE< T > >::iterator &p, ParticleSystem3D< T, PARTICLETYPE > &psSys) override
 
- Public Member Functions inherited from olb::Boundary3D< T, PARTICLETYPE >
 Boundary3D ()
 
 Boundary3D (Boundary3D< T, PARTICLETYPE > &)
 
 Boundary3D (const Boundary3D< T, PARTICLETYPE > &)
 
virtual ~Boundary3D ()
 

Additional Inherited Members

- Protected Attributes inherited from olb::Boundary3D< T, PARTICLETYPE >
OstreamManager clout
 

Detailed Description

template<typename T, template< typename U > class PARTICLETYPE>
class olb::SimpleReflectBoundary3D< T, PARTICLETYPE >

Definition at line 39 of file boundarySimpleReflection3D.h.

Constructor & Destructor Documentation

◆ SimpleReflectBoundary3D()

template<typename T , template< typename U > class PARTICLETYPE>
olb::SimpleReflectBoundary3D< T, PARTICLETYPE >::SimpleReflectBoundary3D ( T dT,
SuperGeometry< T, 3 > & sg,
std::set< int > materials )

Definition at line 33 of file boundarySimpleReflection3D.hh.

33 :
34 Boundary3D<T, PARTICLETYPE>(), _dT(dT), _sg(sg), _materials(materials)
35{
36 _matIter = _materials.begin();
37}

◆ ~SimpleReflectBoundary3D()

template<typename T , template< typename U > class PARTICLETYPE>
olb::SimpleReflectBoundary3D< T, PARTICLETYPE >::~SimpleReflectBoundary3D ( )
inlineoverride

Definition at line 42 of file boundarySimpleReflection3D.h.

42{};

Member Function Documentation

◆ applyBoundary()

template<typename T , template< typename U > class PARTICLETYPE>
void olb::SimpleReflectBoundary3D< T, PARTICLETYPE >::applyBoundary ( typename std::deque< PARTICLETYPE< T > >::iterator & p,
ParticleSystem3D< T, PARTICLETYPE > & psSys )
overridevirtual

Implements olb::Boundary3D< T, PARTICLETYPE >.

Definition at line 40 of file boundarySimpleReflection3D.hh.

41{
42 std::vector<T> oldPos(3,T());
43 oldPos[0] = p->getPos()[0] - _dT * p->getVel()[0];
44 oldPos[1] = p->getPos()[1] - _dT * p->getVel()[1];
45 oldPos[2] = p->getPos()[2] - _dT * p->getVel()[2];
46
47 std::vector<T> line(3,T());
48 line[0] = p->getPos()[0] - oldPos[0];
49 line[1] = p->getPos()[1] - oldPos[1];
50 line[2] = p->getPos()[2] - oldPos[2];
51
52 std::vector<T> reflection(3, T());
53 int latticeR[4] = { 0,0,0,0 };
54 bool outer = false;
55
56 // get material number (Trigger)
57 // TODO: take particle radius into account for collision detection
58 latticeR[0] = p->getCuboid();
59 _sg.getCuboidGeometry().get(latticeR[0]).getLatticeR(&(latticeR[1]),&p->getPos()[0]);
60 int mat = _sg.get(latticeR);
61
62 for (_matIter = _materials.begin(); _matIter != _materials.end(); _matIter++) {
63 if (mat == *_matIter) {
64 // compute discrete normal
65 // TODO: rearrange the if to make computation more efficient
66 std::vector<int> normal(3, T());
67 if (_sg.get(latticeR[0], latticeR[1] - 1, latticeR[2], latticeR[3]) == 1) {
68 normal[0] = -1;
69 }
70 if (_sg.get(latticeR[0], latticeR[1] + 1, latticeR[2], latticeR[3]) == 1) {
71 normal[0] = 1;
72 }
73 if (_sg.get(latticeR[0], latticeR[1], latticeR[2] - 1, latticeR[3]) == 1) {
74 normal[1] = -1;
75 }
76 if (_sg.get(latticeR[0], latticeR[1], latticeR[2] + 1, latticeR[3]) == 1) {
77 normal[1] = 1;
78 }
79 if (_sg.get(latticeR[0], latticeR[1], latticeR[2], latticeR[3] - 1) == 1) {
80 normal[2] = -1;
81 }
82 if (_sg.get(latticeR[0], latticeR[1], latticeR[2], latticeR[3] + 1) == 1) {
83 normal[2] = 1;
84 }
85
86 if (normal[0]==0 && normal[1]==0 && normal[2]==0) {
87 outer = true;
88 // check for outer edge
89 if (_sg.get(latticeR[0], latticeR[1] - 1, latticeR[2] - 1, latticeR[3]) == 1) {
90 normal[0] = -1;
91 normal[1] = -1;
92 }
93 else if (_sg.get(latticeR[0], latticeR[1] - 1, latticeR[2] + 1, latticeR[3]) == 1) {
94 normal[0] = -1;
95 normal[1] = 1;
96 }
97 else if (_sg.get(latticeR[0], latticeR[1] + 1, latticeR[2] - 1, latticeR[3]) == 1) {
98 normal[0] = 1;
99 normal[1] = -1;
100 }
101 else if (_sg.get(latticeR[0], latticeR[1] + 1, latticeR[2] + 1, latticeR[3]) == 1) {
102 normal[0] = 1;
103 normal[1] = 1;
104 }
105 else if (_sg.get(latticeR[0], latticeR[1] - 1, latticeR[2], latticeR[3] - 1) == 1) {
106 normal[0] = -1;
107 normal[2] = -1;
108 }
109 else if (_sg.get(latticeR[0], latticeR[1] - 1, latticeR[2], latticeR[3] + 1) == 1) {
110 normal[0] = -1;
111 normal[2] = 1;
112 }
113 else if (_sg.get(latticeR[0], latticeR[1] + 1, latticeR[2], latticeR[3] - 1) == 1) {
114 normal[0] = 1;
115 normal[2] = -1;
116 }
117 else if (_sg.get(latticeR[0], latticeR[1] + 1, latticeR[2], latticeR[3] + 1) == 1) {
118 normal[0] = 1;
119 normal[2] = 1;
120 }
121 else if (_sg.get(latticeR[0], latticeR[1], latticeR[2] - 1, latticeR[3] - 1) == 1) {
122 normal[1] = -1;
123 normal[2] = -1;
124 }
125 else if (_sg.get(latticeR[0], latticeR[1], latticeR[2] - 1, latticeR[3] + 1) == 1) {
126 normal[1] = -1;
127 normal[2] = 1;
128 }
129 else if (_sg.get(latticeR[0], latticeR[1], latticeR[2] + 1, latticeR[3] - 1) == 1) {
130 normal[1] = +1;
131 normal[2] = -1;
132 }
133 else if (_sg.get(latticeR[0], latticeR[1], latticeR[2] + 1, latticeR[3] + 1) == 1) {
134 normal[1] = +1;
135 normal[2] = 1;
136 }
137 // check for outer corner
138 else if (_sg.get(latticeR[0], latticeR[1] - 1, latticeR[2] - 1, latticeR[3] - 1) == 1) {
139 normal[0] = -1;
140 normal[1] = -1;
141 normal[2] = -1;
142 }
143 else if (_sg.get(latticeR[0], latticeR[1] - 1, latticeR[2] - 1, latticeR[3] + 1) == 1) {
144 normal[0] = -1;
145 normal[1] = -1;
146 normal[2] = 1;
147 }
148 else if (_sg.get(latticeR[0], latticeR[1] - 1, latticeR[2] + 1, latticeR[3] - 1) == 1) {
149 normal[0] = -1;
150 normal[1] = +1;
151 normal[2] = -1;
152 }
153 else if (_sg.get(latticeR[0], latticeR[1] - 1, latticeR[2] + 1, latticeR[3] + 1) == 1) {
154 normal[0] = -1;
155 normal[1] = +1;
156 normal[2] = 1;
157 }
158 else if (_sg.get(latticeR[0], latticeR[1] + 1, latticeR[2] - 1, latticeR[3] - 1) == 1) {
159 normal[0] = +1;
160 normal[1] = -1;
161 normal[2] = -1;
162 }
163 else if (_sg.get(latticeR[0], latticeR[1] + 1, latticeR[2] - 1, latticeR[3] + 1) == 1) {
164 normal[0] = +1;
165 normal[1] = -1;
166 normal[2] = 1;
167 }
168 else if (_sg.get(latticeR[0], latticeR[1] + 1, latticeR[2] + 1, latticeR[3] - 1) == 1) {
169 normal[0] = +1;
170 normal[1] = +1;
171 normal[2] = -1;
172 }
173 else if (_sg.get(latticeR[0], latticeR[1] + 1, latticeR[2] + 1, latticeR[3] + 1) == 1) {
174 normal[0] = +1;
175 normal[1] = +1;
176 normal[2] = 1;
177 }
178 // Error since normal is still zero
179 else {
180 std::cout << "----->>>>> ERROR Normal is ZERO" << std::endl;
181 outer=false;
182 }
183 }
184
185 T prod = line[0]*normal[0] + line[1]*normal[1] + line[2]*normal[2];
186 // if particle has obtuse angle to normal do nothing
187 if (!outer) {
188 if (prod >= 0) {
189 return;
190 }
191 }
192
193 // if particle has acute angle to normal reverse normal component of velocity
194 T invNormNormal = 1. / util::norm2(normal);
195 reflection[0] = line[0] - 2.*prod*normal[0]*invNormNormal;
196 reflection[1] = line[1] - 2.*prod*normal[1]*invNormNormal;
197 reflection[2] = line[2] - 2.*prod*normal[2]*invNormNormal;
198
199 // compute new velocity vector
200 T vel = util::norm(p->getVel());
201 reflection = util::normalize(reflection);
202 reflection[0] = reflection[0]*vel;
203 reflection[1] = reflection[1]*vel;
204 reflection[2] = reflection[2]*vel;
205
206 // TODO: take distance to impact point into account, not just 0.5
207 oldPos[0] += 0.5 * (line[0] + reflection[0]) * _dT;
208 oldPos[1] += 0.5 * (line[1] + reflection[1]) * _dT;
209 oldPos[2] += 0.5 * (line[2] + reflection[2]) * _dT;
210
211 p->getVel() = reflection;
212 p->setPos(oldPos);
213
214 return;
215 }
216 }
217}
int get(int iCglob, LatticeR< D > latticeR) const
Read only access to the material numbers, error handling: returns 0 if data is not available.
CuboidGeometry< T, D > & getCuboidGeometry()
Read and write access to cuboid geometry.
T norm(const std::vector< T > &a)
l2 norm of a vector of arbitrary length
T norm2(const std::vector< T > &a)
l2 norm to the power of 2 of a vector of arbitrary length
Vector< T, D > normalize(const Vector< T, D > &a)

References olb::util::norm(), olb::util::norm2(), and olb::util::normalize().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: