MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / init

Function init

Tools/MeshSkinning/main.cpp:276–432  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274
275
276void init()
277{
278 diameter = static_cast<Real>(2.0) * radius;
279 mass = static_cast<Real>(1.0) * diameter * diameter * diameter * density0;
280
281 restVolumes.resize(x0.size());
282 shepard.resize(mesh.numVertices());
283 densities.resize(x0.size());
284 L.resize(x0.size());
285 F.resize(x0.size());
286
287 supportRadius = supportRadiusFactor * radius;
288
289 CubicKernel::setRadius(supportRadius);
290#ifdef USE_AVX
291 CubicKernel_AVX::setRadius(supportRadius);
292#endif
293 W_zero = CubicKernel::W_zero();
294 kernelFct = CubicKernel::W;
295 gradKernelFct = CubicKernel::gradW;
296
297 // Init neighborhood search
298 neighborhoodSearch = new NeighborhoodSearch(supportRadius, false);
299 neighborhoodSearch->set_radius(supportRadius);
300 neighborhoodSearch->add_point_set(&x0[0][0], x0.size(), true, true);
301
302 // find initial neighbors
303 START_TIMING("neighborhoodSearch");
304 neighborhoodSearch->find_neighbors();
305 STOP_TIMING_AVG;
306
307 // store initial neighbors and init rest volumes
308 int numParticles = (int) x0.size();
309 initialNeighbors.resize(numParticles);
310 #pragma omp parallel default(shared)
311 {
312 #pragma omp for schedule(static)
313 for (int i = 0; i < numParticles; i++)
314 {
315 // only neighbors in same phase will influence elasticity
316 const unsigned int numNeighbors = numberOfNeighbors(0, i);
317 initialNeighbors[i].resize(numNeighbors);
318 for (unsigned int j = 0; j < numNeighbors; j++)
319 initialNeighbors[i][j] = getNeighbor(0, i, j);
320
321 std::sort(initialNeighbors[i].begin(), initialNeighbors[i].end(), Comparator(x0[i], &x0));
322
323 if (initialNeighbors[i].size() > maxNeighbors)
324 initialNeighbors[i].resize(maxNeighbors);
325
326 // compute volume
327 Real d = W_zero;
328 const Vector3r& xi = x0[i];
329 for (unsigned int j = 0; j < numberOfNeighbors(0, i); j++)
330 {
331 const unsigned int neighborIndex = getNeighbor(0, i, j);
332 const Vector3r& xj = x0[neighborIndex];
333 d += kernelFct(xi - xj);

Callers 2

performMeshSkinningFunction · 0.70
initMethod · 0.50

Calls 15

minFunction · 0.85
maxFunction · 0.85
computeMatrixLFunction · 0.85
precomputeValuesFunction · 0.85
numVerticesMethod · 0.80
numberOfNeighborsFunction · 0.70
getNeighborFunction · 0.70
ComparatorClass · 0.70
resizeMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected