Program Listing for File particle_coupling.h

Return to documentation for file (include/particle_coupling.h)

// ---------------------------------------------------------------------
//
// Copyright (C) 2024 by Luca Heltai
//
// This file is part of the reduced_lagrange_multipliers application, based on
// the deal.II library.
//
// The reduced_lagrange_multipliers application is free software; you can use
// it, redistribute it, and/or modify it under the terms of the Apache-2.0
// License WITH LLVM-exception as published by the Free Software Foundation;
// either version 3.0 of the License, or (at your option) any later version. The
// full text of the license can be found in the file LICENSE.md at the top level
// of the reduced_lagrange_multipliers distribution.
//
// ---------------------------------------------------------------------

#ifndef rdl_particle_coupling_h
#define rdl_particle_coupling_h

#include <deal.II/base/bounding_box.h>
#include <deal.II/base/parameter_acceptor.h>

#include <deal.II/distributed/fully_distributed_tria.h>
#include <deal.II/distributed/tria.h>

#include <deal.II/fe/fe_q.h>
#include <deal.II/fe/mapping_q1.h>

#include <deal.II/grid/grid_tools_cache.h>

#include <deal.II/particles/data_out.h>
#include <deal.II/particles/particle_handler.h>
#include <deal.II/particles/utilities.h>

using namespace dealii;


template <int dim>
class ParticleCouplingParameters : public ParameterAcceptor
{
public:
  ParticleCouplingParameters();

  unsigned int rtree_extraction_level = 1;
};


template <int dim>
class ParticleCoupling
{
public:
  ParticleCoupling(const ParticleCouplingParameters<dim> &par);

  void
  output_particles(const std::string &output_name) const;

  void
  initialize_particle_handler(
    const parallel::TriangulationBase<dim> &tria_background,
    const Mapping<dim> &mapping = StaticMappingQ1<dim>::mapping);

  std::vector<std::vector<BoundingBox<dim>>>
  get_global_bounding_boxes() const;

  const Particles::ParticleHandler<dim> &
  get_particles() const;

  std::map<unsigned int, IndexSet>
  insert_points(const std::vector<Point<dim>>          &points,
                const std::vector<std::vector<double>> &properties = {});

protected:
  const ParticleCouplingParameters<dim> &par;

  MPI_Comm mpi_communicator;

  SmartPointer<const parallel::TriangulationBase<dim>> tria_background;

  SmartPointer<const Mapping<dim>> mapping;

  std::vector<std::vector<BoundingBox<dim>>> global_bounding_boxes;

  Particles::ParticleHandler<dim> particles;
};

#endif