CONTACTPOST
ModelingExtract body contact results.
Use
This subroutine can be used to extract rigid or flexible 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"
/>
Format
- Fortran Calling Syntax
-
SUBROUTINE CONTACTPOST (ID, I_GRA_ID, J_GRA_ID, TIME, PAR, NPAR, IFLAG, ENDFLG)
- C/C++ Calling Syntax
-
void STDCALL CONTACTPOST (int *id, int *i_gra_id, int *j_gra_id, double *time, double *par, int *npar, int *iflag, int *endflg)
- Python Calling Syntax
-
def CONTACTPOST(id, i_gra_id, j_gra_id, time, par, npar, iflag, endflg):
- MATLAB Calling Syntax
- Not supported.
Attributes
- ID
- [integer]
- I_GRA_ID
- [integer]
- J_GRA_ID
- [integer]
- TIME
- [double]
- PAR
- [double]
- NPAR
- [integer]
- IFLAG
- [integer]
- ENDFLG
- [integer]
Example
The following example retrieves the penetration depth and total force at each time step for a
simulation that models 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);
intipar[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 (inti=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]);
}
}
Comments
- 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 graphic of a rigid body, the CONTACTPOST is called for each combination of the I graphic (I_GRA_ID) and/or the J graphic (J_GRA_ID).
- 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.
- 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.
- 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.