CFDEMcoupling  2.4
 All Classes
setWeightedSource.H
1 
2 // set force and mass source at cell subCellID
3 {
4  // locate subPoint
5  vector subPosition = position + offset;
6  label partCellId = particleCloud_.locateM().findSingleCell(subPosition,cellID);
7 
8  //NP fprintf(lmp->screen,"cellID=%d, partCellId=%d\n",static_cast<int>(cellID),static_cast<int>(partCellId));
9 
10  if(partCellId!=cellID)
11  {
12  nUnEqual++;
13  }
14  if(partCellId<0)
15  {
16  nNotFound++;
17  }
18  nTotal++;
19 
20  if (partCellId >= 0) // subPoint is in domain
21  {
22  // update voidfraction for each particle read
23  scalar partCellVol = particleCloud_.mesh().V()[partCellId];
24  scalar particleVolume = volume/static_cast<scalar>(nPoints);
25  scalar newAlpha = voidfractionNext_[partCellId]- particleVolume / partCellVol;
26 
27  if(newAlpha > alphaMin_) voidfractionNext_[partCellId] = newAlpha;
28  else
29  {
30  voidfractionNext_[partCellId] = alphaMin_;
31  tooMuch_ += (alphaMin_-newAlpha) * partCellVol;
32  }
33 
34  cellsSet++; // inc counter of cells affected
35 
36  //====================================================//
37  // add sub particle representation
38  bool createNew = true;
39  label storeInIndex=0;
40  for(int i=0; i < cellsPerParticle_[index][0] ; i++)
41  {
42  if(partCellId == particleCloud_.cellIDs()[index][i])
43  {
44  storeInIndex = i;
45  createNew = false;
46  break;
47  }
48  }
49 
50  if(createNew)
51  {
52  cellsPerParticle_[index][0] ++;
53  storeInIndex = cellsPerParticle_[index][0]-1;
54  particleCloud_.cellIDs()[index][storeInIndex] = partCellId;
55 
56  }
57 
58  particleWeights[index][storeInIndex] += 1/static_cast<scalar>(nPoints);
59  particleVolumes[index][storeInIndex] += particleVolume;
60  particleV[index][0] += particleVolume;
61  //====================================================//
62  }
63 }