OpenLB 1.7
Loading...
Searching...
No Matches
particleCreatorFunctions3D.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2021 Nicolas Hafen, Jan E. Marquardt, Mathias J. Krause
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24//TODO: WARNING: For now, there is a lot of code duplication, which has to be sorted out in the future.
25
26/* This file contains particle creator functions.
27 * Those are generally meant for users to be able to create particles
28 * in a comfortable way. As this section might be subject to frequent changes,
29 * those should, however, be avoided inside header files. Here, direct field access
30 * as shown below should be preferred!
31 *
32*/
33
34
35#ifndef PARTICLE_CREATOR_FUNCTIONS_3D_H
36#define PARTICLE_CREATOR_FUNCTIONS_3D_H
37
38
41
42
43namespace olb {
44
45namespace particles {
46
47namespace creators {
48
50
52template<typename T, typename PARTICLETYPE, bool IGNORE_WARNINGS=false>
54 ParticleSystem<T,PARTICLETYPE>& particleSystem,
55 std::size_t idxParticle,
56 const Vector<T,3>& position, T radius, T epsilon, T density=0.,
57 const Vector<T,3>& velocity = Vector<T,3> (0.))
58{
59 using namespace descriptors;
60 typedef SmoothIndicatorF3D<T, T, true> SIndicatorBaseType;
61
62 //Create SmoothIndicator
63 std::unique_ptr<SIndicatorBaseType> sIndicatorPtr(
64 new SmoothIndicatorSphere3D<T, T, true>(Vector<T,3> (0.), radius, epsilon ));
65
66 //Pass smart pointer to particleSystem
67 auto& vectorOfIndicators = particleSystem.template getAssociatedData<
68 std::vector<std::unique_ptr<SIndicatorBaseType>>>();
69 std::size_t idxSurface = vectorOfIndicators.size();
70 vectorOfIndicators.push_back( std::move(sIndicatorPtr) );
71
72 // Safety mechanism for wrong particle type - It is better not to use rotation matrix!
73 if constexpr ( PARTICLETYPE::template providesNested<SURFACE,ROT_MATRIX>()
74 && !IGNORE_WARNINGS ) {
75 OstreamManager clout(std::cout, "creatorSphere3D");
76 clout << "WARNING: A rotation matrix is provided but is not necessary for a sphere." << std::endl;
77 }
78
80 setResolvedObject<T,PARTICLETYPE,true>(particleSystem, idxParticle, idxSurface,
81 position, density, Vector<T,3>(0.), velocity);
82}
83
85template<typename T, typename PARTICLETYPE, bool IGNORE_WARNINGS=false>
87 const Vector<T,3>& position, T radius, T epsilon, T density=0.,
88 const Vector<T,3>& velocity = Vector<T,3> (0.))
89{
90 //Retrieve new index
91 std::size_t idxParticle = particleSystem.size();
92
93 //Initialize particle address
94 particleSystem.extend();
95
97 setResolvedSphere3D<T,PARTICLETYPE,IGNORE_WARNINGS>(
98 particleSystem, idxParticle, position, radius, epsilon, density, velocity );
99}
100
101
103
105template<typename T, typename PARTICLETYPE>
107 ParticleSystem<T,PARTICLETYPE>& particleSystem,
108 std::size_t idxParticle,
109 const Vector<T,3>& position, const Vector<T,3>& normal,
110 T height, T radius, T epsilon, T density=0.,
111 const Vector<T,3>& angleInDegree = Vector<T,3> (0.),
112 const Vector<T,3>& velocity = Vector<T,3> (0.))
113{
114 using namespace descriptors;
115 typedef SmoothIndicatorF3D<T, T, true> SIndicatorBaseType;
116
117 //Create SmoothIndicator
118 std::unique_ptr<SIndicatorBaseType> sIndicatorPtr(
119 new SmoothIndicatorCylinder3D<T, T, true>(Vector<T,3>(0.), normal, radius, height, epsilon ));
120
121 //Pass smart pointer to particleSystem
122 auto& vectorOfIndicators = particleSystem.template getAssociatedData<
123 std::vector<std::unique_ptr<SIndicatorBaseType>>>();
124 std::size_t idxSurface = vectorOfIndicators.size();
125 vectorOfIndicators.push_back( std::move(sIndicatorPtr) );
126
128 setResolvedObject(particleSystem, idxParticle, idxSurface,
129 position, density, angleInDegree, velocity);
130}
131
133template<typename T, typename PARTICLETYPE>
135 const Vector<T,3>& position, const Vector<T,3>& normal,
136 T height, T radius, T epsilon, T density=0.,
137 const Vector<T,3>& angleInDegree = Vector<T,3> (0.),
138 const Vector<T,3>& velocity = Vector<T,3> (0.))
139{
140 //Retrieve new index
141 std::size_t idxParticle = particleSystem.size();
142
143 //Initialize particle address
144 particleSystem.extend();
145
147 setResolvedCylinder3D( particleSystem, idxParticle, position,
148 normal, height, radius, epsilon, density, angleInDegree, velocity );
149}
150
151
153
155template<typename T, typename PARTICLETYPE>
157 std::size_t idxParticle,
158 const Vector<T,3>& position, const Vector<T,3>& extend, T epsilon, T density=0.,
159 const Vector<T,3>& angleInDegree = Vector<T,3> (0.),
160 const Vector<T,3>& velocity = Vector<T,3> (0.))
161{
162 using namespace descriptors;
163 typedef SmoothIndicatorF3D<T, T, true> SIndicatorBaseType;
164
165 //Create SmoothIndicator
166 std::unique_ptr<SIndicatorBaseType> sIndicatorPtr(
167 new SmoothIndicatorCuboid3D<T, T, true>(extend[0], extend[1], extend[2], Vector<T,3>(0.), epsilon ));
168
169 //Pass smart pointer to particleSystem
170 auto& vectorOfIndicators = particleSystem.template getAssociatedData<
171 std::vector<std::unique_ptr<SIndicatorBaseType>>>();
172 std::size_t idxSurface = vectorOfIndicators.size();
173 vectorOfIndicators.push_back( std::move(sIndicatorPtr) );
174
176 setResolvedObject(particleSystem, idxParticle, idxSurface,
177 position, density, angleInDegree, velocity);
178}
179
180
182template<typename T, typename PARTICLETYPE>
184 const Vector<T,3>& position, const Vector<T,3>& extend, T epsilon, T density=0.,
185 const Vector<T,3>& angleInDegree = Vector<T,3> (0.),
186 const Vector<T,3>& velocity = Vector<T,3> (0.))
187{
188 //Retrieve new index
189 std::size_t idxParticle = particleSystem.size();
190
191 //Initialize particle address
192 particleSystem.extend();
193
195 setResolvedCuboid3D( particleSystem, idxParticle, position,
196 extend, epsilon, density, angleInDegree, velocity );
197}
198
199
201
203template<typename T, typename PARTICLETYPE>
205 std::size_t idxParticle,
206 const Vector<T,3>& position1, const Vector<T,3>& position2,
207 T radius1, T radius2, T epsilon, T density=0,
208 const Vector<T,3>& angleInDegree = Vector<T,3> (0.),
209 const Vector<T,3>& velocity = Vector<T,3> (0.))
210{
211 using namespace descriptors;
212 typedef SmoothIndicatorF3D<T, T, true> SIndicatorBaseType;
213
214 //Create SmoothIndicator
215 std::unique_ptr<SIndicatorBaseType> sIndicatorPtr(
216 new SmoothIndicatorCone3D<T, T, true>(position1, position2, radius1, radius2, epsilon ));
217
218 //Pass smart pointer to particleSystem
219 auto& vectorOfIndicators = particleSystem.template getAssociatedData<
220 std::vector<std::unique_ptr<SIndicatorBaseType>>>();
221 std::size_t idxSurface = vectorOfIndicators.size();
222 const Vector<T,3> position = sIndicatorPtr->calcCenterOfMass();
223 vectorOfIndicators.push_back( std::move(sIndicatorPtr) );
224
226 setResolvedObject(particleSystem, idxParticle, idxSurface,
227 position, density, angleInDegree, velocity);
228}
229
230
232template<typename T, typename PARTICLETYPE>
234 const Vector<T,3>& position1, const Vector<T,3>& position2,
235 T radius1, T radius2, T epsilon, T density=0,
236 const Vector<T,3>& angleInDegree = Vector<T,3> (0.),
237 const Vector<T,3>& velocity = Vector<T,3> (0.))
238{
239 //Retrieve new index
240 std::size_t idxParticle = particleSystem.size();
241
242 //Initialize particle address
243 particleSystem.extend();
244
246 setResolvedCone3D( particleSystem, idxParticle,
247 position1, position2, radius1, radius2, epsilon, density, angleInDegree, velocity );
248}
249
250
252
254template<typename T, typename PARTICLETYPE>
256 std::size_t idxParticle,
257 const Vector<T,3>& position,
258 const Vector<T,3>& radius,
259 T epsilon, T density=0.,
260 const Vector<T,3>& angleInDegree = Vector<T,3> (0.),
261 const Vector<T,3>& velocity = Vector<T,3> (0.))
262{
263 using namespace descriptors;
264 typedef SmoothIndicatorF3D<T, T, true> SIndicatorBaseType;
265
266 //Create SmoothIndicator
267 std::unique_ptr<SIndicatorBaseType> sIndicatorPtr(
268 new SmoothIndicatorEllipsoid3D<T, T, true>(Vector<T,3>(0.), radius, epsilon, Vector<T,3>(0.) ));
269
270 //Pass smart pointer to particleSystem
271 auto& vectorOfIndicators = particleSystem.template getAssociatedData<
272 std::vector<std::unique_ptr<SIndicatorBaseType>>>();
273 std::size_t idxSurface = vectorOfIndicators.size();
274 vectorOfIndicators.push_back( std::move(sIndicatorPtr) );
275
277 setResolvedObject(particleSystem, idxParticle, idxSurface,
278 position, density, angleInDegree, velocity);
279}
280
281
283template<typename T, typename PARTICLETYPE>
285 const Vector<T,3>& position,
286 const Vector<T,3>& radius,
287 T epsilon, T density=0.,
288 const Vector<T,3>& angleInDegree = Vector<T,3> (0.),
289 const Vector<T,3>& velocity = Vector<T,3> (0.))
290{
291 //Retrieve new index
292 std::size_t idxParticle = particleSystem.size();
293
294 //Initialize particle address
295 particleSystem.extend();
296
298 setResolvedEllipsoid3D( particleSystem, idxParticle, position,
299 radius, epsilon, density, angleInDegree, velocity );
300}
301
302
304
306template<typename T, typename PARTICLETYPE>
308 std::size_t idxParticle,
309 Vector<T,3> position,
310 T latticeSpacing,
311 std::shared_ptr<IndicatorF3D<T>> indPtr,
312 T epsilon, T density=0.,
313 Vector<T,3> angleInDegree = Vector<T,3> (0.),
314 Vector<T,3> velocity = Vector<T,3> (0.))
315{
316 using namespace descriptors;
317 typedef SmoothIndicatorF3D<T, T, true> SIndicatorBaseType;
318
319 //Create SmoothIndicator
320 std::unique_ptr<SIndicatorBaseType> sIndicatorPtr(
321 new SmoothIndicatorCustom3D<T, T, true>(latticeSpacing, indPtr, Vector<T,3> (0.), epsilon, Vector<T,3> (0.)));
322
323 //Pass smart pointer to particleSystem
324 auto& vectorOfIndicators = particleSystem.template getAssociatedData<
325 std::vector<std::unique_ptr<SIndicatorBaseType>>>();
326 std::size_t idxSurface = vectorOfIndicators.size();
327 vectorOfIndicators.push_back( std::move(sIndicatorPtr) );
328
330 setResolvedObject(particleSystem, idxParticle, idxSurface,
331 position, density, angleInDegree, velocity);
332}
333
335template<typename T, typename PARTICLETYPE>
337 Vector<T,3> position,
338 T latticeSpacing,
339 std::shared_ptr<IndicatorF3D<T>> indPtr,
340 T epsilon, T density=0.,
341 Vector<T,3> angleInDegree = Vector<T,3> (0.),
342 Vector<T,3> velocity = Vector<T,3> (0.))
343{
344 //Retrieve new index
345 std::size_t idxParticle = particleSystem.size();
346
347 //Initialize particle address
348 particleSystem.extend();
349
351 setResolvedArbitraryShape3D( particleSystem, idxParticle, position,
352 latticeSpacing, indPtr, epsilon, density, angleInDegree, velocity );
353}
354
355
357
358//Add subgrid particle
359template<typename T, typename PARTICLETYPE>
361 ParticleSystem<T,PARTICLETYPE>& particleSystem,
362 const Vector<T,3>& position, T radius, T density=0.,
363 const Vector<T,3>& velocity = Vector<T,3> (0.) )
364{
365 addSubgridObject( particleSystem,
366 position, radius, density, velocity );
367}
368
369} //namespace creators
370
371} //namespace particles
372
373} //namespace olb
374
375#endif
IndicatorF3D is an application from .
class for marking output with some text
implements a smooth particle cone in 3D with an _epsilon sector
implements a smooth particle cuboid in 3D with an _epsilon sector.
implements a smooth particle cylinder in 3D with an _epsilon sector.
implements a smooth particle ellipsoid in 3D with an _epsilon sector.
implements a smooth sphere in 3D with an _epsilon sector
Plain old scalar vector.
Definition vector.h:47
constexpr std::size_t size()
Size of ParticleSystem.
void extend()
Extend particle system by one particle.
void addResolvedCone3D(ParticleSystem< T, PARTICLETYPE > &particleSystem, const Vector< T, 3 > &position1, const Vector< T, 3 > &position2, T radius1, T radius2, T epsilon, T density=0, const Vector< T, 3 > &angleInDegree=Vector< T, 3 >(0.), const Vector< T, 3 > &velocity=Vector< T, 3 >(0.))
Add resolved cone as new particle with new surface.
void setResolvedSphere3D(ParticleSystem< T, PARTICLETYPE > &particleSystem, std::size_t idxParticle, const Vector< T, 3 > &position, T radius, T epsilon, T density=0., const Vector< T, 3 > &velocity=Vector< T, 3 >(0.))
Set resolved sphere for existing particle but new surface.
void setResolvedCuboid3D(ParticleSystem< T, PARTICLETYPE > &particleSystem, std::size_t idxParticle, const Vector< T, 3 > &position, const Vector< T, 3 > &extend, T epsilon, T density=0., const Vector< T, 3 > &angleInDegree=Vector< T, 3 >(0.), const Vector< T, 3 > &velocity=Vector< T, 3 >(0.))
Set resolved cuboid for existing particle but new surface.
ParallelParticleLocator addResolvedCylinder3D(SuperParticleSystem< T, PARTICLETYPE > &sParticleSystem, const Vector< T, 3 > &position, const Vector< T, 3 > &normal, T height, T radius, T epsilon, T density=0., const Vector< T, 3 > &angleInDegree=Vector< T, 3 >(0.), const Vector< T, 3 > &velocity=Vector< T, 3 >(0.), const Vector< bool, 3 > &periodicity=Vector< bool, 3 >(false))
ParallelParticleLocator addResolvedCuboid3D(SuperParticleSystem< T, PARTICLETYPE > &sParticleSystem, const Vector< T, 3 > &position, const Vector< T, 3 > &extend, T epsilon, T density=0., const Vector< T, 3 > &angleInDegree=Vector< T, 3 >(0.), const Vector< T, 3 > &velocity=Vector< T, 3 >(0.), const Vector< bool, 3 > &periodicity=Vector< bool, 3 >(false))
void addResolvedEllipsoid3D(ParticleSystem< T, PARTICLETYPE > &particleSystem, const Vector< T, 3 > &position, const Vector< T, 3 > &radius, T epsilon, T density=0., const Vector< T, 3 > &angleInDegree=Vector< T, 3 >(0.), const Vector< T, 3 > &velocity=Vector< T, 3 >(0.))
Add resolved ellipsoid as new particle with new surface.
void setResolvedArbitraryShape3D(ParticleSystem< T, PARTICLETYPE > &particleSystem, std::size_t idxParticle, Vector< T, 3 > position, T latticeSpacing, std::shared_ptr< IndicatorF3D< T > > indPtr, T epsilon, T density=0., Vector< T, 3 > angleInDegree=Vector< T, 3 >(0.), Vector< T, 3 > velocity=Vector< T, 3 >(0.))
Set resolved cuboid for existing particle but new surface.
ParallelParticleLocator addResolvedSphere3D(SuperParticleSystem< T, PARTICLETYPE > &sParticleSystem, const Vector< T, 3 > &position, T radius, T epsilon, T density=0., const Vector< T, 3 > &velocity=Vector< T, 3 >(0.), const Vector< bool, 3 > &periodicity=Vector< bool, 3 >(false))
void setResolvedCylinder3D(ParticleSystem< T, PARTICLETYPE > &particleSystem, std::size_t idxParticle, const Vector< T, 3 > &position, const Vector< T, 3 > &normal, T height, T radius, T epsilon, T density=0., const Vector< T, 3 > &angleInDegree=Vector< T, 3 >(0.), const Vector< T, 3 > &velocity=Vector< T, 3 >(0.))
Set resolved cylinder for existing particle but new surface.
void setResolvedCone3D(ParticleSystem< T, PARTICLETYPE > &particleSystem, std::size_t idxParticle, const Vector< T, 3 > &position1, const Vector< T, 3 > &position2, T radius1, T radius2, T epsilon, T density=0, const Vector< T, 3 > &angleInDegree=Vector< T, 3 >(0.), const Vector< T, 3 > &velocity=Vector< T, 3 >(0.))
Set resolved cone for existing particle but new surface.
void setResolvedEllipsoid3D(ParticleSystem< T, PARTICLETYPE > &particleSystem, std::size_t idxParticle, const Vector< T, 3 > &position, const Vector< T, 3 > &radius, T epsilon, T density=0., const Vector< T, 3 > &angleInDegree=Vector< T, 3 >(0.), const Vector< T, 3 > &velocity=Vector< T, 3 >(0.))
Set resolved ellipsoid for existing particle but new surface.
ParallelParticleLocator addSubgridSphere3D(SuperParticleSystem< T, PARTICLETYPE > &sParticleSystem, const Vector< T, 3 > &position, T radius, T density=0., const Vector< T, 3 > &velocity=Vector< T, 3 >(0.))
void setResolvedObject(ParticleSystem< T, PARTICLETYPE > &particleSystem, std::size_t idxParticle, std::size_t idxSurface, const Vector< T, 2 > &position, T density, T angle, const Vector< T, 2 > &velocity)
ParallelParticleLocator addResolvedArbitraryShape3D(SuperParticleSystem< T, PARTICLETYPE > &sParticleSystem, const Vector< T, 3 > &position, T latticeSpacing, std::shared_ptr< IndicatorF3D< T > > indPtr, T epsilon, T density=0., const Vector< T, 3 > &angleInDegree=Vector< T, 3 >(0.), const Vector< T, 3 > &velocity=Vector< T, 3 >(0.), const Vector< bool, 3 > &periodicity=Vector< bool, 3 >(false))
Particle< T, PARTICLETYPE > addSubgridObject(ParticleSystem< T, PARTICLETYPE > &particleSystem, const Vector< T, PARTICLETYPE::d > &position, T radius, T density=0., const Vector< T, PARTICLETYPE::d > &velocity=Vector< T, PARTICLETYPE::d >(0.))
Add subgrid object as new particle (and return particle object)
Top level namespace for all of OpenLB.