MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / test

Function test

Tests/Particles/InitRandom/main.cpp:81–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81void test ()
82{
83 int ncells, max_grid_size, nlevs, nppc;
84
85 ParmParse pp;
86 pp.get("ncells", ncells);
87 pp.get("max_grid_size", max_grid_size);
88 pp.get("nlevs", nlevs);
89 pp.get("nppc", nppc);
90
91 Vector<Box> domains;
92 Vector<BoxArray> ba;
93 Vector<IntVect> ref_ratio;
94
95 set_grids_nested(domains, ba, ref_ratio);
96
97 RealBox real_box;
98 for (int n = 0; n < AMREX_SPACEDIM; n++) {
99 real_box.setLo(n, 0.0);
100 real_box.setHi(n, 1.0);
101 }
102
103 // This sets the boundary conditions to be doubly or triply periodic
104 int is_per[] = {AMREX_D_DECL(1,1,1)};
105
106 // This defines a Geometry object for each level
107 Vector<Geometry> geom(nlevs);
108 geom[0].define(domains[0], &real_box, CoordSys::cartesian, is_per);
109 for (int lev = 1; lev < nlevs; lev++) {
110 geom[lev].define(domains[lev], &real_box, CoordSys::cartesian, is_per);
111 }
112
113 Vector<DistributionMapping> dmap(nlevs);
114
115 for (int lev = 0; lev < nlevs; lev++) {
116 dmap[lev] = DistributionMapping{ba[lev]};
117 }
118
119 // Add some particles
120 constexpr int NStructReal = 4;
121 constexpr int NStructInt = 1;
122 constexpr int NArrayReal = 8;
123 constexpr int NArrayInt = 3;
124
125 using MyPC = ParticleContainer<NStructReal, NStructInt, NArrayReal, NArrayInt>;
126 MyPC myPC(geom, dmap, ba, ref_ratio);
127 myPC.SetVerbose(false);
128
129 int num_particles = nppc * AMREX_D_TERM(ncells, * ncells, * ncells);
130 bool serialize = false;
131 int iseed = 451;
132 MyPC::ParticleInitData pdata = {{1.0, 2.0, 3.0, 4.0},
133 {5},
134 {6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0},
135 {14, 15, 16}};
136
137 myPC.InitRandom(num_particles, iseed, pdata, serialize);
138 amrex::Print() << "Generated " << myPC.TotalNumberOfParticles() << " particles. \n";

Callers 1

mainFunction · 0.70

Calls 9

PrintClass · 0.85
set_grids_nestedFunction · 0.70
AMREX_D_TERMFunction · 0.50
getMethod · 0.45
setLoMethod · 0.45
setHiMethod · 0.45
defineMethod · 0.45
SetVerboseMethod · 0.45

Tested by

no test coverage detected