# Question on tracking the number of subcontacts experiencing sliding or dilation at different iteration steps

**URL:** <https://forum.itascainternational.com/t/question-on-tracking-the-number-of-subcontacts-experiencing-sliding-or-dilation-at-different-iteration-steps/1297>\
**Category:** 3DEC\
**Created:** [January 17, 2024, 6:58am UTC](https://forum.itascainternational.com/t/question-on-tracking-the-number-of-subcontacts-experiencing-sliding-or-dilation-at-different-iteration-steps/1297 "2024-01-17T06:58:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JLUJYP](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@JLUJYP](https://forum.itascainternational.com/u/JLUJYP)\
**Post date:** [January 17, 2024, 6:58am UTC](https://forum.itascainternational.com/t/question-on-tracking-the-number-of-subcontacts-experiencing-sliding-or-dilation-at-different-iteration-steps/1297/1 "2024-01-17T06:58:01Z")

</div>

How can I monitor the subcontact states (sliding, dilation, etc.) of joint sets in 3DEC 7.0? I want to track the number of subcontacts experiencing sliding or dilation at different iteration steps in the model. Thank you very much!

---

<div class="post-metadata">

**Author:** ![Theophile](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.itascainternational.com/theophile/32/299_2.png) [@Theophile](https://forum.itascainternational.com/u/Theophile)\
**Post date:** [January 17, 2024, 9:39am UTC](https://forum.itascainternational.com/t/question-on-tracking-the-number-of-subcontacts-experiencing-sliding-or-dilation-at-different-iteration-steps/1297/2 "2024-01-17T09:39:15Z")

</div>

Hi @JLUJYP !

You could use the [`fish history`](https://docs.itascacg.com/3dec700/common/kernel/doc/manual/fish/commands/cmd_fish.history.html#fish.history) command.

In PS of this message, I give a script modified after the [slip.dat](https://docs.itascacg.com/3dec700/3dec/docproject/source/theory/mohrcoulomb/mohrcoulomb.html) file from 3DEC documentation.

When plotting the history at the end of the run, I get this result for the number of sliding points (cyan line in the picture):

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/itasca/original/1X/91e294e23a74d841bf75d42c7cffbb1a099746cd.png)

The key points are:

- setting a Fish function to keep track of number of subcontacts (3DEC command `fish define nsliding_nodes`in script below)
- setting the interval history with the 3DEC `history interval` command
- setting the actual tracking with the 3DEC `fish history name` command

You can then customize the subcontacts states you want to keep track of with other state values (see the **States** section in link above).

Notice that `history command` lets you track values on regular intervals.  
You can also base your tracking on _events_ rather than on regular intervals (_e.g._, each time a subcontact enters sliding), see the [`fish callback`](https://docs.itascacg.com/3dec700/common/kernel/doc/manual/fish/commands/cmd_fish.callback.html?node1585) 3DEC command.

Hope it helps!

Regards

Théophile

PS : the script

```auto
; Example from 3DEC documentation, modified to keep track of number of sliding/ruptured joints
; doc/3dec/docproject/source/theory/mohrcoulomb/mohrcoulomb.html

model new
model large-strain on

; Coulomb slip joint model
; direct shear test
;
block create brick -0.15,0.15 -0.10,0.10 -0.10,0
block create brick -0.10,0.10 -0.10,0.10 0,0.10

block zone generate edgelength 0.02

block zone cmodel assign elastic
block zone prop dens=0.0026 bulk=4000 shear=3000
;
 ; Coulomb slip model
block contact jmodel assign mohr
block contact prop stiffness-normal=100000 stiffness-shear=100000 ...
                   friction=30.0 dilation 15 dilation-zero 6e-4

;; Use cohesion for weakening behavior
;block contact prop cohesion 10

block contact material-table default prop stiffness-normal=100000 ...
                                          stiffness-shear=100000 ...
                                          friction=30.0 dilation 15 ...
                                          dilation-zero 6e-4

block hide range pos-z 0 1
block gridpoint apply vel 0 0 0 range pos-z -1 0.1
block hide off
;
; normal load
block face apply stress 0 0 -50 0 0 0 range pos-z 0.1
;
model cycle 100

fish define nsliding_nodes
    ; Compute number of sliding nodes
    local nnodes = 0
    loop foreach local cpnt block.contact.list()
        loop foreach local cxpnt block.contact.subcontactlist(cpnt)
            local sliding_now = math.and(block.subcontact.state(cxpnt), 1)
            if sliding_now
                nnodes += 1
            end_if
        end_loop
    end_loop
    nsliding_nodes = nnodes
end
;
block contact reset disp
block contact reset state

; shear load
block hide range pos-z -.1 0.0
block gridpoint apply vel-x=0.005 range pos-z -.1 1.1
block gridpoint apply vel-y 0 range pos-z -1 1
block hide off
;
his interval 5
fish hist name 'N sliding' nsliding_nodes

model cyc 30000

;model save 'slip1'
program return

```

---

<div class="post-metadata">

**Author:** ![JLUJYP](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@JLUJYP](https://forum.itascainternational.com/u/JLUJYP)\
**Post date:** [January 17, 2024, 12:47pm UTC](https://forum.itascainternational.com/t/question-on-tracking-the-number-of-subcontacts-experiencing-sliding-or-dilation-at-different-iteration-steps/1297/3 "2024-01-17T12:47:41Z")

</div>

Thank you for your kind response. The information you provided has been very helpful to me. Wishing you a joyful life!

---

<div class="post-metadata">

**Author:** ![Theophile](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.itascainternational.com/theophile/32/299_2.png) [@Theophile](https://forum.itascainternational.com/u/Theophile)\
**Post date:** [January 17, 2024, 1:50pm UTC](https://forum.itascainternational.com/t/question-on-tracking-the-number-of-subcontacts-experiencing-sliding-or-dilation-at-different-iteration-steps/1297/4 "2024-01-17T13:50:57Z")

</div>

I’m glad it helped!

Regards

Théophile
