SPHinXsys  alpha version
diffusion_reaction_particles.h
Go to the documentation of this file.
1 /* -------------------------------------------------------------------------*
2  * SPHinXsys *
3  * --------------------------------------------------------------------------*
4  * SPHinXsys (pronunciation: s'finksis) is an acronym from Smoothed Particle *
5  * Hydrodynamics for industrial compleX systems. It provides C++ APIs for *
6  * physical accurate simulation and aims to model coupled industrial dynamic *
7  * systems including fluid, solid, multi-body dynamics and beyond with SPH *
8  * (smoothed particle hydrodynamics), a meshless computational method using *
9  * particle discretization. *
10  * *
11  * SPHinXsys is partially funded by German Research Foundation *
12  * (Deutsche Forschungsgemeinschaft) DFG HU1527/6-1, HU1527/10-1 *
13  * and HU1527/12-1. *
14  * *
15  * Portions copyright (c) 2017-2020 Technical University of Munich and *
16  * the authors' affiliations. *
17  * *
18  * Licensed under the Apache License, Version 2.0 (the "License"); you may *
19  * not use this file except in compliance with the License. You may obtain a *
20  * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. *
21  * *
22  * --------------------------------------------------------------------------*/
29 #ifndef DIFFUSION_REACTION_PARTICLES_H
30 #define DIFFUSION_REACTION_PARTICLES_H
31 
32 #include "base_particles.h"
33 #include "base_body.h"
34 #include "base_material.h"
35 #include "diffusion_reaction.h"
36 
37 namespace SPH
38 {
39 
44  template <class BaseParticlesType = BaseParticles>
46  {
47  protected:
50  std::map<std::string, size_t> species_indexes_map_;
51 
52  public:
53  StdVec<StdLargeVec<Real>> species_n_;
54  StdVec<StdLargeVec<Real>> diffusion_dt_;
56  template <class BaseMaterialType>
58  DiffusionReaction<BaseMaterialType> *diffusion_reaction_material)
59  : BaseParticlesType(sph_body, diffusion_reaction_material),
60  number_of_species_(diffusion_reaction_material->NumberOfSpecies()),
61  number_of_diffusion_species_(diffusion_reaction_material->NumberOfSpeciesDiffusion()),
62  species_indexes_map_(diffusion_reaction_material->SpeciesIndexMap())
63  {
66  };
67  virtual ~DiffusionReactionParticles(){};
68 
69  std::map<std::string, size_t> SpeciesIndexMap() { return species_indexes_map_; };
70 
71  virtual void initializeOtherVariables() override
72  {
73  BaseParticlesType::initializeOtherVariables();
74 
75  std::map<std::string, size_t>::iterator itr;
76  for (itr = species_indexes_map_.begin(); itr != species_indexes_map_.end(); ++itr)
77  {
78  // Register a specie.
79  this->registerVariable(species_n_[itr->second], itr->first);
80  // the scalars will be sorted if particle sorting is called
81  // Note that we call a template function from a template class
82  this->template registerSortableVariable<Real>(itr->first);
83  // add species to basic output particle data
84  this->template addVariableToWrite<Real>(itr->first);
85  }
86 
87  for (size_t m = 0; m < number_of_diffusion_species_; ++m)
88  {
89  constexpr int type_index = DataTypeIndex<Real>::value;
90  //----------------------------------------------------------------------
91  // register reactive change rate terms without giving variable name
92  //----------------------------------------------------------------------
93  std::get<type_index>(this->all_particle_data_).push_back(&diffusion_dt_[m]);
94  diffusion_dt_[m].resize(this->real_particles_bound_, Real(0));
95  }
96  };
97 
98  virtual DiffusionReactionParticles<BaseParticlesType> *ThisObjectPtr() override { return this; };
99  };
100 }
101 #endif // DIFFUSION_REACTION_PARTICLES_H
size_t number_of_species_
Definition: diffusion_reaction_particles.h:48
Complex material for diffusion or/and reactions.
Definition: diffusion_reaction.h:195
size_t number_of_diffusion_species_
Definition: diffusion_reaction_particles.h:49
StdVec< StdLargeVec< Real > > diffusion_dt_
Definition: diffusion_reaction_particles.h:54
This is the base classes of SPH bodies. The real body is for that with cell linked list and the ficti...
This is the base classes of all materials. A function in a derived material class returns a value wit...
StdVec< StdLargeVec< Real > > species_n_
Definition: diffusion_reaction_particles.h:53
This is the base class of SPH particles. The basic data of the particles is saved in separated large ...
A group of particles with diffusion or/and reactions particle data.
Definition: diffusion_reaction_particles.h:45
SPHBody is a base body with basic data and functions. Its derived class can be a real fluid body...
Definition: base_body.h:61
Definition: solid_body_supplementary.cpp:9