Author Topic: User Element - Nh1 and Nh2  (Read 6034 times)

Omid

  • New Member
  • *
  • Posts: 3
User Element - Nh1 and Nh2
« on: December 15, 2016, 01:41:59 PM »
Dear friends,

I am writing a user element for small deformation scheme in FEAP. I must keep track of history variables and use them later on for which I am using "hr" array along with "nh1" and "nh2". According to the manual, nh1 and nh2 are address pointers for the previous and current steps , I want to use them to access the data. I am using something like

his = hr(nh1+0, nh1+nhvpe)  ! nhvpe = number of history variables per element

to retrieve the history variables of the previous step and use them in my computations. Later on I will update them as follows

hr(nh2+0, nh2+nhvpe) = his ! his is the history variables which they just were computed.

which they will be used in next time step. I have a few questions, since  "nh1" and "nh2" are pointers, is it right to use the format I mentioned? I am getting segmentation faults and "nh1" and "nh2" are big integers. Incidentally, I am initializing hr(nh2+0, nh2+nhvpe) to zero in case 14. I am not using case 12 for the updating purposes, and I am doing it in case 3 and 6 in their sub-functions. Thank you in advance for the help.

Regards,

Omid

FEAP_Admin

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 993
Re: User Element - Nh1 and Nh2
« Reply #1 on: December 15, 2016, 04:18:51 PM »
It is more complicated than this.  From program/pform.f the way to compute the needed location is
Code: [Select]
  ! First set n = element number you are interested in
  ! The loop over all materials possibly associated with element n
  include 'cdat1.h'  ! contains nie
  include 'cdata.h'  ! contains nen
  do ma = 1, nummat
  if(ie(nie,ma).gt.0) then  ! IE = mr(np(32)) see programmers manual
    ht1 = np(49) + ix(nen+1,n) + ie(nie-3,ma)    ! IX = mr(np(33))  see programmers manual
    ht2 = np(49) + ix(nen+2,n) + ie(nie-3,ma)
    ! at this stage ht1 and ht2 will allow you to see the history variables
    ! for element n, material ma in locations hr(ht1:ht1+ie(nie,ma)-1) for previously converge time
    ! and in hr(ht2:ht2+ie(nie,ma)-1) for the current time
  endif

Prof. R.L. Taylor

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 2649
Re: User Element - Nh1 and Nh2
« Reply #2 on: December 15, 2016, 06:37:50 PM »
You should follow how the history variables are done in one of the small displacement elements.  Look in
./elements/solid3d/sld3d1.f for example.  Since the nh1 and nh2 are pointers they can have very large numbers.  That is why we have the integer8 and integer4 include subdirectories -- to get the correct values.  Thus, it is best to transfer the values to a subroutine before you do all the manipulations:

call sub1(hr(nh1),hr(nh2), number of values you want to update.

In general for most of the algorithms we use there should be a statement equivalent to: hr(nh2+*) = hr(nh1+*) + change.

You should not make hr(*,*) a double subscript array;  You could make the arrays in subroutine sub1 be double subscripted, but they will not have any association to nh1 and nh2. 

subroutine sub1(array1, array2, ...)

implicit none

array1(5,10), array2(5,10)  as an example (note they must have the same dimensioning if you do this.

Omid

  • New Member
  • *
  • Posts: 3
Re: User Element - Nh1 and Nh2
« Reply #3 on: January 09, 2017, 08:03:34 AM »
Thank you Prof. Taylor for your reply. I tried a similar approach, and it seems the code is working. As an aside, it was a typo in my post. My intention was to write

his = hr(nh1+0: nh1+nhvpe)  ! nhvpe = number of history variables per Gauss point

Apart from that, I faced another problem. When I am trying to run my codes for a 2D rectangular part with 'nen_x'  and 'nen_y' elements  in x and y directions, respectively, under tensile; for some number of elements, I am getting the following error:

feap: malloc.c:3096: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.
Program received signal SIGABRT
raise () in /lib/x86_64-linux-gnu/libc-2.13.so

I tried to use debuggers in order to find out about what's happening there, and I got the following message

#0  0x00007f63c772d125 in raise () in /lib/x86_64-linux-gnu/libc-2.13.so
#1  0x00007f63c77303a0 in abort () in /lib/x86_64-linux-gnu/libc-2.13.so
#2  0x00007f63c7770dba in malloc_usable_size () in /lib/x86_64-linux-gnu/libc-2.13.so
#3  0x00007f63c7773ce3 in malloc_trim () in /lib/x86_64-linux-gnu/libc-2.13.so
#4  0x00007f63c7775a40 in malloc () in /lib/x86_64-linux-gnu/libc-2.13.so
#5  0x00007f63c70cde8a in xcb_wait_for_event () in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
#6  0x00007f63c70cc358 in xcb_connect_to_fd () in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
#7  0x00007f63c70cd697 in xcb_poll_for_reply () in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
#8  0x00007f63c70cd8bb in xcb_wait_for_reply () in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
#9  0x00007f63c9a6a1c9 in _XReply () in /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0
#10 0x00007f63c9a4bb16 in XFlush () in /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0

Do you have any ideas how I can fix the problem? By the way, I am using Intel compiler and Linux operation system. Thank you in advance for the help.

Prof. S. Govindjee

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 1165
Re: User Element - Nh1 and Nh2
« Reply #4 on: January 09, 2017, 09:59:34 AM »
Quote
his = hr(nh1+0: nh1+nhvpe)  ! nhvpe = number of history variables per Gauss point
This is incorrect.  Just think about what it will do if there is only one history variable.

The other error you are getting looks like some sort of system error.  Something appear to be wrong with the X11 server.

Omid

  • New Member
  • *
  • Posts: 3
Re: User Element - Nh1 and Nh2
« Reply #5 on: January 09, 2017, 11:03:53 AM »
Thank you Prof. S. Govindjee. Yes, you're right. It should be

his = hr(nh1+0: nh1+nhvpe-1)

Thanks again.

Edit: I found the problem.
« Last Edit: January 17, 2017, 07:27:14 AM by Omid »