Skip to content

Adding an arbitrary shaped particle.

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

Viewing 8 posts - 1 through 8 (of 8 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);
    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?

    • This topic was modified 4 months ago by avrachan1.
    • This topic was modified 4 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
    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 4 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.

    #9096
    avrachan1
    Participant

    Dear 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!

    #9097
    avrachan1
    Participant
    
    auto 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 3 weeks, 2 days ago by avrachan1.
    #9105
    avrachan1
    Participant

    I 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.

    #9156
    jan
    Participant

    Dear 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

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