Author Topic: output of displacements stress and strain  (Read 7203 times)

adil

  • Jr. Member
  • **
  • Posts: 11
output of displacements stress and strain
« on: December 27, 2015, 06:16:55 AM »
Hello;
I wish to get access to displacements stress and strain values; so i used the same methode as discribed by  Pr.Sanjay at : http://www.ce.berkeley.edu/~sanjay/FEAP/umacr9_parav.f
but all i get is zeros;

hr(np(40)+(i-1)*ndf+ii)

        for(long int n = 0; n<*FEAP::NUMNP; n++)
        {
            for(long int u = 0; u<*FEAP::NDF; u++)
            {
                disp = FEAP::hr[ FEAP::np[40-1] + (n-1) * *FEAP::NDF + u - 1];
                std::cout << "U : " << disp << ",";
            }
            std::cout << endl;
         }

thank you

ps: i'm using c++ to access the library, so i offset the arrays by -1;

Prof. R.L. Taylor

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 2647
Re: output of displacements stress and strain
« Reply #1 on: December 27, 2015, 11:53:48 AM »
Post how you are accessing the pointers (which are 64 bit pointers) and the array 'hr' -- the error must be there!

adil

  • Jr. Member
  • **
  • Posts: 11
Re: output of displacements stress and strain
« Reply #2 on: December 27, 2015, 03:49:37 PM »
hello; this is how i access pointers:

extern "C" {

extern struct
{
    long int ndf;
    long int ndm;
    long int nen1;
    long int nst;
    long int nneq;
}sdata_;

extern struct
{
    long int numnp,numel,nummat,nen,neq,ipr;
} cdata_;

extern struct
{
    long int np [400];
    long int up [200];
}pointer_;

extern struct
{
    double hr [1024];
    long int mr [1024];
}comblk_;

}


and i create a namespace to simplify access to the pointers

header files:

namespace FEAP{

    extern double* hr;
    extern long int* mr;
    extern long int* up;
    extern long int* np;

    /**< MESH INPUT DATA SPECIFICATIONS */
      extern long int *NUMNP;       /**< NUMNP - Number of nodal points;                    */
      extern long int *NUMEL;       /**< NUMEL - Number of elements;                        */
      extern long int *NUMMAT;     /**< NUMMAT - Number of material property sets;         */
      extern long int *NEN;           /**< NEN - Maximum number of nodes per element.         */
      extern long int *NEN1;
      extern long int *NDF;       /**< NDF - Maximum number of unknowns per node; and     */
      extern long int *NDM;       /**< NDM - Space dimension of mesh;                     */
      extern long int *ISTV;           
}

cpp file:

namespace FEAP{

    double* hr = comblk_.hr;
    long int* mr = comblk_.mr;
    long int* up = pointer_.up;
    long int* np = pointer_.np;

    /**< MESH INPUT DATA SPECIFICATIONS */
    long int *NUMNP = &cdata_.numnp;       /**< NUMNP - Number of nodal points;                    */
    long int *NUMEL = &cdata_.numel;       /**< NUMEL - Number of elements;                        */
    long int *NUMMAT = &cdata_.nummat;     /**< NUMMAT - Number of material property sets;         */
    long int *NEN = &cdata_.nen;           /**< NEN - Maximum number of nodes per element.         */
    long int *NEN1 = &sdata_.nen1;
    long int *NDF = &sdata_.ndf;;       /**< NDF - Maximum number of unknowns per node; and     */
    long int *NDM = &sdata_.ndm;       /**< NDM - Space dimension of mesh;                     */
    long int *ISTV = &strnum_.istv;     
}

Prof. R.L. Taylor

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 2647
Re: output of displacements stress and strain
« Reply #3 on: December 27, 2015, 04:26:39 PM »
You should check the precision of each variable.  In general feap uses 32 bit integers, except for  pointer values "np" and "up".  To see which variables need to be used see the include files in integer*8.

adil

  • Jr. Member
  • **
  • Posts: 11
Re: output of displacements stress and strain
« Reply #4 on: December 28, 2015, 09:29:18 AM »
Hi;

i have tried the "long long int" which is supposed to have 64 bit precision at least and "int64_t" which have strictly 64bit.

Thank You,

FEAP_Admin

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 993
Re: output of displacements stress and strain
« Reply #5 on: December 28, 2015, 01:57:19 PM »
long int is the incorrect type for most of these variables.  for example all of the variables in sdata_ are 32-bit signed integers.  long int usually means 64-bit signed integers but most of the variables in FEAP/FEAPpv are FORTRAN integer == 32-bit signed integers.  Thus you should be using "int" in place of "long int".  Note that
pointer arithmetic needs to be 64-bit so you may need to cast to get things to work properly.

If you have an up-to-date working version of f2c, then you can run this on the include/*.h files to see how the common blocks are supposed to translate over to structures.  But easier is to just look in include/*.h as well as include/integer?/*.h to see what you need, noting that FORTRAN integer == C int, FORTRAN integer*8 == C long int, FORTRAN real*4 == C float, FORTRAN real*8 == C double.

adil

  • Jr. Member
  • **
  • Posts: 11
Re: output of displacements stress and strain
« Reply #6 on: December 30, 2015, 03:19:28 PM »
hi,
i changed corrected the types as you said, but i always get zeros;
i've then put the folowing code in the feappv library:
in pmacr3.f before

(
      pfr = pfro
      return

c     Solve equations
)
i put:

      open (unit=outU,file="U.txt",action="write",status="replace")
      write (outU,*) '____________________________________________'
      do i=1,50
          write (outU,*) hr(np(40)+i);
      end do
      close (outU)

and i get the right results in U.txt file;
but when i put it in prtdis.f it gives just zeros"

adil

  • Jr. Member
  • **
  • Posts: 11
Re: output of displacements stress and strain
« Reply #7 on: December 30, 2015, 03:32:34 PM »
does feap empty the array after it finish solving the problem?
thank you;

FEAP_Admin

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 993
Re: output of displacements stress and strain
« Reply #8 on: December 30, 2015, 06:31:13 PM »
No, the data remains it is not cleared.

Why don't you write a simple C function and call it just before your write statement.
Pass in hr( ) and hr(np(40))

Then in the routine check the pointer values for the hr array, hr(np(40)).  Compare these
to what you find for comblk_.hr etc.

The process should be very straightforward.  Someplace you have a simple error.