Ejemplo n.º 1
0
double scenario::diffusionequation::CornerPointField::CornerPointPillar::getPermeability( double depth ) const {
  logTraceInWith2Arguments( "CornerPointPillar::getPermeability(double)", depth, toString() );

  if (_cells.empty()) {
    logTraceOutWith1Argument( "CornerPointPillar::getPermeability(double)", 0.0 );
    return 0.0;
  }

  int currentLayer = 0;
  while (
    (currentLayer < static_cast<int>(_cells.size())-1) &&
    (depth<_cells[currentLayer]._cellsLowerLayer)
  ) {
    currentLayer++;
  }

  if (
    (depth>_cells[currentLayer]._cellsUpperLayer) ||
    (depth<_cells[currentLayer]._cellsLowerLayer)
  ) {
    logTraceOutWith1Argument( "CornerPointPillar::getPermeability(double)", 0.0 );
    return 0.0;
  }

  double result = _cells[currentLayer]._permeability;
  logTraceOutWith2Arguments( "CornerPointPillar::getPermeability(double)", result, currentLayer );
  return result;
}
Ejemplo n.º 2
0
void peano::applications::heatequation::timestepping::mappings::SpacetreeGrid2Smooth::touchVertexLastTime(
    peano::applications::heatequation::timestepping::SpacetreeGridSingleStepVertex&         fineGridVertex,
    const tarch::la::Vector<DIMENSIONS,double>&                    fineGridX,
    const tarch::la::Vector<DIMENSIONS,double>&                    fineGridH,
    peano::applications::heatequation::timestepping::SpacetreeGridSingleStepVertex * const  coarseGridVertices,
    const peano::kernel::gridinterface::VertexEnumerator&          coarseGridVerticesEnumerator,
    peano::applications::heatequation::timestepping::SpacetreeGridCell&           coarseGridCell,
    const tarch::la::Vector<DIMENSIONS,int>&                       fineGridPositionOfVertex
) {
    bool isCurrentActiveGrid =
        coarseGridVerticesEnumerator.getLevel()+1==_activeLevel &&
        fineGridVertex.isInside();
    bool isCoarserLevelThanCurrentFineGridButBelongsToFineGrid =
        fineGridVertex.getRefinementControl()==SpacetreeGridSingleStepVertex::Records::Unrefined &&
        coarseGridVerticesEnumerator.getLevel()+1<_activeLevel &&
        fineGridVertex.isInside();
    if ( isCurrentActiveGrid || isCoarserLevelThanCurrentFineGridButBelongsToFineGrid ) {
        logTraceInWith9Arguments( "touchVertexLastTime(...)", isCurrentActiveGrid, isCoarserLevelThanCurrentFineGridButBelongsToFineGrid, _activeLevel, fineGridVertex, fineGridX, fineGridH, coarseGridVerticesEnumerator.toString(), coarseGridCell, fineGridPositionOfVertex );

        fineGridVertex.setTemperature(
            _solver.getNewTemperatureForImplicitEulerStep(
                fineGridH,
                fineGridVertex.getResidual(),
                fineGridVertex.getStencil(),
                fineGridVertex.getTemperature()
            )
        );
        logTraceOutWith2Arguments( "touchVertexLastTime(...)", fineGridVertex, _activeLevel );
    }
}
Ejemplo n.º 3
0
int peanoclaw::Area::getAreasOverlappedByRemoteGhostlayers(
  const tarch::la::Vector<THREE_POWER_D_MINUS_ONE, int>& adjacentRanks,
  tarch::la::Vector<THREE_POWER_D_MINUS_ONE, int>        overlapOfRemoteGhostlayers,
  const tarch::la::Vector<DIMENSIONS, int>&              subdivisionFactor,
  int                                                    rank,
  Area                                                   areas[THREE_POWER_D_MINUS_ONE]
) {
  logTraceInWith2Arguments("getAreasOverlappedByRemoteGhostlayers(...)", adjacentRanks, overlapOfRemoteGhostlayers);
  int  numberOfAreas = 0;
  bool oneAreaCoversCompleteSubgrid = false;

  for(int dimensionality = 0; dimensionality < DIMENSIONS; dimensionality++) {
    int numberOfManifolds = getNumberOfManifolds(dimensionality);
    for(int manifoldIndex = 0; manifoldIndex < numberOfManifolds; manifoldIndex++) {
      tarch::la::Vector<DIMENSIONS, int> manifoldPosition = getManifold(dimensionality, manifoldIndex);
      int manifoldEntry = linearizeManifoldPosition(manifoldPosition);

      logDebug("getAreasOverlappedByRemoteGhostlayers(...)", "Manifold " << manifoldPosition << " of dimensions " << dimensionality
          << ": entry=" << manifoldEntry << ", rank=" << adjacentRanks[manifoldEntry] << ", overlap=" << overlapOfRemoteGhostlayers[manifoldEntry]);

      if(adjacentRanks[manifoldEntry] == rank && overlapOfRemoteGhostlayers[manifoldEntry] > 0) {
        //Reduce lower-dimensional manifolds
        bool canBeOmitted = checkHigherDimensionalManifoldForOverlap(
          adjacentRanks,
          overlapOfRemoteGhostlayers,
          manifoldPosition,
          dimensionality,
          manifoldEntry,
          rank
        );

        //Restrict size and offset by higher-dimensional manifolds
        logDebug("getAreasOverlappedByRemoteGhostlayers(...)","Testing manifold " << manifoldPosition << " of dimensions " << dimensionality
            << ": " << (canBeOmitted ? "omitting" : "consider"));

        if(!canBeOmitted) {
          tarch::la::Vector<DIMENSIONS, int> size;
          tarch::la::Vector<DIMENSIONS, int> offset;

          //Initialise size and offset
          for(int d = 0; d < DIMENSIONS; d++) {
            size(d) = (manifoldPosition(d) == 0) ? subdivisionFactor(d) : std::min(subdivisionFactor(d), overlapOfRemoteGhostlayers[manifoldEntry]);
            offset(d) = (manifoldPosition(d) == 1) ? subdivisionFactor(d) - size(d) : 0;
          }

          //TODO unterweg debug
//          std::cout << "offset: " << offset << ", size: " << size << std::endl;

          for(int adjacentDimensionality = dimensionality - 1; adjacentDimensionality >= 0; adjacentDimensionality--) {
            int numberOfAdjacentManifolds = getNumberOfAdjacentManifolds(manifoldPosition, dimensionality, adjacentDimensionality);
            for(int adjacentManifoldIndex = 0; adjacentManifoldIndex < numberOfAdjacentManifolds; adjacentManifoldIndex++) {
              tarch::la::Vector<DIMENSIONS, int> adjacentManifoldPosition = getIndexOfAdjacentManifold(
                manifoldPosition,
                dimensionality,
                adjacentDimensionality,
                adjacentManifoldIndex
              );

              //TODO unterweg debug
//              std::cout << "adj. manifold " << adjacentManifoldPosition << std::endl;

              int adjacentEntry = linearizeManifoldPosition(adjacentManifoldPosition);

              if(adjacentRanks[adjacentEntry] == rank) {
                for(int d = 0; d < DIMENSIONS; d++) {
                  if(manifoldPosition(d) == 0) {
                    if(adjacentManifoldPosition(d) < 0) {
                      int overlap = std::max(0, overlapOfRemoteGhostlayers[adjacentEntry] - offset(d));
                      offset(d) += overlap;
                      size(d) -= overlap;

                      //TODO unterweg debug
//                      std::cout << "Reducing bottom " << overlap << std::endl;
                    } else if(adjacentManifoldPosition(d) > 0) {
                      assertion2(adjacentManifoldPosition(d) > 0, adjacentManifoldPosition, d);
                      int overlap = std::max(0, offset(d) + size(d) - (subdivisionFactor(d) - overlapOfRemoteGhostlayers[adjacentEntry]));
                      size(d) -= overlap;

                      //TODO unterweg debug
//                      std::cout << "Reducing top " << overlap << std::endl;
                    }
                  }
                }
              }
            }
          }

          logDebug("getAreasOverlappedByRemoteGhostlayers(...)", "offset: " << offset << ", size: " << size << ", dimensionality=" << dimensionality << ", manifoldIndex=" << manifoldIndex << ", manifoldEntry=" << manifoldEntry);
          if(tarch::la::allGreater(size, 0)) {
            areas[numberOfAreas++] = Area(offset, size);

            oneAreaCoversCompleteSubgrid |= (tarch::la::volume(size) >= tarch::la::volume(subdivisionFactor));

            assertion1(tarch::la::allGreaterEquals(offset, 0), offset);
            assertion3(tarch::la::allGreaterEquals(subdivisionFactor, offset + size), offset, size, subdivisionFactor);
          }
        }
      }
    }
  }

  //Optimize areas
  if(oneAreaCoversCompleteSubgrid) {
    numberOfAreas = 1;
    areas[0] = Area(0, subdivisionFactor);
  }

  logTraceOutWith2Arguments("getAreasOverlappedByRemoteGhostlayers(...)", numberOfAreas, areas);
  return numberOfAreas;
}