mirror of
https://github.com/cosmo-sims/MUSIC.git
synced 2024-09-19 17:03:46 +02:00
Added function to deposit particles onto refgrid
This commit is contained in:
parent
af98d51fe9
commit
5f88186863
1 changed files with 22 additions and 0 deletions
|
@ -38,6 +38,7 @@ class region_multibox_plugin : public region_generator_plugin{
|
||||||
private:
|
private:
|
||||||
int res, reflevel;
|
int res, reflevel;
|
||||||
grid refgrid;
|
grid refgrid;
|
||||||
|
|
||||||
region find_equal(grid ingrid, int level)
|
region find_equal(grid ingrid, int level)
|
||||||
{
|
{
|
||||||
slice curslice;
|
slice curslice;
|
||||||
|
@ -64,6 +65,24 @@ private:
|
||||||
}
|
}
|
||||||
return equal_region;
|
return equal_region;
|
||||||
}
|
}
|
||||||
|
//This function takes the grid, a vector of doubles containing the particle
|
||||||
|
//coordinates, and sets each particle-containing gridcell to maxlevel.
|
||||||
|
void deposit_particles(grid ingrid, std::vector<double> pp, int maxlevel, int res)
|
||||||
|
{
|
||||||
|
int i,j,k;
|
||||||
|
std::vector<double>::iterator cp = pp.begin();
|
||||||
|
while(cp != pp.end())
|
||||||
|
{
|
||||||
|
i = *(cp);
|
||||||
|
cp++;
|
||||||
|
j = *(cp);
|
||||||
|
cp++;
|
||||||
|
k = *(cp);
|
||||||
|
cp++;
|
||||||
|
ingrid[int((i+0.5)*res)][int((j+0.5)*res)][int((k+0.5)*res)] = maxlevel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//This function takes the grid, which has been already had particles
|
//This function takes the grid, which has been already had particles
|
||||||
//deposited onto it, and set to the maximum refinement level. It then
|
//deposited onto it, and set to the maximum refinement level. It then
|
||||||
//fills the remaining refinement levels
|
//fills the remaining refinement levels
|
||||||
|
@ -96,9 +115,12 @@ public:
|
||||||
explicit region_multibox_plugin( config_file& cf )
|
explicit region_multibox_plugin( config_file& cf )
|
||||||
: region_generator_plugin( cf )
|
: region_generator_plugin( cf )
|
||||||
{
|
{
|
||||||
|
std::vector<double> pp;
|
||||||
res = 128;
|
res = 128;
|
||||||
//Initialize the grid with zeros, the base level
|
//Initialize the grid with zeros, the base level
|
||||||
refgrid = grid(res,slice(res,col(res,0)));
|
refgrid = grid(res,slice(res,col(res,0)));
|
||||||
|
deposit_particles(refgrid, pp, reflevel, res);
|
||||||
|
build_refgrid(refgrid, reflevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue