#2541 Mohr Circle: Use correct arguments when calling calculateFOS

This commit is contained in:
Unknown
2018-03-01 12:52:38 +01:00
committed by Rebecca Cox
parent 74e4775395
commit 4f20c7862e

View File

@@ -43,10 +43,8 @@
#include "qwt_legend.h" #include "qwt_legend.h"
#include "qwt_plot_curve.h" #include "qwt_plot_curve.h"
#include "qwt_plot_layout.h" #include "qwt_plot_layout.h"
#include "qwt_plot_marker.h"
#include "qwt_plot_rescaler.h" #include "qwt_plot_rescaler.h"
#include "qwt_plot_shapeitem.h" #include "qwt_plot_shapeitem.h"
#include "qwt_plot_textlabel.h"
#include <cmath> #include <cmath>
@@ -95,9 +93,11 @@ RiuMohrsCirclePlot::~RiuMohrsCirclePlot()
{ {
deleteCircles(); deleteCircles();
deleteEnvelopes(); deleteEnvelopes();
if (m_rescaler)
{
delete m_rescaler; delete m_rescaler;
} }
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
@@ -202,6 +202,7 @@ void RiuMohrsCirclePlot::addMohrCircles(const MohrsCirclesInfo& mohrsCirclesInfo
textBuilder.append(QString("<b>&sigma;<sub>1</sub></b>: %1, ").arg(principals[0])); textBuilder.append(QString("<b>&sigma;<sub>1</sub></b>: %1, ").arg(principals[0]));
textBuilder.append(QString("<b>&sigma;<sub>2</sub></b>: %1, ").arg(principals[1])); textBuilder.append(QString("<b>&sigma;<sub>2</sub></b>: %1, ").arg(principals[1]));
textBuilder.append(QString("<b>&sigma;<sub>3</sub></b>: %1").arg(principals[2])); textBuilder.append(QString("<b>&sigma;<sub>3</sub></b>: %1").arg(principals[2]));
plotItem->setTitle(textBuilder); plotItem->setTitle(textBuilder);
plotItem->setItemAttribute(QwtPlotItem::Legend); plotItem->setItemAttribute(QwtPlotItem::Legend);
} }
@@ -249,8 +250,8 @@ void RiuMohrsCirclePlot::addEnvelope(const cvf::Vec3f& principals, RimGeoMechVie
return; return;
} }
std::vector<double> xVals; double xVals[2];
std::vector<double> yVals; double yVals[2];
double tanFrictionAngle = cvf::Math::abs(cvf::Math::tan(cvf::Math::toRadians(frictionAngle))); double tanFrictionAngle = cvf::Math::abs(cvf::Math::tan(cvf::Math::toRadians(frictionAngle)));
@@ -259,25 +260,29 @@ void RiuMohrsCirclePlot::addEnvelope(const cvf::Vec3f& principals, RimGeoMechVie
return; return;
} }
yVals[0] = 0;
double x = cohesion / tanFrictionAngle; double x = cohesion / tanFrictionAngle;
if (principals[0] < 0) if (principals[0] < 0)
{ {
xVals.push_back(x); xVals[0] = x;
xVals.push_back(principals[2] * 1.1); xVals[1] = principals[2];
yVals[1] = (cohesion / x) * (x + principals[2]);
} }
else else
{ {
xVals.push_back(-x); xVals[0] = -x;
xVals.push_back(principals[0] * 1.1); xVals[1] = principals[0];
yVals[1] = (cohesion / x) * (x + principals[0]);
} }
yVals.push_back(0);
yVals.push_back((x + cvf::Math::abs(principals[0]) * 1.05) * tanFrictionAngle);
// If envelope for the view already exists, check if a "larger" envelope should be created // If envelope for the view already exists, check if a "larger" envelope should be created
if (m_envolopePlotItems.find(view) != m_envolopePlotItems.end()) if (m_envolopePlotItems.find(view) != m_envolopePlotItems.end())
{ {
if (yVals.back() <= m_envolopePlotItems[view]->maxYValue()) if (yVals[1] <= m_envolopePlotItems[view]->maxYValue())
{ {
return; return;
} }
@@ -291,7 +296,7 @@ void RiuMohrsCirclePlot::addEnvelope(const cvf::Vec3f& principals, RimGeoMechVie
QwtPlotCurve* qwtCurve = new QwtPlotCurve(); QwtPlotCurve* qwtCurve = new QwtPlotCurve();
qwtCurve->setSamples(xVals.data(), yVals.data(), 2); qwtCurve->setSamples(xVals, yVals, 2);
qwtCurve->setStyle(QwtPlotCurve::Lines); qwtCurve->setStyle(QwtPlotCurve::Lines);
qwtCurve->setRenderHint(QwtPlotItem::RenderAntialiased, true); qwtCurve->setRenderHint(QwtPlotItem::RenderAntialiased, true);
@@ -364,7 +369,7 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView
} }
double cohesion = geoMechView->geoMechCase()->cohesion(); double cohesion = geoMechView->geoMechCase()->cohesion();
double frictionAngle = geoMechView->geoMechCase()->frictionAngleDeg(); double frictionAngleDeg = geoMechView->geoMechCase()->frictionAngleDeg();
size_t i, j, k; size_t i, j, k;
femPart->structGrid()->ijkFromCellIndex(elmIndex, &i, &j, &k); femPart->structGrid()->ijkFromCellIndex(elmIndex, &i, &j, &k);
@@ -372,7 +377,7 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView
MohrsCirclesInfo mohrsCircle; MohrsCirclesInfo mohrsCircle;
mohrsCircle.color = color; mohrsCircle.color = color;
mohrsCircle.elmIndex = elmIndex; mohrsCircle.elmIndex = elmIndex;
mohrsCircle.factorOfSafety = calculateFOS(principals, cohesion, frictionAngle); mohrsCircle.factorOfSafety = calculateFOS(principals, frictionAngleDeg, cohesion);
mohrsCircle.principals = principals; mohrsCircle.principals = principals;
mohrsCircle.i = i; mohrsCircle.i = i;
mohrsCircle.j = j; mohrsCircle.j = j;
@@ -551,13 +556,18 @@ float RiuMohrsCirclePlot::calculateFOS(const cvf::Vec3f& principals, double fric
float se1 = principals[0]; float se1 = principals[0];
float se3 = principals[2]; float se3 = principals[2];
float tanFricAng = tan(cvf::Math::toRadians(frictionAngle)); if (cvf::Math::cos(frictionAngle) == 0)
float cohPrTanFricAngle = (float)(cohesion / tanFricAng); {
return 0;
}
float tanFricAng = cvf::Math::tan(cvf::Math::toRadians(frictionAngle));
float cohPrTanFricAngle = 1.0f * cohesion / tanFricAng;
float pi_4 = 0.785398163397448309616f; float pi_4 = 0.785398163397448309616f;
float rho = 2.0f * (atan(sqrt((se1 + cohPrTanFricAngle) / (se3 + cohPrTanFricAngle))) - pi_4); float rho = 2.0f * (cvf::Math::atan(cvf::Math::sqrt((se1 + cohPrTanFricAngle) / (se3 + cohPrTanFricAngle))) - pi_4);
return tanFricAng / tan(rho); return tanFricAng / cvf::Math::tan(rho);
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------