/// Read the Eclipse grid format ('.grdecl').
    void CpGridData::processEclipseFormat(const grdecl& input_data, double z_tolerance, bool remove_ij_boundary, bool turn_normals)
    {
        // Process.
#ifdef VERBOSE
        std::cout << "Processing eclipse data." << std::endl;
#endif
        processed_grid output;
        process_grdecl(&input_data, z_tolerance, &output);
        if (remove_ij_boundary) {
            removeOuterCellLayer(output);
            // removeUnusedNodes(output);
        }

        // Move data into the grid's structures.
#ifdef VERBOSE
        std::cout << "Building topology." << std::endl;
#endif
        std::vector<int> face_to_output_face;
        buildTopo(output, global_cell_, cell_to_face_, face_to_cell_, face_to_point_, cell_to_point_, face_to_output_face);
        std::copy(output.dimensions, output.dimensions + 3, logical_cartesian_size_.begin());

#ifdef VERBOSE
        std::cout << "Building geometry." << std::endl;
#endif
        buildGeom(output, cell_to_face_, cell_to_point_, face_to_output_face, geometry_, face_normals_, allcorners_, turn_normals);

#ifdef VERBOSE
        std::cout << "Assigning face tags." << std::endl;
#endif
        int nf = face_to_output_face.size();
        std::vector<enum face_tag> temp_tags(nf);
        for (int i = 0; i < nf; ++i) {
            temp_tags[i] = output.face_tag[face_to_output_face[i]];
        }
        face_tag_.assign(temp_tags.begin(), temp_tags.end());

#ifdef VERBOSE
        std::cout << "Cleaning up." << std::endl;
#endif
        // Clean up the output struct.
        free_processed_grid(&output);

        computeUniqueBoundaryIds();

#ifdef VERBOSE
        std::cout << "Done with grid processing." << std::endl;
#endif
    }
Beispiel #2
0
/* ---------------------------------------------------------------------- */
void
mexFunction(int nlhs,       mxArray *plhs[],
            int nrhs, const mxArray *prhs[])
/* ---------------------------------------------------------------------- */
{
    double                tolerance;
    char                  errmsg[1023 + 1];
    struct grdecl         grdecl;
    struct processed_grid g;

    if (args_ok(nlhs, nrhs, prhs)) {
        mx_init_grdecl(&grdecl, prhs[0]);
        tolerance = define_tolerance(nrhs, prhs);

        process_grdecl(&grdecl, tolerance, &g);

        plhs[0] = allocate_grid(&g, mexFunctionName());

        if (plhs[0] != NULL) {
            fill_grid(plhs[0], &g);
        } else {
            /* Failed to create grid structure.  Return empty. */
            plhs[0] = mxCreateDoubleMatrix(0, 0, mxREAL);
        }

        free_processed_grid(&g);
    } else {
        sprintf(errmsg,
                "Calling sequence is\n\t"
                "G = %s(grdecl)\t%%or\n\t"
                "G = %s(grdecl, tolerance)\n"
                "The 'grdecl' must be a valid structure with fields\n"
                "\t'cartDims', 'COORD', 'ZCORN'",
                mexFunctionName(), mexFunctionName());
        mexErrMsgTxt(errmsg);
    }
}