diff --git a/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.cpp b/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.cpp index 50d0c7eb1b..9801f247ca 100644 --- a/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.cpp +++ b/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.cpp @@ -36,9 +36,9 @@ std::pair RifFaultReactivationModelExporter::exportToStream( std::string applicationNameAndVersion = STRPRODUCTVER; using PartBorderSurface = RigGriddedPart3d::BorderSurface; - std::vector> borders = { { PartBorderSurface::UpperSurface, "top" }, - { PartBorderSurface::FaultSurface, "fault" }, - { PartBorderSurface::LowerSurface, "base" } }; + std::vector> borders = { { PartBorderSurface::UpperSurface, "TOP" }, + { PartBorderSurface::FaultSurface, "FAULT" }, + { PartBorderSurface::LowerSurface, "BASE" } }; using FaultGridPart = RigFaultReactivationModel::GridPart; std::map, int> faces = { { { FaultGridPart::PART1, PartBorderSurface::FaultSurface }, 4 }, @@ -48,24 +48,29 @@ std::pair RifFaultReactivationModelExporter::exportToStream( { { FaultGridPart::PART2, PartBorderSurface::UpperSurface }, 6 }, { { FaultGridPart::PART2, PartBorderSurface::LowerSurface }, 6 } }; + std::map partNames = { + { FaultGridPart::PART1, "LEFT_PART" }, + { FaultGridPart::PART2, "RIGHT_PART" }, + }; + std::map boundaries = { - { RigGriddedPart3d::Boundary::Bottom, "bottom" }, - { RigGriddedPart3d::Boundary::Back, "back" }, - { RigGriddedPart3d::Boundary::Front, "front" }, - { RigGriddedPart3d::Boundary::FarSide, "farside" }, + { RigGriddedPart3d::Boundary::Bottom, "BOTTOM" }, + { RigGriddedPart3d::Boundary::Back, "BACK" }, + { RigGriddedPart3d::Boundary::Front, "FRONT" }, + { RigGriddedPart3d::Boundary::FarSide, "FARSIDE" }, }; double faultFriction = 0.0; printHeading( stream, applicationNameAndVersion ); - printParts( stream, model, borders, faces ); - printAssembly( stream, model, boundaries ); + printParts( stream, model, partNames, borders, faces, boundaries ); + printAssembly( stream, model, partNames ); printMaterials( stream ); printInteractionProperties( stream, faultFriction ); - printBoundaryConditions( stream, boundaries ); - printPredefinedFields( stream ); - printInteractions( stream, borders ); - printSteps( stream ); + printBoundaryConditions( stream, model, partNames, boundaries ); + printPredefinedFields( stream, partNames ); + printInteractions( stream, partNames, borders ); + printSteps( stream, partNames ); // TODO: improve error handling return { true, "" }; @@ -102,17 +107,23 @@ std::pair RifFaultReactivationModelExporter::printHeading( st std::pair RifFaultReactivationModelExporter::printParts( std::ostream& stream, const RigFaultReactivationModel& model, + const std::map& partNames, const std::vector>& borders, - const std::map, int>& faces ) + const std::map, int>& faces, + const std::map& boundaries + +) { RifInpExportTools::printSectionComment( stream, "PARTS" ); - auto parts = model.allGridParts(); - int partIndex = 1; + auto parts = model.allGridParts(); for ( const auto& part : parts ) { - std::string partNameHeading = "Part-" + std::to_string( partIndex ); - RifInpExportTools::printHeading( stream, "Part, name=" + partNameHeading ); + auto partNameIt = partNames.find( part ); + CAF_ASSERT( partNameIt != partNames.end() ); + std::string partName = partNameIt->second; + + RifInpExportTools::printHeading( stream, "Part, name=" + partName ); auto grid = model.grid( part ); @@ -122,12 +133,26 @@ std::pair RifFaultReactivationModelExporter::printParts( const std::vector>& elements = grid->elementIndices(); RifInpExportTools::printElements( stream, elements ); - std::string partName = "part" + std::to_string( partIndex ); RifInpExportTools::printNodeSet( stream, partName, 1, nodes.size(), false ); RifInpExportTools::printElementSet( stream, partName, 1, elements.size() ); + RifInpExportTools::printNodeSet( stream, "PORE_PRESSURE", 1, nodes.size(), true ); + const std::map>& borderSurfaceElements = grid->borderSurfaceElements(); + for ( auto [boundary, boundaryName] : boundaries ) + { + // Create boundary condition sets for each side of the parts (except top). + auto boundaryNodes = grid->boundaryNodes(); + auto boundaryElements = grid->boundaryElements(); + + const std::vector& nodes = boundaryNodes[boundary]; + RifInpExportTools::printNodeSet( stream, boundaryName, false, nodes ); + + const std::vector& elements = boundaryElements[boundary]; + RifInpExportTools::printElementSet( stream, boundaryName, false, elements ); + } + for ( auto [border, borderName] : borders ) { auto elementIt = faces.find( { part, border } ); @@ -139,7 +164,7 @@ std::pair RifFaultReactivationModelExporter::printParts( if ( surfaceElements != borderSurfaceElements.end() ) { std::string borderElementName = "_" + borderName + "_" + sideName; - RifInpExportTools::printElementSet( stream, borderElementName, surfaceElements->second ); + RifInpExportTools::printElementSet( stream, borderElementName, true, surfaceElements->second ); RifInpExportTools::printSurface( stream, borderName, borderElementName, sideName ); } } @@ -149,8 +174,6 @@ std::pair RifFaultReactivationModelExporter::printParts( RifInpExportTools::printLine( stream, "," ); RifInpExportTools::printHeading( stream, "End Part" ); - - partIndex++; } return { true, "" }; @@ -160,10 +183,9 @@ std::pair RifFaultReactivationModelExporter::printParts( /// //-------------------------------------------------------------------------------------------------- std::pair - RifFaultReactivationModelExporter::printAssembly( std::ostream& stream, - const RigFaultReactivationModel& model, - const std::map& boundaries ) - + RifFaultReactivationModelExporter::printAssembly( std::ostream& stream, + const RigFaultReactivationModel& model, + const std::map& partNames ) { // ASSEMBLY part RifInpExportTools::printSectionComment( stream, "ASSEMBLY" ); @@ -171,46 +193,15 @@ std::pair auto parts = model.allGridParts(); - int partIndex = 1; for ( const 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 ); + auto partNameIt = partNames.find( part ); + CAF_ASSERT( partNameIt != partNames.end() ); + std::string partName = partNameIt->second; + std::string instanceName = partName; + RifInpExportTools::printHeading( stream, "Instance, name=" + instanceName + ", part=" + partName ); RifInpExportTools::printHeading( stream, "End Instance" ); - - partIndex++; - } - - partIndex = 1; - for ( const 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" ); @@ -261,13 +252,13 @@ std::pair RifFaultReactivationModelExporter::printInteraction RifInpExportTools::printSectionComment( stream, "INTERACTION PROPERTIES" ); // Fault interaction - RifInpExportTools::printHeading( stream, "Surface Interaction, name=fault" ); + RifInpExportTools::printHeading( stream, "Surface Interaction, name=FAULT" ); RifInpExportTools::printNumber( stream, 1.0 ); - RifInpExportTools::printHeading( stream, "Friction" ); + RifInpExportTools::printHeading( stream, "Friction, slip tolerance=0.005" ); 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::printHeading( stream, "Surface Interaction, name=NON-FAULT" ); RifInpExportTools::printNumber( stream, 1.0 ); RifInpExportTools::printHeading( stream, "Cohesive Behavior" ); @@ -278,13 +269,13 @@ std::pair RifFaultReactivationModelExporter::printInteraction /// //-------------------------------------------------------------------------------------------------- std::pair - RifFaultReactivationModelExporter::printBoundaryConditions( std::ostream& stream, + RifFaultReactivationModelExporter::printBoundaryConditions( std::ostream& stream, + const RigFaultReactivationModel& model, + const std::map& partNames, const std::map& boundaries ) { - auto printBoundaryCondition = - []( std::ostream& stream, const std::string& boundaryName, const std::string& boundarySetName, const std::string& symmetryType ) + auto printBoundaryCondition = []( std::ostream& stream, const std::string& boundarySetName, const std::string& symmetryType ) { - RifInpExportTools::printComment( stream, "Name: BC-" + boundaryName + " Type: Symmetry/Antisymmetry/Encastre" ); RifInpExportTools::printHeading( stream, "Boundary" ); RifInpExportTools::printLine( stream, boundarySetName + ", " + symmetryType ); }; @@ -298,16 +289,31 @@ std::pair }; RifInpExportTools::printSectionComment( stream, "BOUNDARY CONDITIONS" ); - for ( auto [boundary, boundaryName] : boundaries ) + + auto parts = model.allGridParts(); + + for ( const auto& part : parts ) { - std::string boundarySetName = "Set-" + boundaryName; - std::string symmetryType = symmetryTypes[boundary]; - printBoundaryCondition( stream, boundaryName, boundarySetName, symmetryType ); + auto partNameIt = partNames.find( part ); + CAF_ASSERT( partNameIt != partNames.end() ); + std::string partName = partNameIt->second; + + for ( auto [boundary, boundaryName] : boundaries ) + { + std::string boundarySetName = partName + "." + boundaryName; + std::string symmetryType = symmetryTypes[boundary]; + printBoundaryCondition( stream, boundarySetName, symmetryType ); + } } std::string partSymmetry = "XSYMM"; - printBoundaryCondition( stream, "z1", "Part-1-1.part1", partSymmetry ); - printBoundaryCondition( stream, "z2", "Part-2-1.part2", partSymmetry ); + for ( const auto& part : parts ) + { + auto partNameIt = partNames.find( part ); + CAF_ASSERT( partNameIt != partNames.end() ); + std::string partName = partNameIt->second; + printBoundaryCondition( stream, partName + "." + partName, partSymmetry ); + } return { true, "" }; } @@ -315,39 +321,30 @@ std::pair //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::pair RifFaultReactivationModelExporter::printPredefinedFields( std::ostream& stream ) +std::pair + RifFaultReactivationModelExporter::printPredefinedFields( std::ostream& stream, + const std::map& partNames ) { // 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 }, - - }; + std::vector fields; + for ( auto [part, partName] : partNames ) + { + std::string name = partName + "." + partName; + fields.push_back( PredefinedField{ .initialConditionType = "RATIO", .partName = name, .value = 0.3 } ); + fields.push_back( PredefinedField{ .initialConditionType = "PORE PRESSURE", .partName = name, .value = 0.0 } ); + } 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 ) ); } @@ -358,13 +355,17 @@ std::pair RifFaultReactivationModelExporter::printPredefinedF //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::pair RifFaultReactivationModelExporter::printSteps( std::ostream& stream ) +std::pair + RifFaultReactivationModelExporter::printSteps( std::ostream& stream, + const std::map& partNames ) { int numSteps = 2; for ( int i = 0; i < numSteps; i++ ) { - std::string stepName = "Step-" + std::to_string( i + 1 ); + std::string stepNum = std::to_string( i + 1 ); + std::string stepName = "Step-" + stepNum; + RifInpExportTools::printComment( stream, "----------------------------------------------------------------" ); RifInpExportTools::printSectionComment( stream, "STEP: " + stepName ); RifInpExportTools::printHeading( stream, "Step, name=" + stepName + ", nlgeom=NO" ); @@ -375,18 +376,23 @@ std::pair RifFaultReactivationModelExporter::printSteps( std: RifInpExportTools::printSectionComment( stream, "BOUNDARY CONDITIONS" ); RifInpExportTools::printHeading( stream, "Boundary" ); - RifInpExportTools::printLine( stream, "Part-1-1.part1_PP_, 8, 8" ); + + std::string part1Name = partNames.find( RigFaultReactivationModel::GridPart::PART1 )->second; + std::string part2Name = partNames.find( RigFaultReactivationModel::GridPart::PART2 )->second; + + std::string ppName = "PORE_PRESSURE"; + RifInpExportTools::printLine( stream, part1Name + "." + ppName + ", 8, 8" ); RifInpExportTools::printHeading( stream, "Boundary" ); std::string extra = i != 0 ? ", 1e+07" : ""; - RifInpExportTools::printLine( stream, "Part-2-1.part2_PP_, 8, 8" + extra ); + RifInpExportTools::printLine( stream, part2Name + "." + ppName + ", 8, 8" + extra ); RifInpExportTools::printSectionComment( stream, "OUTPUT REQUESTS" ); RifInpExportTools::printHeading( stream, "Restart, write, frequency=0" ); - RifInpExportTools::printSectionComment( stream, "FIELD OUTPUT: F-Output-1" ); + RifInpExportTools::printSectionComment( stream, "FIELD OUTPUT: F-Output-" + stepNum ); RifInpExportTools::printHeading( stream, "Output, field, variable=PRESELECT" ); - RifInpExportTools::printSectionComment( stream, "HISTORY OUTPUT: H-Output-1" ); + RifInpExportTools::printSectionComment( stream, "HISTORY OUTPUT: H-Output-" + stepNum ); RifInpExportTools::printHeading( stream, "Output, history, variable=PRESELECT" ); RifInpExportTools::printHeading( stream, "End Step" ); @@ -399,7 +405,8 @@ std::pair RifFaultReactivationModelExporter::printSteps( std: /// //-------------------------------------------------------------------------------------------------- std::pair - RifFaultReactivationModelExporter::printInteractions( std::ostream& stream, + RifFaultReactivationModelExporter::printInteractions( std::ostream& stream, + const std::map& partNames, const std::vector>& borders ) { RifInpExportTools::printSectionComment( stream, "INTERACTIONS" ); @@ -407,19 +414,19 @@ std::pair { RifInpExportTools::printComment( stream, "Interaction: " + borderName ); - std::string interactionName = "non-fault"; + std::string interactionName = "NON-FAULT"; std::string extra; if ( border == RigGriddedPart3d::BorderSurface::FaultSurface ) { - interactionName = "fault"; + interactionName = "FAULT"; extra = ", adjust=0.0"; } RifInpExportTools::printHeading( stream, "Contact Pair, interaction=" + interactionName + ", small sliding, type=SURFACE TO SURFACE" + extra ); - std::string part1Name = "Part-1-1"; - std::string part2Name = "Part-2-1"; + std::string part1Name = partNames.find( RigFaultReactivationModel::GridPart::PART1 )->second; + std::string part2Name = partNames.find( RigFaultReactivationModel::GridPart::PART2 )->second; RifInpExportTools::printLine( stream, part1Name + "." + borderName + ", " + part2Name + "." + borderName ); } diff --git a/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.h b/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.h index cad6195b96..edde2b108e 100644 --- a/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.h +++ b/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.h @@ -41,21 +41,29 @@ class RifFaultReactivationModelExporter private: static std::pair printHeading( std::ostream& stream, const std::string& applicationNameAndVersion ); static std::pair - printParts( std::ostream& stream, - const RigFaultReactivationModel& model, - const std::vector>& borders, - const std::map, int>& faces ); - static std::pair printAssembly( std::ostream& stream, - const RigFaultReactivationModel& model, - const std::map& boundaries ); + printParts( std::ostream& stream, + const RigFaultReactivationModel& model, + const std::map& partNames, + const std::vector>& borders, + const std::map, int>& faces, + const std::map& boundaries ); + + static std::pair printAssembly( std::ostream& stream, + const RigFaultReactivationModel& model, + const std::map& partNames ); static std::pair printMaterials( std::ostream& stream ); static std::pair printInteractionProperties( std::ostream& stream, double faultFriction ); - static std::pair printBoundaryConditions( std::ostream& stream, + static std::pair printBoundaryConditions( std::ostream& stream, + const RigFaultReactivationModel& model, + const std::map& partNames, const std::map& boundaries ); - static std::pair printPredefinedFields( std::ostream& stream ); - static std::pair printSteps( std::ostream& stream ); - static std::pair - printInteractions( std::ostream& stream, const std::vector>& borders ); + static std::pair printPredefinedFields( std::ostream& stream, + const std::map& partNames ); + static std::pair printSteps( std::ostream& stream, + const std::map& partNames ); + static std::pair printInteractions( std::ostream& stream, + const std::map& partNames, + const std::vector>& borders ); }; diff --git a/ApplicationLibCode/FileInterface/RifInpExportTools.cpp b/ApplicationLibCode/FileInterface/RifInpExportTools.cpp index e340e72c58..19c792f37d 100644 --- a/ApplicationLibCode/FileInterface/RifInpExportTools.cpp +++ b/ApplicationLibCode/FileInterface/RifInpExportTools.cpp @@ -104,12 +104,10 @@ bool RifInpExportTools::printNodeSet( std::ostream& stream, const std::string& p //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifInpExportTools::printNodeSet( std::ostream& stream, - const std::string& partName, - const std::string& instanceName, - const std::vector& nodes ) +bool RifInpExportTools::printNodeSet( std::ostream& stream, const std::string& partName, bool internal, const std::vector& nodes ) { - return printHeading( stream, "Nset, nset=" + partName + ", instance=" + instanceName ) && printElements( stream, nodes ); + std::string internalStr = internal ? ", internal" : ""; + return printHeading( stream, "Nset, nset=" + partName + internalStr ) && printElements( stream, nodes ); } //-------------------------------------------------------------------------------------------------- @@ -127,20 +125,10 @@ bool RifInpExportTools::printElementSet( std::ostream& stream, const std::string //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -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 ) +bool RifInpExportTools::printElementSet( std::ostream& stream, const std::string& elementName, bool internal, const std::vector& elements ) { - return printHeading( stream, "Elset, elset=" + partName + ", instance=" + instanceName ) && printElements( stream, elements ); + std::string internalStr = internal ? ", internal" : ""; + return printHeading( stream, "Elset, elset=" + elementName + internalStr ) && printElements( stream, elements ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/FileInterface/RifInpExportTools.h b/ApplicationLibCode/FileInterface/RifInpExportTools.h index 9abef833e7..caec5968cf 100644 --- a/ApplicationLibCode/FileInterface/RifInpExportTools.h +++ b/ApplicationLibCode/FileInterface/RifInpExportTools.h @@ -37,17 +37,11 @@ class RifInpExportTools 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 printNodeSet( std::ostream& stream, const std::string& partName, bool internal, 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 + printElementSet( std::ostream& stream, const std::string& elementName, bool internal, const std::vector& elements ); static bool printSurface( std::ostream& stream, const std::string& surfaceName, const std::string& surfaceElementName, const std::string& sideName );