MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / initialize

Function initialize

examples/pde/boltzmann_cfd.cpp:201–246  ·  view source on GitHub ↗

* @brief Initializes internal values used for computation * */

Source from the content-addressed store, hash-verified

199 *
200 */
201void initialize(Simulation& sim) {
202 auto& ux = sim.ux;
203 auto& uy = sim.uy;
204 auto& rho = sim.rho;
205 auto& sigma = sim.sigma;
206 auto& f = sim.f;
207 auto& feq = sim.feq;
208
209 auto& ex = sim.ex;
210 auto& ey = sim.ey;
211 auto& wt = sim.wt;
212 auto& ex_ = sim.ex_;
213 auto& ey_ = sim.ey_;
214 auto& ex_T = sim.ex_T;
215 auto& ey_T = sim.ey_T;
216 auto& wt_T = sim.wt_T;
217
218 auto density = sim.density;
219 auto velocity = sim.velocity;
220 auto xcount = sim.grid_width;
221 auto ycount = sim.grid_height;
222
223 ex = af::array(1, 1, 9, ex_vals);
224 ey = af::array(1, 1, 9, ey_vals);
225 wt = af::array(1, 1, 9, wt_vals);
226
227 ex_T = af::array(1, 9, ex_vals);
228 ey_T = af::array(1, 9, ey_vals);
229 wt_T = af::moddims(wt, af::dim4(1, 9));
230
231 rho = af::constant(density, xcount, ycount, f32);
232 sigma = af::constant(0, xcount, ycount, f32);
233
234 f = af::constant(0, xcount, ycount, 9, f32);
235
236 ex_ = af::tile(ex, xcount, ycount, 1);
237 ey_ = af::tile(ey, xcount, ycount, 1);
238
239 // Initialization of the distribution function
240 auto edotu = ex_ * ux + ey_ * uy;
241 auto udotu = ux * ux + uy * uy;
242
243 feq = rho * wt *
244 ((edotu * edotu * 4.5f) - (udotu * 1.5f) + (edotu * 3.0f) + 1.0f);
245 f = feq;
246}
247
248/**
249 * @brief Updates the particle distribution functions for the new simulation

Callers 1

Calls 5

moddimsFunction · 0.85
constantFunction · 0.85
arrayClass · 0.50
dim4Class · 0.50
tileFunction · 0.50

Tested by

no test coverage detected