//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RigReservoirBuilderMock::addFaults(RigEclipseCaseData* eclipseCase) { if (!eclipseCase) return; RigMainGrid* grid = eclipseCase->mainGrid(); if (!grid) return; cvf::Collection<RigFault> faults; { cvf::ref<RigFault> fault = new RigFault; fault->setName("Fault A"); cvf::Vec3st min = cvf::Vec3st::ZERO; cvf::Vec3st max(0, 0, cellDimension().z() - 2); if (cellDimension().x() > 5) { min.x() = cellDimension().x() / 2; max.x() = min.x() + 2; } if (cellDimension().y() > 5) { min.y() = cellDimension().y() / 2; max.y() = cellDimension().y() / 2; } cvf::CellRange cellRange(min, max); fault->addCellRangeForFace(cvf::StructGridInterface::POS_I, cellRange); faults.push_back(fault.p()); } grid->setFaults(faults); // NNCs std::vector<RigConnection>& nncConnections = grid->nncData()->connections(); { size_t i1 = 2; size_t j1 = 2; size_t k1 = 3; size_t i2 = 2; size_t j2 = 3; size_t k2 = 4; addNnc(grid, i1, j1, k1, i2, j2, k2, nncConnections); } { size_t i1 = 2; size_t j1 = 2; size_t k1 = 3; size_t i2 = 2; size_t j2 = 1; size_t k2 = 4; addNnc(grid, i1, j1, k1, i2, j2, k2, nncConnections); } std::vector<double>& tranVals = grid->nncData()->makeStaticConnectionScalarResult(RigNNCData::propertyNameCombTrans()); for (size_t cIdx = 0; cIdx < tranVals.size(); ++cIdx) { tranVals[cIdx] = 0.2; } }
//------------------------------------------------------------------------------------------------------ //setter function that assigns string text to object //------------------------------------------------------------------------------------------------------ void Text::SetText(const std::string& text) { m_text = text; //offsets for VBO data loading below //buffers have different sizes GLuint offsetVert = 0; GLuint offsetColor = 0; GLuint offsetText = 0; GLuint offsetIndex = 0; glm::vec2 textureCell; //loop through the entire text string and //create buffer data for each character for (size_t i = 0; i < m_text.size(); i++) { //*********************** //vertices //*********************** //data that represents vertices for text image //they are whole number values since a pixel is whole GLuint vertices[] = { 0 + i, 1, 0, 1 + i, 1, 0, 1 + i, 0, 0, 0 + i, 0, 0 }; //fill vertex VBO and progress offset m_buffer.AppendVBO(Buffer::VERTEX_BUFFER, vertices, sizeof(vertices), offsetVert); offsetVert += sizeof(vertices); //*********************** //colors //*********************** //data that represents colors for text image //they will all be white for each letter by default GLfloat colors[] = { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }; //fill color VBO and progress offset m_buffer.AppendVBO(Buffer::COLOR_BUFFER, colors, sizeof(colors), offsetColor); offsetColor += sizeof(colors); //*********************** //UVs //*********************** //the texture index is the actual ASCII value of the letter int textureIndex = m_text[i]; //use modulo and divide with the texture index to get exact column/row //index to "cut out", because with text, the texture cell is dynamic textureCell.x = (float)(textureIndex % (int)m_textureDimension.x); textureCell.y = (float)(textureIndex / m_textureDimension.y); //calculate the width and height of each cell relative to the entire texture //this gives us a normalized dimension value for each "cell" in the sprite sheet glm::vec2 cellDimension(1.0f / m_textureDimension.x, 1.0f / m_textureDimension.y); //take the desired cell to "cut out" and multiply it by the cell's dimension value //this gives us a normalized texture coordinate value that is our "starting point" glm::vec2 texCoordOrigin = textureCell * cellDimension; //create new UV data that for our texture coordinates GLfloat UVs[] = { texCoordOrigin.x, texCoordOrigin.y, texCoordOrigin.x + cellDimension.x, texCoordOrigin.y, texCoordOrigin.x + cellDimension.x, texCoordOrigin.y + cellDimension.y, texCoordOrigin.x, texCoordOrigin.y + cellDimension.y }; //fill UV VBO and progress offset m_buffer.AppendVBO(Buffer::TEXTURE_BUFFER, UVs, sizeof(UVs), offsetText); offsetText += sizeof(UVs); //*********************** //indices //*********************** //data that represents indeces for text image GLuint indices[] = { 0 + 4 * i, 1 + 4 * i, 3 + 4 * i, 3 + 4 * i, 1 + 4 * i, 2 + 4 * i }; //fill UV VBO and progress offset m_buffer.AppendEBO(indices, sizeof(indices), offsetIndex); offsetIndex += sizeof(indices); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RigReservoirBuilderMock::populateReservoir(RigEclipseCaseData* eclipseCase) { std::vector<cvf::Vec3d>& mainGridNodes = eclipseCase->mainGrid()->nodes(); appendNodes(m_minWorldCoordinate, m_maxWorldCoordinate, cellDimension(), mainGridNodes); size_t mainGridNodeCount = mainGridNodes.size(); size_t mainGridCellCount = mainGridNodeCount / 8; // Must create cells in main grid here, as this information is used when creating LGRs appendCells(0, mainGridCellCount, eclipseCase->mainGrid(), eclipseCase->mainGrid()->globalCellArray()); size_t totalCellCount = mainGridCellCount; size_t lgrIdx; for (lgrIdx = 0; lgrIdx < m_localGridRefinements.size(); lgrIdx++) { LocalGridRefinement& lgr = m_localGridRefinements[lgrIdx]; // Compute all global cell indices to be replaced by local grid refinement std::vector<size_t> mainGridIndicesWithSubGrid; { size_t i; for (i = lgr.m_mainGridMinCellPosition.x(); i <= lgr.m_mainGridMaxCellPosition.x(); i++) { size_t j; for (j = lgr.m_mainGridMinCellPosition.y(); j <= lgr.m_mainGridMaxCellPosition.y(); j++) { size_t k; for (k = lgr.m_mainGridMinCellPosition.z(); k <= lgr.m_mainGridMaxCellPosition.z(); k++) { mainGridIndicesWithSubGrid.push_back(cellIndexFromIJK(i, j, k)); } } } } // Create local grid and set local grid dimensions RigLocalGrid* localGrid = new RigLocalGrid(eclipseCase->mainGrid()); localGrid->setGridId(1); eclipseCase->mainGrid()->addLocalGrid(localGrid); localGrid->setParentGrid(eclipseCase->mainGrid()); localGrid->setIndexToStartOfCells(mainGridNodes.size() / 8); cvf::Vec3st gridPointDimensions( lgr.m_singleCellRefinementFactors.x() * (lgr.m_mainGridMaxCellPosition.x() - lgr.m_mainGridMinCellPosition.x() + 1) + 1, lgr.m_singleCellRefinementFactors.y() * (lgr.m_mainGridMaxCellPosition.y() - lgr.m_mainGridMinCellPosition.y() + 1) + 1, lgr.m_singleCellRefinementFactors.z() * (lgr.m_mainGridMaxCellPosition.z() - lgr.m_mainGridMinCellPosition.z() + 1) + 1); localGrid->setGridPointDimensions(gridPointDimensions); cvf::BoundingBox bb; size_t cellIdx; for (cellIdx = 0; cellIdx < mainGridIndicesWithSubGrid.size(); cellIdx++) { RigCell& cell = eclipseCase->mainGrid()->globalCellArray()[mainGridIndicesWithSubGrid[cellIdx]]; caf::SizeTArray8& indices = cell.cornerIndices(); int nodeIdx; for (nodeIdx = 0; nodeIdx < 8; nodeIdx++) { bb.add(eclipseCase->mainGrid()->nodes()[indices[nodeIdx]]); } // Deactivate cell in main grid cell.setSubGrid(localGrid); } cvf::Vec3st lgrCellDimensions = gridPointDimensions - cvf::Vec3st(1, 1, 1); appendNodes(bb.min(), bb.max(), lgrCellDimensions, mainGridNodes); size_t subGridCellCount = (mainGridNodes.size() / 8) - totalCellCount; appendCells(totalCellCount*8, subGridCellCount, localGrid, eclipseCase->mainGrid()->globalCellArray()); totalCellCount += subGridCellCount; } eclipseCase->mainGrid()->setGridPointDimensions(m_gridPointDimensions); if (m_enableWellData) { addWellData(eclipseCase, eclipseCase->mainGrid()); } addFaults(eclipseCase); // Set all cells active RigActiveCellInfo* activeCellInfo = eclipseCase->activeCellInfo(RiaDefines::MATRIX_MODEL); activeCellInfo->setReservoirCellCount(eclipseCase->mainGrid()->globalCellArray().size()); for (size_t i = 0; i < eclipseCase->mainGrid()->globalCellArray().size(); i++) { activeCellInfo->setCellResultIndex(i, i); } activeCellInfo->setGridCount(1); activeCellInfo->setGridActiveCellCounts(0, eclipseCase->mainGrid()->globalCellArray().size()); activeCellInfo->computeDerivedData(); // Add grid coarsening for main grid if (cellDimension().x() > 4 && cellDimension().y() > 5 && cellDimension().z() > 6) { eclipseCase->mainGrid()->addCoarseningBox(1, 2, 1, 3, 1, 4); eclipseCase->mainGrid()->addCoarseningBox(3, 4, 4, 5, 5, 6); } }