Skip to content

Commit a90d23d

Browse files
refactor: Move and refactor Mohr Circle plugin (#166)
* Removing systematic calculation and stack of all timesteps and cells
1 parent ef282dc commit a90d23d

31 files changed

+548
-1455
lines changed

docs/geos-posp.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,4 @@ GEOS Post-Processing tools
77

88
./geos_posp_docs/home.rst
99

10-
./geos_posp_docs/modules.rst
11-
12-
./geos_posp_docs/visualization.rst
10+
./geos_posp_docs/modules.rst

docs/geos_posp_docs/PVplugins.rst

Lines changed: 0 additions & 14 deletions
This file was deleted.

docs/geos_posp_docs/visu.PVUtils.rst

Lines changed: 0 additions & 37 deletions
This file was deleted.

docs/geos_posp_docs/visu.rst

Lines changed: 0 additions & 12 deletions
This file was deleted.

docs/geos_posp_docs/visualization.rst

Lines changed: 0 additions & 9 deletions
This file was deleted.

docs/geos_posp_docs/visu.mohrCircles.rst renamed to docs/geos_pv_docs/mohrCircles.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ Mohr's Circle Package
33

44
This package includes utilities to compute and plot Mohr's Circles using the Python View from Paraview.
55

6-
geos_posp.visu.mohrCircles.functionsMohrCircle module
6+
geos.pv.utils.mohrCircles.functionsMohrCircle module
77
--------------------------------------------------------
88

9-
.. automodule:: geos_posp.visu.mohrCircles.functionsMohrCircle
9+
.. automodule:: geos.pv.utils.mohrCircles.functionsMohrCircle
1010
:members:
1111
:undoc-members:
1212
:show-inheritance:
1313

14-
geos_posp.visu.mohrCircles.plotMohrCircles module
14+
geos.pv.utils.mohrCircles.plotMohrCircles module
1515
--------------------------------------------------
1616

17-
.. automodule:: geos_posp.visu.mohrCircles.plotMohrCircles
17+
.. automodule:: geos.pv.utils.mohrCircles.plotMohrCircles
1818
:members:
1919
:undoc-members:
2020
:show-inheritance:

docs/geos_pv_docs/processing.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The plugins include:
55
* A reader that parse GEOS output log file;
66
* 3D mesh cleanning plugins;
77
* Processing plugins to compute additional geomechanical properties;
8-
* Visualization plugins to plot Mohr's circles (currently in `geos_posp`) and cross plots using Paraview Python View.
8+
* Visualization plugins to plot Mohr's circles and cross plots using Paraview Python View.
99

1010

1111
PVAttributeMapping
@@ -67,3 +67,9 @@ PVGeomechanicsCalculator plugin
6767
---------------------------------------
6868

6969
.. automodule:: geos.pv.plugins.PVGeomechanicsCalculator
70+
71+
72+
PVMohrCirclePlot plugin
73+
---------------------------------
74+
75+
.. automodule:: geos.pv.plugins.PVMohrCirclePlot

docs/geos_pv_docs/pyplotUtils.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ geos.pv.pyplotUtils.matplotlibOptions module
1010
.. automodule:: geos.pv.pyplotUtils.matplotlibOptions
1111
:members:
1212
:undoc-members:
13-
:show-inheritance:
13+
:show-inheritance:

docs/geos_pv_docs/utilities.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ Utilities
1111
pythonViewUtils
1212

1313
utils
14+
15+
mohrCircles

geos-geomechanics/src/geos/geomechanics/model/MohrCircle.py

Lines changed: 63 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
# SPDX-FileContributor: Alexandre Benedicto, Martin Lemay
44
import numpy as np
55
import numpy.typing as npt
6-
from typing_extensions import Self
6+
from typing_extensions import Self, Any
77

88
from geos.geomechanics.processing.geomechanicsCalculatorFunctions import (
99
computeStressPrincipalComponentsFromStressVector, )
1010

1111
__doc__ = """
1212
MohrCircle module define the Mohr's circle parameters.
1313
14-
Inputs are a 6 component stress vector, a circle id, and the mechanical
15-
convention used for compression.
14+
Inputs are a 6 component stress vector, and a circle id.
1615
The class computes principal components from stress vector during initialization.
1716
Accessors get access to these 3 principal components as well as circle center
1817
and radius.
@@ -23,21 +22,21 @@
2322
2423
from processing.MohrCircle import MohrCircle
2524
26-
# create the object
27-
stressVector :npt.NDArray[np.float64]
28-
circleId :str
29-
mohrCircle :MohrCircle = MohrCircle(circleId)
25+
# Create the object
26+
stressVector: npt.NDArray[np.float64]
27+
circleId: str
28+
mohrCircle: MohrCircle = MohrCircle(circleId)
3029
31-
# either directly set principal components (p3 <= p2 <= p1)
30+
# Either directly set principal components (p3 <= p2 <= p1)
3231
mohrCircle.SetPrincipalComponents(p3, p2, p1)
33-
# or compute them from stress vector
32+
# Or compute them from stress vector
3433
mohrCircle.computePrincipalComponents(stressVector)
3534
36-
# access to members
37-
id :str = mohrCircle.getCircleId()
38-
p1, p2, p3 :float = mohrCircle.getPrincipalComponents()
39-
radius :float = mohrCircle.getCircleRadius()
40-
center :float = mohrCircle.getCircleCenter()
35+
# Access to members
36+
id: str = mohrCircle.getCircleId()
37+
p1, p2, p3: float = mohrCircle.getPrincipalComponents()
38+
radius: float = mohrCircle.getCircleRadius()
39+
center: float = mohrCircle.getCircleCenter()
4140
"""
4241

4342

@@ -49,60 +48,86 @@ def __init__( self: Self, circleId: str ) -> None:
4948
Args:
5049
circleId (str): Mohr's circle id.
5150
"""
52-
self.m_circleId: str = circleId
51+
self.circleId: str = circleId
5352

54-
self.m_p1: float = 0.0
55-
self.m_p2: float = 0.0
56-
self.m_p3: float = 0.0
53+
self.p1: float = 0.0
54+
self.p2: float = 0.0
55+
self.p3: float = 0.0
5756

5857
def __str__( self: Self ) -> str:
5958
"""Overload of __str__ method."""
60-
return self.m_circleId
59+
return self.circleId
6160

6261
def __repr__( self: Self ) -> str:
6362
"""Overload of __repr__ method."""
64-
return self.m_circleId
63+
return self.circleId
64+
65+
def __eq__( self: Self, other: Any ) -> bool:
66+
"""Overload of __eq__ method."""
67+
if not isinstance( other, MohrCircle ):
68+
return NotImplemented
69+
return self.circleId == other.circleId
70+
71+
def __hash__( self: Self ) -> int:
72+
"""Overload of hash method."""
73+
return hash( self.circleId )
6574

6675
def setCircleId( self: Self, circleId: str ) -> None:
6776
"""Set circle Id variable.
6877
6978
Args:
70-
circleId (str): circle Id.
79+
circleId (str): Circle Id.
7180
"""
72-
self.m_circleId = circleId
81+
self.circleId = circleId
7382

7483
def getCircleId( self: Self ) -> str:
7584
"""Access the Id of the Mohr circle.
7685
7786
Returns:
7887
str: Id of the Mohr circle
7988
"""
80-
return self.m_circleId
89+
return self.circleId
8190

8291
def getCircleRadius( self: Self ) -> float:
83-
"""Compute and return Mohr's circle radius from principal components."""
84-
return ( self.m_p1 - self.m_p3 ) / 2.0
92+
"""Compute and return Mohr's circle radius from principal components.
93+
94+
Returns:
95+
float: Mohr circle radius.
96+
"""
97+
return ( self.p1 - self.p3 ) / 2.0
8598

8699
def getCircleCenter( self: Self ) -> float:
87-
"""Compute and return Mohr's circle center from principal components."""
88-
return ( self.m_p1 + self.m_p3 ) / 2.0
100+
"""Compute and return Mohr's circle center from principal components.
101+
102+
Returns:
103+
float: Mohr circle center.
104+
"""
105+
return ( self.p1 + self.p3 ) / 2.0
89106

90107
def getPrincipalComponents( self: Self ) -> tuple[ float, float, float ]:
91-
"""Get Moh's circle principal components."""
92-
return ( self.m_p3, self.m_p2, self.m_p1 )
108+
"""Get Moh's circle principal components.
109+
110+
Returns:
111+
tuple[float, float, float]: Mohr circle principal components.
112+
"""
113+
return ( self.p3, self.p2, self.p1 )
93114

94115
def setPrincipalComponents( self: Self, p3: float, p2: float, p1: float ) -> None:
95116
"""Set principal components.
96117
97118
Args:
98-
p3 (float): first component. Must be the lowest.
99-
p2 (float): second component.
100-
p1 (float): third component. Must be the greatest.
119+
p3 (float): First component. Must be the lowest.
120+
p2 (float): Second component.
121+
p1 (float): Third component. Must be the greatest.
122+
123+
Raises:
124+
ValueError: Expected p3 <= p2 <= p1.
101125
"""
102-
assert ( p3 <= p2 ) and ( p2 <= p1 ), "Component order is wrong."
103-
self.m_p3 = p3
104-
self.m_p2 = p2
105-
self.m_p1 = p1
126+
if not ( ( p3 <= p2 ) and ( p2 <= p1 ) ):
127+
raise ValueError( "Component order is wrong. Expected p3 <= p2 <= p1." )
128+
self.p3 = p3
129+
self.p2 = p2
130+
self.p1 = p1
106131

107132
def computePrincipalComponents( self: Self, stressVector: npt.NDArray[ np.float64 ] ) -> None:
108133
"""Calculate principal components.
@@ -111,5 +136,5 @@ def computePrincipalComponents( self: Self, stressVector: npt.NDArray[ np.float6
111136
stressVector (npt.NDArray[np.float64]): 6 components stress vector
112137
Stress vector must follow GEOS convention (XX, YY, ZZ, YZ, XZ, XY)
113138
"""
114-
# get stress principal components
115-
self.m_p3, self.m_p2, self.m_p1 = ( computeStressPrincipalComponentsFromStressVector( stressVector ) )
139+
# Get stress principal components
140+
self.p3, self.p2, self.p1 = ( computeStressPrincipalComponentsFromStressVector( stressVector ) )

0 commit comments

Comments
 (0)