Dear Prof. Wolfgang,
Thanks for the guidance. I tried
replacing the " source/particles/particle_handler.cc
<https://github.com/dealii/dealii/pull/10589/files#diff-df7869b8ff6741c5bba620988f7bd995>"
file with the one present in
"https://github.com/dealii/dealii/pull/10589/files". Also
include/deal.II/particles/particle_accessor.h
<https://github.com/dealii/dealii/pull/10319/files#diff-ba98c140727c3e55b479f34172de381b>
and source/particles/particle_accessor.cc
<https://github.com/dealii/dealii/pull/10319/files#diff-0b2cb32ab20618cd2a77e2ddfda9eddd>
from "https://github.com/dealii/dealii/pull/10319/files". Then compiled
again my deal.ii 9.2.0 but it gives error during compilation.Therefore as a second option, I have created a simplified code which represents my problem. Kindly receive the files attached. Looking forward for your guiding response! Thank you very much for ongoing cooperation. Best regards, Muhammad Mashhood On Friday, July 31, 2020 at 5:31:13 PM UTC+2 Wolfgang Bangerth wrote: > On 7/30/20 5:26 PM, Muhammad Mashhood wrote: > > > > _But it gives the following error on running:_ > > > > /An error occurred in line <298> of file > > </home/muhammad/software/dealii-9.2.0/source/particles/particle.cc> in > function > > void dealii::Particles::Particle<dim, > spacedim>::set_properties(const > > dealii::ArrayView<const double>&) [with int dim = 3; int spacedim = 3] > > The violated condition was: > > property_pool != nullptr > > Additional information: > > [...] > > > I explored the mailing list and found someone from the community already > had > > similar problem of assigning the properties to the particles where it > was > > suggested to use following way of assigning the properties: > > I believe that this is a bug that I fixed a while back: > https://github.com/dealii/dealii/pull/10589 > https://github.com/dealii/dealii/issues/10590 > Unfortunately, this happened after the 9.2 release. Are you in a position > to > work with the current development sources? > > If this doesn't solve the problem, can you come up with a simplified piece > of > code that illustrates the issue? > > Best > W. > > -- > ------------------------------------------------------------------------ > Wolfgang Bangerth email: [email protected] > www: http://www.math.colostate.edu/~bangerth/ > > -- The deal.II project is located at http://www.dealii.org/ For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en --- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/dc35abbf-ee56-4917-863b-222199337b76n%40googlegroups.com.
3d_block.msh
Description: Mesh model
#include <deal.II/base/conditional_ostream.h>
#include <deal.II/base/parameter_handler.h>
#include <deal.II/base/utilities.h>
#include <deal.II/base/index_set.h>
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/base/function.h>
#include <deal.II/base/logstream.h>
#include <deal.II/lac/vector.h>
#include <deal.II/lac/full_matrix.h>
#include <deal.II/grid/tria.h>
#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/grid_refinement.h>
#include <deal.II/grid/grid_tools.h>
#include <deal.II/grid/tria_accessor.h>
#include <deal.II/grid/tria_iterator.h>
#include <deal.II/grid/tria_boundary_lib.h>
#include <deal.II/grid/grid_out.h>
#include <deal.II/grid/manifold_lib.h>
#include <deal.II/dofs/dof_handler.h>
#include <deal.II/dofs/dof_accessor.h>
#include <deal.II/dofs/dof_renumbering.h>
#include <deal.II/dofs/dof_tools.h>
#include <deal.II/fe/fe_q.h>
#include <deal.II/fe/fe_system.h>
#include <deal.II/fe/fe_values.h>
#include <deal.II/fe/fe_dgq.h>
#include <deal.II/fe/fe_tools.h>
#include <deal.II/numerics/data_out.h>
#include <deal.II/numerics/fe_field_function.h>
#include <deal.II/grid/grid_in.h>
// For particles handling and data output
#include <deal.II/particles/particle_handler.h>
#include <deal.II/particles/data_out.h>
#include <deal.II/fe/mapping_q.h>
#include <fstream>
#include <iostream>
#include <typeinfo>
#include <cxxabi.h>
#include <sys/stat.h>
using namespace dealii;
int main ()
{
/////////////////////////////////////////////////////////////
////////// Varible declaration and initializations //////////
/////////////////////////////////////////////////////////////
const int dim = 3;
Triangulation<dim> triangulation;
MappingQ<dim> mapping(1);
Particles::ParticleHandler<dim> particle_handler(triangulation, mapping, /*n_properties=*/dim);
types::particle_index next_unused_particle_id;
const unsigned int fe_degree = 1;
FESystem<dim> fe(FE_Q<dim>(QGaussLobatto<1>(fe_degree+1)), dim);
const QGauss<dim> quadrature_formula(fe_degree + 1);
////////////////////////////////////////
////////// Reading mesh file //////////
//////////////////////////////////////
GridIn<dim> gridin;
gridin.attach_triangulation(triangulation);
std::ifstream f("3d_block.msh");
gridin.read_msh(f);
std::cout << " Number of active cells after make_grid(): "
<< triangulation.n_active_cells()
<< std::endl;
//////////////////////////////////////////////////////////////
////////// Distribution of dofs to the dof handler //////////
/////////////////////////////////////////////////////////////
DoFHandler<dim> dof_handler(triangulation);
dof_handler.distribute_dofs(fe);
/////////////////////////////////////////////////////////////////////////////////////////////////////
////////// creating particles and assigning values for quadrature point locations and data //////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
next_unused_particle_id = 1;
FEValues<dim> fe_values (fe, quadrature_formula,
update_values | update_gradients |
update_quadrature_points);
for (const auto &cell : dof_handler.active_cell_iterators())
{
fe_values.reinit(cell);
for (const unsigned int q_point :
fe_values.quadrature_point_indices())
{
const Point<dim> location =
fe_values.quadrature_point(q_point);
// Particles::PropertyPool propertypool(6);
Particles::Particle<dim> new_particle;
new_particle.set_location(location);
new_particle.set_reference_location(
mapping.transform_real_to_unit_cell(cell, location));
new_particle.set_id(next_unused_particle_id);
// new_particle.set_property_pool(propertypool);
// in actual code, the PointHistory is used for current quadrature point strain to be
// assigned to current particle being created
SymmetricTensor<2, dim> strain; /*local_quadrature_points_history[q_point].old_strain;*/
strain = 0;
new_particle.set_properties(make_array_view(strain));
particle_handler.insert_particle(new_particle, cell);
++next_unused_particle_id;
}
}
particle_handler.update_cached_numbers();
///////////////////////////////////////////////////////////////////
/////////// particle output for their ids and coordinates /////////
//////////////////////////////////////////////////////////////////
const std::string filename_base = ("particle_sample");
Particles::DataOut<dim, dim> particle_out;
particle_out.build_patches(
particle_handler/*,
std::vector<std::string>(dim, "velocity"),
std::vector<DataComponentInterpretation::DataComponentInterpretation>(
dim, DataComponentInterpretation::component_is_part_of_vector)*/);
//particle_out.set_flags(
// DataOutBase::VtkFlags(time.get_current_time(), time.get_step_number()));
std::ofstream output(filename_base + ".vtu");
particle_out.write_vtu(output);
std::cout <<filename_base << ".vtu" << std::endl;
}
