mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
#2532 Fracture : Create copy of fracture template if non-matching units is detected
This commit is contained in:
parent
cfa3443cdd
commit
10bc5c92ab
@ -511,6 +511,7 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi
|
||||
}
|
||||
|
||||
oilField->fractureDefinitionCollection()->loadAndUpdateData();
|
||||
oilField->fractureDefinitionCollection()->createAndAssignTemplateCopyForNonMatchingUnit();
|
||||
oilField->fractureDefinitionCollection()->setDefaultConductivityResultIfEmpty();
|
||||
|
||||
{
|
||||
|
@ -342,6 +342,28 @@ cvf::Mat4d RimFracture::transformMatrix() const
|
||||
return m;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFracture::setFractureTemplateNoUpdate(RimFractureTemplate* fractureTemplate)
|
||||
{
|
||||
if (fractureTemplate && fractureTemplate->fractureTemplateUnit() != fractureUnit())
|
||||
{
|
||||
QString fractureUnitText = RiaEclipseUnitTools::UnitSystemType::uiText(fractureUnit());
|
||||
|
||||
QString warningText =
|
||||
QString("Using a fracture template defined in a different unit is not supported.\n\nPlease select a "
|
||||
"fracture template of unit '%1'")
|
||||
.arg(fractureUnitText);
|
||||
|
||||
QMessageBox::warning(nullptr, "Fracture Template Selection", warningText);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_fractureTemplate = fractureTemplate;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -622,21 +644,7 @@ size_t RimFracture::findAnchorEclipseCell(const RigMainGrid* mainGrid ) const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFracture::setFractureTemplate(RimFractureTemplate* fractureTemplate)
|
||||
{
|
||||
if (fractureTemplate && fractureTemplate->fractureTemplateUnit() != fractureUnit())
|
||||
{
|
||||
QString fractureUnitText = RiaEclipseUnitTools::UnitSystemType::uiText(fractureUnit());
|
||||
|
||||
QString warningText =
|
||||
QString("Using a fracture template defined in a different unit is not supported.\n\nPlease select a "
|
||||
"fracture template of unit '%1'")
|
||||
.arg(fractureUnitText);
|
||||
|
||||
QMessageBox::warning(nullptr, "Fracture Template Selection", warningText);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_fractureTemplate = fractureTemplate;
|
||||
setFractureTemplateNoUpdate(fractureTemplate);
|
||||
|
||||
if (!fractureTemplate)
|
||||
{
|
||||
|
@ -72,6 +72,7 @@ public:
|
||||
|
||||
cvf::Mat4d transformMatrix() const;
|
||||
|
||||
void setFractureTemplateNoUpdate(RimFractureTemplate* fractureTemplate);
|
||||
void setFractureTemplate(RimFractureTemplate* fractureTemplate);
|
||||
RimFractureTemplate* fractureTemplate() const;
|
||||
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
#include "RimFractureTemplateCollection.h"
|
||||
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include "RigStatisticsMath.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
@ -127,6 +129,69 @@ void RimFractureTemplateCollection::computeMinMax(const QString& uiResultName, c
|
||||
if (*negClosestToZero) *negClosestToZero = posNegAccumulator.neg;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFractureTemplateCollection::createAndAssignTemplateCopyForNonMatchingUnit()
|
||||
{
|
||||
// If a fracture has different unit than the associated template, create a copy of template in correct unit
|
||||
|
||||
std::vector<RimFractureTemplate*> templatesToBeAdded;
|
||||
|
||||
for (RimFractureTemplate* fractureTemplate : fractureDefinitions())
|
||||
{
|
||||
if (fractureTemplate)
|
||||
{
|
||||
RimFractureTemplate* templateWithMatchingUnit = nullptr;
|
||||
|
||||
std::vector<caf::PdmObjectHandle*> referringObjects;
|
||||
fractureTemplate->objectsWithReferringPtrFields(referringObjects);
|
||||
|
||||
for (auto refObj : referringObjects)
|
||||
{
|
||||
auto fracture = dynamic_cast<RimFracture*>(refObj);
|
||||
if (fracture && fracture->fractureUnit() != fractureTemplate->fractureTemplateUnit())
|
||||
{
|
||||
if (!templateWithMatchingUnit)
|
||||
{
|
||||
templateWithMatchingUnit = dynamic_cast<RimFractureTemplate*>(fractureTemplate->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
|
||||
|
||||
auto currentUnit = fractureTemplate->fractureTemplateUnit();
|
||||
auto neededUnit = RiaEclipseUnitTools::UNITS_UNKNOWN;
|
||||
if (currentUnit == RiaEclipseUnitTools::UNITS_METRIC)
|
||||
{
|
||||
neededUnit = RiaEclipseUnitTools::UNITS_FIELD;
|
||||
}
|
||||
else if (currentUnit == RiaEclipseUnitTools::UNITS_FIELD)
|
||||
{
|
||||
neededUnit = RiaEclipseUnitTools::UNITS_METRIC;
|
||||
}
|
||||
|
||||
templateWithMatchingUnit->convertToUnitSystem(neededUnit);
|
||||
|
||||
QString name = templateWithMatchingUnit->name();
|
||||
name += " (created to match fracture unit)";
|
||||
templateWithMatchingUnit->setName(name);
|
||||
|
||||
templatesToBeAdded.push_back(templateWithMatchingUnit);
|
||||
}
|
||||
|
||||
RiaLogging::warning("Detected fracture with different unit than fracture template. Creating copy of template "
|
||||
"with matching unit.");
|
||||
|
||||
CVF_ASSERT(templateWithMatchingUnit->fractureTemplateUnit() == fracture->fractureUnit());
|
||||
fracture->setFractureTemplateNoUpdate(templateWithMatchingUnit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto templateWithMatchingUnit : templatesToBeAdded)
|
||||
{
|
||||
fractureDefinitions.push_back(templateWithMatchingUnit);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
std::vector<std::pair<QString, QString> > resultNamesAndUnits() const;
|
||||
void computeMinMax(const QString& uiResultName, const QString& unit, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const;
|
||||
|
||||
void createAndAssignTemplateCopyForNonMatchingUnit();
|
||||
void loadAndUpdateData();
|
||||
void setDefaultConductivityResultIfEmpty();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user