Sorry for the second post---it might also be worth noting that 

unsigned int part = 0;
for( auto iter=particleHandler.begin(); iter!=particleHandler.end(); 
++iter, ++part ) {
  std::vector<double> quantities(ncomponents);
  for( unsigned int i=0; i<ncomponents; ++i ) {
    quantities[i] = interpolatedParticleQuantities[part*ncomponents + i];


results in this exceptions:

The violated condition was: 

    property_pool != nullptr

Additional information: 

    This exception -- which is used in many places in the library -- 
usually indicates that some condition which the author of the code thought 
must be satisfied at a certain point in an algorithm, is not fulfilled. An 
example would be that the first part of an algorithm sorts elements of an 
array in ascending order, and a second part of the algorithm later 
encounters an element that is not larger than the previous one.

There is usually not very much you can do if you encounter such an 
exception since it indicates an error in deal.II, not in your own program. 
Try to come up with the smallest possible program that still demonstrates 
the error and contact the deal.II mailing lists with it to obtain help.

On Tuesday, June 16, 2020 at 3:46:36 PM UTC-4, Andrew Davis wrote:
> I have a question about how to set the quantities for dealii::Particles 
> that are stored in a dealii::ParticleHandler. I have successfully created 
> a dealii::ParticleHandler and randomly placed particles. I have also 
> successfully solved a PDE, whose solution is stored in the vector solution. 
> Then I (again, successfully) interpolate the solution from the PDE onto the 
> particle locations.
> Here is the code:
> // create the particle handler
> dealii::Particles::ParticleHandler<dim> particleHandler(triangulation, 
> mapping, ncomponents);
> // randomly place particles in the domain based on some defined pdf 
> dealii::Particles::Generators::probabilistic_locations(triangulation, pdf, 
> true, nparticles, particleHandler mapping);
> // map the conserved properties onto the particles
> dealii::Vector<double> 
> interpolatedParticleQuantities(ncomponents*nparticles);
> dealii::Particles::Utilities::interpolate_field_on_particles(dofHandler, 
> particleHandler, solution, interpolatedParticleQuantities);
> The problem that I have now is: how do I attach the correct components of 
> interpolatedParticleQuantities 
> with the property of the corresponding particle?
> I have tested the implementation by checking:
> unsigned int part = 0;
> for( auto iter=particleHandler.begin(); iter!=particleHandler.end(); 
> ++iter, ++part ) {
>   std::cout << "particle " << part << " quantities: ";
>   for( unsigned int i=0; i<ncomponents; ++i ) {
>       std::cout << interpolatedParticleQuantities[part*ncomponents + i] << 
> " ";
>   }
>   std::cout << std::endl;
> }
> and I have gotten what I expect.  I have also tried attaching the particle 
> properties using: 
> unsigned int npart = 0;
> for( auto iter=particleHandler.begin(); iter!=particleHandler.end(); 
> ++iter, ++part ) {
>   dealii::ArrayView<double> data(interpolatedParticleQuantities.begin() + 
> part*ncomponents, ncomponents);
>   iter->set_properties(data);
> }
> but I get the compiler error:
> *error: *cannot convert ‘*dealii::ArrayView<double>*’ to ‘*const 
> std::vector<double, std::allocator<double> >&*’
>   353 |       iter->set_properties(*data*);
> Does anyone know what I am doing wrong? Or is there is a better way to do 
> this? I'm sure this is a dumb question, but I couldn't find anything in the 
> tutorials/examples.

The deal.II project is located at
For mailing list/forum options, see
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
To view this discussion on the web visit

Reply via email to