From ddd74107306bf237b40064f9afe81b60902d2bc1 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 28 Aug 2023 12:04:07 +0200 Subject: [PATCH] Write more data to inp file. --- .../RifFaultReactivationModelExporter.cpp | 259 +++++++++++++++++- .../FileInterface/RifInpExportTools.cpp | 126 +++++++++ .../FileInterface/RifInpExportTools.h | 21 ++ .../RigFaultReactivationModel.cpp | 2 +- .../ReservoirDataModel/RigGriddedPart3d.cpp | 109 ++++++-- .../ReservoirDataModel/RigGriddedPart3d.h | 21 +- 6 files changed, 507 insertions(+), 31 deletions(-) diff --git a/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.cpp b/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.cpp index 683abec5bb..e9a507fc6a 100644 --- a/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.cpp +++ b/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.cpp @@ -37,31 +37,278 @@ std::pair RifFaultReactivationModelExporter::exportToStream( RifInpExportTools::printHeading( stream, "Preprint, echo=NO, model=NO, history=NO, contact=NO" ); - RifInpExportTools::printComment( stream, "PARTS" ); + RifInpExportTools::printSectionComment( stream, "PARTS" ); auto parts = model.allGridParts(); + std::vector> borders = { { RigGriddedPart3d::BorderSurface::UpperSurface, "top" }, + { RigGriddedPart3d::BorderSurface::FaultSurface, "fault" }, + { RigGriddedPart3d::BorderSurface::LowerSurface, "base" } }; + + std::map, int> faces = + { { { RigFaultReactivationModel::GridPart::PART1, RigGriddedPart3d::BorderSurface::FaultSurface }, 4 }, + { { RigFaultReactivationModel::GridPart::PART1, RigGriddedPart3d::BorderSurface::UpperSurface }, 4 }, + { { RigFaultReactivationModel::GridPart::PART1, RigGriddedPart3d::BorderSurface::LowerSurface }, 4 }, + { { RigFaultReactivationModel::GridPart::PART2, RigGriddedPart3d::BorderSurface::FaultSurface }, 6 }, + { { RigFaultReactivationModel::GridPart::PART2, RigGriddedPart3d::BorderSurface::UpperSurface }, 6 }, + { { RigFaultReactivationModel::GridPart::PART2, RigGriddedPart3d::BorderSurface::LowerSurface }, 6 } }; + int partIndex = 1; for ( auto part : parts ) { - std::string partName = "Part-" + std::to_string( partIndex ); - RifInpExportTools::printHeading( stream, "Part, name=" + partName ); + std::string partNameHeading = "Part-" + std::to_string( partIndex ); + RifInpExportTools::printHeading( stream, "Part, name=" + partNameHeading ); auto grid = model.grid( part ); - const std::vector& nodes = grid->vertices(); + const std::vector& nodes = grid->nodes(); RifInpExportTools::printNodes( stream, nodes ); const std::vector>& elements = grid->elementIndices(); RifInpExportTools::printElements( stream, elements ); - RifInpExportTools::printHeading( stream, "," ); + std::string partName = "part" + std::to_string( partIndex ); + RifInpExportTools::printNodeSet( stream, partName, 1, nodes.size(), false ); + RifInpExportTools::printElementSet( stream, partName, 1, elements.size() ); + + const std::map>& borderSurfaceElements = grid->borderSurfaceElements(); + + for ( auto [border, borderName] : borders ) + { + int elementSide = faces[{ part, border }]; + + std::string sideName = "S" + std::to_string( elementSide ); + auto surfaceElements = borderSurfaceElements.find( border ); + if ( surfaceElements != borderSurfaceElements.end() ) + { + std::string borderElementName = "_" + borderName + "_" + sideName; + RifInpExportTools::printElementSet( stream, borderElementName, surfaceElements->second ); + RifInpExportTools::printSurface( stream, borderName, borderElementName, sideName ); + } + } + + RifInpExportTools::printComment( stream, "Section: sand" ); + RifInpExportTools::printHeading( stream, "Solid Section, elset=" + partName + ", material=sand" ); + + RifInpExportTools::printLine( stream, "," ); RifInpExportTools::printHeading( stream, "End Part" ); partIndex++; } - return { false, "" }; + // ASSEMBLY part + RifInpExportTools::printSectionComment( stream, "ASSEMBLY" ); + RifInpExportTools::printHeading( stream, "Assembly, name=Assembly" ); + + std::map boundaries = { + { RigGriddedPart3d::Boundary::Bottom, "bottom" }, + { RigGriddedPart3d::Boundary::Back, "back" }, + { RigGriddedPart3d::Boundary::Front, "front" }, + { RigGriddedPart3d::Boundary::FarSide, "farside" }, + }; + + partIndex = 1; + for ( auto part : parts ) + { + std::string partName = "Part-" + std::to_string( partIndex ); + std::string instanceName = partName + "-1"; + RifInpExportTools::printHeading( stream, "Instance, name=" + instanceName + ", part=" + partName ); + + std::string nodeSetName = "part_" + std::to_string( partIndex ) + "_PP_"; + auto grid = model.grid( part ); + + const std::vector& nodes = grid->nodes(); + RifInpExportTools::printNodeSet( stream, nodeSetName, 1, nodes.size(), true ); + + RifInpExportTools::printHeading( stream, "End Instance" ); + + partIndex++; + } + + partIndex = 1; + for ( auto part : parts ) + { + std::string partName = "Part-" + std::to_string( partIndex ); + std::string instanceName = partName + "-1"; + + for ( auto [boundary, boundaryName] : boundaries ) + { + // Create boundary condition sets for each side of the parts (except top). + auto grid = model.grid( part ); + + auto boundaryNodes = grid->boundaryNodes(); + auto boundaryElements = grid->boundaryElements(); + + std::string setName = "Set-" + boundaryName; + const std::vector& nodes = boundaryNodes[boundary]; + RifInpExportTools::printNodeSet( stream, setName, instanceName, nodes ); + + const std::vector& elements = boundaryElements[boundary]; + RifInpExportTools::printElementSet( stream, setName, instanceName, elements ); + } + partIndex++; + } + RifInpExportTools::printHeading( stream, "End Assembly" ); + + // MATERIALS PART + struct Material + { + std::string name; + double density; + double elastic1; + double elastic2; + double permeability1; + double permeability2; + }; + + RifInpExportTools::printSectionComment( stream, "MATERIALS" ); + + std::vector materials = { + Material{ .name = "sand", .density = 2000.0, .elastic1 = 5e+09, .elastic2 = 0.2, .permeability1 = 1e-09, .permeability2 = 0.3 } }; + for ( Material mat : materials ) + { + RifInpExportTools::printHeading( stream, "Material, name=" + mat.name ); + RifInpExportTools::printHeading( stream, "Density" ); + RifInpExportTools::printNumber( stream, mat.density ); + RifInpExportTools::printHeading( stream, "Elastic" ); + RifInpExportTools::printNumbers( stream, { mat.elastic1, mat.elastic2 } ); + + RifInpExportTools::printHeading( stream, "Permeability, specific=1." ); + RifInpExportTools::printNumbers( stream, { mat.permeability1, mat.permeability2 } ); + } + + double faultFriction = 0.0; + RifInpExportTools::printSectionComment( stream, "INTERACTION PROPERTIES" ); + + // Fault interaction + RifInpExportTools::printHeading( stream, "Surface Interaction, name=fault" ); + RifInpExportTools::printNumber( stream, 1.0 ); + RifInpExportTools::printHeading( stream, "Friction" ); + RifInpExportTools::printNumber( stream, faultFriction ); + RifInpExportTools::printHeading( stream, "Surface Behavior, no separation, pressure-overclosure=HARD" ); + // Non-fault interaction + RifInpExportTools::printHeading( stream, "Surface Interaction, name=non-fault" ); + RifInpExportTools::printNumber( stream, 1.0 ); + RifInpExportTools::printHeading( stream, "Cohesive Behavior" ); + + auto printBoundaryCondition = + []( std::ostream& stream, const std::string& boundaryConditionName, const std::string& boundaryName, const std::string& symmetryType ) + { + RifInpExportTools::printComment( stream, "Name: BC-" + boundaryConditionName + " Type: Symmetry/Antisymmetry/Encastre" ); + RifInpExportTools::printHeading( stream, "Boundary" ); + std::string setName = "Set-" + boundaryName; + RifInpExportTools::printLine( stream, setName + ", " + symmetryType ); + }; + + std::map symmetryTypes = { + { RigGriddedPart3d::Boundary::Bottom, "ZSYMM" }, + { RigGriddedPart3d::Boundary::Back, "YSYMM" }, + { RigGriddedPart3d::Boundary::Front, "YSYMM" }, + { RigGriddedPart3d::Boundary::FarSide, "XSYMM" }, + + }; + + RifInpExportTools::printSectionComment( stream, "BOUNDARY CONDITIONS" ); + for ( auto [boundary, boundaryName] : boundaries ) + { + std::string boundaryConditionName = boundaryName; + std::string symmetryType = symmetryTypes[boundary]; + printBoundaryCondition( stream, boundaryName, boundaryName, symmetryType ); + } + + std::string partSymmetry = "XSYMM"; + printBoundaryCondition( stream, "z1", "Part-1-1.part1", partSymmetry ); + printBoundaryCondition( stream, "z2", "Part-2-1.part2", partSymmetry ); + + // PREDEFINED FIELDS + struct PredefinedField + { + std::string type; + std::string initialConditionType; + std::string shortName; + std::string partName; + double value; + }; + + std::vector fields = { + PredefinedField{ .type = "Void ratio", .initialConditionType = "RATIO", .shortName = "VR1", .partName = "Part-1-1.part1", .value = 0.3 }, + PredefinedField{ .type = "Pore pressure", + .initialConditionType = "PORE PRESSURE", + .shortName = "PP1", + .partName = "Part-1-1.part1", + .value = 0.0 }, + PredefinedField{ .type = "Pore pressure", + .initialConditionType = "PORE PRESSURE", + .shortName = "PP2", + .partName = "Part-2-1.part2", + .value = 0.0 }, + PredefinedField{ .type = "Void ratio", .initialConditionType = "RATIO", .shortName = "VR2", .partName = "Part-2-1.part2", .value = 0.3 }, + + }; + + RifInpExportTools::printSectionComment( stream, "PREDEFINED FIELDS" ); + + for ( auto field : fields ) + { + RifInpExportTools::printComment( stream, "Name: Predefined Field " + field.shortName + " Type: " + field.type ); + RifInpExportTools::printHeading( stream, "Initial Conditions, TYPE=" + field.initialConditionType ); + RifInpExportTools::printLine( stream, field.partName + ", " + std::to_string( field.value ) ); + } + + RifInpExportTools::printSectionComment( stream, "INTERACTIONS" ); + for ( auto [border, borderName] : borders ) + { + RifInpExportTools::printHeading( stream, "Interaction: " + borderName ); + + std::string interactionName = "non-fault"; + std::string extra; + if ( border == RigGriddedPart3d::BorderSurface::FaultSurface ) + { + interactionName = "fault"; + extra = ", adjust=0.0"; + } + + RifInpExportTools::printHeading( stream, + "Contact Pair, interation=" + interactionName + ", small sliding, type=SURFACE TO SURFACE" + extra ); + + std::string part1Name = "Part1-1"; + std::string part2Name = "Part2-1"; + RifInpExportTools::printLine( stream, part1Name + "." + borderName + ", " + part2Name + "." + borderName ); + } + + int numSteps = 2; + + for ( int i = 0; i < numSteps; i++ ) + { + std::string stepName = "Step-" + std::to_string( i + 1 ); + RifInpExportTools::printSectionComment( stream, "STEP: " + stepName ); + + RifInpExportTools::printHeading( stream, "Step, name=" + stepName + ", nlgeom=NO" ); + + std::string stepType = i == 0 ? "Geostatic, utol" : "Soils, utol=1.0"; + RifInpExportTools::printHeading( stream, stepType ); + RifInpExportTools::printNumbers( stream, { 1.0, 1.0, 1e-05, 1.0 } ); + + RifInpExportTools::printSectionComment( stream, "BOUNDARY CONDITIONS" ); + RifInpExportTools::printHeading( stream, "Boundary" ); + RifInpExportTools::printHeading( stream, "Part-1-1.part1_PP_, 8, 8" ); + RifInpExportTools::printHeading( stream, "Boundary" ); + std::string extra = i != 0 ? ", 1e+07" : ""; + RifInpExportTools::printHeading( stream, "Part-2-1.part2_PP_, 8, 8" + extra ); + + RifInpExportTools::printSectionComment( stream, "OUTPUT REQUESTS" ); + RifInpExportTools::printHeading( stream, "Restart, write, frequency=0" ); + + RifInpExportTools::printSectionComment( stream, "FIELD OUTPUT: F-Output-1" ); + RifInpExportTools::printHeading( stream, "Output, field, variable=PRESELECT" ); + + RifInpExportTools::printSectionComment( stream, "HISTORY OUTPUT: H-Output-1" ); + RifInpExportTools::printHeading( stream, "Output, history, variable=PRESELECT" ); + + RifInpExportTools::printHeading( stream, "End Step" ); + } + + return { true, "" }; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/FileInterface/RifInpExportTools.cpp b/ApplicationLibCode/FileInterface/RifInpExportTools.cpp index 4d4577a858..8e1f7518b6 100644 --- a/ApplicationLibCode/FileInterface/RifInpExportTools.cpp +++ b/ApplicationLibCode/FileInterface/RifInpExportTools.cpp @@ -44,6 +44,14 @@ bool RifInpExportTools::printComment( std::ostream& stream, const std::string& c return printLine( stream, "** " + comment ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifInpExportTools::printSectionComment( std::ostream& stream, const std::string& comment ) +{ + return printComment( stream, "" ) && printComment( stream, comment ) && printComment( stream, "" ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -79,3 +87,121 @@ bool RifInpExportTools::printElements( std::ostream& stream, const std::vector& nodes ) +{ + return printHeading( stream, "Nset, nset=" + partName + ", instance=" + instanceName ) && printElements( stream, nodes ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifInpExportTools::printElementSet( std::ostream& stream, const std::string& partName, size_t start, size_t end ) +{ + // Should look like this: + // *Elset, elset=part1, generate + // 1, 50433, 1 + return printHeading( stream, "Elset, elset=" + partName + ", generate" ) && + printLine( stream, std::to_string( start ) + ", " + std::to_string( end ) + ", " + std::to_string( 1 ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifInpExportTools::printElementSet( std::ostream& stream, const std::string& elementName, const std::vector& elements ) +{ + return printHeading( stream, "Elset, elset=" + elementName + ", internal" ) && printElements( stream, elements ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifInpExportTools::printElementSet( std::ostream& stream, + const std::string& partName, + const std::string& instanceName, + const std::vector& elements ) +{ + return printHeading( stream, "Elset, elset=" + partName + ", instance=" + instanceName ) && printElements( stream, elements ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifInpExportTools::printElements( std::ostream& stream, const std::vector& elements ) +{ + int numItemsPerLine = 16; + + for ( size_t i = 0; i < elements.size(); i++ ) + { + stream << elements[i] + 1; + if ( i != elements.size() - 1 ) stream << ", "; + + // Break lines periodically + bool isFirst = i == 0; + bool isLast = i == ( elements.size() - 1 ); + if ( !isFirst && !isLast && i % numItemsPerLine == 0 ) + { + stream << std::endl; + } + } + stream << std::endl; + + return stream.good(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifInpExportTools::printSurface( std::ostream& stream, + const std::string& surfaceName, + const std::string& surfaceElementName, + const std::string& sideName ) +{ + // Sample surface element: + //*Surface, type=ELEMENT, name=top + //_top_S5, S5 + return printHeading( stream, "Surface, type=ELEMENT, name=" + surfaceName ) && printLine( stream, surfaceElementName + ", " + sideName ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifInpExportTools::printNumber( std::ostream& stream, double value ) +{ + stream << value << "," << std::endl; + return stream.good(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifInpExportTools::printNumbers( std::ostream& stream, const std::vector& values ) +{ + for ( size_t i = 0; i < values.size(); i++ ) + { + stream << values[i]; + if ( i != values.size() - 1 ) stream << ", "; + } + stream << std::endl; + + return stream.good(); +} diff --git a/ApplicationLibCode/FileInterface/RifInpExportTools.h b/ApplicationLibCode/FileInterface/RifInpExportTools.h index a0a0b5f0b1..84b68cc267 100644 --- a/ApplicationLibCode/FileInterface/RifInpExportTools.h +++ b/ApplicationLibCode/FileInterface/RifInpExportTools.h @@ -34,6 +34,27 @@ public: static bool printLine( std::ostream& stream, const std::string& line ); static bool printHeading( std::ostream& stream, const std::string& heading ); static bool printComment( std::ostream& stream, const std::string& comment ); + static bool printSectionComment( std::ostream& stream, const std::string& comment ); static bool printNodes( std::ostream& stream, const std::vector& nodes ); static bool printElements( std::ostream& stream, const std::vector>& elements ); + static bool printNodeSet( std::ostream& stream, const std::string& partName, size_t start, size_t end, bool internal ); + static bool printNodeSet( std::ostream& stream, + const std::string& partName, + const std::string& instanceName, + const std::vector& nodes ); + + static bool printElementSet( std::ostream& stream, const std::string& partName, size_t start, size_t end ); + static bool printElementSet( std::ostream& stream, const std::string& elementName, const std::vector& elements ); + static bool printElementSet( std::ostream& stream, + const std::string& partName, + const std::string& instanceName, + const std::vector& elements ); + + static bool + printSurface( std::ostream& stream, const std::string& surfaceName, const std::string& surfaceElementName, const std::string& sideName ); + static bool printNumbers( std::ostream& stream, const std::vector& values ); + static bool printNumber( std::ostream& stream, double value ); + +private: + static bool printElements( std::ostream& stream, const std::vector& elements ); }; diff --git a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModel.cpp b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModel.cpp index c14d82aab1..34bf6e8386 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModel.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModel.cpp @@ -56,7 +56,7 @@ RigFaultReactivationModel::RigFaultReactivationModel() for ( auto part : allGridParts() ) { - m_3dparts[part] = std::make_shared(); + m_3dparts[part] = std::make_shared( part == GridPart::PART2 ); } } diff --git a/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.cpp b/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.cpp index e899b66db9..55e574adb3 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.cpp @@ -23,7 +23,8 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigGriddedPart3d::RigGriddedPart3d() +RigGriddedPart3d::RigGriddedPart3d( bool flipFrontBack ) + : m_flipFrontBack( flipFrontBack ) { } @@ -39,8 +40,10 @@ RigGriddedPart3d::~RigGriddedPart3d() //-------------------------------------------------------------------------------------------------- void RigGriddedPart3d::reset() { + m_boundaryElements.clear(); + m_boundaryNodes.clear(); m_borderSurfaceElements.clear(); - m_vertices.clear(); + m_nodes.clear(); m_elementIndices.clear(); m_meshLines.clear(); } @@ -108,24 +111,51 @@ void RigGriddedPart3d::generateGeometry( std::vector inputPoints, const std::vector firstSteps = { step0to1, step1to2, step2to3 }; const std::vector lastSteps = { step4to5, step5to6, step6to7 }; - // ** generate vertices + const Boundary boundaryBack = m_flipFrontBack ? Boundary::Front : Boundary::Back; + const Boundary boundaryFront = m_flipFrontBack ? Boundary::Back : Boundary::Front; - m_vertices.reserve( (size_t)( ( nVertCells + 1 ) * ( nHorzCells + 1 ) ) ); + // ** generate nodes + + m_boundaryNodes[boundaryFront] = {}; + m_boundaryNodes[boundaryBack] = {}; + m_boundaryNodes[Boundary::Bottom] = {}; + m_boundaryNodes[Boundary::FarSide] = {}; + + m_nodes.reserve( (size_t)( ( nVertCells + 1 ) * ( nHorzCells + 1 ) ) ); cvf::Vec3d pFrom = inputPoints[0]; cvf::Vec3d pTo = inputPoints[4]; + unsigned int layer = 0; + unsigned int nodeIndex = 0; + for ( int i = 0; i < (int)vertLines.size(); i++ ) { - for ( int v = 0; v < vertLines[i]; v++ ) + for ( int v = 0; v < vertLines[i]; v++, layer++ ) { cvf::Vec3d stepHorz = stepVector( pFrom, pTo, nHorzCells ); cvf::Vec3d p = pFrom; for ( int h = 0; h <= nHorzCells; h++ ) { - for ( int t = 0; t < (int)m_thicknessFactors.size(); t++ ) + for ( int t = 0; t <= nThicknessCells; t++, nodeIndex++ ) { - m_vertices.push_back( p + m_thicknessFactors[t] * tVec ); + m_nodes.push_back( p + m_thicknessFactors[t] * tVec ); + if ( layer == 0 ) + { + m_boundaryNodes[Boundary::Bottom].push_back( nodeIndex ); + } + if ( h == 0 ) + { + m_boundaryNodes[Boundary::FarSide].push_back( nodeIndex ); + } + if ( t == 0 ) + { + m_boundaryNodes[boundaryFront].push_back( nodeIndex ); + } + else if ( t == nThicknessCells ) + { + m_boundaryNodes[boundaryBack].push_back( nodeIndex ); + } } p += stepHorz; @@ -143,24 +173,30 @@ void RigGriddedPart3d::generateGeometry( std::vector inputPoints, m_borderSurfaceElements[BorderSurface::FaultSurface] = {}; m_borderSurfaceElements[BorderSurface::LowerSurface] = {}; - int layerIndex = 0; - int elementIdx = 0; + m_boundaryElements[boundaryFront] = {}; + m_boundaryElements[boundaryBack] = {}; + m_boundaryElements[Boundary::Bottom] = {}; + m_boundaryElements[Boundary::FarSide] = {}; - BorderSurface currentRegion = BorderSurface::LowerSurface; + int layerIndexOffset = 0; + int elementIdx = 0; + layer = 0; + + BorderSurface currentSurfaceRegion = BorderSurface::LowerSurface; const int nextLayerIdxOff = ( nHorzCells + 1 ) * ( nThicknessCells + 1 ); const int nThicknessOff = nThicknessCells + 1; - for ( int v = 0; v < nVertCells; v++ ) + for ( int v = 0; v < nVertCells; v++, layer++ ) { - if ( v >= nVertCellsLower ) currentRegion = BorderSurface::FaultSurface; - if ( v >= nVertCellsLower + nVertCellsMiddle ) currentRegion = BorderSurface::UpperSurface; + if ( v >= nVertCellsLower ) currentSurfaceRegion = BorderSurface::FaultSurface; + if ( v >= nVertCellsLower + nVertCellsMiddle ) currentSurfaceRegion = BorderSurface::UpperSurface; - int i = layerIndex; + int i = layerIndexOffset; for ( int h = 0; h < nHorzCells; h++ ) { - for ( int t = 0; t < nThicknessCells; t++ ) + for ( int t = 0; t < nThicknessCells; t++, elementIdx++ ) { m_elementIndices[elementIdx].push_back( t + i ); m_elementIndices[elementIdx].push_back( t + i + nThicknessOff ); @@ -172,16 +208,31 @@ void RigGriddedPart3d::generateGeometry( std::vector inputPoints, m_elementIndices[elementIdx].push_back( t + nextLayerIdxOff + i + nThicknessOff + 1 ); m_elementIndices[elementIdx].push_back( t + nextLayerIdxOff + i + 1 ); - elementIdx++; + if ( layer == 0 ) + { + m_boundaryElements[Boundary::Bottom].push_back( elementIdx ); + } + if ( h == 0 ) + { + m_boundaryElements[Boundary::FarSide].push_back( elementIdx ); + } + if ( t == 0 ) + { + m_boundaryElements[boundaryFront].push_back( elementIdx ); + } + else if ( t == ( nThicknessCells - 1 ) ) + { + m_boundaryElements[boundaryBack].push_back( elementIdx ); + } } i += nThicknessOff; } // add elements to border surface in current region - m_borderSurfaceElements[currentRegion].push_back( elementIdx - 2 ); - m_borderSurfaceElements[currentRegion].push_back( elementIdx - 1 ); + m_borderSurfaceElements[currentSurfaceRegion].push_back( elementIdx - 2 ); + m_borderSurfaceElements[currentSurfaceRegion].push_back( elementIdx - 1 ); - layerIndex += nextLayerIdxOff; + layerIndexOffset += nextLayerIdxOff; } // generate meshlines for 2d viz @@ -239,9 +290,9 @@ void RigGriddedPart3d::generateMeshlines( std::vector cornerPoints, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const std::vector& RigGriddedPart3d::vertices() const +const std::vector& RigGriddedPart3d::nodes() const { - return m_vertices; + return m_nodes; } //-------------------------------------------------------------------------------------------------- @@ -277,3 +328,19 @@ const std::vector>& RigGriddedPart3d::meshLines() const { return m_meshLines; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::map>& RigGriddedPart3d::boundaryElements() const +{ + return m_boundaryElements; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::map>& RigGriddedPart3d::boundaryNodes() const +{ + return m_boundaryNodes; +} diff --git a/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.h b/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.h index c63331bd04..6b8a77fcd9 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.h +++ b/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.h @@ -38,8 +38,16 @@ public: LowerSurface }; + enum class Boundary + { + Front = 0, + Back, + FarSide, + Bottom + }; + public: - RigGriddedPart3d(); + RigGriddedPart3d( bool flipFrontBack ); ~RigGriddedPart3d() override; void reset(); @@ -51,18 +59,25 @@ public: int nVertCellsUpper, double thickness ); - const std::vector& vertices() const; + const std::vector& nodes() const; const std::vector>& elementIndices() const; const std::map>& borderSurfaceElements() const; const std::vector>& meshLines() const; + const std::map>& boundaryElements() const; + const std::map>& boundaryNodes() const; + protected: cvf::Vec3d stepVector( cvf::Vec3d start, cvf::Vec3d stop, int nSteps ); void generateMeshlines( std::vector cornerPoints, int numHorzCells, int numVertCells ); private: - std::vector m_vertices; + bool m_flipFrontBack; + + std::vector m_nodes; std::vector> m_elementIndices; std::map> m_borderSurfaceElements; std::vector> m_meshLines; + std::map> m_boundaryElements; + std::map> m_boundaryNodes; };