Beispiel #1
0
    void initBlackoilSurfvol(const UnstructuredGrid& grid,
                             const Props& props,
                             State& state)
    {
        state.surfacevol() = state.saturation();
        const int np = props.numPhases();
        const int nc = grid.number_of_cells;
        std::vector<double> allA(nc*np*np);
        std::vector<int> allcells(nc);
        for (int c = 0; c < nc; ++c) {
            allcells[c] = c;
        }
        // Assuming that using the saturation as z argument here does not change
        // the outcome. This is not guaranteed unless we have only a single phase
        // per cell.
        props.matrix(nc, &state.pressure()[0], &state.surfacevol()[0], &allcells[0], &allA[0], 0);
        for (int c = 0; c < nc; ++c) {
            // Using z = As
            double* z = &state.surfacevol()[c*np];
            const double* s = &state.saturation()[c*np];
            const double* A = &allA[c*np*np];

            for (int row = 0; row < np; ++row) { z[row] = 0.0; }

            for (int col = 0; col < np; ++col) {
                for (int row = 0; row < np; ++row) {
                    // Recall: A has column-major ordering.
                    z[row] += A[row + np*col]*s[col];
                }
            }
        }
    }
GuiEditBoundaryConditions::GuiEditBoundaryConditions()
{
  connect(m_Ui.pushButtonAdd, SIGNAL(clicked()), this, SLOT(addVol()));
  connect(m_Ui.pushButtonDelete, SIGNAL(clicked()), this, SLOT(delVol()));
  connect(m_Ui.pushButtonAddBoundaryType, SIGNAL(clicked()), this, SLOT(addBoundaryType()));
  connect(m_Ui.pushButtonDeleteBoundaryType, SIGNAL(clicked()), this, SLOT(deleteBoundaryType()));
  connect(m_Ui.listWidgetBoundaryType, SIGNAL(itemSelectionChanged()), this, SLOT(changePhysicalValues()));
  connect(m_Ui.pushButton_AddProcess, SIGNAL(clicked()), this, SLOT(addProcess()));
  connect(m_Ui.pushButton_RemoveProcess, SIGNAL(clicked()), this, SLOT(deleteProcess()));
  connect(m_Ui.pushButton_ImportHostFile, SIGNAL(clicked()), this, SLOT(importHostFile()));
  connect(m_Ui.pushButton_ExportHostFile, SIGNAL(clicked()), this, SLOT(exportHostFile()));
  connect(m_Ui.pushButtonAllA, SIGNAL(clicked()), this, SLOT(allA()));
  connect(m_Ui.pushButtonAllB, SIGNAL(clicked()), this, SLOT(allB()));
  connect(m_Ui.pushButtonAllOff, SIGNAL(clicked()), this, SLOT(allOff()));

  setupSolvers();
  loadMpiParameters();

  m_BcMap = NULL;
  delegate = new GuiVolumeDelegate();
  delegate->setFirstCol(3);

  //set initial tab
  m_Ui.tabWidget->setCurrentIndex(0);
}
    /// @brief Computes saturation from surface volume
    void computeSaturation(const BlackoilPropertiesInterface& props,
                           BlackoilState& state)
    {

        const int np = props.numPhases();
        const int nc = props.numCells();
        std::vector<double> allA(nc*np*np);
        std::vector<int> allcells(nc);
        for (int c = 0; c < nc; ++c) {
            allcells[c] = c;
        }

        //std::vector<double> res_vol(np);
        const std::vector<double>& z = state.surfacevol();

        props.matrix(nc, &state.pressure()[0], &z[0], &allcells[0], &allA[0], 0);

        // Linear solver.
        MAT_SIZE_T n = np;
        MAT_SIZE_T nrhs = 1;
        MAT_SIZE_T lda = np;
        std::vector<MAT_SIZE_T> piv(np);
        MAT_SIZE_T ldb = np;
        MAT_SIZE_T info = 0;


        //double res_vol;
        double tot_sat;
        const double epsilon = std::sqrt(std::numeric_limits<double>::epsilon());

        for (int c = 0; c < nc; ++c) {
            double* A = &allA[c*np*np];
            const double* z_loc = &z[c*np];
            double* s = &state.saturation()[c*np];

            for (int p = 0; p < np; ++p){
                s[p] = z_loc[p];
                }

            dgesv_(&n, &nrhs, &A[0], &lda, &piv[0], &s[0], &ldb, &info);

            tot_sat = 0;
            for (int p = 0; p < np; ++p){
                if (s[p] < epsilon) // saturation may be less then zero due to round of errors
                    s[p] = 0;

                tot_sat += s[p];
            }

            for (int p = 0; p < np; ++p){
                s[p]  = s[p]/tot_sat;
            }





        }

    }