HyperWorks Solvers

CONTACTPOST

CONTACTPOST

Previous topic Next topic No expanding text in this topic  

CONTACTPOST

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  

Subroutine Type

Modeling

Definition

Used to extract rigid body contact results.

Use

This subroutine can be used to extract rigid body contact results from a MotionSolve simulation which can then be used to generate an output file or process the results programmatically.

 

<Force_Contact

    id                  = "303001"

    ...

    cpost_dll_name      = "my_contact_post_sub"

    cpost_param_string  = "USER(1000) "

    cpost_fnc_name      = "CONTACTPOST"

/>

Calling Syntax

Fortran

SUBROUTINE CONTACTPOST (ID, I_GRA_ID, J_GRA_ID, TIME, PAR, NPAR, IFLAG, ENDFLG)

 

C

void STDCALL CONTACTPOST (int *id, int *i_gra_id, int *j_gra_id, double *time, double *par, int *npar, int *iflag, int *endflg)

 

Python

def CONTACTPOST(id, i_gra_id, j_gra_id, time, par, npar, iflag, endflg):

Input Arguments

[integer] ID

The ID of the contact force modeling element (Force_Contact in XML) for which the results are desired.

This argument is automatically populated and passed in by MotionSolve.

 

[integer] I_GRA_ID

The ID of the I body’s graphic representation.

This argument is automatically populated and passed in by MotionSolve.

 

[integer] J_GRA_ID

The ID of the J body’s graphic representation.

This argument is automatically populated and passed in by MotionSolve.

 

[double] TIME

The current simulation time.

This argument is automatically populated and passed in by MotionSolve.

 

[double] PAR

An array that contains the constant arguments from the list provided in the user-defined statement. 

This argument is defined by the user in the model.

 

[integer] NPAR

The number of entries in the PAR array.

This argument is automatically populated and passed in by MotionSolve based on the size of the PAR array.

 

[integer] IFLAG

The initialization flag. See Comment 3 for more details.

 

[integer] ENDFLG

The end flag. See Comment 3 for more details.

Output Values

None.

Comments

1.The CONTACTPOST subroutine is called by MotionSolve whenever contact occurs between the bodies defined in the corresponding contact force model element. Note, this subroutine is not called when there is no contact between the rigid bodies.

Further, if the I and/or J bodies defined in the contact statement refer to more than one graphics, the CONTACTPOST is called for each combination of the I graphic (I_GRA_ID) and the J graphic (J_GRA_ID).

2.From within the CONTACTPOST subroutine, you may call the access functions GET_NCONTACTS and GET_CONTACT_POST to obtain additional information about the contact states during the simulation. Please see the documentation for syntax and usage of these access functions.
3.The CONTACTPOST is called by MotionSolve with IFLAG set to 1 at the beginning of each simulate. At the end of each simulate, CONTACTPOST is called with ENDFLG set to 1. This allows you to correctly open/close files and do memory allocation/de-allocation properly. If you would like to save data in between multiple simulates, you may use the utility functions SAVPAR and RELPAR to do so.
4.The CONTACTPOST subroutine enables you to obtain information about the rigid body contact states during a MotionSolve simulation that are not otherwise available by using standard MotionSolve expressions. This data can then be written in any format you desire for downstream CAE processes like exporting to an FE/fatigue solver.

Example

The following example retrieves the penetration depth and total force at each time step for a simulation that models rigid body contact:

<Force_Contact

    id                  = "303001"

    label               = "Contact 0"

    num_i_graphics      = "1"

    i_graphics_id       = "90001"

    num_j_graphics      = "1"

    j_graphics_id       = "90000"

    cnf_type            = "Impact"

    stiffness           = "1000."

    exponent            = "1.2"

    damping             = "1."

    dmax                = "0.01"

    cff_type            = "Coulomb_Off"

    cpost_dll_name      = "my_contact_post_sub"

    cpost_param_string  = "USER()"

    cpost_fnc_name      = "CONTACTPOST"

/>

The contents of CONTACTPOST in my_contact_post_sub are:

void STDCALL CONTACTPOST (int *id, int *i_gra_id, int *j_gra_id, double *time, double *par, int *npar, int *iflag, int *endflg)

{

/*

Input argument

----------------------------------------------------------

 id    Identifier of calling CONTACT statement

 i_gra_id Identifier of calling I_GRAPHIC

 j_gra_id Identifier of calling J_GRAPHIC

 time  Time of contact

 par   Array containing passed parameters

 npar  Number of passed parameters

*/

  int nof_contacts;

  bool errflg;

 

   c_get_ncontacts(*id, *i_gra_id, *j_gra_id, &nof_contacts, &errflg);

  int ipar[4] = {30102020, 0, 0, 0};

  double states[6];

  int nstates;

  int ierr;

 

   c_sysary("tdisp", ipar, 1, states, &nstates, &ierr);

   printf(" I gra %d - J gra %d  time : %f  nof %d \n", *i_gra_id, *j_gra_id, *time, nof_contacts);

  for (int i=0; i<nof_contacts; i++)

  {

      double pd;

      double f[3];

      int n_results;

       c_get_contact_post(*id, *i_gra_id, *j_gra_id, "PD", i, &pd, &n_results, &errflg);

       c_get_contact_post(*id, *i_gra_id, *j_gra_id, "TOTAL_FORCE", i, f, &n_results, &errflg);

       printf(" %d PD = %f, F=[%f %f %f] z = %f \n", i, pd, f[0], f[1], f[2], states[2]);

   }

   

}

See Also:

Modeling Subroutines