Adding an arbitrary shaped particle.
OpenLB – Open Source Lattice Boltzmann Code › Forums › on OpenLB › General Topics › Adding an arbitrary shaped particle.
- This topic has 3 replies, 2 voices, and was last updated 1 week, 4 days ago by avrachan1.
-
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 1 week, 6 days 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.
-
AuthorPosts
- You must be logged in to reply to this topic.