Adding an arbitrary shaped particle.
OpenLB – Open Source Lattice Boltzmann Code › Forums › on OpenLB › General Topics › Adding an arbitrary shaped particle.
- This topic has 7 replies, 2 voices, and was last updated 4 months, 4 weeks ago by jan.
-
AuthorPosts
-
May 6, 2024 at 7:12 pm #8614avrachan1Participant
Dear Community,
I used the following function to create a particle of an arbitrary shape.
129 template <typename T, typename DESCRIPTOR>
130 class myindicator : public IndicatorF3D<T>
131 {
132 private :
133 SuperLattice<T,DESCRIPTOR>& sLattice;
134 public :
135 myindicator(SuperLattice<T,DESCRIPTOR>& _sLattice) : IndicatorF3D<T>(), sLattice(_sLattice)
136 {
137 ;
138 this->getName() = “myindicator”;
139 };
140
141 bool operator()(bool output, T X, T Y,T Z)
142 {
143
144 int latticeR[4];
145 T physR[3];
146 physR[0]=X;
147 physR[1]=Y;
148 physR[2]=Z;
149 sLattice.getCuboidGeometry().getLatticeR(latticeR,physR);
150 T phi=sLattice.getBlock(latticeR[0]).get(latticeR[1],latticeR[2],latticeR[3]).computeRho();
151 //std::cout<<phi<<“\t”<<latticeR[0]<<“\n”;
152 if(phi>0.5)
153 return true;
154 else
155 return false;
156 };
157 };440 std::shared_ptr<IndicatorF3D<T>> particle = std::make_shared<myindicator<T,DESCRIPTOR>>( sLattice);
444 creators::addResolvedArbitraryShape3D(particleSystem,center,dx,particle,width,1000.);However, this fails at line 314 of IndicatorBase3D.hh file in the function signedDistance().
As I understand, I need to provide a function to compute the signed distance from the surface of my arbitrary shaped particle.
Am I correct?
May 6, 2024 at 11:41 pm #8621avrachan1ParticipantEven if I try to create a simple shape composed of two overlapping spheres, I get the same error
Vector<T,3> center(lengthX/2.,lengthY/2.,lengthZ/2.);
442 std::shared_ptr<IndicatorSphere3D<T>> sphere1 ( new IndicatorSphere3D<T> (center,5*dx));
443 center[0]=center[0]+5*dx;
444 std::shared_ptr<IndicatorSphere3D<T>> sphere2 ( new IndicatorSphere3D<T> (center,5*dx));
445 //IndicatorIdentity3D<T> combined(sphere1+sphere2);
446 std::shared_ptr<IndicatorF3D<T>> cuboid2 = std::make_shared<IndicatorIdentity3D<T>>(sphere1+sphere2);
447
448 creators::addResolvedArbitraryShape3D(particleSystem,center,dx,cuboid2,2.*W0,1000.);What am I doing wrong ?
PS: How do I paste code in the forum?
- This reply was modified 8 months, 2 weeks ago by avrachan1.
May 7, 2024 at 3:07 pm #8632janParticipantDear avrachan,
the indicator that is passed to
creators::addResolvedArbitraryShape3D
must provide asignedDistance
method. In the second case, when combining two indicators, please try to use the functions provided insrc/functors/analytical/indicator/indicComb3D.h
. For example, you could use theIndicPlus3D
.To highlight code in the forum, you have to use the backtick (https://en.wikipedia.org/wiki/Backtick) and enclose the code within it.
Best regards,
JanMay 8, 2024 at 4:58 pm #8641avrachan1ParticipantDear Jan,
That works. My idea is to make the arbitrary shaped particle by adding cuboids of various sizes.
Thanks.
August 15, 2024 at 11:28 pm #9096avrachan1ParticipantDear Jan,
I have a follow up question regarding this.
I was representing the arbitrary shaped particle by decomposing it into smaller cuboids. This method doesn’t scale well. Now I am trying to convert the surface of the particle into a set of triangles.
I can’t seem to find “IndicatorTriangle3D” functor to use for this purpose. Should I convert the shape into STL file and read it using STLreader ?
Thanks!
August 16, 2024 at 12:20 am #9097avrachan1Participantauto particle_indicator = std::make_shared<STLreader<T>> ( "ArbParticle.stl", L); Vector<T,3> position; creators::addResolvedArbitraryShape3D(particleSystem,position,dx,particle_indicator,pfwidth,1e16);
Gives me the error,
olb-1.6r0/src/particles/functions/particleCreatorFunctions3D.h:334:6: note: candidate template ignored: could not match 'IndicatorF3D' against 'STLreader'
What is the correct way to pass STLreader, as suggested in the thread https://www.openlb.net/forum/topic/particle-flow/
- This reply was modified 5 months, 1 week ago by avrachan1.
August 16, 2024 at 9:20 pm #9105avrachan1ParticipantI managed to get it to work!
std::shared_ptr<IndicatorF3D<T>> particle_indicator_stl = std::make_shared<STLreader<T>> ("PhaseFieldParticle.stl", L);
Still if there is a way to do this without writing to a stl file I would like to know it.
Thanks.
August 26, 2024 at 9:45 am #9156janParticipantDear avrachan1,
what do you mean by “I was representing the arbitrary shaped particle by decomposing it into smaller cuboids. This method doesn’t scale well.”? If you use the function
addResolvedArbitraryShape3D
then it shouldn’t add any additional costs during the simulation, because that leads to the use of a cached signed distance in the background. The interpolation using that cache doesn’t depend on the original geometry.For complex shapes, I usually use the combination of geometries using signed distance functions or STLs. Depending on what shapes you need, you could try to use a superellipsoid or try to introduce a new indicator that serves your needs, but the main options that are currently implemented are the
STLreader
or the combination of primitives.Best regards,
Jan -
AuthorPosts
- You must be logged in to reply to this topic.