Пример #1
0
 inline void MinpvProcessor::setCellZcorn(const int i, const int j, const int k, const std::array<double, 8>& cellz, double* z) const
 {
     const std::array<int, 8> ixs = cornerIndices(i, j, k);
     for (int count = 0; count < 8; ++count) {
         z[ixs[count]] = cellz[count];
     }
 }
inline typename DefaultLocalAssemblerForOperatorsOnSurfacesUtilities<
    BasisFunctionType>::CoordinateType
DefaultLocalAssemblerForOperatorsOnSurfacesUtilities<BasisFunctionType>::
    elementSizeSquared(int elementIndex,
                       const RawGridGeometry<CoordinateType> &rawGeometry) {
  // This implementation could be optimised
  CoordinateType maxEdgeLengthSquared = 0.;
  const arma::Mat<int> &cornerIndices = rawGeometry.elementCornerIndices();
  const arma::Mat<CoordinateType> &vertices = rawGeometry.vertices();
  arma::Col<CoordinateType> edge;
  if (cornerIndices(cornerIndices.n_rows - 1, elementIndex) == -1) {
    // Triangular element
    const int cornerCount = 3;
    for (int i = 0; i < cornerCount; ++i) {
      edge = vertices.col(cornerIndices((i + 1) % cornerCount, elementIndex)) -
             vertices.col(cornerIndices(i, elementIndex));
      CoordinateType edgeLengthSquared = arma::dot(edge, edge);
      maxEdgeLengthSquared = std::max(maxEdgeLengthSquared, edgeLengthSquared);
    }
  } else {
    // Quadrilateral element. We assume it is convex.
    edge = vertices.col(cornerIndices(2, elementIndex)) -
           vertices.col(cornerIndices(0, elementIndex));
    maxEdgeLengthSquared = arma::dot(edge, edge);
    edge = vertices.col(cornerIndices(3, elementIndex)) -
           vertices.col(cornerIndices(1, elementIndex));
    CoordinateType edgeLengthSquared = arma::dot(edge, edge);
    maxEdgeLengthSquared = std::max(maxEdgeLengthSquared, edgeLengthSquared);
  }
  return maxEdgeLengthSquared;
}
Пример #3
0
 // Returns the eight z-values associated with a given cell.
 // The ordering is such that i runs fastest. That is, with
 // L = low and H = high:
 // {LLL, HLL, LHL, HHL, LLH, HLH, LHH, HHH }.
 inline std::array<double, 8> MinpvProcessor::getCellZcorn(const int i, const int j, const int k, const double* z) const
 {
     const std::array<int, 8> ixs = cornerIndices(i, j, k);
     std::array<double, 8> cellz;
     for (int count = 0; count < 8; ++count) {
         cellz[count] = z[ixs[count]];
     }
     return cellz;
 }
inline Vector<typename DefaultLocalAssemblerForOperatorsOnSurfacesUtilities<
    BasisFunctionType>::CoordinateType>
DefaultLocalAssemblerForOperatorsOnSurfacesUtilities<BasisFunctionType>::
    elementCenter(int elementIndex,
                  const RawGridGeometry<CoordinateType> &rawGeometry) {
  const Matrix<int> &cornerIndices = rawGeometry.elementCornerIndices();
  const Matrix<CoordinateType> &vertices = rawGeometry.vertices();
  const int maxCornerCount = cornerIndices.rows();
  // each element has at least one corner
  Vector<CoordinateType> center(vertices.col(cornerIndices(0, elementIndex)));
  int i = 1;
  for (; i < maxCornerCount; ++i) {
    int cornerIndex = cornerIndices(i, elementIndex);
    if (cornerIndex == -1)
      break;
    center += vertices.col(cornerIndex);
  }
  // now i contains the number of corners of the specified element
  center /= i;
  return center;
}