void TransportSolverCompressibleTwophaseReorder::initGravity(const double* grav)
{
    // Set up transmissibilities.
    std::vector<double> htrans(grid_.cell_facepos[grid_.number_of_cells]);
    const int nf = grid_.number_of_faces;
    trans_.resize(nf);
    gravflux_.resize(nf);
    tpfa_htrans_compute(const_cast<UnstructuredGrid*>(&grid_), props_.permeability(), &htrans[0]);
    tpfa_trans_compute(const_cast<UnstructuredGrid*>(&grid_), &htrans[0], &trans_[0]);

    // Remember gravity vector.
    gravity_ = grav;
}
예제 #2
0
int fits_hcompress(int *a, int ny, int nx, int scale, char *output, 
                  long *nbytes, int *status)
{
  /* 
     compress the input image using the H-compress algorithm
  
   a  - input image array
   nx - size of X axis of image
   ny - size of Y axis of image
   scale - quantization scale factor. Larger values results in more (lossy) compression
           scale = 0 does lossless compression
   output - pre-allocated array to hold the output compressed stream of bytes
   nbyts  - input value = size of the output buffer;
            returned value = size of the compressed byte stream, in bytes

 NOTE: the nx and ny dimensions as defined within this code are reversed from
 the usual FITS notation.  ny is the fastest varying dimension, which is
 usually considered the X axis in the FITS image display

  */

  int stat;
  
  if (*status > 0) return(*status);

  /* H-transform */
  stat = htrans(a, nx, ny);
  if (stat) {
     *status = stat;
     return(*status);
  }

  /* digitize */
  digitize(a, nx, ny, scale);

  /* encode and write to output array */

  FFLOCK;
  noutmax = *nbytes;  /* input value is the allocated size of the array */
  *nbytes = 0;  /* reset */

  stat = encode(output, nbytes, a, nx, ny, scale);
  FFUNLOCK;
  
  *status = stat;
  return(*status);
}
예제 #3
0
        DerivedGeology(const UnstructuredGrid& grid,
                       const Props&            props ,
                       const double*           grav = 0)
            : pvol_ (grid.number_of_cells)
            , trans_(grid.number_of_faces)
            , gpot_ (Vector::Zero(grid.cell_facepos[ grid.number_of_cells ], 1))
        {
            // Pore volume
            const typename Vector::Index nc = grid.number_of_cells;
            std::transform(grid.cell_volumes, grid.cell_volumes + nc,
                           props.porosity(), pvol_.data(),
                           std::multiplies<double>());

            // Transmissibility
            Vector htrans(grid.cell_facepos[nc]);
            UnstructuredGrid* ug = const_cast<UnstructuredGrid*>(& grid);
            tpfa_htrans_compute(ug, props.permeability(), htrans.data());
            tpfa_trans_compute (ug, htrans.data()     , trans_.data());

            // Gravity potential
            std::fill(gravity_, gravity_ + 3, 0.0);
            if (grav != 0) {
                const typename Vector::Index nd = grid.dimensions;

                for (typename Vector::Index c = 0; c < nc; ++c) {
                    const double* const cc = & grid.cell_centroids[c*nd + 0];

                    const int* const p = grid.cell_facepos;
                    for (int i = p[c]; i < p[c + 1]; ++i) {
                        const int f = grid.cell_faces[i];

                        const double* const fc = & grid.face_centroids[f*nd + 0];

                        for (typename Vector::Index d = 0; d < nd; ++d) {
                            gpot_[i] += grav[d] * (fc[d] - cc[d]);
                        }
                    }
                }
                std::copy(grav, grav + nd, gravity_);
            }
        }
 void TransportSolverTwophaseReorder::initGravity(const double* grav)
 {
     // Set up gravflux_ = T_ij g (rho_w - rho_o) (z_i - z_j)
     std::vector<double> htrans(grid_.cell_facepos[grid_.number_of_cells]);
     const int nf = grid_.number_of_faces;
     const int dim = grid_.dimensions;
     gravflux_.resize(nf);
     tpfa_htrans_compute(const_cast<UnstructuredGrid*>(&grid_), props_.permeability(), &htrans[0]);
     tpfa_trans_compute(const_cast<UnstructuredGrid*>(&grid_), &htrans[0], &gravflux_[0]);
     const double delta_rho = props_.density()[0] - props_.density()[1];
     for (int f = 0; f < nf; ++f) {
         const int* c = &grid_.face_cells[2*f];
         double gdz = 0.0;
         if (c[0] != -1 && c[1] != -1) {
             for (int d = 0; d < dim; ++d) {
                 gdz += grav[d]*(grid_.cell_centroids[dim*c[0] + d] - grid_.cell_centroids[dim*c[1] + d]);
             }
         }
         gravflux_[f] *= delta_rho*gdz;
     }
 }