foreach (int bc, bcs) { int i_grid = m_BC2GridIndex[bc]; // copy nodes QVector<int> local2global(m_Grids[i_grid]->GetNumberOfPoints()); for (vtkIdType id_node = 0; id_node < m_Grids[i_grid]->GetNumberOfPoints(); ++id_node) { local2global[id_node] = id_node_max; vec3_t x; m_Grids[i_grid]->GetPoint(id_node, x.data()); m_Grid->GetPoints()->SetPoint(id_node_max, x.data()); ++id_node_max; } // copy faces for (vtkIdType id_face = 0; id_face < m_Grids[i_grid]->GetNumberOfCells(); ++id_face) { vtkIdType *pts, N_pts; m_Grids[i_grid]->GetCellPoints(id_face, N_pts, pts); QVector<vtkIdType> new_pts(N_pts); for (int i = 0; i < N_pts; ++i) { new_pts[i] = local2global[pts[i]]; } vtkIdType id_new_face = m_Grid->InsertNextCell(m_Grids[i_grid]->GetCellType(id_face), N_pts, new_pts.data()); cell_code->SetValue(id_new_face, bc); } }
void FieldFromFunction::setup(const MPI_Comm& comm) { info("Setting up field '%s'", name.c_str()); const auto domain = state->domain; CUDA_Check( cudaDeviceSynchronize() ); PinnedBuffer<float> fieldRawData (resolution.x * resolution.y * resolution.z); int3 i; int id = 0; for (i.z = 0; i.z < resolution.z; ++i.z) { for (i.y = 0; i.y < resolution.y; ++i.y) { for (i.x = 0; i.x < resolution.x; ++i.x) { float3 r {i.x * h.x, i.y * h.y, i.z * h.z}; r -= extendedDomainSize*0.5f; r = domain.local2global(r); r = make_periodic(r, domain.globalSize); fieldRawData[id++] = func(r); } } } fieldRawData.uploadToDevice(defaultStream); setupArrayTexture(fieldRawData.devPtr()); }
static int swrite(const Coords *coords, int n, const int *ii, const float3 *rr, /**/ char *s) { int i, id, c, start; float3 r, v, rg; for (i = start = 0; i < n; ++i) { id = ii[i]; r = rr[i]; local2global(coords, r, /**/ &rg); c = sprintf(s + start, "%d %g %g %g %g %g %g\n", id, rg.x, rg.y, rg.z, v.x, v.y, v.z); if (c >= MAX_CHAR_PER_LINE) ERR("buffer too small : %d / %d", c, MAX_CHAR_PER_LINE); start += c; } return start; }
/* Returns relative velocity for a point, in global coordinates */ void velocity_local(struct element *e, vec4 *r, vec4 *v) { _velocity_local(e, r, v); local2global(e, v, v); }