double Advect3D::simulateAdvection(HaloArray3D *u, ProcGrid3D *g, double dtA) { timer->start("simulateAdvection", u->l.prod(), 0); double t = 0.0; int s = 0; if (is2D()) // check that u, g have been set up appropriately assert (u->halo.z == 0 && u->l.z <= 1 && g->P.z == 1); while (t < dtA) { if (method == 0) updateGodunov(u); else if (method == 1) updateLW(u); else updateMacCormack(u); updateBoundary(u, g); t += dt; s++; if (verbosity > 3) { char s[64]; sprintf(s, "after time %.4e, field is:\n", t); u->print(g->myrank, s); } } timer->stop("simulateAdvection"); return t; } //simulateAdvection()
void Advect3D::updateMacCormack(HaloArray3D *u) { timer->start("updateMacCormack", u->l.prod(), 1); if (!is2D()) compute_MacCormack_scheme(dt, u->u, u->l.x, u->l.y, u->l.z, V.x, V.y, V.z, delta.x, delta.y, delta.z); else updateMacCormack2D(u); timer->stop("updateMacCormack"); } //updateLW()
void Advect3D::updateGodunov(HaloArray3D *u) { timer->start("updateGodunov", u->l.prod(), 1); if (!is2D()) compute_godunov_scheme(dt, u->u, u->l.x, u->l.y, u->l.z, V.x, V.y, V.z, delta.x, delta.y, delta.z); else updateGodunov2D(u); timer->stop("updateGodunov"); } //updateLW()
Advect3D::Advect3D(Vec3D<int> gridSz, Vec3D<double> v, double timef, double CFL, int meth, int verb, Timer *t, MPI_Comm myCW, int blk) { B = blk; myCommWorld = myCW; gridSize = gridSz; V = v; delta.x = 1.0 / (gridSize.x - 1); // implicitly on unit square delta.y = 1.0 / (gridSize.y - 1); delta.z = is2D()? 1.0: 1.0 / (gridSize.z - 1); tf = timef; dt = CFL * std::min<double>(delta.x, std::min<double>(delta.y, delta.z)); method = meth; verbosity = verb; timer = t; }
const String DOMMatrixReadOnly::toString() const { std::stringstream stream; if (is2D()) { stream << "matrix(" << a() << ", " << b() << ", " << c() << ", " << d() << ", " << e() << ", " << f(); } else { stream << "matrix3d(" << m11() << ", " << m12() << ", " << m13() << ", " << m14() << ", " << m21() << ", " << m22() << ", " << m23() << ", " << m24() << ", " << m31() << ", " << m32() << ", " << m33() << ", " << m34() << ", " << m41() << ", " << m42() << ", " << m43() << ", " << m44(); } stream << ")"; return String(stream.str().c_str()); }
void MLSignal::dump(std::ostream& s, int verbosity) const { s << "signal @ " << std::hex << this << std::dec << " [" << mWidth*mHeight*mDepth << " frames] : sum " << getSum() << "\n"; int w = mWidth; int h = mHeight; const MLSignal& f = *this; if(verbosity > 0) { if(isConstant()) { s << "constant " << mDataAligned[0] << "\n"; } else if(is2D()) { s << std::setprecision(4); for (int j=0; j<h; ++j) { s << j << " | "; for(int i=0; i<w; ++i) { s << f(i, j) << " "; } s << "\n"; } } else { s << std::setprecision(5); for (int i=0; i<w; ++i) { if(verbosity > 1) { s << "[" << i << "]"; } s << mDataAligned[i] << " "; } s << "\n"; } } }