OpenLB – Open Source Lattice Boltzmann Code Forums on OpenLB General Topics Adding an arbitrary shaped particle.

Viewing 4 posts - 1 through 4 (of 4 total)
• Author
Posts
• #8614
avrachan1
Participant

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);

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?

• This topic was modified 3 months ago by avrachan1.
• This topic was modified 3 months ago by avrachan1.
#8621
avrachan1
Participant

Even 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

What am I doing wrong ?

PS: How do I paste code in the forum?

• This reply was modified 3 months ago by avrachan1.
#8632
jan
Participant

Dear avrachan,

the indicator that is passed to `creators::addResolvedArbitraryShape3D` must provide a `signedDistance` method. In the second case, when combining two indicators, please try to use the functions provided in `src/functors/analytical/indicator/indicComb3D.h`. For example, you could use the `IndicPlus3D`.

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,
Jan

#8641
avrachan1
Participant

Dear Jan,

That works. My idea is to make the arbitrary shaped particle by adding cuboids of various sizes.

Thanks.

Viewing 4 posts - 1 through 4 (of 4 total)
• You must be logged in to reply to this topic.