void peano::applications::heatequation::timestepping::mappings::SpacetreeGrid2Smooth::enterCell(
    peano::applications::heatequation::timestepping::SpacetreeGridCell&                           fineGridCell,
    peano::applications::heatequation::timestepping::SpacetreeGridSingleStepVertex * const        fineGridVertices,
    const peano::kernel::gridinterface::VertexEnumerator&                                         fineGridVerticesEnumerator,
    peano::applications::heatequation::timestepping::SpacetreeGridSingleStepVertex const * const  coarseGridVertices,
    const peano::kernel::gridinterface::VertexEnumerator&                                         coarseGridVerticesEnumerator,
    const peano::applications::heatequation::timestepping::SpacetreeGridCell&                     coarseGridCell,
    const tarch::la::Vector<DIMENSIONS,int>&                                                      fineGridPositionOfCell
) {
    bool isCurrentActiveGrid =
        fineGridVerticesEnumerator.getLevel()==_activeLevel;
    bool isCoarserLevelThanCurrentFineGridButBelongsToFineGrid =
        !fineGridCell.isRefined() &&
        fineGridVerticesEnumerator.getLevel()<_activeLevel;
    bool isCoarserLevelThanCurrentFineGridButIsAdjacentToFineGrid =
        fineGridCell.isRefined() &&
        peano::kernel::spacetreegrid::aspects::VertexStateAnalysis::doesOneVertexCarryRefinementFlag(fineGridVertices,fineGridVerticesEnumerator,peano::applications::heatequation::timestepping::SpacetreeGridSingleStepVertex::Records::Unrefined) &&
        fineGridVerticesEnumerator.getLevel()<_activeLevel;
    if ( isCurrentActiveGrid || isCoarserLevelThanCurrentFineGridButBelongsToFineGrid || isCoarserLevelThanCurrentFineGridButIsAdjacentToFineGrid ) {
        logTraceInWith4Arguments( "enterCell(...)", fineGridCell, fineGridVerticesEnumerator.toString(), coarseGridCell, fineGridPositionOfCell );
#ifdef Debug
        dfor2(k)
        logDebug( "enterCell(...)", "  - vertex " << kScalar << "=" << fineGridVertices[fineGridVerticesEnumerator(k)] );
        enddforx
#endif

        _solver.computeResidualOnCell(fineGridVertices,fineGridVerticesEnumerator);

        logTraceOutWith1Argument( "enterCell(...)", fineGridCell );
#ifdef Debug
        dfor2(k)
        logDebug( "enterCell(...)", "  - vertex " << kScalar << "=" << fineGridVertices[fineGridVerticesEnumerator(k)] );
        enddforx
#endif
    }
void peano::applications::poisson::jacobitutorial::mappings::RegularGrid2PlotSolution::handleCell(
  peano::applications::poisson::jacobitutorial::RegularGridVertex* const vertices,
  peano::applications::poisson::jacobitutorial::RegularGridCell&  cell,
  const peano::kernel::gridinterface::VertexEnumerator&  enumerator
) {
  logTraceInWith2Arguments( "handleCell()", enumerator.toString(), cell );

  /**
   * --- inserted manually ---
   *
   * This is just cell plot mechanics. As the cells have no properties, it is
   * exactly the same what the grid plotter which is generated does.
   */
  tarch::multicore::Lock localLock( _outputStreamSemaphore );

  assertion( DIMENSIONS==2 || DIMENSIONS==3 );
  int vertexIndex[TWO_POWER_D];
  dfor2(i)
    tarch::la::Vector<DIMENSIONS,double> currentVertexPosition = enumerator.getVertexPosition(i);
    assertion1 ( _vertex2IndexMap.find(currentVertexPosition) != _vertex2IndexMap.end(), currentVertexPosition );
    vertexIndex[iScalar] = _vertex2IndexMap[currentVertexPosition];
  enddforx

  if (DIMENSIONS==2) {
    _cellWriter->plotQuadrangle(vertexIndex);
  }
  if (DIMENSIONS==3) {
    _cellWriter->plotHexahedron(vertexIndex);
  }

  logTraceOut( "handleCell()" );
}
void peano::applications::pic::demo2::mappings::RegularGrid2PlotSolution::handleCell(
  peano::applications::pic::demo2::RegularGridVertex* const vertices,
  peano::applications::pic::demo2::RegularGridCell&  cell,
  const peano::kernel::gridinterface::VertexEnumerator&  enumerator
) {
  logTraceInWith2Arguments( "handleCell()", enumerator.toString(), cell );
  // @todo Insert your code here
	assertion( DIMENSIONS==2 || DIMENSIONS==3 );
	int vertexIndex[TWO_POWER_D];
	dfor2(i)
	    tarch::la::Vector<DIMENSIONS,double> currentVertexPosition = enumerator.getVertexPosition(i);
	    assertion1 ( _vertex2IndexMap.find(currentVertexPosition) != _vertex2IndexMap.end(), currentVertexPosition );
	    assertion1( _vertex2IndexMap[currentVertexPosition]>=0, _vertex2IndexMap[currentVertexPosition] );
	    vertexIndex[iScalar] = _vertex2IndexMap[currentVertexPosition];
	enddforx

	int cellIndex;
	if (DIMENSIONS==2) {
	  cellIndex = _cellWriter->plotQuadrangle(vertexIndex);
	}
	if (DIMENSIONS==3) {
	  cellIndex = _cellWriter->plotHexahedron(vertexIndex);
	}

	_cellPWriter->plotCell( cellIndex,cell.getP() );
  logTraceOut( "handleCell()" );
}
void peano::applications::pic::demo2::mappings::SpacetreeGrid2PlotSolution::enterCell(
      peano::applications::pic::demo2::SpacetreeGridCell&                 fineGridCell,
      peano::applications::pic::demo2::SpacetreeGridVertex * const        fineGridVertices,
      const peano::kernel::gridinterface::VertexEnumerator&                fineGridVerticesEnumerator,
      peano::applications::pic::demo2::SpacetreeGridVertex const * const  coarseGridVertices,
      const peano::kernel::gridinterface::VertexEnumerator&                coarseGridVerticesEnumerator,
      const peano::applications::pic::demo2::SpacetreeGridCell&            coarseGridCell,
      const tarch::la::Vector<DIMENSIONS,int>&                             fineGridPositionOfCell
) {
  logTraceInWith4Arguments( "enterCell(...)", fineGridCell, fineGridVerticesEnumerator.toString(), coarseGridCell, fineGridPositionOfCell );
   if ( fineGridCell.isLeaf() ) {
	    assertion( DIMENSIONS==2 || DIMENSIONS==3 );
	    int vertexIndex[TWO_POWER_D];
	     dfor2(i)
	      tarch::la::Vector<DIMENSIONS,double> currentVertexPosition = fineGridVerticesEnumerator.getVertexPosition(i);
	      assertion1 ( _vertex2IndexMap.find(currentVertexPosition) != _vertex2IndexMap.end(), currentVertexPosition );
	      vertexIndex[iScalar] = _vertex2IndexMap[currentVertexPosition];
	    enddforx

	    int cellIndex;
	    if (DIMENSIONS==2) {
	      cellIndex = _cellWriter->plotQuadrangle(vertexIndex);
	    }
	    if (DIMENSIONS==3) {
	      cellIndex = _cellWriter->plotHexahedron(vertexIndex);
	    }

	    _cellPWriter->plotCell( cellIndex,fineGridCell.getP() );
	  }
  logTraceOutWith1Argument( "enterCell(...)", fineGridCell );
}
void peano::applications::poisson::multigrid::mappings::SpacetreeGrid2PlotSolution::enterCell(
      peano::applications::poisson::multigrid::SpacetreeGridCell&                 fineGridCell,
      peano::applications::poisson::multigrid::SpacetreeGridVertex * const        fineGridVertices,
      const peano::kernel::gridinterface::VertexEnumerator&                fineGridVerticesEnumerator,
      peano::applications::poisson::multigrid::SpacetreeGridVertex const * const  coarseGridVertices,
      const peano::kernel::gridinterface::VertexEnumerator&                coarseGridVerticesEnumerator,
      const peano::applications::poisson::multigrid::SpacetreeGridCell&            coarseGridCell,
      const tarch::la::Vector<DIMENSIONS,int>&                             fineGridPositionOfCell
) {
  logTraceInWith4Arguments( "enterCell(...)", fineGridCell, fineGridVerticesEnumerator.toString(), coarseGridCell, fineGridPositionOfCell );

  if (!fineGridCell.isRefined()) {
    #ifdef SharedTBB
    Vertex2IndexMapSemaphore::scoped_lock localLock(_vertex2IndexMapSemaphore);
    #elif SharedOMP
    assertionMsg( false, "here should be a critical section, but I don't know how to implement this. If you implement it, please add it to the templates, too." );
    #endif

    assertion( DIMENSIONS==2 || DIMENSIONS==3 );
    int vertexIndex[TWO_POWER_D];
    dfor2(i)
      tarch::la::Vector<DIMENSIONS,double> currentVertexPosition = fineGridVerticesEnumerator.getVertexPosition(i);
      assertion2 ( _vertex2IndexMap.find(currentVertexPosition) != _vertex2IndexMap.end(), currentVertexPosition, fineGridVertices[fineGridVerticesEnumerator(i)].toString() );
      vertexIndex[iScalar] = _vertex2IndexMap[currentVertexPosition];
    enddforx

    if (DIMENSIONS==2) {
      _cellWriter->plotQuadrangle(vertexIndex);
    }
    if (DIMENSIONS==3) {
      _cellWriter->plotHexahedron(vertexIndex);
    }
  }
void particles::pit::adapters::MoveParticlesAndPlot2VTKGridVisualiser_0::leaveCell(
      particles::pit::Cell&           fineGridCell,
      particles::pit::Vertex * const  fineGridVertices,
      const peano::grid::VertexEnumerator&          fineGridVerticesEnumerator,
      particles::pit::Vertex * const  coarseGridVertices,
      const peano::grid::VertexEnumerator&          coarseGridVerticesEnumerator,
      particles::pit::Cell&           coarseGridCell,
      const tarch::la::Vector<DIMENSIONS,int>&                       fineGridPositionOfCell
) {
  #ifdef Parallel
  if (fineGridCell.isLeaf() && !fineGridCell.isAssignedToRemoteRank()) {
  #else
  if (fineGridCell.isLeaf()) {
  #endif
    assertion( DIMENSIONS==2 || DIMENSIONS==3 );
    int vertexIndex[TWO_POWER_D];
     dfor2(i)
      tarch::la::Vector<DIMENSIONS,double> currentVertexPosition = fineGridVerticesEnumerator.getVertexPosition(i);
      assertion2 ( _vertex2IndexMap.find(currentVertexPosition) != _vertex2IndexMap.end(), currentVertexPosition, fineGridVertices[ fineGridVerticesEnumerator(i) ].toString() );
      vertexIndex[iScalar] = _vertex2IndexMap[currentVertexPosition];
    enddforx
  
    int cellIndex;
    if (DIMENSIONS==2) {
      cellIndex = _cellWriter->plotQuadrangle(vertexIndex);
    }
    if (DIMENSIONS==3) {
      cellIndex = _cellWriter->plotHexahedron(vertexIndex);
    }
    
    _cellStateWriter->plotCell(cellIndex,fineGridVerticesEnumerator.getCellFlags());
    _cellNormWriterX->plotCell(cellIndex,(fineGridCell.getMyNorm())[0]);
    _cellNormWriterY->plotCell(cellIndex,(fineGridCell.getMyNorm())[1]);
  }
}


void particles::pit::adapters::MoveParticlesAndPlot2VTKGridVisualiser_0::beginIteration(
  particles::pit::State&  solverState
) {
  assertion( _vtkWriter==0 );
  
  _vtkWriter = new tarch::plotter::griddata::unstructured::vtk::VTKTextFileWriter();
  
  _vertexWriter     = _vtkWriter->createVertexWriter();
  _cellWriter       = _vtkWriter->createCellWriter();
  
  _vertexTypeWriter               = _vtkWriter->createVertexDataWriter(particles::pit::Vertex::Records::getInsideOutsideDomainMapping()+"/Hanging=-1" ,1);
  _vertexRefinementControlWriter  = _vtkWriter->createVertexDataWriter(particles::pit::Vertex::Records::getRefinementControlMapping() ,1);
  _vertexAdjacentCellsHeight      = _vtkWriter->createVertexDataWriter( peano::grid::getCellFlagsLegend(),1);

  _cellStateWriter                = _vtkWriter->createCellDataWriter( "cell-flag(>=-1=stationary,-1=parallel-boundary,<=-2=not-stationary" ,1);
  _cellNormWriterX                = _vtkWriter->createCellDataWriter( "Norm,X-direction" ,1);
  _cellNormWriterY                = _vtkWriter->createCellDataWriter( "Norm,Y-direction" ,1);
}
void peano::applications::heatequation::timestepping::RegularGridSingleStepVertex::writeStencil(
  const peano::kernel::gridinterface::VertexEnumerator& enumerator,
  RegularGridSingleStepVertex* const vertices,
  const tarch::la::Vector<TWO_POWER_D_TIMES_THREE_POWER_D,double>& values
) {
  dfor2(x)
    tarch::la::Vector<THREE_POWER_D,double> temp;
    temp = tarch::la::slice<THREE_POWER_D>(values,xScalar*THREE_POWER_D);
    vertices[ enumerator(x) ]._vertexData.setStencil( temp );
  enddforx
}
void peano::applications::heatequation::timestepping::adapters::SpacetreeGrid2PlotGrid::enterCell(
      peano::applications::heatequation::timestepping::SpacetreeGridCell&                 fineGridCell,
      peano::applications::heatequation::timestepping::SpacetreeGridSingleStepVertex * const        fineGridVertices,
      const peano::kernel::gridinterface::VertexEnumerator&                fineGridVerticesEnumerator,
      peano::applications::heatequation::timestepping::SpacetreeGridSingleStepVertex const * const  coarseGridVertices,
      const peano::kernel::gridinterface::VertexEnumerator&                coarseGridVerticesEnumerator,
      const peano::applications::heatequation::timestepping::SpacetreeGridCell&            coarseGridCell,
      const tarch::la::Vector<DIMENSIONS,int>&                             fineGridPositionOfCell
) {
  logTraceInWith5Arguments( "enterCell(...)", fineGridCell, fineGridVerticesEnumerator.toString(), coarseGridVerticesEnumerator.toString(), coarseGridCell, fineGridPositionOfCell );


 
  #ifdef SharedTBB
  Vertex2IndexMapSemaphore::scoped_lock localLock(_vertex2IndexMapSemaphore);
  #elif SharedOMP
  #pragma omp critical
  #endif

  if ( fineGridCell.isLeaf() ) { 
    assertion( DIMENSIONS==2 || DIMENSIONS==3 );
    int vertexIndex[TWO_POWER_D];
     dfor2(i)
      tarch::la::Vector<DIMENSIONS,double> currentVertexPosition = fineGridVerticesEnumerator.getVertexPosition(i);
      assertion1 ( _vertex2IndexMap.find(currentVertexPosition) != _vertex2IndexMap.end(), currentVertexPosition );
      vertexIndex[iScalar] = _vertex2IndexMap[currentVertexPosition];
    enddforx
  
    int cellIndex;
    if (DIMENSIONS==2) {
      cellIndex = _cellWriter->plotQuadrangle(vertexIndex);
    }
    if (DIMENSIONS==3) {
      cellIndex = _cellWriter->plotHexahedron(vertexIndex);
    }

    #ifdef Parallel
    _cellDeltaWriter->plotCell( cellIndex,fineGridCell.getDelta() );
    _cellWeightWriter->plotCell( cellIndex,fineGridCell.getWeight() );
    #endif
  }
  
  logTraceOut( "enterCell(...)" );
}
void peano::applications::faxen::adapters::SpacetreeGrid2PlotGrid::enterCell(
      peano::applications::faxen::SpacetreeGridCell&                 fineGridCell,
      peano::applications::faxen::SpacetreeGridVertex * const        fineGridVertices,
      const peano::kernel::gridinterface::VertexEnumerator&                fineGridVerticesEnumerator,
      peano::applications::faxen::SpacetreeGridVertex const * const  coarseGridVertices,
      const peano::kernel::gridinterface::VertexEnumerator&                coarseGridVerticesEnumerator,
      const peano::applications::faxen::SpacetreeGridCell&            coarseGridCell,
      const tarch::la::Vector<DIMENSIONS,int>&                             fineGridPositionOfCell
) {
  logTraceInWith5Arguments( "enterCell(...)", fineGridCell, fineGridVerticesEnumerator.toString(), coarseGridVerticesEnumerator.toString(), coarseGridCell, fineGridPositionOfCell );


 
  #ifdef SharedTBB
  Vertex2IndexMapSemaphore::scoped_lock localLock(_vertex2IndexMapSemaphore);
  #elif SharedOMP
  assertionMsg( false, "here should be a critical section, but I don't know how to implement this. If you implement it, please add it to the templates, too." );
  #endif
 
  if ( fineGridCell.isLeaf() ) { 
    assertion( DIMENSIONS==2 || DIMENSIONS==3 );
    int vertexIndex[TWO_POWER_D];
     dfor2(i)
      tarch::la::Vector<DIMENSIONS,double> currentVertexPosition = fineGridVerticesEnumerator.getVertexPosition(i);
      assertion1 ( _vertex2IndexMap.find(currentVertexPosition) != _vertex2IndexMap.end(), currentVertexPosition );
      vertexIndex[iScalar] = _vertex2IndexMap[currentVertexPosition];
    enddforx
  
    int cellIndex;
    if (DIMENSIONS==2) {
      cellIndex = _cellWriter->plotQuadrangle(vertexIndex);
    }
    if (DIMENSIONS==3) {
      cellIndex = _cellWriter->plotHexahedron(vertexIndex);
    }

    #ifdef Parallel
    _cellDeltaWriter->plotCell( cellIndex,fineGridCell.getDelta() );
    _cellWeightWriter->plotCell( cellIndex,fineGridCell.getWeight() );
    #endif
  }
  
  logTraceOut( "enterCell(...)" );
}
Example #10
0
void scenario::diffusionequation::CornerPointField::plotInputDataToVTKFile(const std::string& outputFile) const {
  logTraceInWith1Argument( "plotInputDataToVTKFile(string)", outputFile );

  tarch::plotter::griddata::unstructured::vtk::VTKTextFileWriter writer;
  tarch::plotter::griddata::unstructured::UnstructuredGridWriter::VertexWriter*  vertexWriter   = writer.createVertexWriter();
  tarch::plotter::griddata::unstructured::UnstructuredGridWriter::CellWriter*    cellWriter     = writer.createCellWriter();
  tarch::plotter::griddata::Writer::CellDataWriter*                              cellLayerWriter        = writer.createCellDataWriter("layer-counter",1);
  tarch::plotter::griddata::Writer::CellDataWriter*                              cellPermeabilityWriter = writer.createCellDataWriter("permeability",1);

  #if defined(Dim2)
  #elif defined(Dim3)
  int entryCounter = 0;
  for (int y=0; y<_pillars(1); y++) {
    for (int x=0; x<_pillars(0); x++) {
      for (int layer=0; layer<static_cast<int>(_entries[entryCounter]._cells.size()); layer++){
        int                          vertexIndex[TWO_POWER_D];
        tarch::la::Vector<3,double>  position;

        dfor2(k)
          position(0)          = static_cast<double>(x+k(0)) * getCornerPointPillarWidth()(0) + _hexahedron.getOffset()(0);
          position(1)          = static_cast<double>(y+k(1)) * getCornerPointPillarWidth()(1) + _hexahedron.getOffset()(1);
          position(2)          = k(2)==0 ? _entries[entryCounter]._cells[layer]._cellsLowerLayer : _entries[entryCounter]._cells[layer]._cellsUpperLayer;
          vertexIndex[kScalar] = vertexWriter->plotVertex(position);
        enddforx

        int cellIndex = cellWriter->plotHexahedron(vertexIndex);
        cellPermeabilityWriter->plotCell( cellIndex, _entries[entryCounter]._cells[layer]._permeability );
        cellLayerWriter->plotCell( cellIndex, layer );

        #if defined(Asserts)
        position(0)          = (static_cast<double>(x)+0.5) * getCornerPointPillarWidth()(0) + _hexahedron.getOffset()(0);
        position(1)          = (static_cast<double>(y)+0.5) * getCornerPointPillarWidth()(1) + _hexahedron.getOffset()(1);
        position(2)          = 0.5 * (_entries[entryCounter]._cells[layer]._cellsLowerLayer + _entries[entryCounter]._cells[layer]._cellsUpperLayer);
        assertionNumericalEquals4(
         _entries[entryCounter]._cells[layer]._permeability,
          getPorosityFromDataSet(position),
          entryCounter, layer,
          position,
          _entries[entryCounter].toString()
        );
        #endif
      }
      entryCounter++;
    }
  }
  #endif

  vertexWriter->close();
  cellWriter->close();
  cellLayerWriter->close();
  cellPermeabilityWriter->close();

  delete vertexWriter;
  delete cellWriter;
  delete cellPermeabilityWriter;
  delete cellLayerWriter;

  writer.writeToFile( outputFile );

  logTraceOut( "plotInputDataToVTKFile(string)" );
}
 void peano::applications::heatequation::timestepping::RegularGridSingleStepVertex::writeResidual(const peano::kernel::gridinterface::VertexEnumerator& enumerator, RegularGridSingleStepVertex* const vertices, const tarch::la::Vector<TWO_POWER_D,double>& values ) { dfor2(x) vertices[ enumerator(x) ]._vertexData.setResidual( values(xScalar) ); enddforx }
tarch::la::Vector<TWO_POWER_D_TIMES_THREE_POWER_D,double>  peano::applications::heatequation::timestepping::RegularGridSingleStepVertex::readStencil(const peano::kernel::gridinterface::VertexEnumerator& enumerator, const RegularGridSingleStepVertex* const vertices)  { tarch::la::Vector<TWO_POWER_D_TIMES_THREE_POWER_D,double> result; dfor2(x) tarch::la::slice<THREE_POWER_D>(result,xScalar*THREE_POWER_D) = vertices[ enumerator(x) ]._vertexData.getStencil(); enddforx return result; }
tarch::la::Vector<TWO_POWER_D,double> peano::applications::heatequation::timestepping::RegularGridSingleStepVertex::readResidual(const peano::kernel::gridinterface::VertexEnumerator& enumerator, const RegularGridSingleStepVertex* const vertices) { tarch::la::Vector<TWO_POWER_D,double> result; dfor2(x) result(xScalar) = vertices[ enumerator(x) ]._vertexData.getResidual(); enddforx return result; }