OpenLB 1.7
Loading...
Searching...
No Matches
particleCreatorFunctions2D.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_2D_H
36#define PARTICLE_CREATOR_FUNCTIONS_2D_H
37
38
41
42
43namespace olb {
44
45namespace particles {
46
47namespace creators {
48
49template<typename T, typename PARTICLETYPE, bool ROTATION_IS_OPTIONAL=false>
51 ParticleSystem<T,PARTICLETYPE>& particleSystem,
52 std::size_t idxParticle, std::size_t idxSurface,
53 const Vector<T,2>& position, T density, T angle,
54 const Vector<T,2>& velocity)
55{
56 setResolvedObject<T,PARTICLETYPE,ROTATION_IS_OPTIONAL>( particleSystem, idxParticle, idxSurface, position, density,
58}
59
61template<typename T, typename PARTICLETYPE>
63 ParticleSystem<T,PARTICLETYPE>& particleSystem, std::size_t idxSurface,
64 const Vector<T,2>& position, T density=0., T angle=0.,
65 const Vector<T,2>& velocity = Vector<T,2> (0.))
66{
68 addResolvedObject( particleSystem, idxSurface, position, density,
70}
71
72
74
76template<typename T, typename PARTICLETYPE>
78 ParticleSystem<T,PARTICLETYPE>& particleSystem,
79 std::size_t idxParticle,
80 Vector<T,2> position, T radius, T epsilon, T density=0.,
81 Vector<T,2> velocity = Vector<T,2>(0.))
82{
83 using namespace descriptors;
84 typedef SmoothIndicatorF2D<T, T, true> SIndicatorBaseType;
85
86 //Create SmoothIndicator
87 std::unique_ptr<SIndicatorBaseType> sIndicatorPtr(
88 new SmoothIndicatorCircle2D<T, T, true>(Vector<T,2>(0.), radius, epsilon ));
89
90 //Pass smart pointer to particleSystem
91 auto& vectorOfIndicators = particleSystem.template getAssociatedData<
92 std::vector<std::unique_ptr<SIndicatorBaseType>>>();
93 std::size_t idxSurface = vectorOfIndicators.size();
94 vectorOfIndicators.push_back( std::move(sIndicatorPtr) );
95
96 // Safety mechanism for wrong particle type - It is better not to use rotation matrix!
97 if constexpr ( PARTICLETYPE::template providesNested<SURFACE,ROT_MATRIX>() ) {
98 OstreamManager clout(std::cout, "creatorCircle2D");
99 clout << "WARNING: A rotation matrix is provided but is not necessary for a circle." << std::endl;
100 }
101
103 setResolvedObject<T,PARTICLETYPE,true>(particleSystem, idxParticle, idxSurface,
104 position, density, 0., velocity);
105}
106
108template<typename T, typename PARTICLETYPE>
110 Vector<T,2> position, T radius, T epsilon, T density=0.,
111 Vector<T,2> velocity = Vector<T,2>(0.))
112{
113 //Retrieve new index
114 std::size_t idxParticle = particleSystem.size();
115
116 //Initialize particle address
117 particleSystem.extend();
118
120 setResolvedCircle2D( particleSystem, idxParticle, position, radius, epsilon, density, velocity );
121}
122
123
125
127template<typename T, typename PARTICLETYPE>
129 std::size_t idxParticle,
130 Vector<T,2> position, Vector<T,2> extend, T epsilon, T density=0.,
131 T angle = 0.,
132 Vector<T,2> velocity = Vector<T,2> (0.))
133{
134 using namespace descriptors;
135 typedef SmoothIndicatorF2D<T, T, true> SIndicatorBaseType;
136
137 //Create SmoothIndicator
138 std::unique_ptr<SIndicatorBaseType> sIndicatorPtr(
139 new SmoothIndicatorCuboid2D<T, T, true>(Vector<T,2>(0.), extend[0], extend[1], epsilon ));
140
141 //Pass smart pointer to particleSystem
142 auto& vectorOfIndicators = particleSystem.template getAssociatedData<
143 std::vector<std::unique_ptr<SIndicatorBaseType>>>();
144 std::size_t idxSurface = vectorOfIndicators.size();
145 vectorOfIndicators.push_back( std::move(sIndicatorPtr) );
146
148 setResolvedObject(particleSystem, idxParticle, idxSurface,
149 position, density, angle, velocity);
150}
151
152
154template<typename T, typename PARTICLETYPE>
156 Vector<T,2> position, Vector<T,2> extend, T epsilon, T density=0.,
157 T angle = 0.,
158 Vector<T,2> velocity = Vector<T,2> (0.))
159{
160 //Retrieve new index
161 std::size_t idxParticle = particleSystem.size();
162
163 //Initialize particle address
164 particleSystem.extend();
165
167 setResolvedCuboid2D( particleSystem, idxParticle, position,
168 extend, epsilon, density, angle, velocity );
169}
170
171
173
175template<typename T, typename PARTICLETYPE>
177 std::size_t idxParticle,
178 Vector<T,2> position, T radius, T epsilon, T density=0.,
179 T angle = 0.,
180 Vector<T,2> velocity = Vector<T,2> (0.))
181{
182 using namespace descriptors;
183 typedef SmoothIndicatorF2D<T, T, true> SIndicatorBaseType;
184
185 //Create SmoothIndicator
186 std::unique_ptr<SIndicatorBaseType> sIndicatorPtr(
187 new SmoothIndicatorTriangle2D<T, T, true>(Vector<T,2>(0.), radius, epsilon ));
188
189 //Pass smart pointer to particleSystem
190 auto& vectorOfIndicators = particleSystem.template getAssociatedData<
191 std::vector<std::unique_ptr<SIndicatorBaseType>>>();
192 std::size_t idxSurface = vectorOfIndicators.size();
193 vectorOfIndicators.push_back( std::move(sIndicatorPtr) );
194
196 setResolvedObject(particleSystem, idxParticle, idxSurface,
197 position, density, angle, velocity);
198}
199
200
202template<typename T, typename PARTICLETYPE>
204 Vector<T,2> position, T radius, T epsilon, T density=0.,
205 T angle = 0.,
206 Vector<T,2> velocity = Vector<T,2> (0.))
207{
208 //Retrieve new index
209 std::size_t idxParticle = particleSystem.size();
210
211 //Initialize particle address
212 particleSystem.extend();
213
215 setResolvedTriangle2D( particleSystem, idxParticle, position,
216 radius, epsilon, density, angle, velocity );
217}
218
219
221
223template<typename T, typename PARTICLETYPE>
225 std::size_t idxParticle,
226 Vector<T,2> position,
227 T latticeSpacing,
228 std::shared_ptr<IndicatorF2D<T>> indPtr,
229 T epsilon, T density=0., T angle = 0.,
230 Vector<T,2> velocity = Vector<T,2> (0.))
231{
232 using namespace descriptors;
233 typedef SmoothIndicatorF2D<T, T, true> SIndicatorBaseType;
234
235 //Create SmoothIndicator
236 std::unique_ptr<SIndicatorBaseType> sIndicatorPtr(
237 new SmoothIndicatorCustom2D<T, T, true>(latticeSpacing, indPtr, Vector<T,2> (0.), epsilon, 0.));
238
239 //Pass smart pointer to particleSystem
240 auto& vectorOfIndicators = particleSystem.template getAssociatedData<
241 std::vector<std::unique_ptr<SIndicatorBaseType>>>();
242 std::size_t idxSurface = vectorOfIndicators.size();
243 vectorOfIndicators.push_back( std::move(sIndicatorPtr) );
244
246 setResolvedObject(particleSystem, idxParticle, idxSurface,
247 position, density, angle, velocity);
248}
249
251template<typename T, typename PARTICLETYPE>
253 Vector<T,2> position,
254 T latticeSpacing,
255 std::shared_ptr<IndicatorF2D<T>> indPtr,
256 T epsilon, T density=0., T angle = 0.,
257 Vector<T,2> velocity = Vector<T,2> (0.))
258{
259 //Retrieve new index
260 std::size_t idxParticle = particleSystem.size();
261
262 //Initialize particle address
263 particleSystem.extend();
264
266 setResolvedArbitraryShape2D( particleSystem, idxParticle, position, latticeSpacing, indPtr,
267 epsilon, density, angle, velocity );
268}
269
270} //namespace creators
271
272} //namespace particles
273
274} //namespace olb
275
276#endif
IndicatorF2D is an application from .
class for marking output with some text
implements a smooth circle in 2D with an _epsilon sector
implements a smooth cuboid in 2D with an _epsilon sector.
implements a smooth triangle in 2D 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.
ParallelParticleLocator addResolvedObject(SuperParticleSystem< T, PARTICLETYPE > &sParticleSystem, std::size_t idxSurface, const Vector< T, PARTICLETYPE::d > &position, T density=0., const Vector< T, utilities::dimensions::convert< PARTICLETYPE::d >::rotation > &angleInDegree=Vector< T, utilities::dimensions::convert< PARTICLETYPE::d >::rotation >(0.), const Vector< T, PARTICLETYPE::d > &velocity=Vector< T, PARTICLETYPE::d >(0.), const Vector< bool, PARTICLETYPE::d > &periodicity=Vector< T, PARTICLETYPE::d >(false))
void setResolvedArbitraryShape2D(ParticleSystem< T, PARTICLETYPE > &particleSystem, std::size_t idxParticle, Vector< T, 2 > position, T latticeSpacing, std::shared_ptr< IndicatorF2D< T > > indPtr, T epsilon, T density=0., T angle=0., Vector< T, 2 > velocity=Vector< T, 2 >(0.))
Set resolved cuboid for existing particle but new surface.
void setResolvedCuboid2D(ParticleSystem< T, PARTICLETYPE > &particleSystem, std::size_t idxParticle, Vector< T, 2 > position, Vector< T, 2 > extend, T epsilon, T density=0., T angle=0., Vector< T, 2 > velocity=Vector< T, 2 >(0.))
Set resolved cuboid for existing particle but new surface.
void addResolvedArbitraryShape2D(ParticleSystem< T, PARTICLETYPE > &particleSystem, Vector< T, 2 > position, T latticeSpacing, std::shared_ptr< IndicatorF2D< T > > indPtr, T epsilon, T density=0., T angle=0., Vector< T, 2 > velocity=Vector< T, 2 >(0.))
Add resolved arbitrary shape as new particle with new surface.
void addResolvedCuboid2D(ParticleSystem< T, PARTICLETYPE > &particleSystem, Vector< T, 2 > position, Vector< T, 2 > extend, T epsilon, T density=0., T angle=0., Vector< T, 2 > velocity=Vector< T, 2 >(0.))
Add resolved cuboid as new particle with new surface.
void setResolvedCircle2D(ParticleSystem< T, PARTICLETYPE > &particleSystem, std::size_t idxParticle, Vector< T, 2 > position, T radius, T epsilon, T density=0., Vector< T, 2 > velocity=Vector< T, 2 >(0.))
Set resolved circle for existing particle but new surface.
ParallelParticleLocator addResolvedCircle2D(SuperParticleSystem< T, PARTICLETYPE > &sParticleSystem, const Vector< T, 2 > &position, T radius, T epsilon, T density=0., const Vector< T, 2 > &velocity=Vector< T, 2 >(0.), const Vector< bool, 2 > &periodicity=Vector< bool, 2 >(false))
void addResolvedTriangle2D(ParticleSystem< T, PARTICLETYPE > &particleSystem, Vector< T, 2 > position, T radius, T epsilon, T density=0., T angle=0., Vector< T, 2 > velocity=Vector< T, 2 >(0.))
Add resolved triangle as new particle with new surface.
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)
void setResolvedTriangle2D(ParticleSystem< T, PARTICLETYPE > &particleSystem, std::size_t idxParticle, Vector< T, 2 > position, T radius, T epsilon, T density=0., T angle=0., Vector< T, 2 > velocity=Vector< T, 2 >(0.))
Set resolved cuboid for existing particle but new surface.
Top level namespace for all of OpenLB.
Converts dimensions by deriving from given cartesian dimension D.