Minor changes to exported INP file based on feedback and testing

This commit is contained in:
Jon Jenssen 2024-01-08 16:47:24 +01:00 committed by jonjenssen
parent 02ad40b127
commit b38e9de2cb
4 changed files with 74 additions and 34 deletions

View File

@ -38,6 +38,7 @@
#include <filesystem>
#include <fstream>
#include <numbers>
//--------------------------------------------------------------------------------------------------
///
@ -86,17 +87,17 @@ std::pair<bool, std::string> RifFaultReactivationModelExporter::exportToStream(
{ RimFaultReactivation::ElementSets::UnderBurden, "UNDERBURDEN" },
};
double faultFriction = 0.0;
bool useGridVoidRatio = rimModel.useGridVoidRatio();
bool useGridPorePressure = rimModel.useGridPorePressure();
bool useGridTemperature = rimModel.useGridTemperature();
bool useGridDensity = rimModel.useGridDensity();
bool useGridElasticProperties = rimModel.useGridElasticProperties();
bool useGridStress = rimModel.useGridStress();
bool useGridVoidRatio = rimModel.useGridVoidRatio();
bool useGridPorePressure = rimModel.useGridPorePressure();
bool useGridTemperature = rimModel.useGridTemperature();
bool useGridDensity = rimModel.useGridDensity();
bool useGridElasticProperties = rimModel.useGridElasticProperties();
bool useGridStress = rimModel.useGridStress();
double seaBedDepth = rimModel.seaBedDepth();
double waterDensity = rimModel.waterDensity();
double seaWaterLoad = RiaWellLogUnitTools<double>::gravityAcceleration() * seaBedDepth * waterDensity;
double seaBedDepth = rimModel.seaBedDepth();
double waterDensity = rimModel.waterDensity();
double seaWaterLoad = RiaWellLogUnitTools<double>::gravityAcceleration() * seaBedDepth * waterDensity;
double frictionValue = std::tan( ( rimModel.frictionAngleDeg() / 180.0 ) * std::numbers::pi );
auto model = rimModel.model();
CAF_ASSERT( !model.isNull() );
@ -106,11 +107,11 @@ std::pair<bool, std::string> RifFaultReactivationModelExporter::exportToStream(
std::vector<std::function<std::pair<bool, std::string>()>> methods = {
[&]() { return printHeading( stream, applicationNameAndVersion ); },
[&]() { return printParts( stream, *model, partNames, borders, faces, boundaries, materialNames ); },
[&]() { return printAssembly( stream, *model, partNames, model->modelLocalNormalsXY() ); },
[&]() { return printAssembly( stream, *model, partNames, !rimModel.useLocalCoordinates(), model->modelLocalNormalsXY() ); },
[&]() {
return printMaterials( stream, rimModel, materialNames, *dataAccess, basePath, partNames, useGridDensity, useGridElasticProperties );
},
[&]() { return printInteractionProperties( stream, faultFriction ); },
[&]() { return printInteractionProperties( stream, frictionValue ); },
[&]() { return printBoundaryConditions( stream, *model, partNames, boundaries ); },
[&]() { return printPredefinedFields( stream, *model, *dataAccess, basePath, partNames, useGridVoidRatio, useGridStress ); },
[&]() { return printInteractions( stream, partNames, borders ); },
@ -264,6 +265,7 @@ std::pair<bool, std::string>
RifFaultReactivationModelExporter::printAssembly( std::ostream& stream,
const RigFaultReactivationModel& model,
const std::map<RimFaultReactivation::GridPart, std::string>& partNames,
bool includeTransform,
const std::pair<cvf::Vec3d, cvf::Vec3d>& transform )
{
// ASSEMBLY part
@ -283,15 +285,18 @@ std::pair<bool, std::string>
RifInpExportTools::printHeading( stream, "End Instance" );
}
for ( const auto& part : parts )
if ( includeTransform )
{
auto partNameIt = partNames.find( part );
CAF_ASSERT( partNameIt != partNames.end() );
std::string partName = partNameIt->second;
for ( const auto& part : parts )
{
auto partNameIt = partNames.find( part );
CAF_ASSERT( partNameIt != partNames.end() );
std::string partName = partNameIt->second;
RifInpExportTools::printHeading( stream, "Transform, nset=" + partName + ".ALL" );
auto [dir1, dir2] = transform;
RifInpExportTools::printNumbers( stream, { dir1.x(), dir1.y(), dir1.z(), dir2.x(), dir2.y(), dir2.z() } );
RifInpExportTools::printHeading( stream, "Transform, nset=" + partName + ".ALL" );
auto [dir1, dir2] = transform;
RifInpExportTools::printNumbers( stream, { dir1.x(), dir1.y(), dir1.z(), dir2.x(), dir2.y(), dir2.z() } );
}
}
RifInpExportTools::printHeading( stream, "End Assembly" );
@ -521,10 +526,9 @@ std::pair<bool, std::string>
{
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" );
RifInpExportTools::printSectionComment( stream, "INITIAL CONDITIONS" );
for ( auto field : fields )
{
@ -574,7 +578,7 @@ std::pair<bool, std::string>
if ( !isOk ) return { false, "Failed to create " + stressName + " file." };
RifInpExportTools::printHeading( stream, "Initial Conditions, TYPE=" + stressName );
RifInpExportTools::printHeading( stream, "Initial Conditions, TYPE=" + stressName + ", geostatic" );
RifInpExportTools::printHeading( stream, "INCLUDE, input=" + fileName.toStdString() );
}
@ -601,17 +605,21 @@ std::pair<bool, std::string> RifFaultReactivationModelExporter::printSteps( std:
{
std::string stepNum = std::to_string( i + 1 );
std::string stepName = timeSteps[i].toString( "yyyy-MM-dd" ).toStdString();
if ( i == 0 ) stepName = "Geostatic_" + stepName;
std::string stepType = i == 0 ? "Geostatic, utol" : "Soils, utol=1.0";
RifInpExportTools::printComment( stream, "----------------------------------------------------------------" );
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 } );
if ( i == 0 )
{
RifInpExportTools::printComment( stream, "GRAVITY LOADS FROM ROCK AND SEAWATER" );
RifInpExportTools::printHeading( stream, "Dload" );
RifInpExportTools::printLine( stream, ",GRAV, 9.80665, 0., 0., -1." );
@ -658,13 +666,14 @@ std::pair<bool, std::string> RifFaultReactivationModelExporter::printSteps( std:
RifInpExportTools::printHeading( stream, "INCLUDE, input=" + fileName.toStdString() );
}
RifInpExportTools::printSectionComment( stream, "OUTPUT REQUESTS" );
RifInpExportTools::printHeading( stream, "Restart, write, frequency=0" );
RifInpExportTools::printSectionComment( stream, "OUTPUT" );
RifInpExportTools::printHeading( stream, "Output, field" );
RifInpExportTools::printHeading( stream, "Node Output" );
RifInpExportTools::printLine( stream, "COORD, POR, U" );
RifInpExportTools::printHeading( stream, "Element Output" );
RifInpExportTools::printLine( stream, "COORD, VOIDR, S, E, TEMP" );
RifInpExportTools::printSectionComment( stream, "FIELD OUTPUT: F-Output-" + stepNum );
RifInpExportTools::printHeading( stream, "Output, field, variable=PRESELECT" );
RifInpExportTools::printSectionComment( stream, "HISTORY OUTPUT: H-Output-" + stepNum );
RifInpExportTools::printComment( stream, "" );
RifInpExportTools::printHeading( stream, "Output, history, variable=PRESELECT" );
RifInpExportTools::printHeading( stream, "End Step" );

View File

@ -51,6 +51,7 @@ private:
static std::pair<bool, std::string> printAssembly( std::ostream& stream,
const RigFaultReactivationModel& model,
const std::map<RimFaultReactivation::GridPart, std::string>& partNames,
bool includeTransform,
const std::pair<cvf::Vec3d, cvf::Vec3d>& transform );
static std::pair<bool, std::string> printMaterials( std::ostream& stream,

View File

@ -126,6 +126,7 @@ RimFaultReactivationModel::RimFaultReactivationModel()
CAF_PDM_InitField( &m_useGridStress, "UseGridStress", false, "Output Grid Stress" );
CAF_PDM_InitField( &m_waterDensity, "WaterDensity", 1030.0, "Water Density [kg/m3]" );
CAF_PDM_InitField( &m_frictionAngleDeg, "FrictionAngle", 20.0, "Friction Angle [degree]" );
CAF_PDM_InitFieldNoDefault( &m_targets, "Targets", "Targets" );
m_targets.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() );
@ -196,19 +197,26 @@ caf::PdmFieldHandle* RimFaultReactivationModel::userDescriptionField()
//--------------------------------------------------------------------------------------------------
std::pair<bool, std::string> RimFaultReactivationModel::validateModel() const
{
const std::string postStr = ". Please check your model settings.";
if ( fault() == nullptr )
{
return std::make_pair( false, "A fault has not been selected. Please check your model settings." );
return std::make_pair( false, "A fault has not been selected" + postStr );
}
if ( selectedTimeSteps().size() < 2 )
{
return std::make_pair( false, "You need at least 2 selected timesteps. Please check your model settings." );
return std::make_pair( false, "You need at least 2 selected timesteps" + postStr );
}
if ( selectedTimeSteps()[0] != m_availableTimeSteps[0] )
{
return std::make_pair( false, "The first available timestep must always be selected. Please check your model settings." );
return std::make_pair( false, "The first available timestep must always be selected" + postStr );
}
if ( ( m_frictionAngleDeg() <= 0.0 ) || ( m_frictionAngleDeg() >= 90.0 ) )
{
return std::make_pair( false, "Friction angle must be between 0 and 90 degrees" + postStr );
}
return std::make_pair( true, "" );
@ -474,6 +482,8 @@ void RimFaultReactivationModel::defineUiOrdering( QString uiConfigName, caf::Pdm
propertiesGrp->add( &m_waterDensity );
}
propertiesGrp->add( &m_frictionAngleDeg );
uiOrdering.skipRemainingFields();
}
@ -482,8 +492,9 @@ void RimFaultReactivationModel::defineUiOrdering( QString uiConfigName, caf::Pdm
//--------------------------------------------------------------------------------------------------
void RimFaultReactivationModel::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
if ( ( changedField == &m_useGridPorePressure ) || ( changedField == &m_useGridVoidRatio ) || ( changedField == &m_useGridTemperature ) ||
( changedField == &m_useGridDensity ) || ( changedField == &m_useGridElasticProperties ) )
if ( ( changedField == &m_useGridPorePressure ) || ( changedField == &m_useGridVoidRatio ) ||
( changedField == &m_useGridTemperature ) || ( changedField == &m_useGridDensity ) ||
( changedField == &m_useGridElasticProperties ) || ( changedField == &m_waterDensity ) || ( changedField == &m_frictionAngleDeg ) )
{
return; // do nothing
}
@ -700,6 +711,14 @@ std::array<double, 3> RimFaultReactivationModel::materialParameters( ElementSets
return retVal;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimFaultReactivationModel::useLocalCoordinates() const
{
return m_useLocalCoordinates();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -756,6 +775,14 @@ double RimFaultReactivationModel::seaBedDepth() const
return m_modelMinZ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimFaultReactivationModel::frictionAngleDeg() const
{
return m_frictionAngleDeg;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -123,9 +123,11 @@ public:
bool useGridDensity() const;
bool useGridElasticProperties() const;
bool useGridStress() const;
bool useLocalCoordinates() const;
double seaBedDepth() const;
double waterDensity() const;
double frictionAngleDeg() const;
RimEclipseCase* eclipseCase() const;
RimGeoMechCase* geoMechCase() const;
@ -179,6 +181,7 @@ private:
caf::PdmField<bool> m_useGridStress;
caf::PdmField<double> m_waterDensity;
caf::PdmField<double> m_frictionAngleDeg;
caf::PdmField<size_t> m_startCellIndex;
caf::PdmField<int> m_startCellFace;