! * \brief Build a local mesh database entry corresponding to a meter web. */
| 228 | * \brief Build a local mesh database entry corresponding to a meter web. |
| 229 | */ |
| 230 | void |
| 231 | build_meter_web(DBfile* dbfile, |
| 232 | std::string& dirname, |
| 233 | const boost::multi_array<Point, 2>& X_web, |
| 234 | const boost::multi_array<Vector, 2>& dA_web, |
| 235 | const int timestep, |
| 236 | const double simulation_time) |
| 237 | { |
| 238 | const int npoints = static_cast<int>(X_web.num_elements()); |
| 239 | |
| 240 | std::vector<float> block_X(NDIM * npoints); |
| 241 | std::vector<float> block_dA(NDIM * npoints); |
| 242 | |
| 243 | for (unsigned int m = 0, i = 0; m < X_web.shape()[0]; ++m) |
| 244 | { |
| 245 | for (unsigned int n = 0; n < X_web.shape()[1]; ++n, ++i) |
| 246 | { |
| 247 | // Get the coordinate and normal vector data. |
| 248 | for (unsigned int d = 0; d < NDIM; ++d) |
| 249 | { |
| 250 | block_X[d * npoints + i] = static_cast<float>(X_web[m][n][d]); |
| 251 | block_dA[d * npoints + i] = static_cast<float>(dA_web[m][n][d]); |
| 252 | } |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | // Set the working directory in the Silo database. |
| 257 | if (DBSetDir(dbfile, dirname.c_str()) == -1) |
| 258 | { |
| 259 | TBOX_ERROR("IBInstrumentPanel::build_meter_web():\n" |
| 260 | << " Could not set directory " << dirname << std::endl); |
| 261 | } |
| 262 | |
| 263 | // Write out the variables. |
| 264 | int cycle = timestep; |
| 265 | auto time = static_cast<float>(simulation_time); |
| 266 | double dtime = simulation_time; |
| 267 | |
| 268 | static const int MAX_OPTS = 3; |
| 269 | DBoptlist* optlist = DBMakeOptlist(MAX_OPTS); |
| 270 | DBAddOption(optlist, DBOPT_CYCLE, &cycle); |
| 271 | DBAddOption(optlist, DBOPT_TIME, &time); |
| 272 | DBAddOption(optlist, DBOPT_DTIME, &dtime); |
| 273 | |
| 274 | const char* meshname = "mesh"; |
| 275 | std::vector<float*> coords(NDIM); |
| 276 | for (unsigned int d = 0; d < NDIM; ++d) |
| 277 | { |
| 278 | coords[d] = &block_X[d * npoints]; |
| 279 | } |
| 280 | |
| 281 | int ndims = NDIM; |
| 282 | |
| 283 | DBPutPointmesh(dbfile, meshname, ndims, &coords[0], npoints, DB_FLOAT, optlist); |
| 284 | |
| 285 | const char* varname = "scaled_normal"; |
| 286 | std::vector<float*> vars(NDIM); |
| 287 | for (unsigned int d = 0; d < NDIM; ++d) |
no test coverage detected