void peano::applications::latticeboltzmann::blocklatticeboltzmann::RegularGridBlockVertex::mergeDensityOnBoundary(const RegularGridBlockVertex& neighbour) {
  assertion2((getVertexNumber()==0) || (getVertexNumber()==peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().getVertexNumber()),getVertexNumber(),peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().getVertexNumber());
  tarch::la::Vector<LB_BLOCK_NUMBER_OF_CELLS,double> &density = peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().getDensity();

  // merge density values in outer close-to-boundary cells
  for (int i = 0; i < LB_BLOCK_NUMBER_OF_CELLS_ON_BLOCKBOUNDARY; i++){
    int index = peano::applications::latticeboltzmann::blocklatticeboltzmann::BLOCKBOUNDARYINDEX.getBlockIndex(i);
    if (   (!peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().getInner()[index])
        && peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().getBoundary()[index]){
#ifdef Debug
      assertion4 ( (Base::_vertexData.getLbDensityOnBoundary(i) == 0.0) || (neighbour.getDensityOnBoundary(i) == 0.0),Base::_vertexData.getLbDensityOnBoundary(i),neighbour.getDensityOnBoundary(i),index,getX() );
#endif
      density(index) += neighbour.getDensityOnBoundary(i);
    }
  }
}
void peano::applications::latticeboltzmann::blocklatticeboltzmann::RegularGridBlockVertex::initPdfDiff(){
  assertion(getVertexNumber()==peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().getVertexNumber());
  for (int i = 0; i < LB_PDFS_ON_BLOCKBOUNDARY; i++){
    // save pdfs pointing out of the block
    Base::_vertexData.setLbPdfDiff(
      i,
      -peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().getPdf()(peano::applications::latticeboltzmann::blocklatticeboltzmann::parallel::BLOCKBOUNDARYINDEX4PDFS.getOutgoingPdf(i))
    );
  }
}
void peano::applications::latticeboltzmann::blocklatticeboltzmann::RegularGridBlockVertex::mergePdfDiff(const RegularGridBlockVertex& neighbour) {
  assertion2((getVertexNumber()==0) || (getVertexNumber()==peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().getVertexNumber()),getVertexNumber(),peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().getVertexNumber());
  tarch::la::Vector<LB_BLOCK_NUMBER_OF_CELLS*LB_CURRENT_DIR,double>& pdf = peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().getPdf();
  // add difference to pdfs
  for (int i = 0; i < LB_PDFS_ON_BLOCKBOUNDARY; i++){
    // if the current pdf-field has not changed
    // -> either the same amount was transfered from some neighbour cell; in this case, adding the difference (which should also
    //    equal zero) should not matter at all
    // -> or: there was no transfer, as the process boundary passes through here; in this case, adding the difference
    //    will just make everything right ;-)
    if (Base::_vertexData.getLbPdfDiff(i) == 0.0){
      pdf(peano::applications::latticeboltzmann::blocklatticeboltzmann::parallel::BLOCKBOUNDARYINDEX4PDFS.getIncomingPdf(i)) =
        pdf(
        peano::applications::latticeboltzmann::blocklatticeboltzmann::parallel::BLOCKBOUNDARYINDEX4PDFS.getIncomingPdf(i)
        )
        + neighbour.getPdfDiff(i);
    }
  }
}
Esempio n. 4
0
void cMesh::clean()
{
    int nbFaces = getFacesNumber();
    for(int i=0 ; i < nbFaces; i++)
    {
        cTriangle * Triangle = getTriangle(i);

        if (Triangle->getEdgesNumber() < 3 && !Triangle->isTextured())
        {
            //cout <<"remove triangle " << Triangle->getIdx() << " with " << Triangle->getEdgesNumber() << " edges" << endl;

            //cout <<"sommets = " << Triangle->getVertex(0) << " " << Triangle->getVertex(1) << " " << Triangle->getVertex(2) << endl;

            removeTriangle(*Triangle);
            nbFaces--;
            i--;
        }
        /*else if (!Triangle->isTextured())
            cout << "triangle " << i << " nb edges = " << Triangle->getEdgesNumber() << " textured= " << Triangle->isTextured() << endl;*/
    }

    //suppression des points n'appartenant à aucun triangle
    for(int aK=0; aK < getVertexNumber();++aK)
    {
        bool found = false;
        for(int i=0 ; i < nbFaces; i++)
        {
            int vertex1, vertex2, vertex3;
            getTriangle(i)->getVertexesIndexes(vertex1, vertex2, vertex3);

            if ((aK==vertex1) || (aK==vertex2) || (aK==vertex3))
            {
                found = true;
                break;
            }
        }

        if (!found) //remove this point
        {
            mVertexes.erase(std::remove(mVertexes.begin(), mVertexes.end(), mVertexes[aK]), mVertexes.end());

            for(int i=0 ; i < nbFaces; i++)
            {
                cTriangle * tri= getTriangle(i);
                int vertex1, vertex2, vertex3;
                tri->getVertexesIndexes(vertex1, vertex2, vertex3);

                if (vertex1>aK) tri->setVertexIndex(0, vertex1-1);
                if (vertex2>aK) tri->setVertexIndex(1, vertex2-1);
                if (vertex3>aK) tri->setVertexIndex(2, vertex3-1);

            }
        }
    }
}
void peano::applications::latticeboltzmann::blocklatticeboltzmann::RegularGridBlockVertex::
setDensityOnBlockBoundary(bool useDynamicGeometry){
  if(!useDynamicGeometry){
    return;
  }

  assertion(getVertexNumber()==peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().getVertexNumber());
  // loop over all cells near the block boundary and copy density values from the grid management service
  // to the parallel buffer
  for (int i = 0; i < LB_BLOCK_NUMBER_OF_CELLS_ON_BLOCKBOUNDARY; i++){
    int index = peano::applications::latticeboltzmann::blocklatticeboltzmann::BLOCKBOUNDARYINDEX.getBlockIndex(i);
    if (   (!peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().getInner()[index])
        && ( peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().getBoundary()[index]) ){
      Base::_vertexData.setLbDensityOnBoundary(
        i,
        peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().getDensity()(index)
      );
    } else {
      Base::_vertexData.setLbDensityOnBoundary(i,0.0);
    }
  }
}
void peano::applications::latticeboltzmann::blocklatticeboltzmann::RegularGridBlockVertex::destroyVertex() const{
  peano::applications::latticeboltzmann::blocklatticeboltzmann::services::GridManagementService::getInstance().
  destroyVertex(getVertexNumber());
}