From dc0133208089e98845787e20b642f81bde4f8824 Mon Sep 17 00:00:00 2001 From: Ibrahim Kaleel Date: Wed, 17 Jan 2024 10:34:34 -0500 Subject: [PATCH 01/55] Updates for macro-micro call --- CalculiX.h | 337 +++-- adapter/CCXHelpers.c | 261 ++-- adapter/CCXHelpers.h | 61 +- adapter/ConfigReader.cpp | 5 + adapter/ConfigReader.h | 3 +- adapter/ConfigReader.hpp | 0 adapter/PreciceInterface.c | 633 ++++++---- adapter/PreciceInterface.h | 130 +- ccx_2.19.c | 2228 ++++++++++++++++++++++++++++++++++ getelementgausspointcoords.f | 336 +++++ getflux.f | 0 getkdeltatemp.f | 0 getstrain.f | 343 ++++++ linstatic_precice.c | 1372 +++++++++++++++++++++ nonlingeo_precice.c | 297 ++--- 15 files changed, 5229 insertions(+), 777 deletions(-) mode change 100644 => 100755 CalculiX.h mode change 100644 => 100755 adapter/CCXHelpers.c mode change 100644 => 100755 adapter/CCXHelpers.h mode change 100644 => 100755 adapter/ConfigReader.cpp mode change 100644 => 100755 adapter/ConfigReader.h mode change 100644 => 100755 adapter/ConfigReader.hpp mode change 100644 => 100755 adapter/PreciceInterface.c mode change 100644 => 100755 adapter/PreciceInterface.h create mode 100755 ccx_2.19.c create mode 100755 getelementgausspointcoords.f mode change 100644 => 100755 getflux.f mode change 100644 => 100755 getkdeltatemp.f create mode 100755 getstrain.f create mode 100755 linstatic_precice.c mode change 100644 => 100755 nonlingeo_precice.c diff --git a/CalculiX.h b/CalculiX.h old mode 100644 new mode 100755 index e069de0c..d0b36f1a --- a/CalculiX.h +++ b/CalculiX.h @@ -1,5 +1,5 @@ /* CALCULIX - A 3-dimensional finite element program */ -/* Copyright (C) 1998-2022 Guido Dhondt */ +/* Copyright (C) 1998-2021 Guido Dhondt */ /* This program is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU General Public License as */ @@ -140,8 +140,6 @@ void FORTRAN(adjustcontactnodes, (char *tieset, ITG *ntie, ITG *itietri, double double *clearslavnode, ITG *itiefac, ITG *ipkon, ITG *kon, char *lakon, ITG *islavsurf)); -void *addmt(ITG *i); - void FORTRAN(addshell, (ITG * nactdof, ITG *node, double *b, ITG *mi, ITG *iperturb, ITG *nmethod, double *cam, double *v)); @@ -172,20 +170,17 @@ void FORTRAN(allocont, (ITG * ncont, ITG *ntie, char *tieset, ITG *nset, char *lakon, ITG *ncone, double *tietol, ITG *ismallsliding, char *kind1, char *kind2, ITG *mortar, ITG *istep)); -void FORTRAN(applybounfem, (ITG * nodeboun, ITG *ndirboun, - double *xbounact, ITG *nk, double *vold, - ITG *isolidsurf, double *xsolidsurf, - ITG *ifreestream, ITG *turbulent, - double *vcon, double *shcon, ITG *nshcon, ITG *ntmat_, - double *physcon, double *v, ITG *compressible, - ITG *nodempc, ITG *ipompc, double *coefmpc, - ITG *inomat, ITG *mi, ITG *ilboun, ITG *ilmpc, - char *labmpc, double *coefmodmpc, ITG *iexplicit, - ITG *nbouna, ITG *nbounb, ITG *nmpca, ITG *nmmpb, - ITG *nfreestreama, ITG *nfreestreamb, - ITG *nsolidsurfa, ITG *nsolidsurfb)); - -void *applybounfemmt(ITG *i); +void FORTRAN(applybounfem, (ITG * nodeboun, ITG *ndirboun, ITG *nboun, + double *xbounact, ITG *ithermal, ITG *nk, + double *vold, ITG *isolidsurf, + ITG *nsolidsurf, double *xsolidsurf, ITG *nfreestream, ITG *ifreestream, + ITG *turbulent, double *vcon, double *shcon, ITG *nshcon, + double *rhcon, ITG *nrhcon, ITG *ntmat_, double *physcon, + double *v, ITG *compressible, ITG *nmpc, ITG *nodempc, + ITG *ipompc, double *coefmpc, ITG *inomat, ITG *mi, + ITG *ilboun, ITG *ilmpc, char *labmpc, + double *coefmodmpc, ITG *ifreesurface, ITG *ierr, double *dgravity, + double *depth, ITG *iexplicit)); void FORTRAN(applybounp, (ITG * nodeboun, ITG *ndirboun, ITG *nboun, double *xbounact, ITG *nk, double *vold, double *v, @@ -321,11 +316,11 @@ void FORTRAN(assigndomtonodes, (ITG * ne, char *lakon, ITG *ipkon, ITG *kon, ITG *mi, ITG *ne2)); void FORTRAN(auglag_inclusion, (double *gcontfull, double *cvec, ITG *nacti, - ITG *iacti, double *mufric, double *atol, - double *rtol, double *alglob, ITG *kitermax, + ITG *iacti, ITG *ncdim, double *mufric, double *atol, + double *rtol, double *pkglob, ITG *kitermax, double *auw, ITG *jqw, ITG *iroww, - ITG *nslavs, double *al, double *alnew, - double *eps_al, double *omega)); + ITG *nslavs, double *pkvec, double *pkvecnew, + double *eps_al)); void FORTRAN(autocovmatrix, (double *co, double *ad, double *au, ITG *jqs, ITG *irows, ITG *ndesi, ITG *nodedesi, double *corrlen, @@ -364,12 +359,6 @@ void FORTRAN(calcdatarget, (ITG * ifront, double *co, ITG *nnfront, double *tinc, double *datarget, double *acrack, ITG *nstep)); -void FORTRAN(calcdev, (double *vold, double *vcon, double *v, ITG *nk, - ITG *iturbulent, ITG *mi, double *vconmax, - double *vmax, ITG *iexplicit, ITG *nka, ITG *nkb)); - -void *calcdevmt(ITG *i); - void FORTRAN(calcenergy, (ITG * ipkon, char *lakon, ITG *kon, double *co, double *ener, ITG *mi, ITG *ne, double *thicke, ITG * ielmat, @@ -430,27 +419,20 @@ void calcshapef(ITG *nvar_, ITG *ipvar, double **var, ITG *ne, ITG *iturbulent, double *yy); void FORTRAN(calcstabletimeinccont, (ITG * ne, char *lakon, ITG *kon, ITG *ipkon, - ITG *mi, ITG *ielmat, double *elcon, - ITG *mortar, double *adb, double *alpha, - ITG *nactdof, double *springarea, ITG *ne0, - ITG *ntmat_, ITG *ncmat_, double *dtcont, - double *smscale, double *dtset, - ITG *mscalmethod)); + ITG *mi, ITG *ielmat, double *elcon, ITG *mortar, double *adb, + double *alpha, ITG *nactdof, double *springarea, ITG *ne0, + ITG *ntmat_, ITG *ncmat_, double *dtcont, double *smscale, + double *dtset, ITG *mscalmethod)); void FORTRAN(calcstabletimeincvol, (ITG * ne0, double *elcon, ITG *nelcon, - double *rhcon, ITG *nrhcon, double *alcon, - ITG *nalcon, double *orab, ITG *ntmat_, - ITG *ithermal, double *alzero, double *plicon, - ITG *nplicon, double *plkcon, ITG *nplkcon, - ITG *npmat_, ITG *mi, double *dtime, - double *xstiff, ITG *ncmat_, double *vold, - ITG *ielmat, double *t0, double *t1, - char *matname, char *lakon, - double *xmatwavespeed, ITG *nmat, ITG *ipkon, - double *co, ITG *kon, double *dtvol, - double *alpha, double *smscale, double *dtset, - ITG *mscalmethod, ITG *mortar, - char *jobnamef)); + double *rhcon, ITG *nrhcon, double *alcon, ITG *nalcon, double *orab, + ITG *ntmat_, ITG *ithermal, double *alzero, double *plicon, + ITG *nplicon, double *plkcon, ITG *nplkcon, ITG *npmat_, ITG *mi, + double *dtime, double *xstiff, ITG *ncmat_, double *vold, ITG *ielmat, + double *t0, double *t1, char *matname, char *lakon, + double *xmatwavespeed, ITG *nmat, ITG *ipkon, double *co, ITG *kon, + double *dtvol, double *alpha, double *smscale, double *dtset, + ITG *mscalmethod)); void FORTRAN(calcstressheatfluxfem, (ITG * kon, char *lakon, ITG *ipkon, ITG *ielmat, ITG *ntmat_, double *vold, char *matname, ITG *mi, double *shcon, @@ -645,9 +627,10 @@ void FORTRAN(cavityext_refine, (ITG * kontet, ITG *ifatet, ITG *ifreetet, double double *cotetorig, ITG *iedge, ITG *iexternnode, double *cg, double *height, ITG *iparentel)); -void FORTRAN(cfdconv, (ITG * nmethod, ITG *iconvergence, ITG *ithermal, ITG *iit, - ITG *turbulent, double *dtimef, double *vconmax, - double *vmax)); +void FORTRAN(cfdconv, (double *vold, double *vcon, double *v, ITG *nk, + ITG *nmethod, ITG *iconvergence, ITG *ithermal, ITG *iit, + ITG *turbulent, ITG *mi, double *dtimef, double *vconmax, + ITG *iexplicit)); ITG cgsolver(double *A, double *x, double *b, ITG neq, ITG len, ITG *ia, ITG *iz, double *eps, ITG *niter, ITG precFlg); @@ -691,7 +674,7 @@ void checkconvnet(ITG *icutb, ITG *iin, double *cam1a, double *cam2a, double *cama, double *vamt, double *vamf, double *vamp, double *vama, double *qa, double *qamt, double *qamf, double *ramt, - double *ramf, double *ramp, ITG *iplausi, + double *ramf, double *ramp, ITG *iplausi, ITG *ichannel, ITG *iaxial); void FORTRAN(checkconstraint, (ITG * nobject, char *objectset, double *g0, @@ -730,19 +713,14 @@ void checkdivergence(double *co, ITG *nk, ITG *kon, ITG *ipkon, char *lakon, void FORTRAN(checkexiedge, (ITG * n1newnodes, ITG *n2newnodes, ITG *ipoed, ITG *iedg, ITG *node)); -void FORTRAN(checkforhomnet, (ITG * ieg, ITG *nflow, char *lakon, ITG *ipkon, - ITG *kon, ITG *itg, ITG *ntg, ITG *iponoel, - ITG *inoel)); - void checkinclength(double *time, double *ttime, double *theta, double *dtheta, - ITG *idrct, double *tper, double *tmax, double *tmin, - double *ctrl, double *amta, ITG *namta, ITG *itpamp, - ITG *inext, double *dthetaref, ITG *itp, ITG *jprint, - ITG *jout); + ITG *idrct, double *tper, double *tmax, double *tmin, double *ctrl, + double *amta, ITG *namta, ITG *itpamp, ITG *inext, double *dthetaref, + ITG *itp, ITG *jprint, ITG *jout); void FORTRAN(checkimpacts, (ITG * ne, ITG *neini, double *temax, double *sizemaxinc, double *energyref, double *tmin, - double *tmax, double *tper, + double *tper, ITG *idivergence, ITG *idirinctime, ITG *istab, double *dtheta, double *enres, double *energy, double *energyini, double *allwk, double *allwkini, @@ -780,8 +758,6 @@ void FORTRAN(cmatrix, (double *ad, double *au, ITG *jqs, ITG *irows, ITG *icols, ITG *ndesi, ITG *nodedesi, double *auc, ITG *jqc, ITG *irowc, ITG *nodedesibou)); -void *collectingmt(ITG *i); - void FORTRAN(combilcfhcf, (double *tempf, double *stressf, double *stress, double *hcfstress, double *temp, ITG *nbounnod, ITG *mei, ITG *nstep)); @@ -881,11 +857,12 @@ void complexfreq(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **lakonp, void FORTRAN(con2phys, (double *vold, double *voldaux, ITG *nk, ITG *ntmat_, double *shcon, ITG *nshcon, double *rhcon, - ITG *nrhcon, double *physcon, ITG *ithermal, ITG *compressible, - ITG *turbulent, ITG *inomat, ITG *mi, ITG *ierr, ITG *ifreesurface, - double *dgravity, double *depth, ITG *nka, ITG *nkb)); - -void *con2physmt(ITG *i); + ITG * nrhcon, + double *physcon, ITG *ithermal, + ITG *compressible, + ITG *turbulent, ITG *inomat, ITG *mi, + ITG *ierr, ITG *ifreesurface, + double *dgravity, double *depth)); void FORTRAN(condrandomfield, (double *ad, double *au, ITG *jqs, ITG *irows, ITG *ndesi, double *rhs, double *vector, @@ -897,7 +874,8 @@ void contact(ITG *ncont, ITG *ntie, char *tieset, ITG *nset, char *set, double *cg, double *straight, ITG *ifree, double *co, double *vold, ITG *ielmat, double *cs, double *elcon, ITG *istep, ITG *iinc, ITG *iit, ITG *ncmat_, ITG *ntmat_, - ITG *ne0, ITG *nmethod, + ITG *ne0, double *vini, + ITG *nmethod, ITG *iperturb, ITG *ikboun, ITG *nboun, ITG *mi, ITG *imastop, ITG *nslavnode, ITG *islavnode, ITG *islavsurf, ITG *itiefac, double *areaslav, ITG *iponoels, ITG *inoels, double *springarea, @@ -909,17 +887,6 @@ void contact(ITG *ncont, ITG *ntie, char *tieset, ITG *nset, char *set, ITG *icutb, ITG *ialeatoric, char *jobnamef, double *alea, double *auw, ITG *jqw, ITG *iroww, ITG *nzsw); -void FORTRAN(contingentsurf, (ITG * ncrack, double *xplanecrack, - ITG *istartcrackbou, ITG *iendcrackbou, - double *costruc, double *cg, double *coproj, - double *crackarea, ITG *nnfront, ITG *isubsurffront, - ITG *istartcrackfro, ITG *iendcrackfro, - ITG *istartfront, ITG *iendfront, double *acrack, - double *xa, ITG *ifrontrel, ITG *integerglob, - double *doubleglob, ITG *nstep, double *surfnor, - double *surfco, double *resarea, double *alambdapj, - double *shape)); - void convert2rowbyrow(double *ad, double *au, ITG *icol, ITG *irow, ITG *jq, ITG *neq, ITG *nzs, double **aupardisop, ITG **pointersp, ITG **icolpardisop); @@ -975,26 +942,18 @@ void FORTRAN(crackprop, (ITG * ifrontrel, ITG *ibounnod, double *dadn, ITG *ncyc, ITG *ifrontprop, ITG *nstep, double *acrack, double *acrackglob, double *datarget, ITG *ieqspace, ITG *iincglob, - ITG *iinc, double *dnglob, ITG *ncyctot)); + ITG *iinc)); void crackpropagation(ITG **ipkonp, ITG **konp, char **lakonp, ITG *ne, ITG *nk, char *jobnamec, ITG *nboun, ITG *iamboun, double *xboun, ITG *nload, char *sideload, ITG *iamload, ITG *nforc, - ITG *iamforc, double *xforc, ITG *ithermal, double **t1p, - ITG **iamt1p, double **cop, ITG *nkon, ITG *mi, ITG **ielmatp, + ITG *iamforc, double *xforc, ITG *ithermal, double *t1, + ITG *iamt1, double **cop, ITG *nkon, ITG *mi, ITG **ielmatp, char *matname, char *output, ITG *nmat, char *set, ITG *nset, ITG *istartset, ITG *iendset, ITG *ialset, ITG *jmax, double *timepar, ITG *nelcon, double *elcon, ITG *ncmat_, ITG *ntmat_, ITG *istep, char *filab, ITG *nmethod, - ITG *mei, ITG *ntrans, ITG **inotrp, double **t0p, - ITG *ne1d, ITG *ne2d, double **t0gp, double **t1gp, - ITG *nam, double **t1oldp, double **voldp, ITG *iperturb, - ITG *iprestr, double **prestrp, ITG *norien, - ITG **ielorienp, ITG *nprop, ITG **ielpropp, - double **offsetp, double **stip, double **emep, - ITG *nener, double **enerp, ITG *nstate_, ITG *mortar, - ITG *nslavs, ITG *nintpoint, double **xstatep, - ITG **iponorp, double **thickep); + ITG *mei); void crackpropdata(char *jobnamec, ITG *nelcon, double *elcon, double **crconp, ITG *ncrconst, ITG *ncrtem, ITG *imat, char *matname, @@ -1019,10 +978,7 @@ void FORTRAN(crackshape, (ITG * nnfront, ITG *ifront, ITG *istartfront, void FORTRAN(create_contactdofs, (ITG * kslav, ITG *lslav, ITG *ktot, ITG *ltot, ITG *nslavs, ITG *islavnode, ITG *nmasts, ITG *imastnode, ITG *nactdof, ITG *mi, - ITG *neqtot, ITG *nslavnode, - double *fric, char *tieset, double *tietol, - ITG *ntie, double *elcon, ITG *ncmat_, - ITG *ntmat_)); + ITG *neqslav, ITG *neqtot)); void FORTRAN(createblock_struct, (ITG * neq, ITG *ipointers, ITG *icolpardiso, double *aupardiso, ITG *nestart, ITG *num_cpus, @@ -1520,20 +1476,19 @@ void expand(double *co, ITG *nk, ITG *kon, ITG *ipkon, char *lakon, void FORTRAN(expand_auw, (double *auw, ITG *jqw, ITG *iroww, ITG *nslavs, double *auwnew, ITG *jqwnew, ITG *irowwnew, - ITG *nactdof, + ITG *neqslav, ITG *nactdof, ITG *mi, ITG *ktot, ITG *neqtot, ITG *islavnode, ITG *imastnode)); void FORTRAN(extendmesh, (ITG * nnfront, ITG *istartfront, ITG *iendfront, - ITG *ifront, ITG *ne, ITG *nkon, char *lakon, + ITG *ifront, ITG *nkold, ITG *ne, ITG *nkon, char *lakon, ITG *ipkon, ITG *kon, ITG *isubsurffront, double *co, ITG *ifronteq, ITG *istartfronteq, ITG *iendfronteq, ITG *nfront, ITG *nfronteq)); void FORTRAN(extern_crackprop, (ITG * ieled, ITG *nedg, ITG *iexternedg, ITG *nexternedg, ITG *iexternnod, - ITG *nexternnod, ITG *iedg, ITG *iedno, - ITG *ier)); + ITG *nexternnod, ITG *iedg, ITG *iedno)); void FORTRAN(extfacepernode, (ITG * iponoelfa, ITG *inoelfa, char *lakonfa, ITG *ipkonfa, ITG *konfa, ITG *nsurfs, ITG *inoelsize)); @@ -1635,15 +1590,13 @@ void FORTRAN(flowoutput, (ITG * itg, ITG *ieg, ITG *ntg, ITG *nteq, double *rhcon, ITG *nrhcon, double *vold, char *jobnamef, char *set, ITG *istartset, ITG *iendset, ITG *ialset, ITG *nset, ITG *mi, - ITG *iaxial, ITG *istep, ITG *iit, ITG *ipobody, - ITG *ibody, double *xbodyact, ITG *nbody, ITG *ndata, - double *sfr, double *sba, ITG *jumpup, ITG *jumpdo)); + ITG *iaxial, ITG *istep, ITG *iit)); -void FORTRAN(flowbc, (ITG * ntg, ITG *itg, double *cam, double *vold, - double *v, - ITG *nload, char *sideload, ITG *nelemload, - double *xloadact, ITG *nactdog, ITG *network, ITG *mi, - ITG *ne, ITG *ipkon, char *lakon, ITG *kon)); +void FORTRAN(flowresult, (ITG * ntg, ITG *itg, double *cam, double *vold, + double *v, + ITG *nload, char *sideload, ITG *nelemload, + double *xloadact, ITG *nactdog, ITG *network, ITG *mi, + ITG *ne, ITG *ipkon, char *lakon, ITG *kon)); void FORTRAN(fluidnodes, (ITG * nef, ITG *ipkonf, char *lakonf, ITG *konf, ITG *ikf, ITG *nk, ITG *nkf)); @@ -1856,18 +1809,16 @@ void FORTRAN(genratio, (double *co, double *doubleglob, ITG *integerglob, ITG *nkold, ITG *nk, ITG *iprfn, ITG *konrfn, double *ratiorfn)); -void FORTRAN(gentiedmpc, (char *tieset, ITG *ntie, ITG *itietri, ITG *ipkon, - ITG *kon, char *lakon, char *set, ITG *istartset, +void FORTRAN(gentiedmpc, (char *tieset, ITG *ntie, ITG *itietri, + ITG *ipkon, ITG *kon, char *lakon, char *set, ITG *istartset, ITG *iendset, ITG *ialset, double *cg, double *straight, - ITG *koncont, double *co, double *xo, double *yo, - double *zo, double *x, double *y, double *z, ITG *nx, - ITG *ny, ITG *nz, ITG *nset, ITG *ifaceslave, - ITG *istartfield, ITG *iendfield, ITG *ifield, - ITG *ipompc, ITG *nodempc, double *coefmpc, ITG *nmpc, - ITG *nmpc_, ITG *mpcfree, ITG *ikmpc, ITG *ilmpc, - char *labmpc, ITG *ithermal, double *tietol, ITG *icfd, - ITG *ncont, ITG *imastop, ITG *ikboun, ITG *nboun, - char *kind, char *jobnamef)); + ITG *koncont, double *co, double *xo, double *yo, double *zo, + double *x, double *y, double *z, ITG *nx, ITG *ny, ITG *nz, ITG *nset, + ITG *ifaceslave, ITG *istartfield, ITG *iendfield, ITG *ifield, + ITG *ipompc, ITG *nodempc, double *coefmpc, ITG *nmpc, ITG *nmpc_, + ITG *mpcfree, ITG *ikmpc, ITG *ilmpc, char *labmpc, ITG *ithermal, + double *tietol, ITG *icfd, ITG *ncont, ITG *imastop, ITG *ikboun, + ITG *nboun, char *kind)); void FORTRAN(geomview, (double *vold, double *co, double *pmid, double *e1, double *e2, double *e3, ITG *kontri, double *area, double *cs, @@ -1883,19 +1834,17 @@ void getuncrackedresults(char *masterfile, ITG **integerglobp, void FORTRAN(getdesiinfo2d, (char *set, ITG *istartset, ITG *iendset, ITG *ialset, ITG *nset, ITG *mi, ITG *nactdof, ITG *ndesi, - ITG *nodedesi, ITG *ntie, char *tieset, - ITG *nodedesiinv, char *lakon, ITG *ipkon, ITG *kon, - ITG *iponoelfa, ITG *iponod2dto3d, ITG *iponor2d, - ITG *knor2d, ITG *iponoel2d, ITG *inoel2d, - ITG *nobject, char *objectset, ITG *iponk2dto3d, - ITG *ne, char *jobnamef)); + ITG *nodedesi, ITG *ntie, char *tieset, ITG *nodedesiinv, + char *lakon, ITG *ipkon, ITG *kon, ITG *iponoelfa, ITG *iponod2dto3d, + ITG *iponor2d, ITG *knor2d, ITG *iponoel2d, ITG *inoel2d, ITG *nobject, + char *objectset, ITG *iponk2dto3d, ITG *ne)); void FORTRAN(getdesiinfo3d, (char *set, ITG *istartset, ITG *iendset, ITG *ialset, ITG *nset, ITG *mi, ITG *nactdof, ITG *ndesi, ITG *nodedesi, ITG *ntie, char *tieset, ITG *itmp, ITG *nmpc, ITG *nodempc, ITG *ipompc, ITG *nodedesiinv, ITG *iponoel, ITG *inoel, char *lakon, ITG *ipkon, ITG *kon, ITG *noregion, - ITG *ipoface, ITG *nodface, ITG *nk, char *jobnamef)); + ITG *ipoface, ITG *nodface, ITG *nk)); void FORTRAN(getdesiinfo3d_robust, (char *set, ITG *istartset, ITG *iendset, ITG *ialset, ITG *nset, ITG *mi, ITG *nactdof, @@ -1905,7 +1854,7 @@ void FORTRAN(getdesiinfo3d_robust, (char *set, ITG *istartset, ITG *iendset, ITG *iponoel, ITG *inoel, char *lakon, ITG *ipkon, ITG *kon, ITG *noregion, ITG *ipoface, ITG *nodface, ITG *nk, - ITG *irandomtype, char *jobnamef)); + ITG *irandomtype)); void FORTRAN(getdesiinfobou, (ITG * ndesibou, ITG *nodedesibou, ITG *nodedesiinv, char *lakon, ITG *ipkon, ITG *kon, ITG *ipoface, @@ -1998,21 +1947,18 @@ void FORTRAN(initialcfdfem, (double *yy, ITG *nk, double *co, ITG *ne, ITG *ipko ITG *ibody, double *xbody, double *depth, ITG *nodfreesurf, double *dgravity, double *xg)); -void FORTRAN(initialchannel, (ITG * itg, ITG *ieg, ITG *ntg, +void FORTRAN(initialchannel, (ITG * itg, ITG *ieg, ITG *ntg, double *ac, double *bc, char *lakon, double *v, ITG *ipkon, ITG *kon, ITG *nflow, ITG *ikboun, ITG *nboun, double *prop, - ITG *ielprop, ITG *ndirboun, + ITG *ielprop, ITG *nactdog, ITG *ndirboun, ITG *nodeboun, double *xbounact, ITG *ielmat, ITG *ntmat_, double *shcon, ITG *nshcon, - double *physcon, + double *physcon, ITG *ipiv, ITG *nteq, double *rhcon, ITG *nrhcon, ITG *ipobody, ITG *ibody, double *xbody, double *co, ITG *nbody, ITG *network, - double *vold, char *set, ITG *istep, + ITG *iin_abs, double *vold, char *set, ITG *istep, ITG *iit, ITG *mi, ITG *ineighe, ITG *ilboun, - double *ttime, double *time, ITG *itreated, - ITG *iponoel, ITG *inoel, ITG *istack, double *sfr, - double *hfr, double *sba, double *hba, ITG *ndata, - ITG *jumpup, ITG *jumpdo)); + double *ttime, double *time, ITG *iaxial)); void FORTRAN(initialnet, (ITG * itg, ITG *ieg, ITG *ntg, double *ac, double *bc, char *lakon, double *v, ITG *ipkon, ITG *kon, @@ -2187,6 +2133,44 @@ void linstatic(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lakonp, ITG *mortar, ITG *mpcinfo, double *tietol, ITG *ics, char *orname, ITG *itempuser, double *t0g, double *t1g); +void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lakonp, + ITG *ne, + ITG *nodeboun, ITG *ndirboun, double *xboun, ITG *nboun, + ITG *ipompc, ITG *nodempc, double *coefmpc, char *labmpc, + ITG *nmpc, + ITG *nodeforc, ITG *ndirforc, double *xforc, ITG *nforc, + ITG *nelemload, char *sideload, double *xload, + ITG *nload, ITG *nactdof, + ITG **icolp, ITG *jq, ITG **irowp, ITG *neq, ITG *nzl, + ITG *nmethod, ITG *ikmpc, ITG *ilmpc, ITG *ikboun, + ITG * ilboun, + double *elcon, ITG *nelcon, double *rhcon, ITG *nrhcon, + double *alcon, ITG *nalcon, double *alzero, ITG **ielmatp, + ITG **ielorienp, ITG *norien, double *orab, ITG *ntmat_, + double *t0, double *t1, double *t1old, + ITG *ithermal, double *prestr, ITG *iprestr, + double *vold, ITG *iperturb, double *sti, ITG *nzs, + ITG *kode, char *filab, double *eme, + ITG *iexpl, double *plicon, ITG *nplicon, double *plkcon, + ITG * nplkcon, + double **xstatep, ITG *npmat_, char *matname, ITG *isolver, + ITG *mi, ITG *ncmat_, ITG *nstate_, double *cs, ITG *mcs, + ITG *nkon, double **enerp, double *xbounold, + double *xforcold, double *xloadold, + char *amname, double *amta, ITG *namta, + ITG *nam, ITG *iamforc, ITG *iamload, + ITG *iamt1, ITG *iamboun, double *ttime, char *output, + char *set, ITG *nset, ITG *istartset, + ITG *iendset, ITG *ialset, ITG *nprint, char *prlab, + char *prset, ITG *nener, double *trab, + ITG *inotr, ITG *ntrans, double *fmpc, ITG *ipobody, ITG *ibody, + double *xbody, ITG *nbody, double *xbodyold, double *timepar, + double *thicke, char *jobnamec, char *tieset, ITG *ntie, + ITG *istep, ITG *nmat, ITG *ielprop, double *prop, char *typeboun, + ITG *mortar, ITG *mpcinfo, double *tietol, ITG *ics, + char *orname, ITG *itempuser, double *t0g, double *t1g, + char *preciceParticipantName, char *configFilename); + void FORTRAN(localaxes, (ITG * ibody, ITG *nbody, double *xbody, double *e1, double *e2, double *xn)); @@ -2869,8 +2853,7 @@ void massless(ITG *kslav, ITG *lslav, ITG *ktot, ITG *ltot, ITG *nactdof, ITG *mi, double *vold, double *volddof, double *veold, ITG *nk, double *fext, ITG *isolver, ITG *iperturb, double *co, double *springarea, - ITG *neqtot, double *qbk, double *b, double *tinc, - double *aloc, double *fric, ITG *iexpl); + ITG *neqslav, ITG *neqtot, double *qbk, double *b); void mastruct(ITG *nk, ITG *kon, ITG *ipkon, char *lakon, ITG *ne, ITG *nodeboun, ITG *ndirboun, ITG *nboun, ITG *ipompc, @@ -3373,14 +3356,6 @@ void peeq_sen_dv(double *co, ITG *nk, ITG *kon, ITG *ipkon, char *lakon, ITG *ne void *peeq_sen_dvmt(ITG *i); -void FORTRAN(phys2con, (ITG * inomat, double *vold, ITG *ntmat_, double *shcon, - ITG *nshcon, double *physcon, ITG *compressible, - double *vcon, double *rhcon, ITG *nrhcon, ITG *ithermal, - ITG *mi, ITG *ifreesurface, ITG *ierr, double *dgravity, - double *depth, ITG *nk, ITG *nka, ITG *nkb)); - -void *phys2conmt(ITG *i); - void FORTRAN(postprojectgrad, (ITG * ndesi, ITG *nodedesi, double *dgdxglob, ITG *nactive, ITG *nobject, ITG *nnlconst, ITG *ipoacti, ITG *nk, char *objectset, @@ -3437,8 +3412,6 @@ void prediction_em(double *uam, ITG *nmethod, double *bet, double *gam, double * ITG *ithermal, ITG *nk, double *veold, double *v, ITG *iinc, ITG *idiscon, double *vold, ITG *nactdof, ITG *mi); -void *predictmt(ITG *i); - void FORTRAN(prefilter, (double *co, ITG *nodedesi, ITG *ndesi, double *xo, double *yo, double *zo, double *x, double *y, double *z, ITG *nx, ITG *ny, ITG *nz)); @@ -3459,11 +3432,9 @@ void FORTRAN(preprojectgrad, (double *vector, ITG *ndesi, ITG *nodedesi, char *objectset, double *xtf)); void FORTRAN(presgradient, (ITG * iponoel, ITG *inoel, double *sa, - double *shockcoef, double *dtimef, ITG *ipkon, + ITG *nk, double *shockcoef, double *dtimef, ITG *ipkon, ITG *kon, char *lakon, double *vold, ITG *mi, - ITG *nactdoh, ITG *nka, ITG *nkb)); - -void *presgradientmt(ITG *i); + ITG *nmethod, ITG *nactdoh, ITG *neqp)); void FORTRAN(prethickness, (double *co, double *xo, double *yo, double *zo, double *x, double *y, double *z, ITG *nx, ITG *ny, @@ -3581,29 +3552,29 @@ void radcyc(ITG *nk, ITG *kon, ITG *ipkon, char *lakon, ITG *ne, double **cop, double **voldp, ITG *ntrit, ITG *inocs, ITG *mi); void radflowload(ITG *itg, ITG *ieg, ITG *ntg, ITG *ntr, double *adrad, - double *aurad, double *bcr, ITG *ipivr, double *ac, double *bc, - ITG *nload, char *sideload, ITG *nelemload, double *xloadact, - char *lakon, ITG *ipiv, ITG *ntmat_, double *vold, double *shcon, - ITG *nshcon, ITG *ipkon, ITG *kon, double *co, ITG *kontri, - ITG *ntri, ITG *nloadtr, double *tarea, double *tenv, - double *physcon, double *erad, double **adviewp, double **auviewp, + double *aurad, + double *bcr, ITG *ipivr, double *ac, double *bc, ITG *nload, + char *sideload, ITG *nelemload, double *xloadact, char *lakon, ITG *ipiv, + ITG *ntmat_, double *vold, double *shcon, ITG *nshcon, ITG *ipkon, + ITG *kon, double *co, ITG *kontri, ITG *ntri, + ITG *nloadtr, double *tarea, double *tenv, double *physcon, double *erad, + double **adviewp, double **auviewp, ITG *nflow, ITG *ikboun, double *xboun, ITG *nboun, ITG *ithermal, ITG *iinc, ITG *iit, double *cs, ITG *mcs, ITG *inocs, ITG *ntrit, ITG *nk, double *fenv, ITG *istep, double *dtime, double *ttime, double *time, ITG *ilboun, ITG *ikforc, ITG *ilforc, double *xforc, ITG *nforc, double *cam, ITG *ielmat, ITG *nteq, double *prop, - ITG *ielprop, ITG *nactdog, ITG *nacteq, ITG *nodeboun, - ITG *ndirboun, ITG *network, double *rhcon, ITG *nrhcon, - ITG *ipobody, ITG *ibody, double *xbody, ITG *nbody, - ITG *iviewfile, char *jobnamef, double *ctrl, double *xloadold, - double *reltime, ITG *nmethod, char *set, ITG *mi, ITG *istartset, - ITG *iendset, ITG *ialset, ITG *nset, ITG *ineighe, ITG *nmpc, - ITG *nodempc, ITG *ipompc, double *coefmpc, char *labmpc, - ITG *iemchange, ITG *nam, + ITG *ielprop, ITG *nactdog, ITG *nacteq, ITG *nodeboun, ITG *ndirboun, + ITG *network, double *rhcon, ITG *nrhcon, + ITG *ipobody, ITG *ibody, double *xbody, ITG *nbody, ITG *iviewfile, + char *jobnamef, double *ctrl, double *xloadold, double *reltime, + ITG *nmethod, char *set, ITG *mi, ITG *istartset, ITG *iendset, + ITG *ialset, ITG *nset, ITG *ineighe, ITG *nmpc, ITG *nodempc, + ITG *ipompc, double *coefmpc, char *labmpc, ITG *iemchange, ITG *nam, ITG *iamload, ITG *jqrad, ITG *irowrad, ITG *nzsrad, ITG *icolrad, ITG *ne, ITG *iaxial, double *qa, double *cocon, ITG *ncocon, ITG *iponoel, ITG *inoel, ITG *nprop, char *amname, ITG *namta, - double *amta, ITG *iexpl); + double *amta); void FORTRAN(radmatrix, (ITG * ntr, double *adrad, double *aurad, double *bcr, char *sideload, ITG *nelemload, double *xloadact, char *lakon, @@ -4012,7 +3983,7 @@ void resultsini(ITG *nk, double *v, ITG *ithermal, char *filab, double *gam, double *dtime, ITG *mi, double *vini, ITG *nprint, char *prlab, ITG *intpointvar, ITG *calcul_fn, ITG *calcul_f, ITG *calcul_qa, ITG *calcul_cauchy, ITG *ikin, ITG *intpointvart, - char *typeboun, ITG *num_cpus, ITG *mortar, ITG *nener); + char *typeboun, ITG *num_cpus, ITG *mortar); void FORTRAN(resultsini_em, (ITG * nk, double *v, ITG *ithermal, char *filab, ITG *iperturb, double *f, double *fn, ITG *nactdof, ITG *iout, @@ -4272,14 +4243,14 @@ void FORTRAN(rhs, (double *co, ITG *nk, ITG *kon, ITG *ipkon, char *lakon, char *matname, ITG *mi, ITG *ikactmech, ITG *nactmech, ITG *ielprop, double *prop, double *sti, double *xstateini, double *xstate, ITG *nstate_, ITG *ntrans, ITG *inotr, - double *trab, double *fnext, ITG *nea, ITG *neb)); + double *trab, ITG *nea, ITG *neb)); void FORTRAN(rhsnodef, (double *co, ITG *kon, ITG *ne, ITG *ipompc, ITG *nodempc, double *coefmpc, ITG *nmpc, ITG *nodeforc, ITG *ndirforc, - double *xforc, ITG *nforc, double *fext, ITG *nactdof, - ITG *nmethod, ITG *ikmpc, ITG *ntmat_, ITG *iperturb, - ITG *mi, ITG *ikactmech, ITG *nactmech, ITG *ntrans, - ITG *inotr, double *trab, double *fnext)); + double *xforc, + ITG *nforc, double *fext, ITG *nactdof, ITG *nmethod, ITG *ikmpc, + ITG *ntmat_, ITG *iperturb, ITG *mi, ITG *ikactmech, ITG *nactmech, + ITG *ntrans, ITG *inotr, double *trab)); void rhsmain(double *co, ITG *nk, ITG *kon, ITG *ipkon, char *lakon, ITG *ne, ITG *ipompc, ITG *nodempc, double *coefmpc, ITG *nmpc, @@ -4305,7 +4276,7 @@ void rhsmain(double *co, ITG *nk, ITG *kon, ITG *ipkon, char *lakon, ITG *ne, ITG *mi, ITG *ikactmech, ITG *nactmech, ITG *ielprop, double *prop, double *sti, double *xstateini, double *xstate, ITG *nstate_, - ITG *ntrans, ITG *inotr, double *trab, double *fnext); + ITG *ntrans, ITG *inotr, double *trab); void *rhsmt(ITG *i); @@ -4531,9 +4502,15 @@ void FORTRAN(smoothshock, (double *aub, double *adl, void *smoothshockmt(ITG *i); -void solveeq(double *adbv, double *aubv, double *adl, - double *b, double *sol, double *aux, ITG *irowv, - ITG *jqv, ITG *neqv, ITG *maxit, ITG *num_cpus); +void FORTRAN(solveeq, (double *adbv, double *aubv, double *adl, + double *b, double *sol, double *aux, ITG *irowv, + ITG *jqv, ITG *neqv, ITG *maxit)); + +void solveeqmain(double *aub, double *adl, double *b, double *sol, ITG *irow, + ITG *jq, ITG *neq, ITG *maxit, ITG *num_cpus); + +void FORTRAN(solveeqpar, (double *aub, double *adl, double *b, double *sol, + double *aux, ITG *irow, ITG *jq, ITG *neqa, ITG *neqb)); void *solveeqparmt(ITG *i); @@ -4545,10 +4522,6 @@ void FORTRAN(sortev, (ITG * nev, ITG *nmd, double *eigxx, ITG *cyclicsymmetry, ITG *istartnmd, ITG *iendnmd, double *aa, double *bb, ITG *nevcomplex)); -void *sortingmt(ITG *i); - -void *sortingfreqmt(ITG *i); - void FORTRAN(spcmatch, (double *xboun, ITG *nodeboun, ITG *ndirboun, ITG *nboun, double *xbounold, ITG *nodebounold, ITG *ndirbounold, ITG *nbounold, ITG *ikboun, ITG *ilboun, double *vold, @@ -4922,7 +4895,7 @@ void tiedcontact(ITG *ntie, char *tieset, ITG *nset, char *set, double **fmpcp, ITG **nodempcp, double **coefmpcp, ITG *ithermal, double *co, double *vold, ITG *nef, ITG *nmpc_, ITG *mi, ITG *nk, ITG *istep, ITG *ikboun, - ITG *nboun, char *kind1, char *kind2, char *jobnamef); + ITG *nboun, char *kind1, char *kind2); void FORTRAN(topocfdfem, (ITG * nelemface, char *sideface, ITG *nface, ITG *ipoface, ITG *nodface, ITG *ne, ITG *ipkon, ITG *kon, char *lakon, @@ -4931,7 +4904,7 @@ void FORTRAN(topocfdfem, (ITG * nelemface, char *sideface, ITG *nface, ITG *ipof ITG *iponoel, ITG *inoel, ITG *inoelfree, double *co, char *set, ITG *istartset, ITG *iendset, ITG *ialset, ITG *nset, ITG *iturbulent, - ITG *inomat, ITG *ielmat, ITG *ipface, ITG *nknew)); + ITG *inomat, ITG *ielmat, ITG *ipface)); void FORTRAN(totalcontact, (char *tieset, ITG *ntie, ITG *ne, ITG *ipkon, ITG *kon, char *lakon, ITG *islavsurf, ITG *itiefac, @@ -4988,9 +4961,7 @@ void FORTRAN(uout, (double *v, ITG *mi, ITG *ithermal, char *filab, void FORTRAN(updatecon, (double *vold, double *vcon, double *v, ITG *nk, ITG *ithermal, ITG *turbulent, ITG *mi, - ITG *compressible, ITG *nka, ITG *nkb)); - -void *updateconmt(ITG *i); + ITG *compressible)); void FORTRAN(updatecont, (ITG * koncont, ITG *ncont, double *co, double *vold, double *cg, double *straight, ITG *mi)); diff --git a/adapter/CCXHelpers.c b/adapter/CCXHelpers.c old mode 100644 new mode 100755 index 5f4b2684..3493e3f2 --- a/adapter/CCXHelpers.c +++ b/adapter/CCXHelpers.c @@ -40,6 +40,8 @@ ITG getSetID(char const *setName, char const *set, ITG nset) } // Set not found: + + if (setName[0] == (char) 'N') { printf("Set ID NOT Found \n"); nodeSetNotFoundError(setName); @@ -68,6 +70,17 @@ void getSurfaceElementsAndFaces(ITG setID, ITG *ialset, ITG *istartset, ITG *ien } } +void getElementsIDs(ITG setID, ITG *ialset, ITG *istartset, ITG *iendset, ITG *elements) +{ + + ITG i, k = 0; + + for (i = istartset[setID] - 1; i < iendset[setID]; i++) { + elements[k] = ialset[i] / 10; + k++; + } +} + void getNodeCoordinates(ITG *nodes, ITG numNodes, int dim, double *co, double *v, int mt, double *coordinates) { @@ -75,13 +88,20 @@ void getNodeCoordinates(ITG *nodes, ITG numNodes, int dim, double *co, double *v for (i = 0; i < numNodes; i++) { int nodeIdx = nodes[i] - 1; - // The displacements are added to the coordinates such that in case of a simulation restart the displaced coordinates are used for initializing the coupling interface instead of the initial coordinates + //The displacements are added to the coordinates such that in case of a simulation restart the displaced coordinates are used for initializing the coupling interface instead of the initial coordinates for (j = 0; j < dim; j++) { coordinates[i * dim + j] = co[nodeIdx * 3 + j] + v[nodeIdx * mt + j + 1]; } } } +//, d +void getElementGaussPointCoordinates(int numElements, int numGPTotal, int *elementIDs, double *co, ITG *kon, char *lakon, ITG *ipkon, int *gp_id, double *gp_coord) +{ + FORTRAN(getelementgausspointcoords,(&numElements, &numGPTotal, elementIDs, co, &lakon, kon, ipkon, gp_id, gp_coord)); + +} + void getNodeTemperatures(ITG *nodes, ITG numNodes, double *v, int mt, double *temperatures) { @@ -106,6 +126,62 @@ void getNodeForces(ITG *nodes, ITG numNodes, int dim, double *fn, ITG mt, double } } +void getStrainNorm(int numElements, int numGPTotal, int *elementIDs, double *eei, double *strainData){ + + int i,j, numGPPerElement, count, idx; + + count = 0; + + for (i=0; i().c_str()); } + + if (config["participants"][participantName]["interfaces"][i]["elements"]) { + interface.elementsMeshName = strdup(config["participants"][participantName]["interfaces"][i]["elements"].as().c_str()); + } + std::string patchName = config["participants"][participantName]["interfaces"][i]["patch"].as(); std::transform(patchName.begin(), patchName.end(), patchName.begin(), toupper); interface.patchName = strdup(patchName.c_str()); diff --git a/adapter/ConfigReader.h b/adapter/ConfigReader.h old mode 100644 new mode 100755 index 4044472d..254de2c4 --- a/adapter/ConfigReader.h +++ b/adapter/ConfigReader.h @@ -13,6 +13,7 @@ typedef struct InterfaceConfig { char * facesMeshName; char * nodesMeshName; + char * elementsMeshName; char * patchName; int map; int numWriteData; @@ -43,7 +44,7 @@ void ConfigReader_Read(char const *configFilename, char const *participantName, * @precondition adapterConfig points to an initialized instance of adapterConfig. * @precondition ConfigReader_Read was called on adapterConfig. * @postcondition all memory held by the struct adapterConfig is freed - * @note This function does not free the pointer adapterConfig + * @note This function does not free the pointer adapterConfig */ void AdapterConfig_Free(AdapterConfig *adapterConfig); diff --git a/adapter/ConfigReader.hpp b/adapter/ConfigReader.hpp old mode 100644 new mode 100755 diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c old mode 100644 new mode 100755 index 09c82fc2..e57c842a --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -82,6 +82,7 @@ void Precice_AdjustSolverTimestep(SimulationData *sim) // Set the solver time step to be the same as the coupling time step sim->solver_dt = sim->precice_dt; + // printf("sim->solver_dt %f \n",sim->solver_dt); } else { printf("Adjusting time step for transient step\n"); printf("precice_dt dtheta = %f, dtheta = %f, solver_dt = %f\n", sim->precice_dt / *sim->tper, *sim->dtheta, fmin(sim->precice_dt, *sim->dtheta * *sim->tper)); @@ -98,6 +99,7 @@ void Precice_AdjustSolverTimestep(SimulationData *sim) void Precice_Advance(SimulationData *sim) { printf("Adapter calling advance()...\n"); + fflush(stdout); sim->precice_dt = precicec_advance(sim->solver_dt); @@ -150,6 +152,10 @@ void Precice_WriteIterationCheckpoint(SimulationData *sim, double *v) printf("Adapter writing checkpoint...\n"); fflush(stdout); + printf("*(sim->theta): %f\n",*(sim->theta)); + printf("*(sim->dtheta): %f\n",*(sim->dtheta)); + fflush(stdout); + // Save time sim->coupling_init_theta = *(sim->theta); @@ -158,52 +164,21 @@ void Precice_WriteIterationCheckpoint(SimulationData *sim, double *v) // Save solution vector v memcpy(sim->coupling_init_v, v, sizeof(double) * sim->mt * sim->nk); -} - -void Precice_ReadIterationCheckpointModal(SimulationData *sim, double *dofs, double *derivatives, int nev) -{ - - printf("Adapter reading checkpoint...\n"); - fflush(stdout); - - // Reload time - *(sim->theta) = sim->coupling_init_theta; - - // Reload step size - *(sim->dtheta) = sim->coupling_init_dtheta; - - // Reload DOFs in eigenmodes space & counters - memcpy(dofs, sim->eigenDOFs, sizeof(double) * nev); - memcpy(derivatives, sim->eigenDOFsDerivatives, sizeof(double) * nev); -} - -void Precice_WriteIterationCheckpointModal(SimulationData *sim, const double *dofs, const double *derivatives, int nev) -{ - printf("Adapter writing checkpoint...\n"); - fflush(stdout); - - // Save time - sim->coupling_init_theta = *(sim->theta); - - // Save step size - sim->coupling_init_dtheta = *(sim->dtheta); - - // Save DOFs in eigenmodes space & counters - memcpy(sim->eigenDOFs, dofs, sizeof(double) * nev); - memcpy(sim->eigenDOFsDerivatives, derivatives, sizeof(double) * nev); } void Precice_ReadCouplingData(SimulationData *sim) { - printf("Adapter reading coupling data...\n"); + printf("Adapter reading coupling data....\n"); + // printf("precicec_isReadDataAvailable() %d \n,",precicec_isReadDataAvailable()); fflush(stdout); PreciceInterface **interfaces = sim->preciceInterfaces; int numInterfaces = sim->numPreciceInterfaces; int i, j; + if (precicec_isReadDataAvailable()) { for (i = 0; i < numInterfaces; i++) { @@ -213,33 +188,28 @@ void Precice_ReadCouplingData(SimulationData *sim) case TEMPERATURE: // Read and set temperature BC if (isQuasi2D3D(interfaces[i]->quasi2D3D)) { - consistentScalarRead(interfaces[i]->mappingQuasi2D3D, interfaces[i]->temperatureDataID); - setNodeTemperatures(interfaces[i]->mappingQuasi2D3D->bufferScalar3D, interfaces[i]->numNodes, interfaces[i]->xbounIndices, sim->xboun); + precicec_readBlockScalarData(interfaces[i]->temperatureDataID, interfaces[i]->num2DNodes, interfaces[i]->preciceNodeIDs, interfaces[i]->node2DScalarData); + mapData2Dto3DScalar(interfaces[i]->node2DScalarData, interfaces[i]->mapping2D3D, interfaces[i]->numNodes, interfaces[i]->nodeScalarData); } else { precicec_readBlockScalarData(interfaces[i]->temperatureDataID, interfaces[i]->numNodes, interfaces[i]->preciceNodeIDs, interfaces[i]->nodeScalarData); - setNodeTemperatures(interfaces[i]->nodeScalarData, interfaces[i]->numNodes, interfaces[i]->xbounIndices, sim->xboun); } + setNodeTemperatures(interfaces[i]->nodeScalarData, interfaces[i]->numNodes, interfaces[i]->xbounIndices, sim->xboun); printf("Reading TEMPERATURE coupling data with ID '%d'. \n", interfaces[i]->temperatureDataID); break; case HEAT_FLUX: // Read and set heat flux BC - // Not working in 2D-3D now precicec_readBlockScalarData(interfaces[i]->fluxDataID, interfaces[i]->numElements, interfaces[i]->preciceFaceCenterIDs, interfaces[i]->faceCenterData); setFaceFluxes(interfaces[i]->faceCenterData, interfaces[i]->numElements, interfaces[i]->xloadIndices, sim->xload); printf("Reading HEAT_FLUX coupling data with ID '%d'. \n", interfaces[i]->fluxDataID); break; case SINK_TEMPERATURE: // Read and set sink temperature in convective film BC - // Not working in 2D-3D now - precicec_readBlockScalarData(interfaces[i]->kDeltaTemperatureReadDataID, interfaces[i]->numElements, interfaces[i]->preciceFaceCenterIDs, interfaces[i]->faceCenterData); setFaceSinkTemperatures(interfaces[i]->faceCenterData, interfaces[i]->numElements, interfaces[i]->xloadIndices, sim->xload); printf("Reading SINK_TEMPERATURE coupling data with ID '%d'. \n", interfaces[i]->kDeltaTemperatureReadDataID); break; case HEAT_TRANSFER_COEFF: // Read and set heat transfer coefficient in convective film BC - // Not working in 2D-3D now - precicec_readBlockScalarData(interfaces[i]->kDeltaReadDataID, interfaces[i]->numElements, interfaces[i]->preciceFaceCenterIDs, interfaces[i]->faceCenterData); setFaceHeatTransferCoefficients(interfaces[i]->faceCenterData, interfaces[i]->numElements, interfaces[i]->xloadIndices, sim->xload); printf("Reading HEAT_TRANSFER_COEFF coupling data with ID '%d'. \n", interfaces[i]->kDeltaReadDataID); @@ -247,30 +217,141 @@ void Precice_ReadCouplingData(SimulationData *sim) case FORCES: // Read and set forces as concentrated loads (Neumann BC) if (isQuasi2D3D(interfaces[i]->quasi2D3D)) { - conservativeVectorRead(interfaces[i]->mappingQuasi2D3D, interfaces[i]->forcesDataID); - setNodeForces(interfaces[i]->mappingQuasi2D3D->bufferVector3D, interfaces[i]->numNodes, interfaces[i]->dimCCX, interfaces[i]->xforcIndices, sim->xforc); + precicec_readBlockVectorData(interfaces[i]->forcesDataID, interfaces[i]->num2DNodes, interfaces[i]->preciceNodeIDs, interfaces[i]->node2DVectorData); + mapData2Dto3DVector(interfaces[i]->node2DVectorData, interfaces[i]->mapping2D3D, interfaces[i]->numNodes, interfaces[i]->nodeVectorData); } else { precicec_readBlockVectorData(interfaces[i]->forcesDataID, interfaces[i]->numNodes, interfaces[i]->preciceNodeIDs, interfaces[i]->nodeVectorData); - setNodeForces(interfaces[i]->nodeVectorData, interfaces[i]->numNodes, interfaces[i]->dimCCX, interfaces[i]->xforcIndices, sim->xforc); } + setNodeForces(interfaces[i]->nodeVectorData, interfaces[i]->numNodes, interfaces[i]->dimCCX, interfaces[i]->xforcIndices, sim->xforc); printf("Reading FORCES coupling data with ID '%d'. \n", interfaces[i]->forcesDataID); break; - case PRESSURE: - precicec_readBlockScalarData(interfaces[i]->pressureDataID, interfaces[i]->numElements, interfaces[i]->preciceFaceCenterIDs, interfaces[i]->faceCenterData); - setFacePressure(interfaces[i]->faceCenterData, interfaces[i]->numElements, interfaces[i]->xloadIndices, sim->xload); - printf("Reading PRESSURE coupling data with ID '%d'. \n", interfaces[i]->pressureDataID); - break; case DISPLACEMENTS: // Read and set displacements as single point constraints (Dirichlet BC) if (isQuasi2D3D(interfaces[i]->quasi2D3D)) { - conservativeVectorRead(interfaces[i]->mappingQuasi2D3D, interfaces[i]->displacementsDataID); - setNodeDisplacements(interfaces[i]->mappingQuasi2D3D->bufferVector3D, interfaces[i]->numNodes, interfaces[i]->dimCCX, interfaces[i]->xbounIndices, sim->xboun); + precicec_readBlockVectorData(interfaces[i]->displacementsDataID, interfaces[i]->num2DNodes, interfaces[i]->preciceNodeIDs, interfaces[i]->node2DVectorData); + mapData2Dto3DVector(interfaces[i]->node2DVectorData, interfaces[i]->mapping2D3D, interfaces[i]->numNodes, interfaces[i]->nodeVectorData); } else { precicec_readBlockVectorData(interfaces[i]->displacementsDataID, interfaces[i]->numNodes, interfaces[i]->preciceNodeIDs, interfaces[i]->nodeVectorData); - setNodeDisplacements(interfaces[i]->nodeVectorData, interfaces[i]->numNodes, interfaces[i]->dimCCX, interfaces[i]->xbounIndices, sim->xboun); } + setNodeDisplacements(interfaces[i]->nodeVectorData, interfaces[i]->numNodes, interfaces[i]->dimCCX, interfaces[i]->xbounIndices, sim->xboun); printf("Reading DISPLACEMENTS coupling data with ID '%d'. \n", interfaces[i]->displacementsDataID); break; + case MATERTIAL_TANGENT_1: + + interfaces[i]->strainGPData = malloc(interfaces[i]->numGPTotal * 3 * sizeof(double)); + precicec_readBlockVectorData(interfaces[i]->materialTangent1DataID, interfaces[i]->numGPTotal, interfaces[i]->elemGPID, interfaces[i]->strainGPData); + + // for (int k = 0; k < interfaces[i]->numGPTotal; k++) { + // printf( " %i, %e, %e, %e \n", k, interfaces[i]->strainGPData[k*3], interfaces[i]->strainGPData[k*3+1], interfaces[i]->strainGPData[k*3+2]); + // } + setMaterialTangentMatrix(0, interfaces[i]->numElements, interfaces[i]->numGPTotal, interfaces[i]->elementIDs, interfaces[i]->strainGPData, sim->xstiff); + printf("Reading MATERIAL TANGENT 1 coupling data with ID '%d'. \n", interfaces[i]->materialTangent1DataID); + fflush(stdout); + free(interfaces[i]->strainGPData); + break; + case MATERTIAL_TANGENT_2: + + interfaces[i]->strainGPData = malloc(interfaces[i]->numGPTotal * 3 * sizeof(double)); + precicec_readBlockVectorData(interfaces[i]->materialTangent2DataID, interfaces[i]->numGPTotal, interfaces[i]->elemGPID, interfaces[i]->strainGPData); + + // for (int k = 0; k < interfaces[i]->numGPTotal; k++) { + // printf( " %i, %e, %e, %e \n", k, interfaces[i]->strainGPData[k*3], interfaces[i]->strainGPData[k*3+1], interfaces[i]->strainGPData[k*3+2]); + // } + setMaterialTangentMatrix(3, interfaces[i]->numElements, interfaces[i]->numGPTotal, interfaces[i]->elementIDs, interfaces[i]->strainGPData, sim->xstiff); + printf("Reading MATERIAL TANGENT 2 coupling data with ID '%d'. \n", interfaces[i]->materialTangent2DataID); + fflush(stdout); + free(interfaces[i]->strainGPData); + break; + case MATERTIAL_TANGENT_3: + + interfaces[i]->strainGPData = malloc(interfaces[i]->numGPTotal * 3 * sizeof(double)); + precicec_readBlockVectorData(interfaces[i]->materialTangent3DataID, interfaces[i]->numGPTotal, interfaces[i]->elemGPID, interfaces[i]->strainGPData); + + // for (int k = 0; k < interfaces[i]->numGPTotal; k++) { + // printf( " %i, %e, %e, %e \n", k, interfaces[i]->strainGPData[k*3], interfaces[i]->strainGPData[k*3+1], interfaces[i]->strainGPData[k*3+2]); + // } + setMaterialTangentMatrix(6, interfaces[i]->numElements, interfaces[i]->numGPTotal, interfaces[i]->elementIDs, interfaces[i]->strainGPData, sim->xstiff); + printf("Reading MATERIAL TANGENT 3 coupling data with ID '%d'. \n", interfaces[i]->materialTangent3DataID); + fflush(stdout); + free(interfaces[i]->strainGPData); + break; + case MATERTIAL_TANGENT_4: + + interfaces[i]->strainGPData = malloc(interfaces[i]->numGPTotal * 3 * sizeof(double)); + precicec_readBlockVectorData(interfaces[i]->materialTangent4DataID, interfaces[i]->numGPTotal, interfaces[i]->elemGPID, interfaces[i]->strainGPData); + + // for (int k = 0; k < interfaces[i]->numGPTotal; k++) { + // printf( " %i, %e, %e, %e \n", k, interfaces[i]->strainGPData[k*3], interfaces[i]->strainGPData[k*3+1], interfaces[i]->strainGPData[k*3+2]); + // } + setMaterialTangentMatrix(9, interfaces[i]->numElements, interfaces[i]->numGPTotal, interfaces[i]->elementIDs, interfaces[i]->strainGPData, sim->xstiff); + printf("Reading MATERIAL TANGENT 4 coupling data with ID '%d'. \n", interfaces[i]->materialTangent4DataID); + fflush(stdout); + free(interfaces[i]->strainGPData); + break; + case MATERTIAL_TANGENT_5: + + interfaces[i]->strainGPData = malloc(interfaces[i]->numGPTotal * 3 * sizeof(double)); + precicec_readBlockVectorData(interfaces[i]->materialTangent5DataID, interfaces[i]->numGPTotal, interfaces[i]->elemGPID, interfaces[i]->strainGPData); + + // for (int k = 0; k < interfaces[i]->numGPTotal; k++) { + // printf( " %i, %e, %e, %e \n", k, interfaces[i]->strainGPData[k*3], interfaces[i]->strainGPData[k*3+1], interfaces[i]->strainGPData[k*3+2]); + // } + setMaterialTangentMatrix(12, interfaces[i]->numElements, interfaces[i]->numGPTotal, interfaces[i]->elementIDs, interfaces[i]->strainGPData, sim->xstiff); + printf("Reading MATERIAL TANGENT 5 coupling data with ID '%d'. \n", interfaces[i]->materialTangent5DataID); + fflush(stdout); + free(interfaces[i]->strainGPData); + break; + case MATERTIAL_TANGENT_6: + + interfaces[i]->strainGPData = malloc(interfaces[i]->numGPTotal * 3 * sizeof(double)); + precicec_readBlockVectorData(interfaces[i]->materialTangent6DataID, interfaces[i]->numGPTotal, interfaces[i]->elemGPID, interfaces[i]->strainGPData); + + // for (int k = 0; k < interfaces[i]->numGPTotal; k++) { + // printf( " %i, %e, %e, %e \n", k, interfaces[i]->strainGPData[k*3], interfaces[i]->strainGPData[k*3+1], interfaces[i]->strainGPData[k*3+2]); + // } + setMaterialTangentMatrix(15, interfaces[i]->numElements, interfaces[i]->numGPTotal, interfaces[i]->elementIDs, interfaces[i]->strainGPData, sim->xstiff); + printf("Reading MATERIAL TANGENT 6 coupling data with ID '%d'. \n", interfaces[i]->materialTangent6DataID); + fflush(stdout); + free(interfaces[i]->strainGPData); + break; + case MATERTIAL_TANGENT_7: + + interfaces[i]->strainGPData = malloc(interfaces[i]->numGPTotal * 3 * sizeof(double)); + precicec_readBlockVectorData(interfaces[i]->materialTangent7DataID, interfaces[i]->numGPTotal, interfaces[i]->elemGPID, interfaces[i]->strainGPData); + + // for (int k = 0; k < interfaces[i]->numGPTotal; k++) { + // printf( " %i, %e, %e, %e \n", k, interfaces[i]->strainGPData[k*3], interfaces[i]->strainGPData[k*3+1], interfaces[i]->strainGPData[k*3+2]); + // } + setMaterialTangentMatrix(18, interfaces[i]->numElements, interfaces[i]->numGPTotal, interfaces[i]->elementIDs, interfaces[i]->strainGPData, sim->xstiff); + printf("Reading MATERIAL TANGENT 7 coupling data with ID '%d'. \n", interfaces[i]->materialTangent7DataID); + fflush(stdout); + free(interfaces[i]->strainGPData); + break; + case RVE_ID: + printf("RVE ID cannot be used as read data.\n"); + fflush(stdout); + exit(EXIT_FAILURE); + break; + case STRAIN_NORM: + printf("Normal Strain cannot be used as read data.\n"); + fflush(stdout); + exit(EXIT_FAILURE); + break; + case STRAIN_SHEAR: + printf("Shear Strain cannot be used as read data.\n"); + fflush(stdout); + exit(EXIT_FAILURE); + break; + case STRESS_NORM: + printf("Normal Stress cannot be used as read data.\n"); + fflush(stdout); + exit(EXIT_FAILURE); + break; + case STRESS_SHEAR: + printf("Shear Stress cannot be used as read data.\n"); + fflush(stdout); + exit(EXIT_FAILURE); + break; case DISPLACEMENTDELTAS: printf("DisplacementDeltas cannot be used as read data\n"); fflush(stdout); @@ -303,6 +384,8 @@ void Precice_WriteCouplingData(SimulationData *sim) int i, j; int iset; + + if (precicec_isWriteDataRequired(sim->solver_dt) || precicec_isActionRequired("write-initial-data")) { for (i = 0; i < numInterfaces; i++) { // Prepare data @@ -324,7 +407,7 @@ void Precice_WriteCouplingData(SimulationData *sim) sim->istartset, sim->iendset, sim->ipkon, - sim->lakon, + *sim->lakon, sim->kon, sim->ialset, sim->ielmat, @@ -340,17 +423,17 @@ void Precice_WriteCouplingData(SimulationData *sim) switch (interfaces[i]->writeData[j]) { case TEMPERATURE: + getNodeTemperatures(interfaces[i]->nodeIDs, interfaces[i]->numNodes, sim->vold, sim->mt, interfaces[i]->nodeScalarData); if (isQuasi2D3D(interfaces[i]->quasi2D3D)) { - getNodeTemperatures(interfaces[i]->nodeIDs, interfaces[i]->numNodes, sim->vold, sim->mt, interfaces[i]->mappingQuasi2D3D->bufferScalar3D); - consistentScalarWrite(interfaces[i]->mappingQuasi2D3D, interfaces[i]->temperatureDataID); + setDoubleArrayZero(interfaces[i]->node2DScalarData, interfaces[i]->num2DNodes, 1); + mapData3Dto2DScalar(interfaces[i]->nodeScalarData, interfaces[i]->mapping2D3D, interfaces[i]->numNodes, interfaces[i]->node2DScalarData); + precicec_writeBlockScalarData(interfaces[i]->temperatureDataID, interfaces[i]->num2DNodes, interfaces[i]->preciceNodeIDs, interfaces[i]->node2DScalarData); } else { - getNodeTemperatures(interfaces[i]->nodeIDs, interfaces[i]->numNodes, sim->vold, sim->mt, interfaces[i]->nodeScalarData); precicec_writeBlockScalarData(interfaces[i]->temperatureDataID, interfaces[i]->numNodes, interfaces[i]->preciceNodeIDs, interfaces[i]->nodeScalarData); } printf("Writing TEMPERATURE coupling data with ID '%d'. \n", interfaces[i]->temperatureDataID); break; case HEAT_FLUX: - // Not implemented: 2D-3D iset = interfaces[i]->faceSetID + 1; // Adjust index before calling Fortran function FORTRAN(getflux, (sim->co, sim->ntmat_, @@ -361,7 +444,7 @@ void Precice_WriteCouplingData(SimulationData *sim) sim->istartset, sim->iendset, sim->ipkon, - sim->lakon, + *sim->lakon, sim->kon, sim->ialset, sim->ielmat, @@ -371,33 +454,31 @@ void Precice_WriteCouplingData(SimulationData *sim) printf("Writing HEAT_FLUX coupling data with ID '%d'. \n", interfaces[i]->fluxDataID); break; case SINK_TEMPERATURE: - // Not implemented: 2D-3D - precicec_writeBlockScalarData(interfaces[i]->kDeltaTemperatureWriteDataID, interfaces[i]->numElements, interfaces[i]->preciceFaceCenterIDs, T); printf("Writing SINK_TEMPERATURE coupling data with ID '%d'. \n", interfaces[i]->kDeltaTemperatureWriteDataID); break; case HEAT_TRANSFER_COEFF: - // Not implemented: 2D-3D - precicec_writeBlockScalarData(interfaces[i]->kDeltaWriteDataID, interfaces[i]->numElements, interfaces[i]->preciceFaceCenterIDs, KDelta); printf("Writing HEAT_TRANSFER_COEFF coupling data with ID '%d'. \n", interfaces[i]->kDeltaWriteDataID); break; case DISPLACEMENTS: + getNodeDisplacements(interfaces[i]->nodeIDs, interfaces[i]->numNodes, interfaces[i]->dimCCX, sim->vold, sim->mt, interfaces[i]->nodeVectorData); if (isQuasi2D3D(interfaces[i]->quasi2D3D)) { - getNodeDisplacements(interfaces[i]->nodeIDs, interfaces[i]->numNodes, interfaces[i]->dimCCX, sim->vold, sim->mt, interfaces[i]->mappingQuasi2D3D->bufferVector3D); - consistentVectorWrite(interfaces[i]->mappingQuasi2D3D, interfaces[i]->displacementsDataID); + setDoubleArrayZero(interfaces[i]->node2DVectorData, interfaces[i]->num2DNodes, interfaces[i]->dim); + mapData3Dto2DVector(interfaces[i]->nodeVectorData, interfaces[i]->mapping2D3D, interfaces[i]->numNodes, interfaces[i]->node2DVectorData); + precicec_writeBlockVectorData(interfaces[i]->displacementsDataID, interfaces[i]->num2DNodes, interfaces[i]->preciceNodeIDs, interfaces[i]->node2DVectorData); } else { - getNodeDisplacements(interfaces[i]->nodeIDs, interfaces[i]->numNodes, interfaces[i]->dimCCX, sim->vold, sim->mt, interfaces[i]->nodeVectorData); precicec_writeBlockVectorData(interfaces[i]->displacementsDataID, interfaces[i]->numNodes, interfaces[i]->preciceNodeIDs, interfaces[i]->nodeVectorData); } printf("Writing DISPLACEMENTS coupling data with ID '%d'. \n", interfaces[i]->displacementsDataID); break; case DISPLACEMENTDELTAS: + getNodeDisplacementDeltas(interfaces[i]->nodeIDs, interfaces[i]->numNodes, interfaces[i]->dimCCX, sim->vold, sim->coupling_init_v, sim->mt, interfaces[i]->nodeVectorData); if (isQuasi2D3D(interfaces[i]->quasi2D3D)) { - getNodeDisplacementDeltas(interfaces[i]->nodeIDs, interfaces[i]->numNodes, interfaces[i]->dimCCX, sim->vold, sim->coupling_init_v, sim->mt, interfaces[i]->mappingQuasi2D3D->bufferVector3D); - consistentVectorWrite(interfaces[i]->mappingQuasi2D3D, interfaces[i]->displacementDeltasDataID); + setDoubleArrayZero(interfaces[i]->node2DVectorData, interfaces[i]->num2DNodes, interfaces[i]->dim); + mapData3Dto2DVector(interfaces[i]->nodeVectorData, interfaces[i]->mapping2D3D, interfaces[i]->numNodes, interfaces[i]->node2DVectorData); + precicec_writeBlockVectorData(interfaces[i]->displacementDeltasDataID, interfaces[i]->num2DNodes, interfaces[i]->preciceNodeIDs, interfaces[i]->node2DVectorData); } else { - getNodeDisplacementDeltas(interfaces[i]->nodeIDs, interfaces[i]->numNodes, interfaces[i]->dimCCX, sim->vold, sim->coupling_init_v, sim->mt, interfaces[i]->nodeVectorData); precicec_writeBlockVectorData(interfaces[i]->displacementDeltasDataID, interfaces[i]->numNodes, interfaces[i]->preciceNodeIDs, interfaces[i]->nodeVectorData); } printf("Writing DISPLACEMENTDELTAS coupling data with ID '%d'. \n", interfaces[i]->displacementDeltasDataID); @@ -417,7 +498,59 @@ void Precice_WriteCouplingData(SimulationData *sim) precicec_writeBlockVectorData(interfaces[i]->forcesDataID, interfaces[i]->numNodes, interfaces[i]->preciceNodeIDs, interfaces[i]->nodeVectorData); printf("Writing FORCES coupling data with ID '%d'. \n", interfaces[i]->forcesDataID); break; + + case RVE_ID: + + interfaces[i]->rveGPData = malloc(interfaces[i]->numGPTotal * sizeof(double)); + + // Getting RVE tags + getRVETag(interfaces[i]->numGPTotal,interfaces[i]->rveGPData); + + // for (int k = 0; k < interfaces[i]->numGPTotal; k++) { + // printf( "%i, %e \n", k, interfaces[i]->rveGPData[k]); + // } + + precicec_writeBlockScalarData(interfaces[i]->rveIdDataID, interfaces[i]->numGPTotal, interfaces[i]->elemGPID, interfaces[i]->rveGPData); + + printf("Writing RVE ID coupling data with ID '%d'. \n", interfaces[i]->rveIdDataID); + free(interfaces[i]->rveGPData); + break; + + case STRAIN_NORM: + + interfaces[i]->strainGPData = malloc(interfaces[i]->numGPTotal * 3 * sizeof(double)); + getStrainNorm(interfaces[i]->numElements, interfaces[i]->numGPTotal, interfaces[i]->elementIDs, sim->eei, interfaces[i]->strainGPData); + + // for (int k = 0; k < interfaces[i]->numGPTotal; k++) { + // printf( " %i, %e, %e, %e \n", k, interfaces[i]->strainGPData[k*3], interfaces[i]->strainGPData[k*3+1], interfaces[i]->strainGPData[k*3+2]); + // } + + precicec_writeBlockVectorData(interfaces[i]->strainNormDataID, interfaces[i]->numGPTotal, interfaces[i]->elemGPID, interfaces[i]->strainGPData); + printf("Writing STRAIN NORMAL coupling data with ID '%d'. \n", interfaces[i]->strainNormDataID); + free(interfaces[i]->strainGPData); + break; + + case STRAIN_SHEAR: + + interfaces[i]->strainGPData = malloc(interfaces[i]->numGPTotal * 3 * sizeof(double)); + getStrainShear(interfaces[i]->numElements, interfaces[i]->numGPTotal, interfaces[i]->elementIDs, sim->eei, interfaces[i]->strainGPData); + + // for (int k = 0; k < interfaces[i]->numGPTotal; k++) { + // printf( " %i, %e, %e, %e \n", k, interfaces[i]->strainGPData[k*3], interfaces[i]->strainGPData[k*3+1], interfaces[i]->strainGPData[k*3+2]); + // } + + precicec_writeBlockVectorData(interfaces[i]->strainShearDataID, interfaces[i]->numGPTotal, interfaces[i]->elemGPID, interfaces[i]->strainGPData); + printf("Writing STRAIN SHEAR coupling data with ID '%d'. \n", interfaces[i]->strainShearDataID); + free(interfaces[i]->strainGPData); + break; + + + + } + + + } // Cleanup data free(T); @@ -443,15 +576,6 @@ void Precice_FreeData(SimulationData *sim) } free(sim->preciceInterfaces); - - // Clean up checkpointing buffers - if (sim->eigenDOFs != NULL) { - free(sim->eigenDOFs); - } - if (sim->eigenDOFsDerivatives != NULL) { - free(sim->eigenDOFsDerivatives); - } - precicec_finalize(); } @@ -465,8 +589,9 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I interface->faceCenterCoordinates = NULL; interface->preciceFaceCenterIDs = NULL; interface->nodeCoordinates = NULL; + interface->node2DCoordinates = NULL; interface->nodeIDs = NULL; - interface->mappingQuasi2D3D = NULL; + interface->mapping2D3D = NULL; interface->preciceNodeIDs = NULL; interface->nodeScalarData = NULL; interface->node2DScalarData = NULL; @@ -476,8 +601,7 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I interface->xbounIndices = NULL; interface->xloadIndices = NULL; interface->xforcIndices = NULL; - interface->writeData = NULL; - interface->readData = NULL; + interface->elementGPData = NULL; // Initialize data ids to -1 interface->temperatureDataID = -1; @@ -491,7 +615,18 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I interface->positionsDataID = -1; interface->velocitiesDataID = -1; interface->forcesDataID = -1; - interface->pressureDataID = -1; + interface->rveIdDataID = -1; + interface->strainNormDataID = -1; + interface->strainShearDataID = -1; + interface->stressNormDataID = -1; + interface->stressShearDataID = -1; + interface->materialTangent1DataID = -1; + interface->materialTangent2DataID = -1; + interface->materialTangent3DataID = -1; + interface->materialTangent4DataID = -1; + interface->materialTangent5DataID = -1; + interface->materialTangent6DataID = -1; + interface->materialTangent7DataID = -1; // Check if quasi 2D-3D coupling needs to be implemented if (interface->dim == 2) { @@ -503,8 +638,8 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I interface->dimCCX = interface->dim; } - // Mapping Type - // The patch identifies the set used as interface in Calculix + //Mapping Type + // The patch identifies the set used as interface in Calculix interface->name = strdup(config->patchName); // Calculix needs to know if nearest-projection mapping is implemented. config->map = 1 is for nearest-projection, config->map = 0 is for everything else interface->mapNPType = config->map; @@ -528,31 +663,66 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I PreciceInterface_ConfigureTetraFaces(interface, sim); } + // Element mesh + interface->elementMeshID = -1; + interface->elementMeshName = NULL; + if (config->elementsMeshName) { + interface->elementMeshName = strdup(config->elementsMeshName); + // Configuring element mesh + PreciceInterface_ConfigureElementsMesh(interface, sim); + } + + PreciceInterface_ConfigureCouplingData(interface, sim, config); } -static enum ElemType findSimulationMeshType(SimulationData *sim) + +void PreciceInterface_ConfigureElementsMesh(PreciceInterface *interface, SimulationData *sim) { - // Assuming only tetrahedra are used, or only hexaedral, for faces meshes. - // Return first non-zero mesh type. - // lakon tab takes 8 chars per element - - const char *lakon_ptr = sim->lakon; - for (int i = 0; i < sim->ne; ++i) { - if (startsWith(lakon_ptr, "C3D4") || startsWith(lakon_ptr, "C3D10")) { - return TETRAHEDRA; - } else if (startsWith(lakon_ptr, "C3D8") || startsWith(lakon_ptr, "C3D20")) { - return HEXAHEDRA; - } - lakon_ptr += 8; - } + printf("Entering ConfigureElementsMesh \n"); + char *elementSetName = interface->name; //toFaceSetName(interface->name); + interface->elementSetID = getSetID(elementSetName, sim->set, sim->nset); + interface->numElements = getNumSetElements(interface->elementSetID, sim->istartset, sim->iendset); + interface->elementMeshID = precicec_getMeshID(interface->elementMeshName); + + + printf("element mesh id : %d\n", interface->elementMeshID); + printf("element set id : %d\n", interface->elementSetID); + printf("num elements : %d\n", interface->numElements); + + interface->elementIDs = malloc(interface->numElements * sizeof(ITG)); + getElementsIDs(interface->elementSetID, sim->ialset, sim->istartset, sim->iendset, interface->elementIDs); + + for(int j = 0; j< interface->numElements; j++){ + printf( " %d, element id: %d \n", j, interface->elementIDs[j]); + } + + // Find guass point coordinates of the element -> Serves as mesh for data transfer + int numElt = interface->numElements; + interface->numGPTotal = 8 * interface->numElements; // Gauss point mesh coordinate -Each element 8 gauss points + interface->elemGPCoordinates = malloc(interface->numGPTotal * 3 * sizeof(double)); + interface->elemGPID = malloc(interface->numGPTotal * sizeof(int)); + + for(int j = 0; j< interface->numGPTotal; j++){ + // interface->elemGPID[j] = j; + interface->elemGPCoordinates[j*3] = j; + interface->elemGPCoordinates[j*3+1] = 0.0; + interface->elemGPCoordinates[j*3+2] = 0.0; + } + - return INVALID_ELEMENT; + // getElementGaussPointCoordinates(interface->numElements, interface->numGPTotal, interface->elementIDs, sim->co, + // sim->kon, sim->lakon, sim->ipkon, interface->elemGPID, interface->elemGPCoordinates); + + precicec_setMeshVertices(interface->elementMeshID, interface->numGPTotal, interface->elemGPCoordinates, interface->elemGPID); } + + + void PreciceInterface_ConfigureFaceCentersMesh(PreciceInterface *interface, SimulationData *sim) { - // printf("Entering ConfigureFaceCentersMesh \n"); + //printf("Entering ConfigureFaceCentersMesh \n"); char *faceSetName = toFaceSetName(interface->name); interface->faceSetID = getSetID(faceSetName, sim->set, sim->nset); interface->numElements = getNumSetElements(interface->faceSetID, sim->istartset, sim->iendset); @@ -563,59 +733,66 @@ void PreciceInterface_ConfigureFaceCentersMesh(PreciceInterface *interface, Simu interface->faceCenterCoordinates = malloc(interface->numElements * 3 * sizeof(double)); interface->preciceFaceCenterIDs = malloc(interface->numElements * 3 * sizeof(int)); - - enum ElemType elemType = findSimulationMeshType(sim); - - if (elemType == TETRAHEDRA) { - printf("Configuring faces mesh with tetrahedra.\n"); - getTetraFaceCenters(interface->elementIDs, interface->faceIDs, interface->numElements, sim->kon, sim->ipkon, sim->co, interface->faceCenterCoordinates); - } else if (elemType == HEXAHEDRA) { - printf("Configuring faces mesh with hexahedra.\n"); - getHexaFaceCenters(interface->elementIDs, interface->faceIDs, interface->numElements, sim->kon, sim->ipkon, sim->co, interface->faceCenterCoordinates); - } else { - supportedElementError(); - } + getTetraFaceCenters(interface->elementIDs, interface->faceIDs, interface->numElements, sim->kon, sim->ipkon, sim->co, interface->faceCenterCoordinates); interface->faceCentersMeshID = precicec_getMeshID(interface->faceCentersMeshName); interface->preciceFaceCenterIDs = malloc(interface->numElements * sizeof(int)); - sendFaceCentersVertices(interface); -} - -void sendFaceCentersVertices(PreciceInterface *interface) -{ - // Send the data of face centers to preCICE. If 2D coupling is used, skip the z component! - - if (!isQuasi2D3D(interface->quasi2D3D)) { - precicec_setMeshVertices(interface->faceCentersMeshID, interface->numElements, interface->faceCenterCoordinates, interface->preciceFaceCenterIDs); - } else { - double *coordinates2D = malloc(interface->numElements * 2 * sizeof(double)); - for (int i = 0; i < interface->numElements; ++i) { - coordinates2D[2 * i] = interface->faceCenterCoordinates[3 * i]; - coordinates2D[2 * i + 1] = interface->faceCenterCoordinates[3 * i + 1]; - } - precicec_setMeshVertices(interface->faceCentersMeshID, interface->numElements, coordinates2D, interface->preciceFaceCenterIDs); - free(coordinates2D); - } + precicec_setMeshVertices(interface->faceCentersMeshID, interface->numElements, interface->faceCenterCoordinates, interface->preciceFaceCenterIDs); } void PreciceInterface_ConfigureNodesMesh(PreciceInterface *interface, SimulationData *sim) { - // printf("Entering configureNodesMesh \n"); + //printf("Entering configureNodesMesh \n"); char *nodeSetName = toNodeSetName(interface->name); interface->nodeSetID = getSetID(nodeSetName, sim->set, sim->nset); interface->numNodes = getNumSetElements(interface->nodeSetID, sim->istartset, sim->iendset); - interface->nodeIDs = &sim->ialset[sim->istartset[interface->nodeSetID] - 1]; // Lucia: make a copy + interface->nodeIDs = &sim->ialset[sim->istartset[interface->nodeSetID] - 1]; //Lucia: make a copy interface->nodeCoordinates = malloc(interface->numNodes * interface->dimCCX * sizeof(double)); getNodeCoordinates(interface->nodeIDs, interface->numNodes, interface->dimCCX, sim->co, sim->vold, sim->mt, interface->nodeCoordinates); - // If 2D-3Q coupling is used (for a node mesh) delegate this to the specialized data structure. + // Extract 2D coordinates from 3D coordinates for quasi 2D-3D coupling + if (isQuasi2D3D(interface->quasi2D3D)) { + int count = 0; + int dim = interface->dim; + int dimCCX = interface->dimCCX; + interface->num2DNodes = interface->numNodes / 2; + interface->node2DCoordinates = malloc(interface->num2DNodes * dim * sizeof(double)); + interface->mapping2D3D = malloc(interface->numNodes * sizeof(int)); + for (int i = 0; i < interface->numNodes; i++) { + // Filter out nodes which are in the XY plane (Z = 0) for getting 2D mesh + if (isDoubleEqual(interface->nodeCoordinates[i * dimCCX + 2], 0.0)) { + interface->node2DCoordinates[count * dim] = interface->nodeCoordinates[i * dimCCX]; + interface->node2DCoordinates[count * dim + 1] = interface->nodeCoordinates[i * dimCCX + 1]; + count += 1; + } + } + assert(count == interface->num2DNodes && "Filtering of 2D nodes not done properly. Please make sure the out-of-plane axis is Z-axis"); + + count = 0; + for (int i = 0; i < interface->numNodes; i++) { + for (int ii = 0; ii < interface->numNodes; ii++) { + // Compare each node with every other node to find nodes with matching X and Y coordinates + if (isDoubleEqual(interface->nodeCoordinates[ii * dimCCX], interface->nodeCoordinates[i * dimCCX]) && + isDoubleEqual(interface->nodeCoordinates[ii * dimCCX + 1], interface->nodeCoordinates[i * dimCCX + 1]) && + !isDoubleEqual(interface->nodeCoordinates[ii * dimCCX + 2], interface->nodeCoordinates[i * dimCCX + 2])) { + if (!isDoubleEqual(interface->nodeCoordinates[i * dimCCX + 2], 0.0)) { + interface->mapping2D3D[i] = count; + interface->mapping2D3D[ii] = count; + count += 1; + } + } + } + } + } + if (interface->nodesMeshName != NULL) { + //printf("nodesMeshName is not null \n"); interface->nodesMeshID = precicec_getMeshID(interface->nodesMeshName); - if (isQuasi2D3D(interface->quasi2D3D)) { - interface->mappingQuasi2D3D = createMapping(interface->nodeCoordinates, interface->numNodes, interface->nodesMeshID); + interface->preciceNodeIDs = malloc(interface->num2DNodes * sizeof(int)); + precicec_setMeshVertices(interface->nodesMeshID, interface->num2DNodes, interface->node2DCoordinates, interface->preciceNodeIDs); } else { interface->preciceNodeIDs = malloc(interface->numNodes * sizeof(int)); precicec_setMeshVertices(interface->nodesMeshID, interface->numNodes, interface->nodeCoordinates, interface->preciceNodeIDs); @@ -642,30 +819,25 @@ void PreciceInterface_NodeConnectivity(PreciceInterface *interface, SimulationDa PreciceInterface_ConfigureTetraFaces(interface, sim); } -void PreciceInterface_EnsureValidNodesMeshID(PreciceInterface *interface, const char *type) +void PreciceInterface_EnsureValidNodesMeshID(PreciceInterface *interface) { if (interface->nodesMeshID < 0) { - printf("Nodes mesh configuration not provided in YAML config file. They are required for writing/reading the data %s.\n" - " Please check you configured a nodes-mesh or nodes-mesh-with-connectivity in the config file.\n", - type); + printf("Nodes mesh not provided in YAML config file\n"); fflush(stdout); exit(EXIT_FAILURE); } } -void PreciceInterface_EnsureValidRead(SimulationData *sim, enum CouplingDataType type) +void PreciceInterface_EnsureValidElementsMeshID(PreciceInterface *interface) { - // Forbidden read data in modal dynamic simulations - if (sim->isModalDynamic) { - if (type == TEMPERATURE || type == DISPLACEMENTS || type == DISPLACEMENTDELTAS || type == VELOCITIES || type == POSITIONS) { - printf("Error: in modal dynamic simulations, only loads (forces, pressures, heat fluxes) can be read.\n" - "Degrees of freedom (positions, velocities, temperatures) cannot be read from preCICE."); - fflush(stdout); - exit(EXIT_FAILURE); - } + if (interface->elementMeshID < 0) { + printf("Element mesh not provided in YAML config file\n"); + fflush(stdout); + exit(EXIT_FAILURE); } } + void PreciceInterface_ConfigureTetraFaces(PreciceInterface *interface, SimulationData *sim) { int i; @@ -681,84 +853,111 @@ void PreciceInterface_ConfigureTetraFaces(PreciceInterface *interface, Simulatio } } -void PreciceInterface_EnsureValidFacesMeshID(PreciceInterface *interface, const char *type) -{ - if (interface->faceCentersMeshID < 0) { - printf("Faces centers mesh configuration not provided in YAML config file. They are required for writing/reading the data %s.\n" - " Please check you configured a faces-mesh (mesh) in the config file.\n", - type); - fflush(stdout); - exit(EXIT_FAILURE); - } -} - void PreciceInterface_ConfigureCouplingData(PreciceInterface *interface, SimulationData *sim, InterfaceConfig const *config) { interface->nodeScalarData = malloc(interface->numNodes * sizeof(double)); interface->nodeVectorData = malloc(interface->numNodes * 3 * sizeof(double)); + + if (isQuasi2D3D(interface->quasi2D3D)) { + interface->node2DScalarData = malloc(interface->num2DNodes * sizeof(double)); + interface->node2DVectorData = malloc(interface->num2DNodes * 2 * sizeof(double)); + + int dim = interface->dim; + for (int i = 0; i < interface->num2DNodes; i++) { + interface->node2DScalarData[i] = 0.0; + interface->node2DVectorData[i * dim] = 0.0; + interface->node2DVectorData[i * dim + 1] = 0.0; + } + } + interface->faceCenterData = malloc(interface->numElements * sizeof(double)); - // Configure all the read data, then the write data int i; interface->numReadData = config->numReadData; if (config->numReadData > 0) interface->readData = malloc(config->numReadData * sizeof(int)); for (i = 0; i < config->numReadData; i++) { - if (startsWith(config->readDataNames[i], "Temperature")) { - PreciceInterface_EnsureValidNodesMeshID(interface, "Temperature"); - PreciceInterface_EnsureValidRead(sim, TEMPERATURE); + if (isEqual(config->readDataNames[i], "Temperature")) { + PreciceInterface_EnsureValidNodesMeshID(interface); interface->readData[i] = TEMPERATURE; interface->xbounIndices = malloc(interface->numNodes * sizeof(int)); - interface->temperatureDataID = precicec_getDataID(config->readDataNames[i], interface->nodesMeshID); + interface->temperatureDataID = precicec_getDataID("Temperature", interface->nodesMeshID); getXbounIndices(interface->nodeIDs, interface->numNodes, sim->nboun, sim->ikboun, sim->ilboun, interface->xbounIndices, TEMPERATURE); printf("Read data '%s' found with ID # '%d'.\n", config->readDataNames[i], interface->temperatureDataID); - } else if (startsWith(config->readDataNames[i], "Heat-Flux")) { + } else if (isEqual(config->readDataNames[i], "Heat-Flux")) { interface->readData[i] = HEAT_FLUX; interface->xloadIndices = malloc(interface->numElements * sizeof(int)); getXloadIndices("DFLUX", interface->elementIDs, interface->faceIDs, interface->numElements, sim->nload, sim->nelemload, sim->sideload, interface->xloadIndices); - PreciceInterface_EnsureValidFacesMeshID(interface, "Heat-Flux"); - PreciceInterface_EnsureValidRead(sim, HEAT_FLUX); - interface->fluxDataID = precicec_getDataID(config->readDataNames[i], interface->faceCentersMeshID); + interface->fluxDataID = precicec_getDataID("Heat-Flux", interface->faceCentersMeshID); printf("Read data '%s' found with ID # '%d'.\n", config->readDataNames[i], interface->fluxDataID); - } else if (startsWith(config->readDataNames[i], "Sink-Temperature")) { + } else if (startsWith(config->readDataNames[i], "Sink-Temperature-")) { interface->readData[i] = SINK_TEMPERATURE; interface->xloadIndices = malloc(interface->numElements * sizeof(int)); getXloadIndices("FILM", interface->elementIDs, interface->faceIDs, interface->numElements, sim->nload, sim->nelemload, sim->sideload, interface->xloadIndices); - PreciceInterface_EnsureValidFacesMeshID(interface, "Sink Temperature"); - PreciceInterface_EnsureValidRead(sim, SINK_TEMPERATURE); interface->kDeltaTemperatureReadDataID = precicec_getDataID(config->readDataNames[i], interface->faceCentersMeshID); printf("Read data '%s' found with ID # '%d'.\n", config->readDataNames[i], interface->kDeltaTemperatureReadDataID); - } else if (startsWith(config->readDataNames[i], "Heat-Transfer-Coefficient")) { - interface->readData[i] = HEAT_TRANSFER_COEFF; - PreciceInterface_EnsureValidFacesMeshID(interface, "Heat Transfer Coefficient"); - PreciceInterface_EnsureValidRead(sim, HEAT_TRANSFER_COEFF); + } else if (startsWith(config->readDataNames[i], "Heat-Transfer-Coefficient-")) { + interface->readData[i] = HEAT_TRANSFER_COEFF; interface->kDeltaReadDataID = precicec_getDataID(config->readDataNames[i], interface->faceCentersMeshID); printf("Read data '%s' found with ID # '%d'.\n", config->readDataNames[i], interface->kDeltaReadDataID); - } else if (startsWith(config->readDataNames[i], "Pressure")) { - interface->readData[i] = PRESSURE; - interface->xloadIndices = malloc(interface->numElements * sizeof(int)); - PreciceInterface_EnsureValidRead(sim, PRESSURE); - getXloadIndices("PRESSUREDLOAD", interface->elementIDs, interface->faceIDs, interface->numElements, sim->nload, sim->nelemload, sim->sideload, interface->xloadIndices); - interface->pressureDataID = precicec_getDataID(config->readDataNames[i], interface->faceCentersMeshID); - printf("Read data '%s' found with ID # '%d'.\n", config->readDataNames[i], interface->pressureDataID); } else if (startsWith(config->readDataNames[i], "Force")) { - PreciceInterface_EnsureValidNodesMeshID(interface, "Force"); - PreciceInterface_EnsureValidRead(sim, FORCES); + PreciceInterface_EnsureValidNodesMeshID(interface); interface->readData[i] = FORCES; interface->xforcIndices = malloc(interface->numNodes * 3 * sizeof(int)); interface->forcesDataID = precicec_getDataID(config->readDataNames[i], interface->nodesMeshID); getXforcIndices(interface->nodeIDs, interface->numNodes, sim->nforc, sim->ikforc, sim->ilforc, interface->xforcIndices); printf("Read data '%s' found with ID # '%d'.\n", config->readDataNames[i], interface->forcesDataID); } else if (startsWith(config->readDataNames[i], "Displacement")) { - PreciceInterface_EnsureValidNodesMeshID(interface, "Displacement"); - PreciceInterface_EnsureValidRead(sim, DISPLACEMENTS); + PreciceInterface_EnsureValidNodesMeshID(interface); interface->readData[i] = DISPLACEMENTS; interface->xbounIndices = malloc(interface->numNodes * 3 * sizeof(int)); interface->displacementsDataID = precicec_getDataID(config->readDataNames[i], interface->nodesMeshID); getXbounIndices(interface->nodeIDs, interface->numNodes, sim->nboun, sim->ikboun, sim->ilboun, interface->xbounIndices, DISPLACEMENTS); printf("Read data '%s' found with ID # '%d'.\n", config->readDataNames[i], interface->displacementsDataID); + } else if (startsWith(config->readDataNames[i], "Material-Tangent-1")) { + PreciceInterface_EnsureValidElementsMeshID(interface); + interface->readData[i] = MATERTIAL_TANGENT_1; + interface->elementGPData = malloc(interface->numGPTotal * 38 * sizeof(double)); // 9 entries per gauss point + interface->materialTangent1DataID = precicec_getDataID(config->readDataNames[i], interface->elementMeshID); + printf("Read data '%s' found with ID # '%d'.\n", config->readDataNames[i], interface->materialTangent1DataID); + } else if (startsWith(config->readDataNames[i], "Material-Tangent-2")) { + PreciceInterface_EnsureValidElementsMeshID(interface); + interface->readData[i] = MATERTIAL_TANGENT_2; + // interface->elementGPData = malloc(interface->numGPTotal * 38 * sizeof(double)); // 9 entries per gauss point + interface->materialTangent2DataID = precicec_getDataID(config->readDataNames[i], interface->elementMeshID); + printf("Read data '%s' found with ID # '%d'.\n", config->readDataNames[i], interface->materialTangent2DataID); + } else if (startsWith(config->readDataNames[i], "Material-Tangent-3")) { + PreciceInterface_EnsureValidElementsMeshID(interface); + interface->readData[i] = MATERTIAL_TANGENT_3; + // interface->elementGPData = malloc(interface->numGPTotal * 38 * sizeof(double)); // 9 entries per gauss point + interface->materialTangent3DataID = precicec_getDataID(config->readDataNames[i], interface->elementMeshID); + printf("Read data '%s' found with ID # '%d'.\n", config->readDataNames[i], interface->materialTangent3DataID); + } else if (startsWith(config->readDataNames[i], "Material-Tangent-4")) { + PreciceInterface_EnsureValidElementsMeshID(interface); + interface->readData[i] = MATERTIAL_TANGENT_4; + // interface->elementGPData = malloc(interface->numGPTotal * 38 * sizeof(double)); // 9 entries per gauss point + interface->materialTangent4DataID = precicec_getDataID(config->readDataNames[i], interface->elementMeshID); + printf("Read data '%s' found with ID # '%d'.\n", config->readDataNames[i], interface->materialTangent4DataID); + } else if (startsWith(config->readDataNames[i], "Material-Tangent-5")) { + PreciceInterface_EnsureValidElementsMeshID(interface); + interface->readData[i] = MATERTIAL_TANGENT_5; + // interface->elementGPData = malloc(interface->numGPTotal * 38 * sizeof(double)); // 9 entries per gauss point + interface->materialTangent5DataID = precicec_getDataID(config->readDataNames[i], interface->elementMeshID); + printf("Read data '%s' found with ID # '%d'.\n", config->readDataNames[i], interface->materialTangent5DataID); + } else if (startsWith(config->readDataNames[i], "Material-Tangent-6")) { + PreciceInterface_EnsureValidElementsMeshID(interface); + interface->readData[i] = MATERTIAL_TANGENT_6; + // interface->elementGPData = malloc(interface->numGPTotal * 38 * sizeof(double)); // 9 entries per gauss point + interface->materialTangent6DataID = precicec_getDataID(config->readDataNames[i], interface->elementMeshID); + printf("Read data '%s' found with ID # '%d'.\n", config->readDataNames[i], interface->materialTangent6DataID); + } else if (startsWith(config->readDataNames[i], "Material-Tangent-7")) { + PreciceInterface_EnsureValidElementsMeshID(interface); + interface->readData[i] = MATERTIAL_TANGENT_7; + // interface->elementGPData = malloc(interface->numGPTotal * 38 * sizeof(double)); // 9 entries per gauss point + interface->materialTangent7DataID = precicec_getDataID(config->readDataNames[i], interface->elementMeshID); + printf("Read data '%s' found with ID # '%d'.\n", config->readDataNames[i], interface->materialTangent7DataID); } else { - printf("ERROR: Read data '%s' is not of a known type for the CalculiX-preCICE adapter. Check the adapter configuration file.\n", config->readDataNames[i]); + printf("ERROR: Read data '%s' does not exist!\n", config->readDataNames[i]); exit(EXIT_FAILURE); } } @@ -768,56 +967,62 @@ void PreciceInterface_ConfigureCouplingData(PreciceInterface *interface, Simulat interface->writeData = malloc(config->numWriteData * sizeof(int)); for (i = 0; i < config->numWriteData; i++) { - if (startsWith(config->writeDataNames[i], "Temperature")) { - PreciceInterface_EnsureValidNodesMeshID(interface, "Temperature"); + if (isEqual(config->writeDataNames[i], "Temperature")) { + PreciceInterface_EnsureValidNodesMeshID(interface); interface->writeData[i] = TEMPERATURE; - interface->temperatureDataID = precicec_getDataID(config->writeDataNames[i], interface->nodesMeshID); + interface->temperatureDataID = precicec_getDataID("Temperature", interface->nodesMeshID); printf("Write data '%s' found with ID # '%d'.\n", config->writeDataNames[i], interface->temperatureDataID); - } else if (startsWith(config->writeDataNames[i], "Heat-Flux")) { + } else if (isEqual(config->writeDataNames[i], "Heat-Flux")) { interface->writeData[i] = HEAT_FLUX; - PreciceInterface_EnsureValidFacesMeshID(interface, "Heat Flux"); - interface->fluxDataID = precicec_getDataID(config->writeDataNames[i], interface->faceCentersMeshID); + interface->fluxDataID = precicec_getDataID("Heat-Flux", interface->faceCentersMeshID); printf("Write data '%s' found with ID # '%d'.\n", config->writeDataNames[i], interface->fluxDataID); - } else if (startsWith(config->writeDataNames[i], "Sink-Temperature")) { - interface->writeData[i] = SINK_TEMPERATURE; - PreciceInterface_EnsureValidFacesMeshID(interface, "Sink temperature"); + } else if (startsWith(config->writeDataNames[i], "Sink-Temperature-")) { + interface->writeData[i] = SINK_TEMPERATURE; interface->kDeltaTemperatureWriteDataID = precicec_getDataID(config->writeDataNames[i], interface->faceCentersMeshID); printf("Write data '%s' found with ID # '%d'.\n", config->writeDataNames[i], interface->kDeltaTemperatureWriteDataID); - } else if (startsWith(config->writeDataNames[i], "Heat-Transfer-Coefficient")) { - interface->writeData[i] = HEAT_TRANSFER_COEFF; - PreciceInterface_EnsureValidFacesMeshID(interface, "Heat Transfer Coefficient"); + } else if (startsWith(config->writeDataNames[i], "Heat-Transfer-Coefficient-")) { + interface->writeData[i] = HEAT_TRANSFER_COEFF; interface->kDeltaWriteDataID = precicec_getDataID(config->writeDataNames[i], interface->faceCentersMeshID); printf("Write data '%s' found with ID # '%d'.\n", config->writeDataNames[i], interface->kDeltaWriteDataID); } else if (startsWith(config->writeDataNames[i], "DisplacementDelta")) { - PreciceInterface_EnsureValidNodesMeshID(interface, "DisplacementDeltas"); + PreciceInterface_EnsureValidNodesMeshID(interface); interface->writeData[i] = DISPLACEMENTDELTAS; interface->displacementDeltasDataID = precicec_getDataID(config->writeDataNames[i], interface->nodesMeshID); printf("Write data '%s' found with ID # '%d'.\n", config->writeDataNames[i], interface->displacementDeltasDataID); } else if (startsWith(config->writeDataNames[i], "Displacement")) { - PreciceInterface_EnsureValidNodesMeshID(interface, "Displacement"); + PreciceInterface_EnsureValidNodesMeshID(interface); interface->writeData[i] = DISPLACEMENTS; interface->displacementsDataID = precicec_getDataID(config->writeDataNames[i], interface->nodesMeshID); printf("Write data '%s' found with ID # '%d'.\n", config->writeDataNames[i], interface->displacementsDataID); } else if (startsWith(config->writeDataNames[i], "Position")) { - PreciceInterface_EnsureValidNodesMeshID(interface, "Position"); + PreciceInterface_EnsureValidNodesMeshID(interface); interface->writeData[i] = POSITIONS; interface->positionsDataID = precicec_getDataID(config->writeDataNames[i], interface->nodesMeshID); printf("Write data '%s' found with ID # '%d'.\n", config->writeDataNames[i], interface->positionsDataID); - - } - /* Both "Velocities" and "Velocity" are valid, so we accept Velocit[...]*/ - else if (startsWith(config->writeDataNames[i], "Velocit")) { - PreciceInterface_EnsureValidNodesMeshID(interface, "Velocity"); + } else if (startsWith(config->writeDataNames[i], "Velocit")) { + PreciceInterface_EnsureValidNodesMeshID(interface); interface->writeData[i] = VELOCITIES; interface->velocitiesDataID = precicec_getDataID(config->writeDataNames[i], interface->nodesMeshID); printf("Write data '%s' found with ID # '%d'.\n", config->writeDataNames[i], interface->velocitiesDataID); } else if (startsWith(config->writeDataNames[i], "Force")) { - PreciceInterface_EnsureValidNodesMeshID(interface, "Force"); + PreciceInterface_EnsureValidNodesMeshID(interface); interface->writeData[i] = FORCES; interface->forcesDataID = precicec_getDataID(config->writeDataNames[i], interface->nodesMeshID); printf("Write data '%s' found with ID # '%d'.\n", config->writeDataNames[i], interface->forcesDataID); - } else { - printf("ERROR: Write data '%s' is not of a known type for the CalculiX-preCICE adapter. Check the adapter configuration file.\n", config->writeDataNames[i]); + } else if (isEqual(config->writeDataNames[i], "RVE-ID")) { + interface->writeData[i] = RVE_ID; + interface->rveIdDataID = precicec_getDataID("RVE-ID", interface->elementMeshID); + printf("Write data '%s' found with ID # '%d'.\n", config->writeDataNames[i], interface->rveIdDataID); + } else if (isEqual(config->writeDataNames[i], "Strain-Norm")) { + interface->writeData[i] = STRAIN_NORM; + interface->strainNormDataID = precicec_getDataID("Strain-Norm", interface->elementMeshID); + printf("Write data '%s' found with ID # '%d'.\n", config->writeDataNames[i], interface->strainNormDataID); + } else if (isEqual(config->writeDataNames[i], "Strain-Shear")) { + interface->writeData[i] = STRAIN_SHEAR; + interface->strainShearDataID = precicec_getDataID("Strain-Shear", interface->elementMeshID); + printf("Write data '%s' found with ID # '%d'.\n", config->writeDataNames[i], interface->strainShearDataID); + }else { + printf("ERROR: Write data '%s' does not exist!\n", config->writeDataNames[i]); exit(EXIT_FAILURE); } } @@ -853,6 +1058,10 @@ void PreciceInterface_FreeData(PreciceInterface *preciceInterface) free(preciceInterface->nodeCoordinates); } + if (preciceInterface->node2DCoordinates != NULL) { + free(preciceInterface->node2DCoordinates); + } + if (preciceInterface->preciceNodeIDs != NULL) { free(preciceInterface->preciceNodeIDs); } @@ -889,7 +1098,7 @@ void PreciceInterface_FreeData(PreciceInterface *preciceInterface) free(preciceInterface->xforcIndices); } - if (preciceInterface->mappingQuasi2D3D != NULL) { - freeMapping(preciceInterface->mappingQuasi2D3D); + if (preciceInterface->mapping2D3D != NULL) { + free(preciceInterface->mapping2D3D); } } diff --git a/adapter/PreciceInterface.h b/adapter/PreciceInterface.h old mode 100644 new mode 100755 index 171fa8bd..8d33ec65 --- a/adapter/PreciceInterface.h +++ b/adapter/PreciceInterface.h @@ -11,7 +11,6 @@ #define PRECICEINTERFACE_H #include -#include "2D3DCoupling.h" #include "CCXHelpers.h" #include "ConfigReader.h" @@ -26,14 +25,16 @@ typedef struct PreciceInterface { int dimCCX; // Dimension as seen by CalculiX // Interface nodes - int numNodes; - int * nodeIDs; - Mapping2D3D *mappingQuasi2D3D; - double * nodeCoordinates; - int nodeSetID; - int * preciceNodeIDs; - int nodesMeshID; - char * nodesMeshName; + int numNodes; + int num2DNodes; // Nodes in a single plane in case of quasi 2D-3D coupling + int * nodeIDs; + int * mapping2D3D; // Node IDs to filter out 2D place in quasi 2D-3D coupling + double *nodeCoordinates; + double *node2DCoordinates; // 2D coordinates for quasi 2D-3D coupling + int nodeSetID; + int * preciceNodeIDs; + int nodesMeshID; + char * nodesMeshName; // Interface face elements int numElements; @@ -45,12 +46,26 @@ typedef struct PreciceInterface { char * faceCentersMeshName; int * preciceFaceCenterIDs; + // Interface volumetric elements + int elementMeshID; + char *elementMeshName; + int elementSetID; + int numGPTotal; + double *elemGPCoordinates; + int *elemGPID; + + + + // Arrays to store the coupling data double *nodeScalarData; double *node2DScalarData; // Scalar quantities in 2D in case quasi 2D-3D coupling is done double *nodeVectorData; // Forces, displacements, velocities, positions and displacementDeltas are vector quantities double *node2DVectorData; // Vector quantities in 2D in case quasi 2D-3D coupling is done double *faceCenterData; + double *elementGPData; + double *strainGPData; + double *rveGPData; // preCICE Data IDs int temperatureDataID; @@ -59,12 +74,23 @@ typedef struct PreciceInterface { int kDeltaTemperatureWriteDataID; int kDeltaReadDataID; int kDeltaTemperatureReadDataID; - int displacementsDataID; // New data ID for displacements - int displacementDeltasDataID; // New data ID for displacementDeltas - int positionsDataID; // New data ID for positions - int velocitiesDataID; // New data ID for velocities - int forcesDataID; // New data ID for forces - int pressureDataID; // New data ID for pressure + int displacementsDataID; //New data ID for displacements + int displacementDeltasDataID; //New data ID for displacementDeltas + int positionsDataID; //New data ID for positions + int velocitiesDataID; //New data ID for velocities + int forcesDataID; //New data ID for forces + int rveIdDataID; //New data ID for RVE ID + int strainNormDataID; //New data ID for strain norm + int strainShearDataID; //New data ID for strain shear + int stressNormDataID; //New data ID for stress normal + int stressShearDataID; //New data ID for stress shear + int materialTangent1DataID; //New data ID for material tangent + int materialTangent2DataID; //New data ID for material tangent + int materialTangent3DataID; //New data ID for material tangent + int materialTangent4DataID; //New data ID for material tangent + int materialTangent5DataID; //New data ID for material tangent + int materialTangent6DataID; //New data ID for material tangent + int materialTangent7DataID; //New data ID for material tangent // Indices that indicate where to apply the boundary conditions / forces int *xloadIndices; @@ -97,38 +123,41 @@ typedef struct SimulationData { ITG * ielmat; ITG * istartset; ITG * iendset; - char * lakon; + char ** lakon; ITG * kon; ITG * ipkon; ITG nset; char * set; double *co; ITG nboun; - ITG nforc; // total number of forces + ITG nforc; //total number of forces ITG * ikboun; - ITG * ikforc; // the DoFs are all stored here in an array in numerical order + ITG * ikforc; //the DoFs are all stored here in an array in numerical order ITG * ilboun; - ITG * ilforc; // number of the force is stored here + ITG * ilforc; //number of the force is stored here ITG * nelemload; int nload; char * sideload; double nk; - ITG ne; ITG mt; double *theta; double *dtheta; double *tper; ITG * nmethod; double *xload; - double *xforc; // scalar value of the force in one direction + double *xforc; //scalar value of the force in one direction double *xboun; ITG * ntmat_; double *vold; double *veold; - double *fn; // values of forces read from calculix + double *fn; //values of forces read from calculix double *cocon; ITG * ncocon; ITG * mi; + ITG *nea; // element bounds in each thread - start + ITG *neb; // element bounds in each thread - end + double *eei; // Strain values + double *xstiff; // Strain values // Interfaces int numPreciceInterfaces; @@ -141,16 +170,6 @@ typedef struct SimulationData { double precice_dt; double solver_dt; - // Configuration information - int isModalDynamic; // 0 for regular simulations, 1 for modal dynamic - - // Modal dynamic simulation checkpointing buffers - double *eigenDOFs; // Called "bj" or "cd" in CCX code - double *eigenDOFsDerivatives; // Called "bjp" (p for prime) or "cv" in CCX code - int stored_iinc; - int stored_jprint; - int kode_value; - } SimulationData; /** @@ -158,6 +177,8 @@ typedef struct SimulationData { * @param configFilename: YAML config file * @param participantName * @param sim + * @param preciceInterfaces + * @param numPreciceInterfaces */ void Precice_Setup(char *configFilename, char *participantName, SimulationData *sim); @@ -223,24 +244,6 @@ void Precice_ReadIterationCheckpoint(SimulationData *sim, double *v); */ void Precice_WriteIterationCheckpoint(SimulationData *sim, double *v); -/** - * @brief Reads iteration checkpoint (in dyna_precice) - * @param sim: Structure with CalculiX data - * @param dofs: array containing the degrees of freedom in eigenspace - * @param derivatives: array containing the time derivatives (velocities) of the dofs - * @param nev: number of eigenvalues used (i.e. array size) - */ -void Precice_ReadIterationCheckpointModal(SimulationData *sim, double *dofs, double *derivatives, int nev); - -/** - * @brief Writes iteration checkpoint - * @param sim: Structure with CalculiX data (in dyna_precice) - * @param dofs: array containing the degrees of freedom in eigenspace - * @param derivatives: array containing the time derivatives (velocities) of the dofs - * @param nev: number of eigenvalues used (i.e. array size) - */ -void Precice_WriteIterationCheckpointModal(SimulationData *sim, const double *dofs, const double *derivatives, int nev); - /** * @brief Reads the coupling data for all interfaces * @param sim @@ -274,20 +277,12 @@ void Precice_FreeData(SimulationData *sim); void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, InterfaceConfig const *config); /** - * @brief Configures the face centers mesh and calls sendFaceCentersVertices, - * who is responsible for calling preCICE + * @brief Configures the face centers mesh and calls setMeshVertices on preCICE * @param interface * @param sim */ void PreciceInterface_ConfigureFaceCentersMesh(PreciceInterface *interface, SimulationData *sim); -/** - * @brief Send the faces centers to preCICE. - * - * @param interface - */ -void sendFaceCentersVertices(PreciceInterface *interface); - /** * @brief Configures the nodes mesh * @param interface @@ -298,23 +293,8 @@ void PreciceInterface_ConfigureNodesMesh(PreciceInterface *interface, Simulation /** * @brief Terminate execution if the nodes mesh ID is not valid * @param interface - * @param type of data requiring mesh ID - */ -void PreciceInterface_EnsureValidNodesMeshID(PreciceInterface *interface, const char *type); - -/** - * @brief Terminate execution if the faces mesh ID is not valid - * @param interface - * @param type of data requiring mesh ID - */ -void PreciceInterface_EnsureValidFacesMeshID(PreciceInterface *interface, const char *type); - -/** - * @brief Terminate execution if this kind of data can't be read - * @param sim - * @param type of data to check */ -void PreciceInterface_EnsureValidRead(SimulationData *sim, enum CouplingDataType type); +void PreciceInterface_EnsureValidNodesMeshID(PreciceInterface *interface); /** * @brief Configures the faces mesh (for tetrahedral elements only) diff --git a/ccx_2.19.c b/ccx_2.19.c new file mode 100755 index 00000000..7ae806e4 --- /dev/null +++ b/ccx_2.19.c @@ -0,0 +1,2228 @@ +/* CalculiX - A 3-dimensional finite element program */ +/* Copyright (C) 1998-2021 Guido Dhondt */ + +/* This program is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License as */ +/* published by the Free Software Foundation(version 2); */ +/* */ + +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU General Public License for more details. */ + +/* You should have received a copy of the GNU General Public License */ +/* along with this program; if not, write to the Free Software */ +/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifdef __WIN32 +_set_output_format(_TWO_DIGIT_EXPONENT); +#endif + +#ifdef CALCULIX_MPI +#include +#endif + +#include +#include +#include +#include +#include "CalculiX.h" + +#ifdef CALCULIX_MPI +ITG myid = 0, nproc = 0; +#endif + +struct timespec totalCalculixTimeStart, totalCalculixTimeEnd; + +int main(int argc, char *argv[]) +{ + + FILE *f1; + + char *sideload = NULL, *set = NULL, *matname = NULL, *orname = NULL, *amname = NULL, + *filab = NULL, *lakon = NULL, *labmpc = NULL, *prlab = NULL, *prset = NULL, + jobnamec[792] = "", jobnamef[132] = "", output[5], *typeboun = NULL, + *inpc = NULL, *tieset = NULL, *cbody = NULL, fneig[132], *sideloadtemp = NULL, + kind1[2], kind2[2], *heading = NULL, *objectset = NULL; + + ITG *kon = NULL, *nodeboun = NULL, *ndirboun = NULL, *ipompc = NULL, + *nodempc = NULL, *nodeforc = NULL, *ndirforc = NULL, + *nelemload = NULL, im, *inodesd = NULL, nload1, *idefforc = NULL, + *nactdof = NULL, *icol = NULL, *ics = NULL, itempuser[3], + *jq = NULL, *mast1 = NULL, *irow = NULL, *rig = NULL, *idefbody = NULL, + *ikmpc = NULL, *ilmpc = NULL, *ikboun = NULL, *ilboun = NULL, + *nreorder = NULL, *ipointer = NULL, *idefload = NULL, + *istartset = NULL, *iendset = NULL, *ialset = NULL, *ielmat = NULL, + *ielorien = NULL, *nrhcon = NULL, *nodebounold = NULL, *ndirbounold = NULL, + *nelcon = NULL, *nalcon = NULL, *iamforc = NULL, *iamload = NULL, + *iamt1 = NULL, *namta = NULL, *ipkon = NULL, *iamboun = NULL, + *nplicon = NULL, *nplkcon = NULL, *inotr = NULL, *iponor = NULL, *knor = NULL, + *ikforc = NULL, *ilforc = NULL, *iponoel = NULL, *inoel = NULL, *nshcon = NULL, + *ncocon = NULL, *ibody = NULL, *ielprop = NULL, *islavsurf = NULL, + *ipoinpc = NULL, mt, nxstate, nload0, iload, *iuel = NULL, *ne2boun = NULL, + *irandomtype = NULL, irobustdesign[3], *iparentel = NULL, ifreebody, + *ipobody = NULL, inewton = 0, *iprfn = NULL, *konrfn = NULL; + + ITG nk, ne, nboun, nmpc, nforc, nload, nprint, nset, nalset, nentries = 18, + nmethod, neq[3], i, mpcfree, mei[4] = {0, 0, 0, 0}, j, nzl, nam, nbounold, + nforcold, nloadold, nbody, nbody_, nbodyold, network, nheading_, + k, nzs[3], nmpc_, nload_, nforc_, istep, istat, nboun_, nintpoint, + iperturb[2], nmat, ntmat_, norien, ithermal[2] = {0, 0}, nmpcold, + iprestr, kode, isolver, nslavs, nkon_, ne0, nkon0, mortar, + jout[2], nlabel, nkon, idrct, jmax[2], iexpl, nevtot, ifacecount, + iplas, npmat_, mi[3], ntrans, mpcend, namtot_, iumat, iheading, + icascade, maxlenmpc, mpcinfo[4], ne1d, ne2d, infree[4], + callfrommain, nflow, jin = 0, irstrt[2], nener, jrstrt, nenerold, + nline, *ipoinp = NULL, *inp = NULL, ntie, ntie_, mcs, nprop_, + nprop, itpamp, iviewfile, nkold, nevdamp_, npt_, cyclicsymmetry, + nmethodl, iaxial, inext, icontact, nobject, nobject_, iit, + nzsprevstep[3], memmpcref_, mpcfreeref, maxlenmpcref, *nodempcref = NULL, + *ikmpcref = NULL, isens, namtot, nstam, ndamp, nef, inp_size, + *ipoinp_sav = NULL, *inp_sav = NULL, irefineloop = 0, icoordinate = 0, + *nodedesi = NULL, ndesi = 0, nobjectstart = 0, nfc_, ndc_, nfc, ndc, *ikdc = NULL; + + ITG *meminset = NULL, *rmeminset = NULL; + + ITG nzs_, nk_, ne_, nset_ = 0, nalset_, nmat_, norien_, nam_, + ntrans_, ncs_, nstate_, ncmat_, memmpc_, nprint_, nuel_ = 0; + + double *co = NULL, *xboun = NULL, *coefmpc = NULL, *xforc = NULL, *clearini = NULL, + *xload = NULL, *xbounold = NULL, *xforcold = NULL, *randomval = NULL, + *vold = NULL, *sti = NULL, *xloadold = NULL, *xnor = NULL, + *reorder = NULL, *dcs = NULL, *thickn = NULL, *thicke = NULL, *offset = NULL, + *elcon = NULL, *rhcon = NULL, *alcon = NULL, *alzero = NULL, *t0 = NULL, *t1 = NULL, + *prestr = NULL, *orab = NULL, *amta = NULL, *veold = NULL, *accold = NULL, + *t1old = NULL, *eme = NULL, *plicon = NULL, *pslavsurf = NULL, *plkcon = NULL, + *xstate = NULL, *trab = NULL, *ener = NULL, *shcon = NULL, *cocon = NULL, + *cs = NULL, *tietol = NULL, *fmpc = NULL, *prop = NULL, *t0g = NULL, *t1g = NULL, + *xbody = NULL, *xbodyold = NULL, *coefmpcref = NULL, *dacon = NULL, *vel = NULL, + *velo = NULL, *veloo = NULL, energy[5], *ratiorfn = NULL, *dgdxglob = NULL, + *g0 = NULL, *xdesi = NULL, *coeffc = NULL, *edc = NULL; + + double ctrl[57]; + + double fei[3], *xmodal = NULL, timepar[5], alpha[2], ttime, qaold[2], physcon[14]; + + double totalCalculixTime; + + /* + * Additional variables for the coupling with preCICE + * preCICE is used only if a participant name is provided as a command line argument! + */ + char preciceParticipantName[256] = "", configFilename[256] = "config.yml"; + int preciceUsed = 0; + +#ifdef CALCULIX_MPI + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &myid); + MPI_Comm_size(MPI_COMM_WORLD, &nproc); +#endif + + clock_gettime(CLOCK_MONOTONIC, &totalCalculixTimeStart); + + if (argc == 1) { + printf("Usage: CalculiX.exe -i jobname\n"); + FORTRAN(stop, ()); + } else { + for (i = 1; i < argc; i++) { + if (strcmp1(argv[i], "-i") == 0) { + strcpy(jobnamec, argv[i + 1]); + strcpy1(jobnamef, argv[i + 1], 132); + jin++; + break; + } + if (strcmp1(argv[i], "-v") == 0) { + printf("\nThis is Version 2.19\n\n"); + FORTRAN(stop, ()); + } + } + if (jin == 0) { + strcpy(jobnamec, argv[1]); + strcpy1(jobnamef, argv[1], 132); + } + + /* next lines deactivated on March 18, 2020 */ + + /* for(i=1;i= 0) { + + fflush(stdout); + + /* in order to reduce the number of variables to be transferred to + the subroutines, the max. field sizes are (for most fields) copied + into the real sizes */ + + nzs[1] = nzs_; + + if ((istep == 0) || (irstrt[0] < 0)) { + ne = ne_; + nset = nset_; + nalset = nalset_; + nmat = nmat_; + norien = norien_; + ntrans = ntrans_; + ntie = ntie_; + + /* allocating space before the first step */ + + /* coordinates and topology */ + + NNEW(co, double, 3 * nk_); + NNEW(kon, ITG, nkon_); + NNEW(ipkon, ITG, ne_); + NNEW(lakon, char, 8 * ne_); + + /* property cards */ + + if (nprop_ > 0) { + NNEW(ielprop, ITG, ne_); + for (i = 0; i < ne_; i++) + ielprop[i] = -1; + NNEW(prop, double, nprop_); + } + + /* fields for 1-D and 2-D elements */ + + if ((ne1d != 0) || (ne2d != 0)) { + NNEW(iponor, ITG, 2 * nkon_); + for (i = 0; i < 2 * nkon_; i++) + iponor[i] = -1; + NNEW(xnor, double, 36 * ne1d + 24 * ne2d); + NNEW(knor, ITG, 24 * (ne1d + ne2d) * (mi[2] + 1)); + NNEW(thickn, double, 2 * nk_); + NNEW(thicke, double, mi[2] * nkon_); + NNEW(offset, double, 2 * ne_); + NNEW(iponoel, ITG, nk_); + NNEW(inoel, ITG, 9 * ne1d + 24 * ne2d); + NNEW(rig, ITG, nk_); + NNEW(ne2boun, ITG, 2 * nk_); + if (infree[2] == 0) + infree[2] = 1; + } + + /* SPC's */ + + NNEW(nodeboun, ITG, nboun_); + NNEW(ndirboun, ITG, nboun_); + NNEW(typeboun, char, nboun_ + 1); + if ((istep == 0) || ((irstrt[0] < 0) && (nam_ > 0))) + NNEW(iamboun, ITG, nboun_); + NNEW(xboun, double, nboun_); + NNEW(ikboun, ITG, nboun_); + NNEW(ilboun, ITG, nboun_); + + /* MPC's */ + + NNEW(ipompc, ITG, nmpc_); + NNEW(nodempc, ITG, 3 * memmpc_); + for (i = 0; i < 3 * memmpc_; i += 3) { + nodempc[i + 2] = i / 3 + 2; + } + nodempc[3 * memmpc_ - 1] = 0; + NNEW(coefmpc, double, memmpc_); + NNEW(labmpc, char, 20 * nmpc_ + 1); + NNEW(ikmpc, ITG, nmpc_); + NNEW(ilmpc, ITG, nmpc_); + NNEW(fmpc, double, nmpc_); + + /* coupling, distributed */ + + if (nfc_ > 0) { + NNEW(coeffc, double, 7 * nfc_); + NNEW(ikdc, ITG, ndc_); + NNEW(edc, double, 12 * ndc_); + } + + /* nodal loads */ + + NNEW(nodeforc, ITG, 2 * nforc_); + NNEW(ndirforc, ITG, nforc_); + if ((istep == 0) || ((irstrt[0] < 0) && (nam_ > 0))) + NNEW(iamforc, ITG, nforc_); + NNEW(idefforc, ITG, nforc_); + NNEW(xforc, double, nforc_); + NNEW(ikforc, ITG, nforc_); + NNEW(ilforc, ITG, nforc_); + + /* distributed facial loads */ + + NNEW(nelemload, ITG, 2 * nload_); + if ((istep == 0) || ((irstrt[0] < 0) && (nam_ > 0))) + NNEW(iamload, ITG, 2 * nload_); + NNEW(idefload, ITG, nload_); + NNEW(sideload, char, 20 * nload_); + NNEW(xload, double, 2 * nload_); + + /* distributed volumetric loads */ + + NNEW(cbody, char, 81 * nbody_); + NNEW(idefbody, ITG, nbody_); + NNEW(ibody, ITG, 3 * nbody_); + NNEW(xbody, double, 7 * nbody_); + NNEW(xbodyold, double, 7 * nbody_); + + /* printing output */ + + NNEW(prlab, char, 6 * nprint_); + NNEW(prset, char, 81 * nprint_); + + /* set definitions */ + + RENEW(set, char, 81 * nset); + NNEW(istartset, ITG, nset); + DMEMSET(istartset, 0, nset, 1); + NNEW(iendset, ITG, nset); + NNEW(ialset, ITG, nalset); + + /* (hyper)elastic constants */ + + NNEW(elcon, double, (ncmat_ + 1) * ntmat_ * nmat); + NNEW(nelcon, ITG, 2 * nmat); + + /* density */ + + NNEW(rhcon, double, 2 * ntmat_ * nmat); + NNEW(nrhcon, ITG, nmat); + + /* damping */ + + if (ndamp > 0) { + NNEW(dacon, double, nmat); + } + + /* specific heat */ + + NNEW(shcon, double, 4 * ntmat_ * nmat); + NNEW(nshcon, ITG, nmat); + + /* thermal expansion coefficients */ + + NNEW(alcon, double, 7 * ntmat_ * nmat); + NNEW(nalcon, ITG, 2 * nmat); + NNEW(alzero, double, nmat); + + /* conductivity */ + + NNEW(cocon, double, 7 * ntmat_ * nmat); + NNEW(ncocon, ITG, 2 * nmat); + + /* isotropic and kinematic hardening coefficients*/ + + if (npmat_ > 0) { + NNEW(plicon, double, (2 * npmat_ + 1) * ntmat_ * nmat); + NNEW(nplicon, ITG, (ntmat_ + 1) * nmat); + NNEW(plkcon, double, (2 * npmat_ + 1) * ntmat_ * nmat); + NNEW(nplkcon, ITG, (ntmat_ + 1) * nmat); + } + + /* linear dynamic properties */ + + NNEW(xmodal, double, 11 + nevdamp_); + xmodal[10] = nevdamp_ + 0.5; + + /* internal state variables (nslavs is needed for restart + calculations) */ + + if (mortar != 1) { + NNEW(xstate, double, nstate_ *mi[0] * (ne + nslavs)); + nxstate = nstate_ * mi[0] * (ne + nslavs); + } else if (mortar == 1) { + NNEW(xstate, double, nstate_ *mi[0] * (ne + nintpoint)); + nxstate = nstate_ * mi[0] * (ne + nintpoint); + } + + /* material orientation */ + + if ((istep == 0) || ((irstrt[0] < 0) && (norien > 0))) { + NNEW(orname, char, 80 * norien); + NNEW(orab, double, 7 * norien); + NNEW(ielorien, ITG, mi[2] * ne_); + } + + /* transformations */ + + if ((istep == 0) || ((irstrt[0] < 0) && (ntrans > 0))) { + NNEW(trab, double, 7 * ntrans); + NNEW(inotr, ITG, 2 * nk_); + } + + /* amplitude definitions */ + + if ((istep == 0) || ((irstrt[0] < 0) && (nam_ > 0))) { + NNEW(amname, char, 80 * nam_); + NNEW(amta, double, 2 * namtot_); + NNEW(namta, ITG, 3 * nam_); + } + + if ((istep == 0) || ((irstrt[0] < 0) && (ithermal[0] > 0))) { + NNEW(t0, double, nk_); + NNEW(t1, double, nk_); + if ((ne1d != 0) || (ne2d != 0) || (nuel_ != 0)) { + NNEW(t0g, double, 2 * nk_); + NNEW(t1g, double, 2 * nk_); + } + } + + /* the number in next line is NOT 1.2357111317 -> points + to user input; instead it is a generic nonzero + initialization */ + + if (istep == 0) { + DMEMSET(t0, 0, nk_, 1.2357111319); + DMEMSET(t1, 0, nk_, 1.2357111319); + } + + if ((istep == 0) || ((irstrt[0] < 0) && (ithermal[0] > 0) && (nam_ > 0))) + NNEW(iamt1, ITG, nk_); + + if ((istep == 0) || ((irstrt[0] < 0) && (iprestr > 0))) + NNEW(prestr, double, 6 * mi[0] * ne_); + + NNEW(vold, double, mt *nk_); + NNEW(veold, double, mt *nk_); + + /* CFD-results */ + + NNEW(vel, double, 8 * nef); + NNEW(velo, double, 8 * nef); + NNEW(veloo, double, 8 * nef); + + NNEW(ielmat, ITG, mi[2] * ne_); + + NNEW(matname, char, 80 * nmat); + + NNEW(filab, char, 87 * nlabel); + + /* tied constraints */ + + if (ntie_ > 0) { + NNEW(tieset, char, 243 * ntie_); + NNEW(tietol, double, 4 * ntie_); + NNEW(cs, double, 17 * ntie_); + } + + /* objectives for sensitivity analysis */ + + if (nobject_ > 0) { + NNEW(nodedesi, ITG, nk_); + NNEW(dgdxglob, double, nobject_ * 2 * nk_); + NNEW(g0, double, nobject_); + NNEW(xdesi, double, 3 * nk_); + NNEW(objectset, char, 405 * nobject_); + for (i = 0; i < 405 * nobject_; i++) { + objectset[i] = ' '; + } + } + + /* temporary fields for cyclic symmetry calculations */ + + if ((ncs_ > 0) || (npt_ > 0)) { + if (2 * npt_ > 24 * ncs_) { + NNEW(ics, ITG, 2 * npt_); + } else { + NNEW(ics, ITG, 24 * ncs_); + } + if (npt_ > 30 * ncs_) { + NNEW(dcs, double, npt_); + } else { + NNEW(dcs, double, 30 * ncs_); + } + } + + /* slave faces */ + + NNEW(islavsurf, ITG, 2 * ifacecount + 2); + + /* robustdesign analysis */ + + if (irobustdesign[0] > 0) { + NNEW(irandomtype, ITG, nk_); + NNEW(randomval, double, 2 * nk_); + } + + } else { + + /* allocating and reallocating space for subsequent steps */ + + if ((nmethod != 4) && (nmethod != 5) && (nmethod != 8) && (nmethod != 9) && + ((abs(nmethod) != 1) || (iperturb[0] < 2))) { + NNEW(veold, double, mt *nk_); + } else { + RENEW(veold, double, mt *nk_); + DMEMSET(veold, mt * nk, mt * nk_, 0.); + } + RENEW(vold, double, mt *nk_); + DMEMSET(vold, mt * nk, mt * nk_, 0.); + + RENEW(nodeboun, ITG, nboun_); + RENEW(ndirboun, ITG, nboun_); + RENEW(typeboun, char, nboun_ + 1); + RENEW(xboun, double, nboun_); + RENEW(ikboun, ITG, nboun_); + RENEW(ilboun, ITG, nboun_); + + RENEW(nodeforc, ITG, 2 * nforc_); + RENEW(ndirforc, ITG, nforc_); + NNEW(idefforc, ITG, nforc_); + RENEW(xforc, double, nforc_); + RENEW(ikforc, ITG, nforc_); + RENEW(ilforc, ITG, nforc_); + + RENEW(nelemload, ITG, 2 * nload_); + NNEW(idefload, ITG, nload_); + RENEW(sideload, char, 20 * nload_); + RENEW(xload, double, 2 * nload_); + + RENEW(cbody, char, 81 * nbody_); + NNEW(idefbody, ITG, nbody_); + RENEW(ibody, ITG, 3 * nbody_); + RENEW(xbody, double, 7 * nbody_); + RENEW(xbodyold, double, 7 * nbody_); + for (i = 7 * nbodyold; i < 7 * nbody_; i++) + xbodyold[i] = 0; + + if (nam > 0) { + RENEW(iamforc, ITG, nforc_); + RENEW(iamload, ITG, 2 * nload_); + RENEW(iamboun, ITG, nboun_); + RENEW(amname, char, 80 * nam_); + RENEW(amta, double, 2 * namtot_); + RENEW(namta, ITG, 3 * nam_); + } + + RENEW(ipompc, ITG, nmpc_); + + RENEW(labmpc, char, 20 * nmpc_ + 1); + RENEW(ikmpc, ITG, nmpc_); + RENEW(ilmpc, ITG, nmpc_); + RENEW(fmpc, double, nmpc_); + + if (ntrans > 0) { + RENEW(inotr, ITG, 2 * nk_); + DMEMSET(inotr, 2 * nk, 2 * nk_, 0); + } + + RENEW(co, double, 3 * nk_); + DMEMSET(co, 3 * nk, 3 * nk_, 0.); + + if (ithermal[0] != 0) { + RENEW(t0, double, nk_); + DMEMSET(t0, nk, nk_, 0.); + RENEW(t1, double, nk_); + DMEMSET(t1, nk, nk_, 0.); + if ((ne1d != 0) || (ne2d != 0) || (nuel_ != 0)) { + RENEW(t0g, double, 2 * nk_); + DMEMSET(t0g, 2 * nk, 2 * nk_, 0.); + RENEW(t1g, double, 2 * nk_); + DMEMSET(t1g, 2 * nk, 2 * nk_, 0.); + } + if (nam > 0) { + RENEW(iamt1, ITG, nk_); + } + } + } + + /* allocation of fields in the restart file */ + + if (irstrt[0] < 0) { + NNEW(nodebounold, ITG, nboun_); + NNEW(ndirbounold, ITG, nboun_); + NNEW(xbounold, double, nboun_); + NNEW(xforcold, double, nforc_); + NNEW(xloadold, double, 2 * nload_); + if (ithermal[0] != 0) + NNEW(t1old, double, nk_); + NNEW(sti, double, 6 * mi[0] * ne); + NNEW(eme, double, 6 * mi[0] * ne); + if (nener == 1) + NNEW(ener, double, mi[0] * ne * 2); + if (mcs > ntie_) + RENEW(cs, double, 17 * mcs); + if (mortar == 1) { + NNEW(pslavsurf, double, 3 * nintpoint); + NNEW(clearini, double, 3 * 9 * ifacecount); + } + } + + nenerold = nener; + nkold = nk; + + /* opening the eigenvalue file and checking for cyclic symmetry */ + + strcpy(fneig, jobnamec); + strcat(fneig, ".eig"); + cyclicsymmetry = 0; + if ((f1 = fopen(fneig, "rb")) != NULL) { + if (fread(&cyclicsymmetry, sizeof(ITG), 1, f1) != 1) { + printf("*ERROR reading the information whether cyclic symmetry is involved in the eigenvalue file"); + exit(0); + } + fclose(f1); + } + + nmpcold = nmpc; + + /* reading the input file */ + + // if(istep==0)mortar=-2; + FORTRAN(calinput, (co, &nk, kon, ipkon, lakon, &nkon, &ne, nodeboun, ndirboun, xboun, + &nboun, ipompc, nodempc, coefmpc, &nmpc, &nmpc_, nodeforc, + ndirforc, xforc, &nforc, &nforc_, nelemload, sideload, xload, + &nload, &nload_, &nprint, prlab, prset, &mpcfree, &nboun_, mei, + set, istartset, iendset, ialset, &nset, &nalset, elcon, nelcon, + rhcon, nrhcon, alcon, nalcon, alzero, t0, t1, matname, ielmat, + orname, orab, ielorien, amname, amta, namta, &nam, &nmethod, + iamforc, iamload, iamt1, ithermal, iperturb, &istat, &istep, + &nmat, &ntmat_, &norien, prestr, &iprestr, &isolver, fei, veold, + timepar, xmodal, filab, jout, &nlabel, &idrct, jmax, &iexpl, + alpha, iamboun, plicon, nplicon, plkcon, nplkcon, &iplas, + &npmat_, mi, &nk_, trab, inotr, &ntrans, ikboun, ilboun, ikmpc, + ilmpc, ics, dcs, &ncs_, &namtot_, cs, &nstate_, &ncmat_, &iumat, + &mcs, labmpc, iponor, xnor, knor, thickn, thicke, ikforc, ilforc, + offset, iponoel, inoel, rig, infree, nshcon, shcon, cocon, + ncocon, physcon, &nflow, ctrl, &maxlenmpc, &ne1d, &ne2d, &nener, + vold, nodebounold, ndirbounold, xbounold, xforcold, xloadold, + t1old, eme, sti, ener, xstate, jobnamec, irstrt, &ttime, qaold, + output, typeboun, inpc, ipoinp, inp, tieset, tietol, &ntie, fmpc, + cbody, ibody, xbody, &nbody, &nbody_, xbodyold, &nam_, ielprop, + &nprop, &nprop_, prop, &itpamp, &iviewfile, ipoinpc, &nslavs, + t0g, t1g, &network, &cyclicsymmetry, idefforc, idefload, + idefbody, &mortar, &ifacecount, islavsurf, pslavsurf, + clearini, heading, &iaxial, &nobject, objectset, &nprint_, + iuel, &nuel_, nodempcref, coefmpcref, ikmpcref, &memmpcref_, + &mpcfreeref, &maxlenmpcref, &memmpc_, &isens, &namtot, &nstam, + dacon, vel, &nef, velo, veloo, ne2boun, itempuser, + irobustdesign, irandomtype, randomval, &nfc, &nfc_, coeffc, + ikdc, &ndc, &ndc_, edc)); + + SFREE(idefforc); + SFREE(idefload); + SFREE(idefbody); + + if (istat < 0) + break; + + /* assigning the body forces to the elements */ + + if (nbody > 0) { + ifreebody = ne + 1; + NNEW(ipobody, ITG, 2 * ifreebody * nbody); + for (k = 1; k <= nbody; k++) { + FORTRAN(bodyforce, (cbody, ibody, ipobody, &nbody, set, istartset, + iendset, ialset, &inewton, &nset, &ifreebody, &k)); + RENEW(ipobody, ITG, 2 * (ne + ifreebody)); + } + RENEW(ipobody, ITG, 2 * (ifreebody - 1)); + } + + if (irefineloop == 1) { + + /* in the last step refinement was requested and the mesh + was appropriately refined; this mesh has to be read */ + + readnewmesh(jobnamec, &nboun, nodeboun, iamboun, xboun, &nload, sideload, + iamload, &nforc, nodeforc, iamforc, xforc, ithermal, &nk, &t1, &iamt1, + &ne, &lakon, &ipkon, &kon, istartset, iendset, ialset, set, &nset, + filab, &co, &ipompc, &nodempc, &coefmpc, &nmpc, &nmpc_, &labmpc, + &mpcfree, &memmpc_, &ikmpc, &ilmpc, &nk_, &ne_, &nkon_, &istep, + &nprop_, &ielprop, &ne1d, &ne2d, &iponor, &thickn, &thicke, mi, + &offset, &iponoel, &rig, &ne2boun, &ielorien, &inotr, &t0, &t0g, &t1g, + &prestr, &vold, &veold, &ielmat, irobustdesign, &irandomtype, + &randomval, &nalset, &nalset_, &nkon, xnor, &iaxial, + &network, &nlabel, iuel, iperturb, &iprestr, &ntie, tieset, + &iparentel, ikboun, &ifreebody, &ipobody, &nbody, &iprfn, + &konrfn, &ratiorfn, nodempcref, coefmpcref, &memmpcref_, + &mpcfreeref, &maxlenmpcref, &maxlenmpc, &norien, tietol); + } + +#ifdef CALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT + for (i = 0; i != nmat; ++i) { + calculix_registerExternalBehaviour(matname + 80 * i); + } +#endif /* CALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT */ + + // if((istep==1)&&(mortar==-1)){mortar=0;}else{icontact=1;} + + nload0 = nload; + + if (iheading == 0) { + writeheading(jobnamec, heading, &nheading_); + iheading = 1; + } + + /* if(nheading_>=0){ + writeheading(jobnamec,heading,&nheading_); + SFREE(heading); + nheading_=-1; + }*/ + + if ((abs(nmethod) != 1) || (iperturb[0] < 2)) + icascade = 0; + + // FORTRAN(writeboun,(nodeboun,ndirboun,xboun,typeboun,&nboun)); + + if (istep == 1) { + + SFREE(iuel); + + /* tied contact constraints: generate appropriate MPC's */ + + tiedcontact(&ntie, tieset, &nset, set, istartset, iendset, ialset, + lakon, ipkon, kon, tietol, &nmpc, &mpcfree, &memmpc_, + &ipompc, &labmpc, &ikmpc, &ilmpc, &fmpc, &nodempc, &coefmpc, + ithermal, co, vold, &nef, &nmpc_, mi, &nk, &istep, ikboun, &nboun, + kind1, kind2); + + /* reallocating space in the first step */ + + /* allocating and initializing fields pointing to the previous step */ + + RENEW(vold, double, mt *nk); + NNEW(sti, double, 6 * mi[0] * ne); + + /* strains */ + + NNEW(eme, double, 6 * mi[0] * ne); + + /* residual stresses/strains */ + + if (iprestr == 1) { + RENEW(prestr, double, 6 * mi[0] * ne); + for (i = 0; i < ne; i++) { + for (j = 0; j < mi[0]; j++) { + for (k = 0; k < 6; k++) { + sti[6 * mi[0] * i + 6 * j + k] = prestr[6 * mi[0] * i + 6 * j + k]; + } + } + } + } else if (iprestr == 2) { + RENEW(prestr, double, 6 * mi[0] * ne); + for (i = 0; i < ne; i++) { + for (j = 0; j < mi[0]; j++) { + for (k = 0; k < 6; k++) { + eme[6 * mi[0] * i + 6 * j + k] = prestr[6 * mi[0] * i + 6 * j + k]; + } + } + } + } else { + SFREE(prestr); + } + + NNEW(nodebounold, ITG, nboun); + NNEW(ndirbounold, ITG, nboun); + NNEW(xbounold, double, nboun); + NNEW(xforcold, double, nforc); + NNEW(xloadold, double, 2 * nload); + + /* initial temperatures: store in the "old" boundary conditions */ + + if (ithermal[0] > 1) { + for (i = 0; i < nboun; i++) { + if (strcmp1(&typeboun[i], "F") == 0) + continue; + if (ndirboun[i] == 0) { + xbounold[i] = vold[mt * (nodeboun[i] - 1)]; + } + } + } + + /* initial temperatures: store in the "old" temperature field */ + + if (ithermal[0] != 0) { + NNEW(t1old, double, nk); + for (i = 0; i < nk; i++) + t1old[i] = t0[i]; + } + + /* element definition */ + + RENEW(kon, ITG, nkon); + RENEW(ipkon, ITG, ne); + RENEW(lakon, char, 8 * ne); + + /* property cards */ + + if (nprop_ > 0) { + RENEW(ielprop, ITG, ne); + RENEW(prop, double, nprop); + } else { + SFREE(ielprop); + SFREE(prop); + } + + /* coupling, distributed */ + + if (nfc > 0) { + RENEW(coeffc, double, 7 * nfc); + RENEW(ikdc, ITG, ndc); + RENEW(edc, double, 12 * ndc); + } else { + SFREE(coeffc); + SFREE(ikdc); + SFREE(edc); + } + + /* fields for 1-D and 2-D elements */ + + if ((ne1d != 0) || (ne2d != 0)) { + RENEW(iponor, ITG, 2 * nkon); + RENEW(xnor, double, infree[0]); + RENEW(knor, ITG, infree[1]); + SFREE(thickn); + RENEW(thicke, double, mi[2] * nkon); + RENEW(offset, double, 2 * ne); + RENEW(inoel, ITG, 3 * (infree[2] - 1)); + RENEW(iponoel, ITG, infree[3]); + RENEW(rig, ITG, infree[3]); + RENEW(ne2boun, ITG, 2 * infree[3]); + } + + /* set definitions */ + + RENEW(set, char, 81 * nset); + RENEW(istartset, ITG, nset); + RENEW(iendset, ITG, nset); + RENEW(ialset, ITG, nalset); + + /* material properties */ + + RENEW(elcon, double, (ncmat_ + 1) * ntmat_ * nmat); + RENEW(nelcon, ITG, 2 * nmat); + + RENEW(rhcon, double, 2 * ntmat_ * nmat); + RENEW(nrhcon, ITG, nmat); + + if (ndamp > 0) { + RENEW(dacon, double, nmat); + } + + RENEW(shcon, double, 4 * ntmat_ * nmat); + RENEW(nshcon, ITG, nmat); + + RENEW(cocon, double, 7 * ntmat_ * nmat); + RENEW(ncocon, ITG, 2 * nmat); + + RENEW(alcon, double, 7 * ntmat_ * nmat); + RENEW(nalcon, ITG, 2 * nmat); + RENEW(alzero, double, nmat); + + RENEW(matname, char, 80 * nmat); + RENEW(ielmat, ITG, mi[2] * ne); + + /* allocating space for the state variables */ + + if (mortar != 1) { + RENEW(xstate, double, nstate_ *mi[0] * (ne + nslavs)); + for (i = nxstate; i < nstate_ * mi[0] * (ne + nslavs); i++) { + xstate[i] = 0.; + } + } else if (mortar == 1) { + RENEW(xstate, double, nstate_ *mi[0] * (ne + nintpoint)); + for (i = nxstate; i < nstate_ * mi[0] * (ne + nintpoint); i++) { + xstate[i] = 0.; + } + } + + /* next statements for plastic materials and nonlinear springs */ + + if (npmat_ > 0) { + RENEW(plicon, double, (2 * npmat_ + 1) * ntmat_ * nmat); + RENEW(nplicon, ITG, (ntmat_ + 1) * nmat); + RENEW(plkcon, double, (2 * npmat_ + 1) * ntmat_ * nmat); + RENEW(nplkcon, ITG, (ntmat_ + 1) * nmat); + } + + /* material orientation */ + + if (norien > 0) { + RENEW(orname, char, 80 * norien); + RENEW(ielorien, ITG, mi[2] * ne); + RENEW(orab, double, 7 * norien); + } else { + SFREE(orname); + SFREE(ielorien); + SFREE(orab); + } + + /* amplitude definitions */ + + if (nam > 0) { + RENEW(amname, char, 80 * nam); + RENEW(namta, ITG, 3 * nam); + RENEW(amta, double, 2 * namta[3 * nam - 2]); + } else { + SFREE(amname); + SFREE(amta); + SFREE(namta); + SFREE(iamforc); + SFREE(iamload); + SFREE(iamboun); + } + + if (ntrans > 0) { + RENEW(trab, double, 7 * ntrans); + } else { + SFREE(trab); + SFREE(inotr); + } + + if (ithermal[0] == 0) { + SFREE(t0); + SFREE(t1); + if ((ne1d != 0) || (ne2d != 0) || (nuel_ != 0)) { + SFREE(t0g); + SFREE(t1g); + } + } + + if ((ithermal[0] == 0) || (nam <= 0)) { + SFREE(iamt1); + } + + if (ncs_ > 0) { + RENEW(ics, ITG, ncs_); + } else if (npt_ > 0) { + SFREE(ics); + } + if ((ncs_ > 0) || (npt_ > 0)) { + SFREE(dcs); + } + + if (mcs > 0) { + RENEW(cs, double, 17 * mcs); + } else { + SFREE(cs); + } + + /* check for design variables */ + + for (i = 0; i < ntie; i++) { + if (strcmp1(&tieset[i * 243 + 80], "D") == 0) { + if (strcmp1(&tieset[i * 243], "COORDINATE") == 0) { + icoordinate = 1; + } + } + } + + } else { + + /* reallocating space in all but the first step (>1) */ + + RENEW(vold, double, mt *nk); + + /* if the SPC boundary conditions were changed in the present step, + they have to be rematched with those in the last step. Removed SPC + boundary conditions do not appear any more (this is different from + forces and loads, where removed forces or loads are reset to zero; + a removed SPC constraint does not have a numerical value any more) */ + + NNEW(reorder, double, nboun); + NNEW(nreorder, ITG, nboun); + if (nbounold < nboun) { + RENEW(xbounold, double, nboun); + RENEW(nodebounold, ITG, nboun); + RENEW(ndirbounold, ITG, nboun); + } + FORTRAN(spcmatch, (xboun, nodeboun, ndirboun, &nboun, xbounold, nodebounold, + ndirbounold, &nbounold, ikboun, ilboun, vold, reorder, nreorder, + mi, typeboun)); + RENEW(xbounold, double, nboun); + RENEW(nodebounold, ITG, nboun); + RENEW(ndirbounold, ITG, nboun); + SFREE(reorder); + SFREE(nreorder); + + /* for additional forces or loads in the present step, the + corresponding slots in the force and load fields of the + previous steps are initialized */ + + RENEW(xforcold, double, nforc); + for (i = nforcold; i < nforc; i++) + xforcold[i] = 0; + + RENEW(xloadold, double, 2 * nload); + for (i = 2 * nloadold; i < 2 * nload; i++) + xloadold[i] = 0; + + if (ithermal[0] != 0) { + RENEW(t1old, double, nk); + } + + if (nam > 0) { + RENEW(amname, char, 80 * nam); + RENEW(namta, ITG, 3 * nam); + RENEW(amta, double, 2 * namta[3 * nam - 2]); + } + } + + /* reallocating fields for all steps (>=1) */ + + RENEW(co, double, 3 * nk); + + RENEW(nodeboun, ITG, nboun); + RENEW(ndirboun, ITG, nboun); + RENEW(typeboun, char, nboun + 1); + RENEW(xboun, double, nboun); + RENEW(ikboun, ITG, nboun); + RENEW(ilboun, ITG, nboun); + + RENEW(nodeforc, ITG, 2 * nforc); + RENEW(ndirforc, ITG, nforc); + RENEW(xforc, double, nforc); + RENEW(ikforc, ITG, nforc); + RENEW(ilforc, ITG, nforc); + + /* temperature loading */ + + if (ithermal[0] != 0) { + RENEW(t0, double, nk); + RENEW(t1, double, nk); + if ((ne1d != 0) || (ne2d != 0) || (nuel_ != 0)) { + RENEW(t0g, double, 2 * nk); + RENEW(t1g, double, 2 * nk); + } + if (nam > 0) { + RENEW(iamt1, ITG, nk); + } + } + + RENEW(nelemload, ITG, 2 * nload); + RENEW(sideload, char, 20 * nload); + RENEW(xload, double, 2 * nload); + + RENEW(cbody, char, 81 * nbody); + RENEW(ibody, ITG, 3 * nbody); + RENEW(xbody, double, 7 * nbody); + RENEW(xbodyold, double, 7 * nbody); + + RENEW(ipompc, ITG, nmpc); + RENEW(labmpc, char, 20 * nmpc + 1); + RENEW(ikmpc, ITG, nmpc); + RENEW(ilmpc, ITG, nmpc); + RENEW(fmpc, double, nmpc); + + /* energy */ + + if ((nener == 1) && (nenerold == 0)) { + NNEW(ener, double, mi[0] * ne * 2); + if ((istep > 1) && (iperturb[0] > 1)) { + printf(" *ERROR in CalculiX: in nonlinear calculations\n"); + printf(" energy output must be selected in the first step\n\n"); + FORTRAN(stop, ()); + } + } + + /* initial velocities and accelerations */ + + if ((nmethod == 4) || (nmethod == 5) || (nmethod == 8) || (nmethod == 9) || + ((abs(nmethod) == 1) && (iperturb[0] >= 2))) { + RENEW(veold, double, mt *nk); + } else { + SFREE(veold); + } + + if ((nmethod == 4) && (iperturb[0] > 1)) { + NNEW(accold, double, mt *nk); + } + + if (nam > 0) { + RENEW(iamforc, ITG, nforc); + RENEW(iamload, ITG, 2 * nload); + RENEW(iamboun, ITG, nboun); + } + + /* generate force convection elements */ + + if (network > 0) { + ne0 = ne; + nkon0 = nkon; + nload1 = nload; + RENEW(ipkon, ITG, ne + nload); + RENEW(ielmat, ITG, mi[2] * (ne + nload)); + for (i = mi[2] * ne; i < mi[2] * (ne + nload); i++) + ielmat[i] = 0; + if (norien > 0) { + RENEW(ielorien, ITG, mi[2] * (ne + nload)); + for (i = mi[2] * ne; i < mi[2] * (ne + nload); i++) + ielorien[i] = 0; + } + RENEW(lakon, char, 8 * (ne + nload)); + RENEW(kon, ITG, nkon + 9 * nload); + NNEW(inodesd, ITG, nk); + RENEW(nelemload, ITG, 4 * nload); + RENEW(sideload, char, 40 * nload); + + FORTRAN(genadvecelem, (inodesd, ipkon, &ne, lakon, kon, &nload, + sideload, nelemload, &nkon, &network)); + + SFREE(inodesd); + RENEW(ipkon, ITG, ne); + RENEW(lakon, char, 8 * ne); + RENEW(kon, ITG, nkon); + RENEW(sti, double, 6 * mi[0] * ne); + RENEW(eme, double, 6 * mi[0] * ne); + if (iprestr > 0) + RENEW(prestr, double, 6 * mi[0] * ne); + if (nprop > 0) + RENEW(ielprop, ITG, ne); + if ((ne1d != 0) || (ne2d != 0)) + RENEW(offset, double, 2 * ne); + RENEW(nelemload, ITG, 2 * nload); + RENEW(sideload, char, 20 * nload); + RENEW(xload, double, 2 * nload); + RENEW(xloadold, double, 2 * nload); + if (nam > 0) { + RENEW(iamload, ITG, 2 * nload); + for (i = 2 * nload1; i < 2 * nload; i++) + iamload[i] = 0; + } + if (nener == 1) + RENEW(ener, double, mi[0] * ne * 2); + if (norien > 0) + RENEW(ielorien, ITG, mi[2] * ne); + RENEW(ielmat, ITG, mi[2] * ne); + for (i = mi[2] * ne0; i < mi[2] * ne; i++) + ielmat[i] = 1; + } + + if (ntrans > 0) { + RENEW(inotr, ITG, 2 * nk); + } + + /* calling the user routine ufaceload (can be empty) */ + + if (ithermal[1] >= 2) { + NNEW(sideloadtemp, char, 20 * nload); + for (i = 0; i < nload; i++) { + strcpy1(&sideloadtemp[20 * i], &sideload[20 * i], 20); + if ((strcmp1(&sideload[20 * i], " ") == 0) && + (strcmp1(&sideload[20 * i + 1], " ") != 0)) { + strcpy1(&sideloadtemp[20 * i], "F", 1); + } + } + FORTRAN(ufaceload, (co, ipkon, kon, lakon, &nboun, nodeboun, + nelemload, sideloadtemp, &nload, &ne, &nk)); + SFREE(sideloadtemp); + } + + /* storing the undecascaded MPC's if needed (triggered by + mpcfreeref=-1); this is the case: + 1) in the first step always + 2) in any subsequent step in which the MPC's were changed by + the user in the input deck */ + + if (mpcfreeref == -1) { + if (istep > 1) { + SFREE(nodempcref); + SFREE(coefmpcref); + SFREE(ikmpcref); + } + memmpcref_ = memmpc_; + mpcfreeref = mpcfree; + maxlenmpcref = maxlenmpc; + NNEW(nodempcref, ITG, 3 * memmpc_); + memcpy(nodempcref, nodempc, sizeof(ITG) * 3 * memmpc_); + NNEW(coefmpcref, double, memmpc_); + memcpy(coefmpcref, coefmpc, sizeof(double) * memmpc_); + NNEW(ikmpcref, ITG, nmpc); + memcpy(ikmpcref, ikmpc, sizeof(ITG) * nmpc); + } + + /* decascading MPC's only necessary if MPC's changed */ + + if (((istep == 1) || (ntrans > 0) || (mpcend < 0) || (nk != nkold) || (nmpc != nmpcold)) && (icascade == 0)) { + + /* decascading the MPC's */ + + printf(" Decascading the MPC's\n\n"); + + callfrommain = 1; + cascade(ipompc, &coefmpc, &nodempc, &nmpc, + &mpcfree, nodeboun, ndirboun, &nboun, ikmpc, + ilmpc, ikboun, ilboun, &mpcend, + labmpc, &nk, &memmpc_, &icascade, &maxlenmpc, + &callfrommain, iperturb, ithermal); + } + + /* determining the matrix structure: changes if SPC's have changed */ + + if ((icascade == 0) && (nmethod < 8)) + printf(" Determining the structure of the matrix:\n"); + + NNEW(nactdof, ITG, mt * nk); + NNEW(mast1, ITG, nzs[1]); + NNEW(irow, ITG, 1); + + if ((mcs == 0) || (cs[1] < 0)) { + + NNEW(icol, ITG, mt * nk); + NNEW(jq, ITG, mt * nk + 1); + NNEW(ipointer, ITG, mt * nk); + + if ((icascade == 0) && ((nmethod < 8) || (nmethod > 10))) { + if ((nmethod == 11) || (nmethod == 13)) { + nmethodl = 2; + } else { + nmethodl = nmethod; + } + mastruct(&nk, kon, ipkon, lakon, &ne, nodeboun, ndirboun, &nboun, ipompc, + nodempc, &nmpc, nactdof, icol, jq, &mast1, &irow, &isolver, neq, + ikmpc, ilmpc, ipointer, nzs, &nmethodl, ithermal, + ikboun, ilboun, iperturb, mi, &mortar, typeboun, labmpc, + &iit, &icascade, &network, &iexpl); + } else { + neq[0] = 1; + neq[1] = 1; + neq[2] = 1; + } + } else { + + NNEW(icol, ITG, 8 * nk); + NNEW(jq, ITG, 8 * nk + 1); + NNEW(ipointer, ITG, 8 * nk); + + if (nmethod == 13) { + nmethodl = 2; + } else { + nmethodl = nmethod; + } + mastructcs(&nk, kon, ipkon, lakon, &ne, nodeboun, ndirboun, &nboun, + ipompc, nodempc, &nmpc, nactdof, icol, jq, &mast1, &irow, &isolver, + neq, ikmpc, ilmpc, ipointer, nzs, &nmethodl, + ics, cs, labmpc, &mcs, mi, &mortar); + } + + SFREE(ipointer); + SFREE(mast1); + if ((icascade == 0) && (nmethod < 8)) + RENEW(irow, ITG, nzs[2]); + + /* nmethod=1: static analysis */ + /* nmethod=2: frequency analysis */ + /* nmethod=3: buckling analysis */ + /* nmethod=4: (linear or nonlinear) dynamic analysis */ + /* nmethod=5: steady state dynamics analysis */ + /* nmethod=6: Coriolis frequency calculation */ + /* nmethod=7: flutter frequency calculation */ + /* nmethod=8: magnetostatics */ + /* nmethod=9: magnetodynamics */ + /* nmethod=10: electromagnetic eigenvalue problems */ + /* nmethod=11: superelement creation */ + /* nmethod=12: sensitivity analysis */ + /* nmethod=13: Green function calculation */ + /* nmethod=14: Robustness w.r.t. to geometric tolerances */ + /* nmethod=15: Crack propagation */ + /* nmethod=16: Feasible direction based on sensitivity information */ + if (preciceUsed) { + int isStaticOrDynamic = (nmethod == 1) || (nmethod == 4); + int isDynamic = nmethod == 4; + int isThermalAnalysis = ithermal[0] >= 2; + + if (isStaticOrDynamic && isThermalAnalysis) { + + printf("Starting CHT analysis via preCICE...\n"); + + mpcinfo[0] = memmpc_; + mpcinfo[1] = mpcfree; + mpcinfo[2] = icascade; + mpcinfo[3] = maxlenmpc; + + + nonlingeo_precice(&co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, &nboun, + &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, ndirforc, xforc, + &nforc, &nelemload, &sideload, xload, &nload, + nactdof, &icol, jq, &irow, neq, &nzl, &nmethod, &ikmpc, + &ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, + alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, + t0, t1, t1old, ithermal, prestr, &iprestr, + &vold, iperturb, sti, nzs, &kode, filab, &idrct, jmax, + jout, timepar, eme, xbounold, xforcold, xloadold, + veold, accold, amname, amta, namta, + &nam, iamforc, &iamload, iamt1, alpha, + &iexpl, iamboun, plicon, nplicon, plkcon, nplkcon, + &xstate, &npmat_, &istep, &ttime, matname, qaold, mi, + &isolver, &ncmat_, &nstate_, &iumat, cs, &mcs, &nkon, &ener, + mpcinfo, output, + shcon, nshcon, cocon, ncocon, physcon, &nflow, ctrl, + set, &nset, istartset, iendset, ialset, &nprint, prlab, + prset, &nener, ikforc, ilforc, trab, inotr, &ntrans, &fmpc, + cbody, ibody, xbody, &nbody, xbodyold, ielprop, prop, + &ntie, tieset, &itpamp, &iviewfile, jobnamec, tietol, &nslavs, thicke, + ics, &nintpoint, &mortar, + &ifacecount, typeboun, &islavsurf, &pslavsurf, &clearini, &nmat, + xmodal, &iaxial, &inext, &nprop, &network, orname, vel, &nef, + velo, veloo, energy, itempuser, + /* New args from 2.19 */ + &ipobody, &inewton, &t0g, &t1g, &ifreebody, + /* PreCICE args */ + preciceParticipantName, configFilename); + + memmpc_ = mpcinfo[0]; + mpcfree = mpcinfo[1]; + icascade = mpcinfo[2]; + maxlenmpc = mpcinfo[3]; + + } else if (isDynamic && !isThermalAnalysis) { + + printf("Starting FSI analysis via preCICE"); + + if (iperturb[1] == 0) { + printf(" using the geometrically linear CalculiX solver...\n"); + + mpcinfo[0] = memmpc_; + mpcinfo[1] = mpcfree; + mpcinfo[2] = icascade; + mpcinfo[3] = maxlenmpc; + + nonlingeo_precice(&co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, &nboun, + &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, ndirforc, xforc, + &nforc, &nelemload, &sideload, xload, &nload, + nactdof, &icol, jq, &irow, neq, &nzl, &nmethod, &ikmpc, + &ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, + alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, + t0, t1, t1old, ithermal, prestr, &iprestr, + &vold, iperturb, sti, nzs, &kode, filab, &idrct, jmax, + jout, timepar, eme, xbounold, xforcold, xloadold, + veold, accold, amname, amta, namta, + &nam, iamforc, &iamload, iamt1, alpha, + &iexpl, iamboun, plicon, nplicon, plkcon, nplkcon, + &xstate, &npmat_, &istep, &ttime, matname, qaold, mi, + &isolver, &ncmat_, &nstate_, &iumat, cs, &mcs, &nkon, &ener, + mpcinfo, output, + shcon, nshcon, cocon, ncocon, physcon, &nflow, ctrl, + set, &nset, istartset, iendset, ialset, &nprint, prlab, + prset, &nener, ikforc, ilforc, trab, inotr, &ntrans, &fmpc, + cbody, ibody, xbody, &nbody, xbodyold, ielprop, prop, + &ntie, tieset, &itpamp, &iviewfile, jobnamec, tietol, &nslavs, thicke, + ics, &nintpoint, &mortar, + &ifacecount, typeboun, &islavsurf, &pslavsurf, &clearini, &nmat, + xmodal, &iaxial, &inext, &nprop, &network, orname, vel, &nef, + velo, veloo, energy, itempuser, + /* New args from 2.19 */ + &ipobody, &inewton, &t0g, &t1g, &ifreebody, + /* PreCICE args */ + preciceParticipantName, configFilename); + + memmpc_ = mpcinfo[0]; + mpcfree = mpcinfo[1]; + icascade = mpcinfo[2]; + maxlenmpc = mpcinfo[3]; + } else if (iperturb[1] == 1) { + printf(" using the geometrically non-linear CalculiX solver...\n"); + + mpcinfo[0] = memmpc_; + mpcinfo[1] = mpcfree; + mpcinfo[2] = icascade; + mpcinfo[3] = maxlenmpc; + + nonlingeo_precice(&co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, &nboun, + &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, ndirforc, xforc, + &nforc, &nelemload, &sideload, xload, &nload, + nactdof, &icol, jq, &irow, neq, &nzl, &nmethod, &ikmpc, + &ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, + alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, + t0, t1, t1old, ithermal, prestr, &iprestr, + &vold, iperturb, sti, nzs, &kode, filab, &idrct, jmax, + jout, timepar, eme, xbounold, xforcold, xloadold, + veold, accold, amname, amta, namta, + &nam, iamforc, &iamload, iamt1, alpha, + &iexpl, iamboun, plicon, nplicon, plkcon, nplkcon, + &xstate, &npmat_, &istep, &ttime, matname, qaold, mi, + &isolver, &ncmat_, &nstate_, &iumat, cs, &mcs, &nkon, &ener, + mpcinfo, output, + shcon, nshcon, cocon, ncocon, physcon, &nflow, ctrl, + set, &nset, istartset, iendset, ialset, &nprint, prlab, + prset, &nener, ikforc, ilforc, trab, inotr, &ntrans, &fmpc, + cbody, ibody, xbody, &nbody, xbodyold, ielprop, prop, + &ntie, tieset, &itpamp, &iviewfile, jobnamec, tietol, &nslavs, thicke, + ics, &nintpoint, &mortar, + &ifacecount, typeboun, &islavsurf, &pslavsurf, &clearini, &nmat, + xmodal, &iaxial, &inext, &nprop, &network, orname, vel, &nef, + velo, veloo, energy, itempuser, + /* New args from 2.19 */ + &ipobody, &inewton, &t0g, &t1g, &ifreebody, + /* PreCICE args */ + preciceParticipantName, configFilename); + + memmpc_ = mpcinfo[0]; + mpcfree = mpcinfo[1]; + icascade = mpcinfo[2]; + maxlenmpc = mpcinfo[3]; + } else { + printf("ERROR: This simulation type is not available with preCICE"); + exit(0); + } + } + + else if (isStaticOrDynamic) { + + mpcinfo[0] = memmpc_; + mpcinfo[1] = mpcfree; + mpcinfo[2] = icascade; + mpcinfo[3] = maxlenmpc; + + if (icascade != 0) { + printf(" *ERROR in CalculiX: the matrix structure may"); + printf(" change due to nonlinear equations;"); + printf(" a purely linear calculation is not"); + printf(" feasible; use NLGEOM on the *STEP card."); + FORTRAN(stop, ()); + } + + printf("Starting Multiscale Linear Static Analysis via preCICE...\n"); + + linstatic_precice(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, + &nboun, + ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, ndirforc, xforc, + &nforc, nelemload, sideload, xload, &nload, + nactdof, &icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, + ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, + alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, + t0, t1, t1old, ithermal, prestr, &iprestr, vold, iperturb, sti, nzs, + &kode, filab, eme, &iexpl, plicon, + nplicon, plkcon, nplkcon, &xstate, &npmat_, matname, + &isolver, mi, &ncmat_, &nstate_, cs, &mcs, &nkon, &ener, + xbounold, xforcold, xloadold, amname, amta, namta, + &nam, iamforc, iamload, iamt1, iamboun, &ttime, + output, set, &nset, istartset, iendset, ialset, &nprint, prlab, + prset, &nener, trab, inotr, &ntrans, fmpc, ipobody, ibody, xbody, + &nbody, + xbodyold, timepar, thicke, jobnamec, tieset, &ntie, &istep, &nmat, + ielprop, prop, typeboun, &mortar, mpcinfo, tietol, ics, + orname, itempuser, t0g, t1g, + /* PreCICE args */ + preciceParticipantName, configFilename); + + for (i = 0; i < 3; i++) { + nzsprevstep[i] = nzs[i]; + } + + memmpc_ = mpcinfo[0]; + mpcfree = mpcinfo[1]; + icascade = mpcinfo[2]; + maxlenmpc = mpcinfo[3]; + + } + + else { + printf("ERROR: Only thermal coupling or FSI is available with preCICE"); + exit(0); + } + } else if ((nmethod <= 1) || (nmethod == 11) || ((iperturb[0] > 1) && (nmethod < 8))) { + if (iperturb[0] < 2) { + + mpcinfo[0] = memmpc_; + mpcinfo[1] = mpcfree; + mpcinfo[2] = icascade; + mpcinfo[3] = maxlenmpc; + + if (icascade != 0) { + printf(" *ERROR in CalculiX: the matrix structure may"); + printf(" change due to nonlinear equations;"); + printf(" a purely linear calculation is not"); + printf(" feasible; use NLGEOM on the *STEP card."); + FORTRAN(stop, ()); + } + + linstatic(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, + &nboun, + ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, ndirforc, xforc, + &nforc, nelemload, sideload, xload, &nload, + nactdof, &icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, + ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, + alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, + t0, t1, t1old, ithermal, prestr, &iprestr, vold, iperturb, sti, nzs, + &kode, filab, eme, &iexpl, plicon, + nplicon, plkcon, nplkcon, &xstate, &npmat_, matname, + &isolver, mi, &ncmat_, &nstate_, cs, &mcs, &nkon, &ener, + xbounold, xforcold, xloadold, amname, amta, namta, + &nam, iamforc, iamload, iamt1, iamboun, &ttime, + output, set, &nset, istartset, iendset, ialset, &nprint, prlab, + prset, &nener, trab, inotr, &ntrans, fmpc, ipobody, ibody, xbody, + &nbody, + xbodyold, timepar, thicke, jobnamec, tieset, &ntie, &istep, &nmat, + ielprop, prop, typeboun, &mortar, mpcinfo, tietol, ics, + orname, itempuser, t0g, t1g); + + for (i = 0; i < 3; i++) { + nzsprevstep[i] = nzs[i]; + } + + memmpc_ = mpcinfo[0]; + mpcfree = mpcinfo[1]; + icascade = mpcinfo[2]; + maxlenmpc = mpcinfo[3]; + + } + + else { + + mpcinfo[0] = memmpc_; + mpcinfo[1] = mpcfree; + mpcinfo[2] = icascade; + mpcinfo[3] = maxlenmpc; + + nonlingeo(&co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, + &nboun, &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, + ndirforc, xforc, &nforc, &nelemload, &sideload, xload, &nload, + nactdof, &icol, jq, &irow, neq, &nzl, &nmethod, &ikmpc, &ilmpc, + ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, alcon, nalcon, + alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, t0, t1, t1old, + ithermal, prestr, &iprestr, &vold, iperturb, sti, nzs, &kode, + filab, &idrct, jmax, jout, timepar, eme, xbounold, xforcold, + xloadold, veold, accold, amname, amta, namta, &nam, iamforc, + &iamload, iamt1, alpha, &iexpl, iamboun, plicon, nplicon, plkcon, + nplkcon, &xstate, &npmat_, &istep, &ttime, matname, qaold, mi, + &isolver, &ncmat_, &nstate_, &iumat, cs, &mcs, &nkon, &ener, + mpcinfo, output, shcon, nshcon, cocon, ncocon, physcon, &nflow, + ctrl, set, &nset, istartset, iendset, ialset, &nprint, prlab, + prset, &nener, ikforc, ilforc, trab, inotr, &ntrans, &fmpc, cbody, + ibody, xbody, &nbody, xbodyold, ielprop, prop, &ntie, tieset, + &itpamp, &iviewfile, jobnamec, tietol, &nslavs, thicke, ics, + &nintpoint, &mortar, &ifacecount, typeboun, &islavsurf, + &pslavsurf, &clearini, &nmat, xmodal, &iaxial, &inext, &nprop, + &network, orname, vel, &nef, velo, veloo, energy, itempuser, + ipobody, &inewton, t0g, t1g, &ifreebody); + + memmpc_ = mpcinfo[0]; + mpcfree = mpcinfo[1]; + icascade = mpcinfo[2]; + maxlenmpc = mpcinfo[3]; + + for (i = 0; i < 3; i++) { + nzsprevstep[i] = nzs[i]; + } + } + } else if ((nmethod == 2) || (nmethod == 13)) { + + /* FREQUENCY ANALYSIS */ + + if ((mcs == 0) || (cs[1] < 0)) { +#ifdef ARPACK + + mpcinfo[0] = memmpc_; + mpcinfo[1] = mpcfree; + mpcinfo[2] = icascade; + mpcinfo[3] = maxlenmpc; + + arpack(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, &nboun, + ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, ndirforc, xforc, + &nforc, nelemload, sideload, xload, &nload, + nactdof, icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, + ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, + shcon, nshcon, cocon, ncocon, + alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, + t0, t1, t1old, ithermal, prestr, &iprestr, vold, iperturb, sti, nzs, + &kode, mei, fei, filab, + &iexpl, plicon, nplicon, plkcon, nplkcon, + &xstate, &npmat_, matname, mi, &ncmat_, &nstate_, &ener, jobnamec, + output, set, &nset, istartset, iendset, ialset, &nprint, prlab, + prset, &nener, &isolver, trab, inotr, &ntrans, &ttime, fmpc, ipobody, + ibody, xbody, &nbody, thicke, &nslavs, tietol, &nkon, mpcinfo, + &ntie, &istep, &mcs, ics, tieset, cs, &nintpoint, &mortar, &ifacecount, + &islavsurf, &pslavsurf, &clearini, &nmat, typeboun, ielprop, prop, + orname, &inewton, t0g, t1g); + + memmpc_ = mpcinfo[0]; + mpcfree = mpcinfo[1]; + icascade = mpcinfo[2]; + maxlenmpc = mpcinfo[3]; + + for (i = 0; i < 3; i++) { + nzsprevstep[i] = nzs[i]; + } + +#else + printf("*ERROR in CalculiX: the ARPACK library is not linked\n\n"); + FORTRAN(stop, ()); +#endif + + } else { + +#ifdef ARPACK + + mpcinfo[0] = memmpc_; + mpcinfo[1] = mpcfree; + mpcinfo[2] = icascade; + mpcinfo[3] = maxlenmpc; + + arpackcs(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, + xboun, &nboun, + ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, ndirforc, xforc, + &nforc, nelemload, sideload, xload, &nload, + nactdof, icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, + ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, + alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, + t0, t1, t1old, ithermal, prestr, &iprestr, + vold, iperturb, sti, nzs, &kode, mei, fei, filab, + &iexpl, plicon, nplicon, plkcon, nplkcon, + &xstate, &npmat_, matname, mi, ics, cs, &mpcend, &ncmat_, + &nstate_, &mcs, &nkon, jobnamec, output, set, &nset, istartset, + iendset, ialset, &nprint, prlab, + prset, &nener, &isolver, trab, inotr, &ntrans, &ttime, fmpc, ipobody, + ibody, xbody, &nbody, &nevtot, thicke, &nslavs, tietol, mpcinfo, + &ntie, &istep, tieset, &nintpoint, &mortar, &ifacecount, &islavsurf, + &pslavsurf, &clearini, &nmat, typeboun, ielprop, prop, orname, + &inewton, t0g, t1g); + + memmpc_ = mpcinfo[0]; + mpcfree = mpcinfo[1]; + icascade = mpcinfo[2]; + maxlenmpc = mpcinfo[3]; + + for (i = 0; i < 3; i++) { + nzsprevstep[i] = nzs[i]; + } + +#else + printf("*ERROR in CalculiX: the ARPACK library is not linked\n\n"); + FORTRAN(stop, ()); +#endif + } + } else if (nmethod == 3) { + +#ifdef ARPACK + arpackbu(co, &nk, kon, ipkon, lakon, &ne, nodeboun, ndirboun, xboun, &nboun, + ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, ndirforc, xforc, + &nforc, + nelemload, sideload, xload, &nload, + nactdof, icol, jq, irow, neq, &nzl, &nmethod, ikmpc, + ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, + alcon, nalcon, alzero, ielmat, ielorien, &norien, orab, &ntmat_, + t0, t1, t1old, ithermal, prestr, &iprestr, + vold, iperturb, sti, nzs, &kode, mei, fei, filab, + eme, &iexpl, plicon, nplicon, plkcon, nplkcon, + xstate, &npmat_, matname, mi, &ncmat_, &nstate_, ener, output, + set, &nset, istartset, iendset, ialset, &nprint, prlab, + prset, &nener, &isolver, trab, inotr, &ntrans, &ttime, fmpc, ipobody, + ibody, xbody, &nbody, thicke, jobnamec, &nmat, ielprop, prop, + orname, typeboun, t0g, t1g); +#else + printf("*ERROR in CalculiX: the ARPACK library is not linked\n\n"); + FORTRAN(stop, ()); +#endif + } else if (nmethod == 4) { + if ((ne1d != 0) || (ne2d != 0)) { + printf(" *WARNING: 1-D or 2-D elements may cause problems in modal dynamic calculations\n"); + printf(" ensure that point loads defined in a *MODAL DYNAMIC step\n"); + printf(" and applied to nodes belonging to 1-D or 2-D elements have been\n"); + printf(" applied to the same nodes in the preceding FREQUENCY step with\n"); + printf(" magnitude zero; look at example shellf.inp for a guideline.\n\n"); + } + + printf(" Composing the dynamic response from the eigenmodes\n\n"); + + dyna(&co, &nk, &kon, &ipkon, &lakon, &ne, &nodeboun, &ndirboun, &xboun, &nboun, + &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, ndirforc, xforc, + &nforc, + nelemload, sideload, xload, &nload, + &nactdof, neq, &nzl, icol, irow, &nmethod, &ikmpc, &ilmpc, &ikboun, &ilboun, + elcon, nelcon, rhcon, nrhcon, cocon, ncocon, + alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, &t0, + &t1, ithermal, prestr, &iprestr, &vold, iperturb, &sti, nzs, + timepar, xmodal, &veold, amname, amta, + namta, &nam, iamforc, iamload, &iamt1, + jout, &kode, filab, &eme, xforcold, xloadold, + &t1old, &iamboun, &xbounold, &iexpl, plicon, + nplicon, plkcon, nplkcon, &xstate, &npmat_, matname, + mi, &ncmat_, &nstate_, &ener, jobnamec, &ttime, set, &nset, + istartset, iendset, &ialset, &nprint, prlab, + prset, &nener, trab, &inotr, &ntrans, &fmpc, ipobody, ibody, xbody, &nbody, + xbodyold, &istep, &isolver, jq, output, &mcs, &nkon, &mpcend, ics, cs, + &ntie, tieset, &idrct, jmax, ctrl, &itpamp, tietol, &nalset, + ikforc, ilforc, thicke, &nslavs, &nmat, typeboun, ielprop, prop, orname, + t0g, t1g); + } else if (nmethod == 5) { + if ((ne1d != 0) || (ne2d != 0)) { + printf(" *WARNING: 1-D or 2-D elements may cause problems in steady state calculations\n"); + printf(" ensure that point loads defined in a *STEADY STATE DYNAMICS step\n"); + printf(" and applied to nodes belonging to 1-D or 2-D elements have been\n"); + printf(" applied to the same nodes in the preceding FREQUENCY step with\n"); + printf(" magnitude zero; look at example shellf.inp for a guideline.\n\n"); + } + + printf(" Composing the steady state response from the eigenmodes\n\n"); + + steadystate(&co, &nk, &kon, &ipkon, &lakon, &ne, &nodeboun, &ndirboun, &xboun, + &nboun, + &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, ndirforc, + xforc, &nforc, + nelemload, sideload, xload, &nload, + &nactdof, neq, &nzl, icol, irow, &nmethod, &ikmpc, &ilmpc, &ikboun, + &ilboun, + elcon, nelcon, rhcon, nrhcon, cocon, ncocon, + alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, + &t0, + &t1, ithermal, prestr, &iprestr, &vold, iperturb, sti, nzs, + timepar, xmodal, &veold, amname, amta, + namta, &nam, iamforc, iamload, &iamt1, + jout, &kode, filab, &eme, xforcold, xloadold, + &t1old, &iamboun, &xbounold, &iexpl, plicon, + nplicon, plkcon, nplkcon, xstate, &npmat_, matname, + mi, &ncmat_, &nstate_, &ener, jobnamec, &ttime, set, &nset, + istartset, iendset, ialset, &nprint, prlab, + prset, &nener, trab, &inotr, &ntrans, &fmpc, ipobody, ibody, xbody, + &nbody, + xbodyold, &istep, &isolver, jq, output, &mcs, &nkon, ics, cs, + &mpcend, + ctrl, ikforc, ilforc, thicke, &nmat, typeboun, ielprop, prop, + orname, + &ndamp, dacon, t0g, t1g); + } else if ((nmethod == 6) || (nmethod == 7)) { + + printf(" Composing the complex eigenmodes from the real eigenmodes\n\n"); + + complexfreq(&co, &nk, &kon, &ipkon, &lakon, &ne, &nodeboun, &ndirboun, &xboun, + &nboun, &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, + ndirforc, xforc, &nforc, + nelemload, sideload, xload, &nload, + &nactdof, neq, &nzl, icol, irow, &nmethod, &ikmpc, &ilmpc, &ikboun, + &ilboun, + elcon, nelcon, rhcon, nrhcon, cocon, ncocon, + alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, + &t0, + &t1, ithermal, prestr, &iprestr, &vold, iperturb, &sti, nzs, + timepar, xmodal, &veold, amname, amta, + namta, &nam, iamforc, iamload, &iamt1, + jout, &kode, filab, &eme, xforcold, xloadold, + &t1old, &iamboun, &xbounold, &iexpl, plicon, + nplicon, plkcon, nplkcon, xstate, &npmat_, matname, + mi, &ncmat_, &nstate_, &ener, jobnamec, &ttime, set, &nset, + istartset, iendset, &ialset, &nprint, prlab, + prset, &nener, trab, &inotr, &ntrans, &fmpc, ipobody, ibody, xbody, + &nbody, + xbodyold, &istep, &isolver, jq, output, &mcs, &nkon, &mpcend, ics, + cs, + &ntie, tieset, &idrct, jmax, ctrl, &itpamp, tietol, &nalset, + ikforc, ilforc, thicke, jobnamef, mei, &nmat, ielprop, prop, orname, + typeboun, t0g, t1g); + } else if ((nmethod > 7) && (nmethod < 12)) { + + mpcinfo[0] = memmpc_; + mpcinfo[1] = mpcfree; + mpcinfo[2] = icascade; + mpcinfo[3] = maxlenmpc; + + electromagnetics(&co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, + ndirboun, xboun, &nboun, + &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, + ndirforc, xforc, + &nforc, &nelemload, &sideload, xload, &nload, + nactdof, &icol, &jq, &irow, neq, &nzl, &nmethod, &ikmpc, + &ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, + alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, + &ntmat_, + t0, t1, t1old, ithermal, prestr, &iprestr, + &vold, iperturb, sti, nzs, &kode, filab, &idrct, jmax, + jout, timepar, eme, xbounold, xforcold, xloadold, + veold, accold, amname, amta, namta, + &nam, iamforc, &iamload, iamt1, alpha, + &iexpl, iamboun, plicon, nplicon, plkcon, nplkcon, + &xstate, &npmat_, &istep, &ttime, matname, qaold, mi, + &isolver, &ncmat_, &nstate_, &iumat, cs, &mcs, &nkon, &ener, + mpcinfo, output, + shcon, nshcon, cocon, ncocon, physcon, &nflow, ctrl, + &set, &nset, &istartset, &iendset, &ialset, &nprint, prlab, + prset, &nener, ikforc, ilforc, trab, inotr, &ntrans, &fmpc, + ipobody, ibody, xbody, &nbody, xbodyold, ielprop, prop, + &ntie, &tieset, &itpamp, &iviewfile, jobnamec, &tietol, + &nslavs, thicke, + ics, &nalset, &nmpc_, &nmat, typeboun, &iaxial, &nload_, &nprop, + &network, orname, t0g, t1g); + + memmpc_ = mpcinfo[0]; + mpcfree = mpcinfo[1]; + icascade = mpcinfo[2]; + maxlenmpc = mpcinfo[3]; + } + + else if (nmethod == 12) { + + if (icoordinate == 1) { + sensi_coor(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, + xboun, &nboun, ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, + ndirforc, xforc, &nforc, nelemload, sideload, xload, &nload, + nactdof, icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, + ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, + alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, + t0, t1, t1old, ithermal, prestr, &iprestr, vold, iperturb, sti, nzs, + &kode, filab, eme, &iexpl, plicon, + nplicon, plkcon, nplkcon, &xstate, &npmat_, matname, + &isolver, mi, &ncmat_, &nstate_, cs, &mcs, &nkon, &ener, + xbounold, xforcold, xloadold, amname, amta, namta, + &nam, iamforc, iamload, iamt1, iamboun, &ttime, + output, set, &nset, istartset, iendset, ialset, &nprint, prlab, + prset, &nener, trab, inotr, &ntrans, fmpc, ipobody, ibody, xbody, + &nbody, + xbodyold, timepar, thicke, jobnamec, tieset, &ntie, &istep, &nmat, + ielprop, prop, typeboun, &mortar, mpcinfo, tietol, ics, + &nobject, &objectset, &istat, orname, nzsprevstep, &nlabel, + physcon, + jobnamef, iponor, knor, &ne2d, iponoel, inoel, &mpcend, dgdxglob, + g0, &nodedesi, &ndesi, &nobjectstart, &xdesi); + + } else { + sensi_orien(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, + xboun, &nboun, ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, + ndirforc, xforc, &nforc, nelemload, sideload, xload, &nload, + nactdof, icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, + ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, + alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, + t0, t1, t1old, ithermal, prestr, &iprestr, vold, iperturb, sti, nzs, + &kode, filab, eme, &iexpl, plicon, + nplicon, plkcon, nplkcon, &xstate, &npmat_, matname, + &isolver, mi, &ncmat_, &nstate_, cs, &mcs, &nkon, &ener, + xbounold, xforcold, xloadold, amname, amta, namta, + &nam, iamforc, iamload, iamt1, iamboun, &ttime, + output, set, &nset, istartset, iendset, ialset, &nprint, prlab, + prset, &nener, trab, inotr, &ntrans, fmpc, ipobody, ibody, xbody, + &nbody, + xbodyold, timepar, thicke, jobnamec, tieset, &ntie, &istep, &nmat, + ielprop, prop, typeboun, &mortar, mpcinfo, tietol, ics, + &nobject, &objectset, &istat, orname, nzsprevstep, &nlabel, + physcon, + jobnamef, iponor, knor, &ne2d, iponoel, inoel, &mpcend); + } + + } + + else if (nmethod == 14) { + + robustdesign(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, + &nboun, ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, + ndirforc, xforc, &nforc, nelemload, sideload, xload, &nload, + nactdof, icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, ilmpc, ikboun, + ilboun, elcon, nelcon, rhcon, nrhcon, alcon, nalcon, alzero, + &ielmat, &ielorien, &norien, orab, &ntmat_, t0, t1, t1old, ithermal, + prestr, &iprestr, vold, iperturb, sti, nzs, &kode, filab, eme, + &iexpl, plicon, nplicon, plkcon, nplkcon, &xstate, &npmat_, + matname, &isolver, mi, &ncmat_, &nstate_, cs, &mcs, &nkon, &ener, + xbounold, xforcold, xloadold, amname, amta, namta, &nam, iamforc, + iamload, iamt1, iamboun, &ttime, output, set, &nset, istartset, + iendset, ialset, &nprint, prlab, prset, &nener, trab, inotr, + &ntrans, fmpc, ipobody, ibody, xbody, &nbody, xbodyold, timepar, + thicke, jobnamec, tieset, &ntie, &istep, &nmat, ielprop, prop, + typeboun, &mortar, mpcinfo, tietol, ics, &nobject, + &objectset, &istat, orname, nzsprevstep, &nlabel, physcon, + jobnamef, iponor, knor, &ne2d, iponoel, inoel, &mpcend, + irobustdesign, irandomtype, randomval); + } + + else if (nmethod == 15) { + + crackpropagation(&ipkon, &kon, &lakon, &ne, &nk, jobnamec, &nboun, iamboun, xboun, + &nload, sideload, iamload, &nforc, iamforc, xforc, ithermal, t1, + iamt1, &co, &nkon, mi, &ielmat, matname, output, &nmat, set, + &nset, istartset, iendset, ialset, jmax, timepar, nelcon, + elcon, &ncmat_, &ntmat_, &istep, filab, &nmethod, mei); + } + + else if (nmethod == 16) { + + feasibledirection(&nobject, &objectset, &dgdxglob, g0, &ndesi, nodedesi, &nk, + &isolver, &ipkon, &kon, &lakon, &ne, nelemload, &nload, + nodeboun, &nboun, ndirboun, ithermal, co, vold, mi, &ielmat, + ielprop, prop, &kode, &nmethod, filab, &nstate_, &istep, cs, + set, &nset, istartset, iendset, ialset, jobnamec, output, + &ntrans, inotr, trab, orname, xdesi); + } + + SFREE(nactdof); + SFREE(icol); + SFREE(jq); + SFREE(irow); + SFREE(ipobody); + + /* check whether refinement was active */ + + // if(irefineloop==20){ + if (strcmp1(&filab[4089], "RM") == 0) { + irefineloop++; + + if (irefineloop == 1) { + + /* refinement was requested in the step which was just + finished and a refined mesh was created and stored. + The calculation has to restart from the beginning with + this new mesh */ + + memcpy(ipoinp, ipoinp_sav, sizeof(ITG) * 2 * nentries); + memcpy(inp, inp_sav, sizeof(ITG) * inp_size); + + /* deallocating fields */ + + dealloc_cal(&ncs_, &ics, &mcs, &cs, &tieset, &tietol, &co, + &kon, &ipkon, &lakon, &nodeboun, &ndirboun, &typeboun, &xboun, + &ikboun, &ilboun, &nodebounold, &ndirbounold, &xbounold, &ipompc, + &labmpc, &ikmpc, &ilmpc, &fmpc, &nodempc, &coefmpc, &nodempcref, + &coefmpcref, &ikmpcref, &nodeforc, &ndirforc, &xforc, + &ikforc, &ilforc, &xforcold, &nelemload, &sideload, &xload, + &xloadold, &cbody, &ibody, &xbody, &xbodyold, &nam, + &iamboun, &iamforc, &iamload, &amname, &amta, &namta, &set, + &istartset, &iendset, &ialset, &elcon, &nelcon, &rhcon, + &nrhcon, &shcon, &nshcon, &cocon, &ncocon, &alcon, + &nalcon, &alzero, &nprop, &ielprop, &prop, &npmat_, + &plicon, &nplicon, &plkcon, &nplkcon, &ndamp, &dacon, &norien, + &orname, &orab, &ielorien, &ntrans, &trab, &inotr, &iprestr, + &prestr, ithermal, &t0, &t1, &t1old, &iamt1, &ne1d, + &ne2d, &t0g, &t1g, irobustdesign, &irandomtype, + &randomval, &prlab, &prset, &filab, &xmodal, &ielmat, + &matname, &sti, &eme, &ener, &xstate, &vold, + &veold, &vel, &velo, &veloo, &iponor, &xnor, + &knor, &thicke, &offset, &iponoel, &inoel, &rig, + &ne2boun, &islavsurf, &mortar, &pslavsurf, &clearini, + &nobject_, &objectset, &nmethod, iperturb, &irefineloop, + &iparentel, &iprfn, &konrfn, &ratiorfn, &heading, + &nodedesi, &dgdxglob, &g0, &nuel_, &xdesi, &nfc, &coeffc, + &ikdc, &edc); + + /* closing and reopening the output files */ + + FORTRAN(openfile, (jobnamef)); + + /* initialization of the variables */ + + ini_cal(jobnamec, output, fneig, kind1, kind2, itempuser, irobustdesign, + &nprint, neq, &mpcfree, &nbounold, &nforcold, &nloadold, &nbody_, + &nbodyold, &network, &nheading_, &nmpc_, &nload_, &nforc_, &nboun_, + &nintpoint, iperturb, &ntmat_, ithermal, &isolver, &nslavs, &nkon_, + &mortar, jout, &nkon, &nevtot, &ifacecount, &iplas, &npmat_, mi, + &mpcend, &namtot_, &iumat, &icascade, &ne1d, &ne2d, infree, &nflow, + irstrt, &nener, &jrstrt, &ntie_, &mcs, &nprop_, &nprop, &itpamp, + &nevdamp_, &npt_, &iaxial, &inext, &icontact, &nobject, &nobject_, + &iit, &mpcfreeref, &isens, &namtot, &nstam, &ndamp, &nef, + &nk_, &ne_, &nalset_, &nmat_, &norien_, &nam_, &ntrans_, + &ncs_, &nstate_, &ncmat_, &memmpc_, &nprint_, energy, ctrl, alpha, + qaold, physcon, &istep, &istat, &iprestr, &kode, &nload, &nbody, &nforc, + &nboun, &nk, &nmpc, &nam, &nzs_, &nlabel, &ttime, &iheading, &nfc, + &nfc_, &ndc, &ndc_); + + NNEW(set, char, 81 * nset_); + NNEW(meminset, ITG, nset_); + NNEW(rmeminset, ITG, nset_); + NNEW(iuel, ITG, 4 * nuel_); + + FORTRAN(allocation, (&nload_, &nforc_, &nboun_, &nk_, &ne_, &nmpc_, &nset_, + &nalset_, &nmat_, &ntmat_, &npmat_, &norien_, &nam_, + &nprint_, mi, &ntrans_, set, meminset, rmeminset, &ncs_, + &namtot_, &ncmat_, &memmpc_, &ne1d, &ne2d, &nflow, + jobnamec, irstrt, ithermal, &nener, &nstate_, &istep, + inpc, ipoinp, inp, &ntie_, &nbody_, + &nprop_, ipoinpc, &nevdamp_, &npt_, &nslavs, &nkon_, &mcs, + &mortar, &ifacecount, &nintpoint, infree, &nheading_, + &nobject_, iuel, &iprestr, &nstam, &ndamp, &nef, + &nbounold, &nforcold, &nloadold, &nbodyold, &mpcend, + irobustdesign, &nfc_, &ndc_)); + + // SFREE(set); + SFREE(meminset); + SFREE(rmeminset); + mt = mi[1] + 1; + NNEW(heading, char, 66 * nheading_); + + continue; + } + } + + /* reset tempuserflag */ + + itempuser[0] = 0; + + /* deleting the perturbation loads and temperatures */ + + if ((iperturb[0] == 1) && (nmethod == 3)) { + nforc = 0; + nload = 0; + nbody = 0; + if (ithermal[0] == 1) { + for (k = 0; k < nk; ++k) { + t1[k] = t0[k]; + } + } + } else { + nbounold = nboun; + for (i = 0; i < nboun; i++) { + nodebounold[i] = nodeboun[i]; + ndirbounold[i] = ndirboun[i]; + } + nforcold = nforc; + nloadold = nload; + nbodyold = nbody; + + /* resetting the amplitude to none except for time=total time amplitudes */ + + if (nam > 0) { + for (i = 0; i < nboun; i++) { + if (iamboun[i] > 0) { + if (namta[3 * iamboun[i] - 1] > 0) { + iamboun[i] = 0; + xboun[i] = xbounold[i]; + } + } + } + for (i = 0; i < nforc; i++) { + if (iamforc[i] > 0) { + if (namta[3 * iamforc[i] - 1] > 0) { + iamforc[i] = 0; + xforc[i] = xforcold[i]; + } + } + } + for (i = 0; i < 2 * nload; i++) { + if (iamload[i] > 0) { + if (namta[3 * iamload[i] - 1] > 0) { + iamload[i] = 0; + xload[i] = xloadold[i]; + } + } + } + for (i = 1; i < 3 * nbody; i = i + 3) { + if (ibody[i] > 0) { + if (namta[3 * ibody[i] - 1] > 0) { + ibody[i] = 0; + xbody[7 * (i - 1) / 3] = xbodyold[7 * (i - 1) / 3]; + } + } + } + if (ithermal[0] == 1) { + if (iamt1[i] > 0) { + if (namta[3 * iamt1[i] - 1] > 0) { + iamt1[i] = 0; + t1[i] = t1old[i]; + } + } + } + } + } + + /* removing the advective elements, if any */ + + if (network > 0) { + ne = ne0; + nkon = nkon0; + RENEW(ipkon, ITG, ne); + RENEW(lakon, char, 8 * ne); + RENEW(kon, ITG, nkon); + RENEW(sti, double, 6 * mi[0] * ne); + RENEW(eme, double, 6 * mi[0] * ne); + if (iprestr > 0) + RENEW(prestr, double, 6 * mi[0] * ne); + if (nprop > 0) + RENEW(ielprop, ITG, ne); + if ((ne1d != 0) || (ne2d != 0)) + RENEW(offset, double, 2 * ne); + if (nener == 1) + RENEW(ener, double, mi[0] * ne * 2); + if (norien > 0) + RENEW(ielorien, ITG, mi[2] * ne); + RENEW(ielmat, ITG, mi[2] * ne); + + /* reactivating the original load labels */ + + for (i = nload - 1; i >= nload0; i--) { + if (strcmp2(&sideload[20 * i], " ", 20) == 0) { + iload = nelemload[2 * i + 1]; + strcpy1(&sideload[20 * (iload - 1)], "F", 1); + } + } + } + + nload = nload0; + + if ((nmethod == 4) && (iperturb[0] > 1)) + SFREE(accold); + + if (irstrt[0] > 0) { + jrstrt++; + if (jrstrt >= irstrt[0]) { + jrstrt = 0; + FORTRAN(restartwrite, (&istep, &nset, &nload, &nforc, &nboun, &nk, &ne, &nmpc, + &nalset, &nmat, &ntmat_, &npmat_, &norien, &nam, + &nprint, mi, &ntrans, &ncs_, &namtot, &ncmat_, &mpcend, + &maxlenmpc, &ne1d, &ne2d, &nflow, &nlabel, &iplas, + &nkon, ithermal, &nmethod, iperturb, &nstate_, &nener, + set, istartset, iendset, ialset, co, kon, ipkon, lakon, + nodeboun, ndirboun, iamboun, xboun, ikboun, ilboun, + ipompc, nodempc, coefmpc, labmpc, ikmpc, ilmpc, + nodeforc, ndirforc, iamforc, xforc, ikforc, ilforc, + nelemload, iamload, sideload, xload, elcon, nelcon, + rhcon, nrhcon, alcon, nalcon, alzero, plicon, nplicon, + plkcon, nplkcon, orname, orab, ielorien, trab, inotr, + amname, amta, namta, t0, t1, iamt1, veold, ielmat, + matname, prlab, prset, filab, vold, nodebounold, + ndirbounold, xbounold, xforcold, xloadold, t1old, eme, + iponor, xnor, knor, thicke, offset, iponoel, inoel, rig, + shcon, nshcon, cocon, ncocon, ics, sti, ener, xstate, + jobnamec, infree, prestr, &iprestr, cbody, ibody, + xbody, &nbody, xbodyold, &ttime, qaold, cs, &mcs, + output, physcon, ctrl, typeboun, fmpc, tieset, &ntie, + tietol, &nslavs, t0g, t1g, &nprop, ielprop, prop, + &mortar, &nintpoint, &ifacecount, islavsurf, + pslavsurf, clearini, irstrt, vel, &nef, velo, veloo, + ne2boun, &memmpc_, heading, &nheading_, &network, + &nfc, &ndc, coeffc, ikdc, edc)); + } + } + } + + FORTRAN(closefile, ()); + + strcpy(fneig, jobnamec); + strcat(fneig, ".frd"); + if ((f1 = fopen(fneig, "ab")) == NULL) { + printf("*ERROR in frd: cannot open frd file for writing..."); + exit(0); + } + fprintf(f1, " 9999\n"); + fclose(f1); + + /* deallocating the fields + this section is addressed immediately after leaving calinput */ + + SFREE(ipoinpc); + SFREE(inpc); + SFREE(inp); + SFREE(ipoinp); + SFREE(inp_sav); + SFREE(ipoinp_sav); + + dealloc_cal(&ncs_, &ics, &mcs, &cs, &tieset, &tietol, &co, + &kon, &ipkon, &lakon, &nodeboun, &ndirboun, &typeboun, &xboun, + &ikboun, &ilboun, &nodebounold, &ndirbounold, &xbounold, &ipompc, + &labmpc, &ikmpc, &ilmpc, &fmpc, &nodempc, &coefmpc, + &nodempcref, &coefmpcref, &ikmpcref, &nodeforc, &ndirforc, &xforc, + &ikforc, &ilforc, &xforcold, &nelemload, &sideload, &xload, + &xloadold, &cbody, &ibody, &xbody, &xbodyold, &nam, + &iamboun, &iamforc, &iamload, &amname, &amta, &namta, &set, + &istartset, &iendset, &ialset, &elcon, &nelcon, &rhcon, + &nrhcon, &shcon, &nshcon, &cocon, &ncocon, &alcon, + &nalcon, &alzero, &nprop, &ielprop, &prop, &npmat_, + &plicon, &nplicon, &plkcon, &nplkcon, &ndamp, &dacon, &norien, + &orname, &orab, &ielorien, &ntrans, &trab, &inotr, &iprestr, + &prestr, ithermal, &t0, &t1, &t1old, &iamt1, &ne1d, + &ne2d, &t0g, &t1g, irobustdesign, &irandomtype, + &randomval, &prlab, &prset, &filab, &xmodal, &ielmat, + &matname, &sti, &eme, &ener, &xstate, &vold, + &veold, &vel, &velo, &veloo, &iponor, &xnor, + &knor, &thicke, &offset, &iponoel, &inoel, &rig, + &ne2boun, &islavsurf, &mortar, &pslavsurf, &clearini, + &nobject_, &objectset, &nmethod, iperturb, &irefineloop, + &iparentel, &iprfn, &konrfn, &ratiorfn, &heading, + &nodedesi, &dgdxglob, &g0, &nuel_, &xdesi, &nfc, &coeffc, + &ikdc, &edc); + +#ifdef CALCULIX_MPI + MPI_Finalize(); +#endif + +#ifdef CALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT + calculix_freeExternalBehaviours(); +#endif /* CALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT */ + + clock_gettime(CLOCK_MONOTONIC, &totalCalculixTimeEnd); + + totalCalculixTime = (totalCalculixTimeEnd.tv_sec - totalCalculixTimeStart.tv_sec) * 1e9; + totalCalculixTime = (totalCalculixTime + (totalCalculixTimeEnd.tv_nsec - totalCalculixTimeStart.tv_nsec)) * 1e-9; + + printf("________________________________________\n\n"); + + printf("Total CalculiX Time: %lf\n", totalCalculixTime); + + printf("________________________________________\n"); + + return 0; +} diff --git a/getelementgausspointcoords.f b/getelementgausspointcoords.f new file mode 100755 index 00000000..75b8f9fe --- /dev/null +++ b/getelementgausspointcoords.f @@ -0,0 +1,336 @@ +! +! CalculiX - A 3-dimensional finite element program +! Copyright (C) 1998-2015 Guido Dhondt +! +! This program is free software; you can redistribute it and/or +! modify it under the terms of the GNU General Public License as +! published by the Free Software Foundation(version 2); +! +! +! This program is distributed in the hope that it will be useful, +! but WITHOUT ANY WARRANTY; without even the implied warranty of +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +! GNU General Public License for more details. +! +! You should have received a copy of the GNU General Public License +! along with this program; if not, write to the Free Software +! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +! +! subroutine getgausspointscoords(co, +! & iset,istartset,iendset,ipkon,lakon,kon, +! & ialset) +! ! +! ! calculation and printout of the lift and drag forces +! ! +! implicit none +! ! +! character*8 lakonl,lakon(*) +! ! +! integer konl(20),ifaceq(8,6),nelem,ii,i,j,i1,i2,j1, +! & k1,jj,ig,nope,nopes, +! & mint2d,ifacet(6,4),ifacew(8,5),iflag,indexe,jface,istartset(*), +! & iendset(*),ipkon(*),kon(*),iset,ialset(*), +! & fidx +! ! +! real*8 co(3,*),xl(3,20),shp(4,20),xs2(3,7),dvi,f(0:3), +! & vkl(0:3,3),t(3,3),div, +! & xl2(3,8),xsj2(3), +! & shp2(7,8),xi,et,xsj,temp,xi3d,et3d,ze3d,weight, +! & xlocal20(3,9,6),xlocal4(3,1,4),xlocal10(3,3,4),xlocal6(3,1,5), +! & xlocal15(3,4,5),xlocal8(3,4,6),xlocal8r(3,1,6),pres, +! & tf(0:3),tn,tt,dd,coords(3) +! ! +! include "gauss.f" +! include "xlocal.f" +! ! +! data ifaceq /4,3,2,1,11,10,9,12, +! & 5,6,7,8,13,14,15,16, +! & 1,2,6,5,9,18,13,17, +! & 2,3,7,6,10,19,14,18, +! & 3,4,8,7,11,20,15,19, +! & 4,1,5,8,12,17,16,20/ +! data ifacet /1,3,2,7,6,5, +! & 1,2,4,5,9,8, +! & 2,3,4,6,10,9, +! & 1,4,3,8,10,7/ +! data ifacew /1,3,2,9,8,7,0,0, +! & 4,5,6,10,11,12,0,0, +! & 1,2,5,4,7,14,10,13, +! & 2,3,6,5,8,15,11,14, +! & 4,6,3,1,12,15,9,13/ +! data iflag /3/ +! ! +! ! +! ! +! ! initialisierung of the flux +! ! +! f(0)=0.d0 + +! ! index for the output array +! fidx=1 + +! ! +! ! +! do jj=istartset(iset),iendset(iset) +! ! +! jface=ialset(jj) +! ! +! nelem=int(jface/10.d0) +! ig=jface-10*nelem +! lakonl=lakon(nelem) +! indexe=ipkon(nelem) +! ! +! if(lakonl(4:4).eq.'2') then +! nope=20 +! nopes=8 +! elseif(lakonl(4:4).eq.'8') then +! nope=8 +! nopes=4 +! elseif(lakonl(4:5).eq.'10') then +! nope=10 +! nopes=6 +! elseif(lakonl(4:4).eq.'4') then +! nope=4 +! nopes=3 +! elseif(lakonl(4:5).eq.'15') then +! nope=15 +! elseif(lakonl(4:4).eq.'6') then +! nope=6 +! endif +! ! +! if(lakonl(4:5).eq.'8R') then +! mint2d=1 +! elseif((lakonl(4:4).eq.'8').or.(lakonl(4:6).eq.'20R')) +! & then +! if((lakonl(7:7).eq.'A').or.(lakonl(7:7).eq.'S').or. +! & (lakonl(7:7).eq.'E')) then +! mint2d=2 +! else +! mint2d=4 +! endif +! elseif(lakonl(4:4).eq.'2') then +! mint2d=9 +! elseif(lakonl(4:5).eq.'10') then +! mint2d=3 +! elseif(lakonl(4:4).eq.'4') then +! mint2d=1 +! endif +! ! +! ! local topology +! ! +! do i=1,nope +! konl(i)=kon(indexe+i) +! enddo +! ! +! ! computation of the coordinates of the local nodes +! ! +! do i=1,nope +! do j=1,3 +! xl(j,i)=co(j,konl(i)) +! enddo +! enddo +! ! +! ! treatment of wedge faces +! ! +! if(lakonl(4:4).eq.'6') then +! mint2d=1 +! if(ig.le.2) then +! nopes=3 +! else +! nopes=4 +! endif +! endif +! if(lakonl(4:5).eq.'15') then +! if(ig.le.2) then +! mint2d=3 +! nopes=6 +! else +! mint2d=4 +! nopes=8 +! endif +! endif +! ! +! if((nope.eq.20).or.(nope.eq.8)) then +! do i=1,nopes +! do j=1,3 +! xl2(j,i)=co(j,konl(ifaceq(i,ig))) +! enddo +! enddo +! elseif((nope.eq.10).or.(nope.eq.4)) then +! do i=1,nopes +! do j=1,3 +! xl2(j,i)=co(j,konl(ifacet(i,ig))) +! enddo +! enddo +! else +! do i=1,nopes +! do j=1,3 +! xl2(j,i)=co(j,konl(ifacew(i,ig))) +! enddo +! enddo +! endif +! ! + + +! do i=1,mint2d +! ! +! ! local coordinates of the surface integration +! ! point within the surface local coordinate system +! ! +! if((lakonl(4:5).eq.'8R').or. +! & ((lakonl(4:4).eq.'6').and.(nopes.eq.4))) then +! xi=gauss2d1(1,i) +! et=gauss2d1(2,i) +! weight=weight2d1(i) +! elseif((lakonl(4:4).eq.'8').or. +! & (lakonl(4:6).eq.'20R').or. +! & ((lakonl(4:5).eq.'15').and.(nopes.eq.8))) then +! xi=gauss2d2(1,i) +! et=gauss2d2(2,i) +! weight=weight2d2(i) +! elseif(lakonl(4:4).eq.'2') then +! xi=gauss2d3(1,i) +! et=gauss2d3(2,i) +! weight=weight2d3(i) +! elseif((lakonl(4:5).eq.'10').or. +! & ((lakonl(4:5).eq.'15').and.(nopes.eq.6))) then +! xi=gauss2d5(1,i) +! et=gauss2d5(2,i) +! weight=weight2d5(i) +! elseif((lakonl(4:4).eq.'4').or. +! & ((lakonl(4:4).eq.'6').and.(nopes.eq.3))) then +! xi=gauss2d4(1,i) +! et=gauss2d4(2,i) +! weight=weight2d4(i) +! endif +! ! +! ! local surface normal +! ! +! if(nopes.eq.8) then +! call shape8q(xi,et,xl2,xsj2,xs2,shp2,iflag) +! elseif(nopes.eq.4) then +! call shape4q(xi,et,xl2,xsj2,xs2,shp2,iflag) +! elseif(nopes.eq.6) then +! call shape6tri(xi,et,xl2,xsj2,xs2,shp2,iflag) +! else +! call shape3tri(xi,et,xl2,xsj2,xs2,shp2,iflag) +! endif +! ! +! ! global coordinates of the integration point +! ! +! do j1=1,3 +! coords(j1)=0.d0 +! do i1=1,nopes +! coords(j1)=coords(j1)+shp2(4,i1)*xl2(j1,i1) +! enddo +! enddo + +! print *, coords(1), coords(2), coords(3) + +! ! +! enddo + + +! enddo +! ! +! ! +! return +! end +!, NGP, ELEM_IDS, CO, LAKON, KON, ELEM_GP_ID, ELEM_GP_COORD + subroutine getelementgausspointcoords(NELEM, NGP, ELEM_IDS,CO, + & LAKON, KON, IPKON, ELEM_GP_ID, ELEM_GP_COORD) + + implicit none + + + !Input/Output variables + integer :: NELEM ! Number of elements + integer :: NGP ! Total number of elements (nelem * 8) + integer :: ELEM_IDS(*) ! Element Ids - Need to increment by 1 for C->Fortran conversion + real(8) :: CO(3,*) ! Nodal coordinates of all nodes + character(8):: LAKON(*) + integer :: KON(*) + integer :: IPKON(*) + + integer :: ELEM_GP_ID(*) ! GP ID + real :: ELEM_GP_COORD(*) ! GP coords + + + ! !Internal variables + INTEGER(4) :: IEL, EL_ID, INDEXE, I,J,K,L, KONL(8), GP_ID + INTEGER(4) :: GP_TOT,IFLAG + CHARACTER(8) :: LAKONL + REAL(8) :: XL(3,8), XI, ET, ZE, xsj,shp(4,20) + + + include "gauss.f" + + data iflag /1/ + + GP_TOT = 1 + DO IEL = 1, NELEM + EL_ID = ELEM_IDS(IEL) + + LAKONL=LAKON(EL_ID) + INDEXE=ipkon(EL_ID) + + ! Connectivity + do i=1,8 + konl(i)=kon(indexe+i) + enddo + + ! Local nodal coordinates + do i=1,8 + do j=1,3 + xl(j,i)=co(j,konl(i)) + enddo + enddo + + ! Loop through gauss points fo each element + DO GP_ID = 1,8 + ELEM_GP_ID(GP_TOT) = GP_TOT-1 + + ! GAUSS POINTS + xi=gauss3d2(1,GP_ID) + et=gauss3d2(2,GP_ID) + ze=gauss3d2(3,GP_ID) + + ! SHAPE FUNCTION + call shape8h(xi,et,ze,xl,xsj,shp,iflag) + + ! GAUSS POINT COORDINATES + + ! do k=1,3 + ! do l=1,8 + ! ELEM_GP_COORD(k,GP_TOT)=ELEM_GP_COORD(k,GP_TOT) + ! & +xl(k,l)*shp(4,l) + ! enddo + ! enddo + ELEM_GP_COORD((GP_TOT-1)*3+1) = GP_TOT-1 + ! ELEM_GP_COORD(1,GP_TOT)=GP_TOT-1 + write(*,*) ELEM_GP_ID(GP_TOT), ELEM_GP_COORD((GP_TOT-1)*3+1) + + GP_TOT = GP_TOT+1 + + + ENDDO + + + + + + + + + + + ENDDO + + + RETURN + + end subroutine getelementgausspointcoords + + + + diff --git a/getflux.f b/getflux.f old mode 100644 new mode 100755 diff --git a/getkdeltatemp.f b/getkdeltatemp.f old mode 100644 new mode 100755 diff --git a/getstrain.f b/getstrain.f new file mode 100755 index 00000000..f7259a6e --- /dev/null +++ b/getstrain.f @@ -0,0 +1,343 @@ +! +! CalculiX - A 3-dimensional finite element program +! Copyright (C) 1998-2015 Guido Dhondt +! +! This program is free software; you can redistribute it and/or +! modify it under the terms of the GNU General Public License as +! published by the Free Software Foundation(version 2); +! +! +! This program is distributed in the hope that it will be useful, +! but WITHOUT ANY WARRANTY; without even the implied warranty of +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +! GNU General Public License for more details. +! +! You should have received a copy of the GNU General Public License +! along with this program; if not, write to the Free Software +! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +! + subroutine getstrain(co,ntmat_,vold, + & cocon,ncocon,iset,istartset,iendset,ipkon,lakon,kon, + & ialset,ielmat,mi,kdelta,reftemp) + ! + ! returns the strain vector for given set of elements and corresponding gauss points. + ! Each set consists of the following: [element_id, gp_id, mat_id, eps_11, eps_22, eps_33, eps_12, eps_13, eps_23] + implicit none + ! +! character*8 lakonl,lakon(*) +! ! +! integer konl(20),ifaceq(8,6),nelem,ii,i,j,i1,i2,j1, +! & ncocon(2,*),k1,jj,ig,ntmat_,nope,nopes,imat, +! & mint2d,ifacet(6,4),ifacew(8,5),iflag,indexe,jface,istartset(*), +! & iendset(*),ipkon(*),kon(*),iset,ialset(*),nset, +! & mi(*),ielmat(mi(3),*),fidx +! ! +! real*8 co(3,*),xl(3,20),shp(4,20),xs2(3,7),dvi,f(0:3), +! & vkl(0:3,3),t(3,3),div, +! & voldl(0:mi(2),20),cocon(0:6,ntmat_,*),xl2(3,8),xsj2(3), +! & shp2(7,8),vold(0:mi(2),*),xi,et,xsj,temp,xi3d,et3d,ze3d,weight, +! & xlocal20(3,9,6),xlocal4(3,1,4),xlocal10(3,3,4),xlocal6(3,1,5), +! & xlocal15(3,4,5),xlocal8(3,4,6),xlocal8r(3,1,6),pres, +! & tf(0:3),tn,tt,dd,coords(3),cond, kdelta(*), reftemp(*), +! & avgkdelta, avgreftemp +! ! +! include "gauss.f" +! include "xlocal.f" +! ! +! data ifaceq /4,3,2,1,11,10,9,12, +! & 5,6,7,8,13,14,15,16, +! & 1,2,6,5,9,18,13,17, +! & 2,3,7,6,10,19,14,18, +! & 3,4,8,7,11,20,15,19, +! & 4,1,5,8,12,17,16,20/ +! data ifacet /1,3,2,7,6,5, +! & 1,2,4,5,9,8, +! & 2,3,4,6,10,9, +! & 1,4,3,8,10,7/ +! data ifacew /1,3,2,9,8,7,0,0, +! & 4,5,6,10,11,12,0,0, +! & 1,2,5,4,7,14,10,13, +! & 2,3,6,5,8,15,11,14, +! & 4,6,3,1,12,15,9,13/ +! data iflag /3/ +! ! +! ! +! ! +! ! initialisierung of the flux +! ! +! f(0)=0.d0 + +! ! index for the output array +! fidx=1 + +! ! +! ! +! do jj=istartset(iset),iendset(iset) +! ! +! jface=ialset(jj) +! ! +! nelem=int(jface/10.d0) +! ig=jface-10*nelem +! lakonl=lakon(nelem) +! indexe=ipkon(nelem) +! imat=ielmat(1,nelem) ! what is this? +! ! +! if(lakonl(4:4).eq.'2') then +! nope=20 +! nopes=8 +! elseif(lakonl(4:4).eq.'8') then +! nope=8 +! nopes=4 +! elseif(lakonl(4:5).eq.'10') then +! nope=10 +! nopes=6 +! elseif(lakonl(4:4).eq.'4') then +! nope=4 +! nopes=3 +! elseif(lakonl(4:5).eq.'15') then +! nope=15 +! elseif(lakonl(4:4).eq.'6') then +! nope=6 +! endif +! ! +! if(lakonl(4:5).eq.'8R') then +! mint2d=1 +! elseif((lakonl(4:4).eq.'8').or.(lakonl(4:6).eq.'20R')) +! & then +! if((lakonl(7:7).eq.'A').or.(lakonl(7:7).eq.'S').or. +! & (lakonl(7:7).eq.'E')) then +! mint2d=2 +! else +! mint2d=4 +! endif +! elseif(lakonl(4:4).eq.'2') then +! mint2d=9 +! elseif(lakonl(4:5).eq.'10') then +! mint2d=3 +! elseif(lakonl(4:4).eq.'4') then +! mint2d=1 +! endif +! ! +! ! local topology +! ! +! do i=1,nope +! konl(i)=kon(indexe+i) +! enddo +! ! +! ! computation of the coordinates of the local nodes +! ! +! do i=1,nope +! do j=1,3 +! xl(j,i)=co(j,konl(i)) +! enddo +! enddo +! ! +! ! temperature, velocity and auxiliary variables +! ! (rho*energy density, rho*velocity and rho) +! ! +! do i1=1,nope +! do i2=0,mi(2) +! voldl(i2,i1)=vold(i2,konl(i1)) +! enddo +! enddo +! ! +! ! treatment of wedge faces +! ! +! if(lakonl(4:4).eq.'6') then +! mint2d=1 +! if(ig.le.2) then +! nopes=3 +! else +! nopes=4 +! endif +! endif +! if(lakonl(4:5).eq.'15') then +! if(ig.le.2) then +! mint2d=3 +! nopes=6 +! else +! mint2d=4 +! nopes=8 +! endif +! endif +! ! +! if((nope.eq.20).or.(nope.eq.8)) then +! do i=1,nopes +! do j=1,3 +! xl2(j,i)=co(j,konl(ifaceq(i,ig))) +! enddo +! enddo +! elseif((nope.eq.10).or.(nope.eq.4)) then +! do i=1,nopes +! do j=1,3 +! xl2(j,i)=co(j,konl(ifacet(i,ig))) +! enddo +! enddo +! else +! do i=1,nopes +! do j=1,3 +! xl2(j,i)=co(j,konl(ifacew(i,ig))) +! enddo +! enddo +! endif +! ! + + + +! ! very simple averaging over the integration points!! +! ! TODO: check whether this needs to be improved! +! avgkdelta=0 +! avgreftemp=0 + + +! do i=1,mint2d +! ! +! ! local coordinates of the surface integration +! ! point within the surface local coordinate system +! ! +! if((lakonl(4:5).eq.'8R').or. +! & ((lakonl(4:4).eq.'6').and.(nopes.eq.4))) then +! xi=gauss2d1(1,i) +! et=gauss2d1(2,i) +! weight=weight2d1(i) +! elseif((lakonl(4:4).eq.'8').or. +! & (lakonl(4:6).eq.'20R').or. +! & ((lakonl(4:5).eq.'15').and.(nopes.eq.8))) then +! xi=gauss2d2(1,i) +! et=gauss2d2(2,i) +! weight=weight2d2(i) +! elseif(lakonl(4:4).eq.'2') then +! xi=gauss2d3(1,i) +! et=gauss2d3(2,i) +! weight=weight2d3(i) +! elseif((lakonl(4:5).eq.'10').or. +! & ((lakonl(4:5).eq.'15').and.(nopes.eq.6))) then +! xi=gauss2d5(1,i) +! et=gauss2d5(2,i) +! weight=weight2d5(i) +! elseif((lakonl(4:4).eq.'4').or. +! & ((lakonl(4:4).eq.'6').and.(nopes.eq.3))) then +! xi=gauss2d4(1,i) +! et=gauss2d4(2,i) +! weight=weight2d4(i) +! endif +! ! +! ! local surface normal +! ! +! if(nopes.eq.8) then +! call shape8q(xi,et,xl2,xsj2,xs2,shp2,iflag) +! elseif(nopes.eq.4) then +! call shape4q(xi,et,xl2,xsj2,xs2,shp2,iflag) +! elseif(nopes.eq.6) then +! call shape6tri(xi,et,xl2,xsj2,xs2,shp2,iflag) +! else +! call shape3tri(xi,et,xl2,xsj2,xs2,shp2,iflag) +! endif +! ! +! ! global coordinates of the integration point +! ! +! do j1=1,3 +! coords(j1)=0.d0 +! do i1=1,nopes +! coords(j1)=coords(j1)+shp2(4,i1)*xl2(j1,i1) +! enddo +! enddo +! ! +! ! local coordinates of the surface integration +! ! point within the element local coordinate system +! ! +! if(lakonl(4:5).eq.'8R') then +! xi3d=xlocal8r(1,i,ig) +! et3d=xlocal8r(2,i,ig) +! ze3d=xlocal8r(3,i,ig) +! call shape8h(xi3d,et3d,ze3d,xl,xsj,shp,iflag) +! elseif(lakonl(4:4).eq.'8') then +! xi3d=xlocal8(1,i,ig) +! et3d=xlocal8(2,i,ig) +! ze3d=xlocal8(3,i,ig) +! call shape8h(xi3d,et3d,ze3d,xl,xsj,shp,iflag) +! elseif(lakonl(4:6).eq.'20R') then +! xi3d=xlocal8(1,i,ig) +! et3d=xlocal8(2,i,ig) +! ze3d=xlocal8(3,i,ig) +! call shape20h(xi3d,et3d,ze3d,xl,xsj,shp,iflag) +! elseif(lakonl(4:4).eq.'2') then +! xi3d=xlocal20(1,i,ig) +! et3d=xlocal20(2,i,ig) +! ze3d=xlocal20(3,i,ig) +! call shape20h(xi3d,et3d,ze3d,xl,xsj,shp,iflag) +! elseif(lakonl(4:5).eq.'10') then +! xi3d=xlocal10(1,i,ig) +! et3d=xlocal10(2,i,ig) +! ze3d=xlocal10(3,i,ig) +! call shape10tet(xi3d,et3d,ze3d,xl,xsj,shp,iflag) +! elseif(lakonl(4:4).eq.'4') then +! xi3d=xlocal4(1,i,ig) +! et3d=xlocal4(2,i,ig) +! ze3d=xlocal4(3,i,ig) +! call shape4tet(xi3d,et3d,ze3d,xl,xsj,shp,iflag) +! elseif(lakonl(4:5).eq.'15') then +! xi3d=xlocal15(1,i,ig) +! et3d=xlocal15(2,i,ig) +! ze3d=xlocal15(3,i,ig) +! call shape15w(xi3d,et3d,ze3d,xl,xsj,shp,iflag) +! elseif(lakonl(4:4).eq.'6') then +! xi3d=xlocal6(1,i,ig) +! et3d=xlocal6(2,i,ig) +! ze3d=xlocal6(3,i,ig) +! call shape6w(xi3d,et3d,ze3d,xl,xsj,shp,iflag) +! endif +! ! +! ! calculating of +! ! the temperature temp +! ! in the integration point +! ! + +! temp=0.d0 +! do j1=1,3 +! vkl(0,j1)=0.d0 +! enddo +! do i1=1,nope +! temp=temp+shp(4,i1)*voldl(0,i1) +! do k1=1,3 +! vkl(0,k1)=vkl(0,k1)+shp(k1,i1)*voldl(0,i1) +! enddo +! enddo +! ! +! ! material data (conductivity) +! ! +! call materialdata_cond(imat,ntmat_,temp,cocon, +! & ncocon,cond) +! ! +! ! determining the stress +! ! +! dd=dsqrt(xsj2(1)*xsj2(1)+xsj2(2)*xsj2(2)+ +! & xsj2(3)*xsj2(3)) +! ! +! tf(0)=-cond*(vkl(0,1)*xsj2(1)+ +! & vkl(0,2)*xsj2(2)+ +! & vkl(0,3)*xsj2(3)) +! f(0)=f(0)+tf(0)*weight +! tf(0)=tf(0)/dd +! ! dd = .1; +! ! print *, temp, tf(0), dd, temp+tf(0)/cond +! avgreftemp = avgreftemp + (temp + tf(0) / cond * dd) +! avgkdelta = avgkdelta + cond / dd +! ! +! ! print *, fidx, avgreftemp, avgkdelta, tf(0), cond +! enddo + +! reftemp(fidx) = avgreftemp / mint2d +! kdelta(fidx) = avgkdelta / mint2d + +! fidx=fidx+1 + +! enddo + ! + ! + return + end + + + + \ No newline at end of file diff --git a/linstatic_precice.c b/linstatic_precice.c new file mode 100755 index 00000000..d18e27b1 --- /dev/null +++ b/linstatic_precice.c @@ -0,0 +1,1372 @@ +/* CalculiX - A 3-dimensional finite element program */ +/* Copyright (C) 1998-2021 Guido Dhondt */ + +/* This program is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License as */ +/* published by the Free Software Foundation(version 2); */ +/* */ + +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU General Public License for more details. */ + +/* You should have received a copy of the GNU General Public License */ +/* along with this program; if not, write to the Free Software */ +/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include "CalculiX.h" +#ifdef SPOOLES +#include "spooles.h" +#endif +#ifdef SGI +#include "sgi.h" +#endif +#ifdef TAUCS +#include "tau.h" +#endif +#ifdef PARDISO +#include "pardiso.h" +#endif +#ifdef PASTIX +#include "pastix.h" +#endif + +/* Adapter: Add header */ +#include "adapter/PreciceInterface.h" + + +void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, + ITG *ne, + ITG *nodeboun,ITG *ndirboun,double *xboun,ITG *nboun, + ITG *ipompc,ITG *nodempc,double *coefmpc,char *labmpc, + ITG *nmpc, + ITG *nodeforc,ITG *ndirforc,double *xforc,ITG *nforc, + ITG *nelemload,char *sideload,double *xload, + ITG *nload,ITG *nactdof, + ITG **icolp,ITG *jq,ITG **irowp,ITG *neq,ITG *nzl, + ITG *nmethod,ITG *ikmpc,ITG *ilmpc,ITG *ikboun, + ITG *ilboun, + double *elcon,ITG *nelcon,double *rhcon,ITG *nrhcon, + double *alcon,ITG *nalcon,double *alzero,ITG **ielmatp, + ITG **ielorienp,ITG *norien,double *orab,ITG *ntmat_, + double *t0,double *t1,double *t1old, + ITG *ithermal,double *prestr,ITG *iprestr, + double *vold,ITG *iperturb,double *sti,ITG *nzs, + ITG *kode,char *filab,double *eme, + ITG *iexpl,double *plicon,ITG *nplicon,double *plkcon, + ITG *nplkcon, + double **xstatep,ITG *npmat_,char *matname,ITG *isolver, + ITG *mi,ITG *ncmat_,ITG *nstate_,double *cs,ITG *mcs, + ITG *nkon,double **enerp,double *xbounold, + double *xforcold,double *xloadold, + char *amname,double *amta,ITG *namta, + ITG *nam,ITG *iamforc,ITG *iamload, + ITG *iamt1,ITG *iamboun,double *ttime,char *output, + char *set,ITG *nset,ITG *istartset, + ITG *iendset,ITG *ialset,ITG *nprint,char *prlab, + char *prset,ITG *nener,double *trab, + ITG *inotr,ITG *ntrans,double *fmpc,ITG *ipobody,ITG *ibody, + double *xbody,ITG *nbody,double *xbodyold,double *timepar, + double *thicke,char *jobnamec,char *tieset,ITG *ntie, + ITG *istep,ITG *nmat,ITG *ielprop,double *prop,char *typeboun, + ITG *mortar,ITG *mpcinfo,double *tietol,ITG *ics, + char *orname,ITG *itempuser,double *t0g,double *t1g, + /* Adapter: Add variables for the participant name and the config file */ + char *preciceParticipantName, char *configFilename){ + + char description[13]=" ",*lakon=NULL,stiffmatrix[132]="", + fneig[132]="",jobnamef[396]="",*labmpc2=NULL; + + ITG *inum=NULL,k,*icol=NULL,*irow=NULL,ielas=0,icmd=0,iinc=1,nasym=0,i,j,ic,ir, + mass[2]={0,0},stiffness=1,buckling=0,rhsi=1,intscheme=0,*ncocon=NULL, + *nshcon=NULL,mode=-1,noddiam=-1,coriolis=0,iout, + *itg=NULL,ntg=0,symmetryflag=0,inputformat=0,ngraph=1,im, + mt=mi[1]+1,ne0,*integerglob=NULL,iglob=0,*ipneigh=NULL,*neigh=NULL, + icfd=0,*inomat=NULL,*islavact=NULL,*islavnode=NULL,*nslavnode=NULL, + *islavsurf=NULL,nretain,*iretain=NULL,*noderetain=NULL,*ndirretain=NULL, + nmethodl,nintpoint,ifacecount,memmpc_,mpcfree,icascade,maxlenmpc, + ncont=0,*itietri=NULL,*koncont=NULL,nslavs=0,ismallsliding=0, + *itiefac=NULL,*imastnode=NULL,*nmastnode=NULL,*imastop=NULL,iitsta, + *iponoels=NULL,*inoels=NULL,*ipe=NULL,*ime=NULL,iit=-1,iflagact=0, + icutb=0,*kon=NULL,*ipkon=NULL,*ielmat=NULL,ialeatoric=0,kscale=1, + *iponoel=NULL,*inoel=NULL,zero=0,nherm=1,nev=*nforc,node,idir, + *ielorien=NULL,network=0,nrhs=1,iperturbsav,mscalmethod=0,*jqw=NULL, + *iroww=NULL,nzsw,*islavelinv=NULL,*irowtloc=NULL,*jqtloc=NULL,nboun2, + *ndirboun2=NULL,*nodeboun2=NULL,nmpc2,*ipompc2=NULL,*nodempc2=NULL, + *ikboun2=NULL,*ilboun2=NULL,*ikmpc2=NULL,*ilmpc2=NULL,mortartrafoflag=0, + *ikforc=NULL, *ilforc=NULL; + + double *stn=NULL,*v=NULL,*een=NULL,cam[5],*xstiff=NULL,*stiini=NULL,*tper, + *f=NULL,*fn=NULL,qa[4],*fext=NULL,*epn=NULL,*xstateini=NULL,dtheta, + *vini=NULL,*stx=NULL,*enern=NULL,*xbounact=NULL,*xforcact=NULL, + *xloadact=NULL,*t1act=NULL,*ampli=NULL,*xstaten=NULL,*eei=NULL, + *enerini=NULL,*cocon=NULL,*shcon=NULL,*physcon=NULL,*qfx=NULL, + *qfn=NULL,sigma=0.,*cgr=NULL,*xbodyact=NULL,*vr=NULL,*vi=NULL, + *stnr=NULL,*stni=NULL,*vmax=NULL,*stnmax=NULL,*springarea=NULL, + *eenmax=NULL,*fnr=NULL,*fni=NULL,*emn=NULL,*clearini=NULL,ptime, + *emeini=NULL,*doubleglob=NULL,*au=NULL,*ad=NULL,*b=NULL,*aub=NULL, + *adb=NULL,*pslavsurf=NULL,*pmastsurf=NULL,*cdn=NULL,*cdnr=NULL, + *cdni=NULL,*submatrix=NULL,*xnoels=NULL,*cg=NULL,*straight=NULL, + *areaslav=NULL,*xmastnor=NULL,theta=0.,*ener=NULL,*xstate=NULL, + *fnext=NULL,*energyini=NULL,*energy=NULL,*d=NULL,alea=0.1,*smscale=NULL, + *auw=NULL,*autloc=NULL,*xboun2=NULL,*coefmpc2=NULL; + + FILE *f1,*f2; + +#ifdef SGI + ITG token; +#endif + + /* dummy arguments for the results call */ + + double *veold=NULL,*accold=NULL,bet,gam,dtime,time,reltime=1.; + + irow=*irowp;ener=*enerp;xstate=*xstatep;ipkon=*ipkonp;lakon=*lakonp; + kon=*konp;ielmat=*ielmatp;ielorien=*ielorienp;icol=*icolp; + + for(k=0;k<3;k++){ + strcpy1(&jobnamef[k*132],&jobnamec[k*132],132); + } + + tper=&timepar[1]; + + time=*tper; + dtime=*tper; + + ne0=*ne; + + + /* Adapter: Put all the CalculiX data that is needed for the coupling into an array */ + struct SimulationData simulationData = { + .ialset = ialset, + .ielmat = ielmat, + .istartset = istartset, + .iendset = iendset, + .kon = kon, + .ipkon = ipkon, + .lakon = &lakon, + .co = co, + .set = set, + .nset = *nset, + .ikboun = ikboun, + .ikforc = ikforc, + .ilboun = ilboun, + .ilforc = ilforc, + .nboun = *nboun, + .nforc = *nforc, + .nelemload = nelemload, + .nload = *nload, + .sideload = sideload, + .mt = mt, + .nk = *nk, + .theta = &theta, + .dtheta = &dtheta, + .tper = tper, + .nmethod = nmethod, + .xload = xload, + .xforc = xforc, + .xboun = xboun, + .ntmat_ = ntmat_, + .vold = vold, + .veold = veold, + .fn = fn, + .cocon = cocon, + .ncocon = ncocon, + .mi = mi, + // .eei = &eei, + // .xstiff = &xstiff + }; + + /* determining the global values to be used as boundary conditions + for a submodel */ + + /* iglob=-1 if global results are from a *FREQUENCY calculation + iglob=0 if no global results are used by boundary conditions + iglob=1 if global results are from a *STATIC calculation */ + + ITG irefine=0; + getglobalresults(&jobnamec[396],&integerglob,&doubleglob,nboun,iamboun,xboun, + nload,sideload,iamload,&iglob,nforc,iamforc,xforc, + ithermal,nk,t1,iamt1,&sigma,&irefine); + + /* reading temperatures from frd-file */ + + if((itempuser[0]==2)&&(itempuser[1]!=itempuser[2])) { + utempread(t1,&itempuser[2],jobnamec); + } + + /* allocating fields for the actual external loading */ + + NNEW(xbounact,double,*nboun); + for(k=0;k<*nboun;++k){xbounact[k]=xbounold[k];} + NNEW(xforcact,double,*nforc); + NNEW(xloadact,double,2**nload); + NNEW(xbodyact,double,7**nbody); + /* copying the rotation axis and/or acceleration vector */ + for(k=0;k<7**nbody;k++){xbodyact[k]=xbody[k];} + if(*ithermal==1){ + NNEW(t1act,double,*nk); + for(k=0;k<*nk;++k){t1act[k]=t1old[k];} + } + + /* assigning the body forces to the elements */ + + /* if(*nbody>0){ + ifreebody=*ne+1; + NNEW(ipobody,ITG,2*ifreebody**nbody); + for(k=1;k<=*nbody;k++){ + FORTRAN(bodyforce,(cbody,ibody,ipobody,nbody,set,istartset, + iendset,ialset,&inewton,nset,&ifreebody,&k)); + RENEW(ipobody,ITG,2*(*ne+ifreebody)); + } + RENEW(ipobody,ITG,2*(ifreebody-1)); + }*/ + + /* contact conditions */ + + // if(*icontact==1){ + if(*mortar>-2){ + + memmpc_=mpcinfo[0];mpcfree=mpcinfo[1];icascade=mpcinfo[2]; + maxlenmpc=mpcinfo[3]; + + inicont(nk,&ncont,ntie,tieset,nset,set,istartset,iendset,ialset,&itietri, + lakon,ipkon,kon,&koncont,&nslavs,tietol,&ismallsliding,&itiefac, + &islavsurf,&islavnode,&imastnode,&nslavnode,&nmastnode, + mortar,&imastop,nkon,&iponoels,&inoels,&ipe,&ime,ne,&ifacecount, + iperturb,ikboun,nboun,co,istep,&xnoels); + + if(ncont!=0){ + + NNEW(cg,double,3*ncont); + NNEW(straight,double,16*ncont); + + /* 11 instead of 10: last position is reserved for the + local contact spring element number; needed as + pointer into springarea */ + + if(*mortar==0){ + RENEW(kon,ITG,*nkon+11*nslavs); + NNEW(springarea,double,2*nslavs); + if(*nener==1){ + RENEW(ener,double,mi[0]*(*ne+nslavs)*2); + } + RENEW(ipkon,ITG,*ne+nslavs); + RENEW(lakon,char,8*(*ne+nslavs)); + + if(*norien>0){ + RENEW(ielorien,ITG,mi[2]*(*ne+nslavs)); + for(k=mi[2]**ne;k0){ + RENEW(ielorien,ITG,mi[2]*(*ne+nintpoint)); + for(k=mi[2]**ne;k0)){ + iperturbsav=iperturb[0]; + iperturb[0]=0; + } + + iout=-1; + NNEW(v,double,mt**nk); + NNEW(fn,double,mt**nk); + NNEW(stx,double,6*mi[0]**ne); + NNEW(inum,ITG,*nk); + results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, + elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, + ielorien,norien,orab,ntmat_,t0,t1act,ithermal, + prestr,iprestr,filab,eme,emn,een,iperturb, + f,fn,nactdof,&iout,qa,vold,b,nodeboun, + ndirboun,xbounact,nboun,ipompc, + nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold,accold, + &bet,&gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, + xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas, + &icmd,ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern, + emeini,xstaten,eei,enerini,cocon,ncocon,set,nset,istartset, + iendset,ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans, + fmpc,nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea, + &reltime,&ne0,thicke,shcon,nshcon, + sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, + mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, + islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, + inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, + itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, + islavelinv,autloc,irowtloc,jqtloc,&nboun2, + ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, + labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, + &intscheme); + SFREE(v);SFREE(fn);SFREE(stx);SFREE(inum); + iout=1; + + // RECIEVING MATERIAL TANGENT FROM NASMAT + simulationData.xstiff = xstiff; + Precice_ReadCouplingData(&simulationData); + + } + + precicec_finalize(); + + if((*nmethod==1)&&(iglob<0)&&(iperturb[0]>0)){ + iperturb[0]=iperturbsav; + } + + /* determining the system matrix and the external forces */ + + NNEW(ad,double,*neq); + NNEW(fext,double,*neq); + + if(*nmethod==11){ + + /* determining the nodes and the degrees of freedom in those nodes + belonging to the substructure */ + + NNEW(iretain,ITG,*nk); + NNEW(noderetain,ITG,*nk); + NNEW(ndirretain,ITG,*nk); + nretain=0; + + for(i=0;i<*nboun;i++){ + if(strcmp1(&typeboun[i],"C")==0){ + iretain[nretain]=i+1; + noderetain[nretain]=nodeboun[i]; + ndirretain[nretain]=ndirboun[i]; + nretain++; + } + } + + /* nretain!=0: submatrix application + nretain==0: Green function application */ + + if(nretain>0){ + RENEW(iretain,ITG,nretain); + RENEW(noderetain,ITG,nretain); + RENEW(ndirretain,ITG,nretain); + }else{ + SFREE(iretain);SFREE(noderetain);SFREE(ndirretain); + } + + /* creating the right size au */ + + NNEW(au,double,nzs[2]); + rhsi=0; + // nmethodl=2; + nmethodl=*nmethod; + + /* providing for the mass matrix in case of Green functions */ + + if(nretain==0){ + mass[0]=1.; + NNEW(adb,double,*neq); + NNEW(aub,double,nzs[1]); + } + + }else{ + + /* linear static calculation */ + + NNEW(au,double,*nzs); + nmethodl=*nmethod; + + /* if submodel calculation with a global model obtained by + a *FREQUENCY calculation: replace stiffness matrix K by + K-sigma*M */ + + if(iglob<0){ + mass[0]=1; + NNEW(adb,double,*neq); + NNEW(aub,double,nzs[1]); + } + + } + + + mafillsmmain(co,nk,kon,ipkon,lakon,ne,nodeboun,ndirboun,xbounact,nboun, + ipompc,nodempc,coefmpc,nmpc,nodeforc,ndirforc,xforcact, + nforc,nelemload,sideload,xloadact,nload,xbodyact,ipobody, + nbody,cgr,ad,au,fext,nactdof,icol,jq,irow,neq,nzl,&nmethodl, + ikmpc,ilmpc,ikboun,ilboun, + elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, + ielorien,norien,orab,ntmat_, + t0,t1act,ithermal,prestr,iprestr,vold,iperturb,sti, + nzs,stx,adb,aub,iexpl,plicon,nplicon,plkcon,nplkcon, + xstiff,npmat_,&dtime,matname,mi, + ncmat_,mass,&stiffness,&buckling,&rhsi,&intscheme,physcon, + shcon,nshcon,cocon,ncocon,ttime,&time,istep,&iinc,&coriolis, + ibody,xloadold,&reltime,veold,springarea,nstate_, + xstateini,xstate,thicke,integerglob,doubleglob, + tieset,istartset,iendset,ialset,ntie,&nasym,pslavsurf, + pmastsurf,mortar,clearini,ielprop,prop,&ne0,fnext,&kscale, + iponoel,inoel,&network,ntrans,inotr,trab,smscale,&mscalmethod, + set,nset,islavelinv,autloc,irowtloc,jqtloc,&mortartrafoflag); + + /* check for negative Jacobians */ + + if(nmethodl==0) *nmethod=0; + + if(nasym==1){ + RENEW(au,double,2*nzs[1]); + symmetryflag=2; + inputformat=1; + + mafillsmasmain(co,nk,kon,ipkon,lakon,ne,nodeboun, + ndirboun,xbounact,nboun, + ipompc,nodempc,coefmpc,nmpc,nodeforc,ndirforc,xforcact, + nforc,nelemload,sideload,xloadact,nload,xbodyact,ipobody, + nbody,cgr,ad,au,fext,nactdof,icol,jq,irow,neq,nzl, + nmethod,ikmpc,ilmpc,ikboun,ilboun, + elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero, + ielmat,ielorien,norien,orab,ntmat_, + t0,t1act,ithermal,prestr,iprestr,vold,iperturb,sti, + nzs,stx,adb,aub,iexpl,plicon,nplicon,plkcon,nplkcon, + xstiff,npmat_,&dtime,matname,mi, + ncmat_,mass,&stiffness,&buckling,&rhsi,&intscheme, + physcon,shcon,nshcon,cocon,ncocon,ttime,&time,istep,&iinc, + &coriolis,ibody,xloadold,&reltime,veold,springarea,nstate_, + xstateini,xstate,thicke, + integerglob,doubleglob,tieset,istartset,iendset, + ialset,ntie,&nasym,pslavsurf,pmastsurf,mortar,clearini, + ielprop,prop,&ne0,&kscale,iponoel,inoel,&network,set,nset); + + /* FORTRAN(mafillsmas,(co,nk,kon,ipkon,lakon,ne,nodeboun, + ndirboun,xbounact,nboun, + ipompc,nodempc,coefmpc,nmpc,nodeforc,ndirforc,xforcact, + nforc,nelemload,sideload,xloadact,nload,xbodyact,ipobody, + nbody,cgr,ad,au,fext,nactdof,icol,jq,irow,neq,nzl, + nmethod,ikmpc,ilmpc,ikboun,ilboun, + elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero, + ielmat,ielorien,norien,orab,ntmat_, + t0,t1act,ithermal,prestr,iprestr,vold,iperturb,sti, + nzs,stx,adb,aub,iexpl,plicon,nplicon,plkcon,nplkcon, + xstiff,npmat_,&dtime,matname,mi, + ncmat_,mass,&stiffness,&buckling,&rhsi,&intscheme, + physcon,shcon,nshcon,cocon,ncocon,ttime,&time,istep,&iinc, + &coriolis,ibody,xloadold,&reltime,veold,springarea,nstate_, + xstateini,xstate,thicke, + integerglob,doubleglob,tieset,istartset,iendset, + ialset,ntie,&nasym,pslavsurf,pmastsurf,mortar,clearini, + ielprop,prop,&ne0,&kscale,iponoel,inoel,&network));*/ + } + + /* determining the right hand side */ + + NNEW(b,double,*neq); + for(k=0;k<*neq;++k){ + b[k]=fext[k]-f[k]; + } + SFREE(fext);SFREE(f); + + + /* generation of a substructure stiffness matrix (nretain>0) or treating + Green functions (nretain=0) */ + + if(*nmethod==11){ + + /* recovering omega_0^2 for Green applications */ + + if(nretain==0){ + if(*nforc>0){sigma=xforc[0];} + } + + /* factorizing the matrix */ + + if(*neq>0){ + if(*isolver==0){ + #ifdef SPOOLES + spooles_factor(ad,au,adb,aub,&sigma,icol,irow,neq,nzs,&symmetryflag, + &inputformat,&nzs[2]); + #else + printf("*ERROR in linstatic: the SPOOLES library is not linked\n\n"); + FORTRAN(stop,()); + #endif + } + else if(*isolver==7){ + #ifdef PARDISO + pardiso_factor(ad,au,adb,aub,&sigma,icol,irow,neq,nzs, + &symmetryflag,&inputformat,jq,&nzs[2]); + #else + printf("*ERROR in linstatic: the PARDISO library is not linked\n\n"); + FORTRAN(stop,()); + #endif + } + else if(*isolver==8){ + #ifdef PASTIX + pastix_factor_main(ad,au,adb,aub,&sigma,icol,irow,neq,nzs, + &symmetryflag,&inputformat,jq,&nzs[2]); + #else + printf("*ERROR in linstatic: the PASTIX library is not linked\n\n"); + FORTRAN(stop,()); + #endif + } + } + + + /* solving the system of equations with appropriate rhs */ + + if(nretain>0){ + + /* substructure calculations */ + + NNEW(submatrix,double,nretain*nretain); + + for(i=0;i0){ + if(*isolver==0){ + #ifdef SPOOLES + spooles_solve(b,neq); + #endif + } + else if(*isolver==7){ + #ifdef PARDISO + pardiso_solve(b,neq,&symmetryflag,&inputformat,&nrhs); + #endif + + } + else if(*isolver==8){ + #ifdef PASTIX + pastix_solve(b,neq,&symmetryflag,&nrhs); + #endif + + } + } + + /* calculating the internal forces */ + + + + NNEW(v,double,mt**nk); + NNEW(fn,double,mt**nk); + NNEW(stn,double,6**nk); + NNEW(inum,ITG,*nk); + NNEW(stx,double,6*mi[0]**ne); + + if(strcmp1(&filab[261],"E ")==0) NNEW(een,double,6**nk); + if(strcmp1(&filab[2697],"ME ")==0) NNEW(emn,double,6**nk); + if(strcmp1(&filab[522],"ENER")==0) NNEW(enern,double,*nk); + + NNEW(eei,double,6*mi[0]**ne); + if(*nener==1){ + NNEW(stiini,double,6*mi[0]**ne); + NNEW(emeini,double,6*mi[0]**ne); + NNEW(enerini,double,mi[0]**ne);} + + /* replacing the appropriate boundary value by unity */ + + xbounact[iretain[i]-1]=1.; + + + + results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, + elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, + ielorien,norien,orab,ntmat_,t0,t1act,ithermal, + prestr,iprestr,filab,eme,emn,een,iperturb, + f,fn,nactdof,&iout,qa,vold,b,nodeboun,ndirboun, + xbounact,nboun,ipompc, + nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold, + accold,&bet, + &gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, + xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas,&icmd, + ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern,emeini, + xstaten,eei,enerini,cocon,ncocon,set,nset,istartset,iendset, + ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans,fmpc, + nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea,&reltime, + &ne0,thicke,shcon,nshcon, + sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, + mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, + islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, + inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, + itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, + islavelinv,autloc,irowtloc,jqtloc,&nboun2, + ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, + labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, + &intscheme); + + xbounact[iretain[i]-1]=0.; + + SFREE(v);SFREE(stn);SFREE(inum);SFREE(stx); + + if(strcmp1(&filab[261],"E ")==0) SFREE(een); + if(strcmp1(&filab[2697],"ME ")==0) SFREE(emn); + if(strcmp1(&filab[522],"ENER")==0) SFREE(enern); + + SFREE(eei);if(*nener==1){SFREE(stiini);SFREE(emeini);SFREE(enerini);} + + /* storing the internal forces in the substructure + stiffness matrix */ + + for(j=0;j0){ + if(*isolver==0){ + #ifdef SPOOLES + spooles_solve(b,neq); + #endif + } + else if(*isolver==7){ + #ifdef PARDISO + pardiso_solve(b,neq,&symmetryflag,&inputformat,&nrhs); + #endif + + } + else if(*isolver==8){ + #ifdef PASTIX + pastix_solve(b,neq,&symmetryflag,&nrhs); + #endif + + } + } + + /* storing the Green function */ + + if(fwrite(b,sizeof(double),*neq,f2)!=*neq){ + printf("*ERROR saving data to the eigenvalue file..."); + exit(0); + } + + /* calculating the displacements and the stresses and storing */ + /* the results in frd format for each valid eigenmode */ + + NNEW(v,double,mt**nk); + NNEW(fn,double,mt**nk); + NNEW(stn,double,6**nk); + NNEW(inum,ITG,*nk); + NNEW(stx,double,6*mi[0]**ne); + + if(strcmp1(&filab[261],"E ")==0) NNEW(een,double,6**nk); + if(strcmp1(&filab[2697],"ME ")==0) NNEW(emn,double,6**nk); + if(strcmp1(&filab[522],"ENER")==0) NNEW(enern,double,*nk); + if(strcmp1(&filab[2175],"CONT")==0) NNEW(cdn,double,6**nk); + + NNEW(eei,double,6*mi[0]**ne); + if(*nener==1){ + NNEW(stiini,double,6*mi[0]**ne); + NNEW(emeini,double,6*mi[0]**ne); + NNEW(enerini,double,mi[0]**ne);} + + + results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, + elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, + ielorien,norien,orab,ntmat_,t0,t1act,ithermal, + prestr,iprestr,filab,eme,emn,een,iperturb, + f,fn,nactdof,&iout,qa,vold,b,nodeboun,ndirboun, + xbounact,nboun,ipompc, + nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold, + accold,&bet, + &gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, + xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas,&icmd, + ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern,emeini, + xstaten,eei,enerini,cocon,ncocon,set,nset,istartset,iendset, + ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans,fmpc, + nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea,&reltime, + &ne0,thicke,shcon,nshcon, + sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, + mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, + islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, + inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, + itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, + islavelinv,autloc,irowtloc,jqtloc,&nboun2, + ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, + labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, + &intscheme); + + SFREE(eei); + if(*nener==1){ + SFREE(stiini);SFREE(emeini);SFREE(enerini);} + + /* memcpy(&vold[0],&v[0],sizeof(double)*mt**nk); + memcpy(&sti[0],&stx[0],sizeof(double)*6*mi[0]*ne0);*/ + + ++*kode; + time=1.*i; + + /* for cyclic symmetric sectors: duplicating the results */ + + if(*mcs>0){ + ptime=*ttime+time; + frdcyc(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod,kode,filab,een,t1act, + fn,&ptime,epn,ielmat,matname,cs,mcs,nkon,enern,xstaten, + nstate_,istep,&iinc,iperturb,ener,mi,output,ithermal, + qfn,ialset,istartset,iendset,trab,inotr,ntrans,orab, + ielorien,norien,sti,veold,&noddiam,set,nset,emn,thicke, + jobnamec,&ne0,cdn,mortar,nmat,qfx,ielprop,prop); + } + else{ + if(strcmp1(&filab[1044],"ZZS")==0){ + NNEW(neigh,ITG,40**ne); + NNEW(ipneigh,ITG,*nk); + } + ptime=*ttime+time; + frd(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod, + kode,filab,een,t1act,fn,&ptime,epn,ielmat,matname,enern,xstaten, + nstate_,istep,&iinc,ithermal,qfn,&mode,&noddiam,trab,inotr, + ntrans,orab,ielorien,norien,description,ipneigh,neigh, + mi,stx,vr,vi,stnr,stni,vmax,stnmax,&ngraph,veold,ener,ne, + cs,set,nset,istartset,iendset,ialset,eenmax,fnr,fni,emn, + thicke,jobnamec,output,qfx,cdn,mortar,cdnr,cdni,nmat, + ielprop,prop,sti); + if(strcmp1(&filab[1044],"ZZS")==0){SFREE(ipneigh);SFREE(neigh);} + } + + SFREE(v);SFREE(stn);SFREE(inum); + SFREE(stx);SFREE(fn); + + if(strcmp1(&filab[261],"E ")==0) SFREE(een); + if(strcmp1(&filab[2697],"ME ")==0) SFREE(emn); + if(strcmp1(&filab[522],"ENER")==0) SFREE(enern); + if(strcmp1(&filab[2175],"CONT")==0) SFREE(cdn); + + } + + + fclose(f2); + + } + + SFREE(au);SFREE(ad);SFREE(b); + + SFREE(xbounact);SFREE(xforcact);SFREE(xloadact);SFREE(t1act);SFREE(ampli); + SFREE(xbodyact); + + // if(*nbody>0) SFREE(ipobody); + + SFREE(xstiff); + + if(iglob!=0){SFREE(integerglob);SFREE(doubleglob);} + + return; + + + }else if(*nmethod!=0){ + + /* linear static applications */ + + if(*isolver==0){ + #ifdef SPOOLES + spooles(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs,&symmetryflag, + &inputformat,&nzs[2]); + #else + printf("*ERROR in linstatic: the SPOOLES library is not linked\n\n"); + FORTRAN(stop,()); + #endif + } + else if((*isolver==2)||(*isolver==3)){ + if(nasym>0){ + printf(" *ERROR in nonlingeo: the iterative solver cannot be used for asymmetric matrices\n\n"); + FORTRAN(stop,()); + } + preiter(ad,&au,b,&icol,&irow,neq,nzs,isolver,iperturb); + } + else if(*isolver==4){ + #ifdef SGI + if(nasym>0){ + printf(" *ERROR in nonlingeo: the SGI solver cannot be used for asymmetric matrices\n\n"); + FORTRAN(stop,()); + } + token=1; + sgi_main(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs,token); + #else + printf("*ERROR in linstatic: the SGI library is not linked\n\n"); + FORTRAN(stop,()); + #endif + } + else if(*isolver==5){ + #ifdef TAUCS + if(nasym>0){ + printf(" *ERROR in nonlingeo: the TAUCS solver cannot be used for asymmetric matrices\n\n"); + FORTRAN(stop,()); + } + tau(ad,&au,adb,aub,&sigma,b,icol,&irow,neq,nzs); + #else + printf("*ERROR in linstatic: the TAUCS library is not linked\n\n"); + FORTRAN(stop,()); + #endif + } + else if(*isolver==7){ + #ifdef PARDISO + pardiso_main(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs, + &symmetryflag,&inputformat,jq,&nzs[2],&nrhs); + #else + printf("*ERROR in linstatic: the PARDISO library is not linked\n\n"); + FORTRAN(stop,()); + #endif + } + else if(*isolver==8){ + #ifdef PASTIX + pastix_main(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs, + &symmetryflag,&inputformat,jq,&nzs[2],&nrhs); + #else + printf("*ERROR in linstatic: the PASTIX library is not linked\n\n"); + FORTRAN(stop,()); + #endif + } + + /* saving of ad and au for sensitivity analysis */ + + for(i=0;i<*ntie;i++){ + if(strcmp1(&tieset[i*243+80],"D")==0){ + + strcpy(stiffmatrix,jobnamec); + strcat(stiffmatrix,".stm"); + + if((f1=fopen(stiffmatrix,"wb"))==NULL){ + printf("*ERROR in linstatic: cannot open stiffness matrix file for writing..."); + exit(0); + } + + /* storing the stiffness matrix */ + + /* nzs,irow,jq and icol have to be stored too, since the static analysis + can involve contact, whereas in the sensitivity analysis contact is not + taken into account while determining the structure of the stiffness + matrix (in mastruct.c) + */ + + if(fwrite(&nasym,sizeof(ITG),1,f1)!=1){ + printf("*ERROR saving the symmetry flag to the stiffness matrix file..."); + exit(0); + } + if(fwrite(nzs,sizeof(ITG),3,f1)!=3){ + printf("*ERROR saving the number of subdiagonal nonzeros to the stiffness matrix file..."); + exit(0); + } + if(fwrite(irow,sizeof(ITG),nzs[2],f1)!=nzs[2]){ + printf("*ERROR saving irow to the stiffness matrix file..."); + exit(0); + } + if(fwrite(jq,sizeof(ITG),neq[1]+1,f1)!=neq[1]+1){ + printf("*ERROR saving jq to the stiffness matrix file..."); + exit(0); + } + if(fwrite(icol,sizeof(ITG),neq[1],f1)!=neq[1]){ + printf("*ERROR saving icol to the stiffness matrix file..."); + exit(0); + } + if(fwrite(ad,sizeof(double),neq[1],f1)!=neq[1]){ + printf("*ERROR saving the diagonal of the stiffness matrix to the stiffness matrix file..."); + exit(0); + } + if(fwrite(au,sizeof(double),nzs[2],f1)!=nzs[2]){ + printf("*ERROR saving the off-diagonal terms of the stiffness matrix to the tiffness matrix file..."); + exit(0); + } + fclose(f1); + + break; + } + } + + SFREE(ad);SFREE(au); + if(iglob<0){SFREE(adb);SFREE(aub);} + + /* calculating the displacements and the stresses and storing */ + /* the results in frd format for each valid eigenmode */ + + NNEW(v,double,mt**nk); + NNEW(fn,double,mt**nk); + NNEW(stn,double,6**nk); + NNEW(inum,ITG,*nk); + NNEW(stx,double,6*mi[0]**ne); + + if(strcmp1(&filab[261],"E ")==0) NNEW(een,double,6**nk); + if(strcmp1(&filab[2697],"ME ")==0) NNEW(emn,double,6**nk); + if(strcmp1(&filab[522],"ENER")==0) NNEW(enern,double,*nk); + if(strcmp1(&filab[2175],"CONT")==0) NNEW(cdn,double,6**nk); + + NNEW(eei,double,6*mi[0]**ne); + if(*nener==1){ + NNEW(stiini,double,6*mi[0]**ne); + NNEW(emeini,double,6*mi[0]**ne); + NNEW(enerini,double,mi[0]**ne);} + + + results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, + elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, + ielorien,norien,orab,ntmat_,t0,t1act,ithermal, + prestr,iprestr,filab,eme,emn,een,iperturb, + f,fn,nactdof,&iout,qa,vold,b,nodeboun,ndirboun,xbounact,nboun,ipompc, + nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold,accold,&bet, + &gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, + xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas,&icmd, + ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern,emeini, + xstaten,eei,enerini,cocon,ncocon,set,nset,istartset,iendset, + ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans,fmpc, + nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea,&reltime, + &ne0,thicke,shcon,nshcon, + sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, + mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, + islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, + inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, + itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, + islavelinv,autloc,irowtloc,jqtloc,&nboun2, + ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, + labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, + &intscheme); + + SFREE(eei); + if(*nener==1){ + SFREE(stiini);SFREE(emeini);SFREE(enerini);} + + memcpy(&vold[0],&v[0],sizeof(double)*mt**nk); + memcpy(&sti[0],&stx[0],sizeof(double)*6*mi[0]*ne0); + + ++*kode; + + /* for cyclic symmetric sectors: duplicating the results */ + + if(*mcs>0){ + ptime=*ttime+time; + frdcyc(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod,kode,filab,een,t1act, + fn,&ptime,epn,ielmat,matname,cs,mcs,nkon,enern,xstaten, + nstate_,istep,&iinc,iperturb,ener,mi,output,ithermal, + qfn,ialset,istartset,iendset,trab,inotr,ntrans,orab, + ielorien,norien,sti,veold,&noddiam,set,nset,emn,thicke, + jobnamec,&ne0,cdn,mortar,nmat,qfx,ielprop,prop); + } + else{ + if(strcmp1(&filab[1044],"ZZS")==0){ + NNEW(neigh,ITG,40**ne); + NNEW(ipneigh,ITG,*nk); + } + ptime=*ttime+time; + frd(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod, + kode,filab,een,t1act,fn,&ptime,epn,ielmat,matname,enern,xstaten, + nstate_,istep,&iinc,ithermal,qfn,&mode,&noddiam,trab,inotr, + ntrans,orab,ielorien,norien,description,ipneigh,neigh, + mi,stx,vr,vi,stnr,stni,vmax,stnmax,&ngraph,veold,ener,ne, + cs,set,nset,istartset,iendset,ialset,eenmax,fnr,fni,emn, + thicke,jobnamec,output,qfx,cdn,mortar,cdnr,cdni,nmat,ielprop, + prop,sti); + if(strcmp1(&filab[1044],"ZZS")==0){SFREE(ipneigh);SFREE(neigh);} + } + + /* updating the .sta file */ + + iitsta=1; + FORTRAN(writesta,(istep,&iinc,&icutb,&iitsta,ttime,&time,&dtime)); + + SFREE(v);SFREE(stn);SFREE(inum); + SFREE(b);SFREE(stx);SFREE(fn); + + if(strcmp1(&filab[261],"E ")==0) SFREE(een); + if(strcmp1(&filab[2697],"ME ")==0) SFREE(emn); + if(strcmp1(&filab[522],"ENER")==0) SFREE(enern); + if(strcmp1(&filab[2175],"CONT")==0) SFREE(cdn); + + } + else { + + /* error occurred in mafill: storing the geometry in frd format */ + + ++*kode; + NNEW(inum,ITG,*nk);for(k=0;k<*nk;k++) inum[k]=1; + if(strcmp1(&filab[1044],"ZZS")==0){ + NNEW(neigh,ITG,40**ne); + NNEW(ipneigh,ITG,*nk); + } + ptime=*ttime+time; + frd(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod, + kode,filab,een,t1,fn,&ptime,epn,ielmat,matname,enern,xstaten, + nstate_,istep,&iinc,ithermal,qfn,&mode,&noddiam,trab,inotr, + ntrans,orab,ielorien,norien,description,ipneigh,neigh, + mi,sti,vr,vi,stnr,stni,vmax,stnmax,&ngraph,veold,ener,ne, + cs,set,nset,istartset,iendset,ialset,eenmax,fnr,fni,emn, + thicke,jobnamec,output,qfx,cdn,mortar,cdnr,cdni,nmat,ielprop, + prop,sti); + if(strcmp1(&filab[1044],"ZZS")==0){SFREE(ipneigh);SFREE(neigh);} + SFREE(inum);FORTRAN(stop,()); + + } + + if(*mortar>-2){ + if(ncont!=0){ + *ne=ne0; + if(*nener==1){ + RENEW(ener,double,mi[0]**ne*2); + } + RENEW(ipkon,ITG,*ne); + RENEW(lakon,char,8**ne); + RENEW(kon,ITG,*nkon); + if(*norien>0){ + RENEW(ielorien,ITG,mi[2]**ne); + } + RENEW(ielmat,ITG,mi[2]**ne); + SFREE(cg);SFREE(straight); + SFREE(imastop);SFREE(itiefac);SFREE(islavnode);SFREE(islavsurf); + SFREE(nslavnode);SFREE(iponoels);SFREE(inoels);SFREE(imastnode); + SFREE(nmastnode);SFREE(itietri);SFREE(koncont);SFREE(xnoels); + SFREE(springarea);SFREE(xmastnor); + + if(*mortar==0){ + SFREE(areaslav); + }else if(*mortar==1){ + SFREE(pmastsurf);SFREE(ipe);SFREE(ime);SFREE(pslavsurf); + SFREE(islavact);SFREE(clearini); + } + } + mpcinfo[0]=memmpc_;mpcinfo[1]=mpcfree;mpcinfo[2]=icascade; + mpcinfo[3]=maxlenmpc; + } + + /* updating the loading at the end of the step; + important in case the amplitude at the end of the step + is not equal to one */ + + for(k=0;k<*nboun;++k){xbounold[k]=xbounact[k];} + for(k=0;k<*nforc;++k){xforcold[k]=xforcact[k];} + for(k=0;k<2**nload;++k){xloadold[k]=xloadact[k];} + for(k=0;k<7**nbody;k=k+7){xbodyold[k]=xbodyact[k];} + if(*ithermal==1){ + for(k=0;k<*nk;++k){t1old[k]=t1act[k];} + for(k=0;k<*nk;++k){vold[mt*k]=t1act[k];} + } + + SFREE(xbounact);SFREE(xforcact);SFREE(xloadact);SFREE(t1act);SFREE(ampli); + SFREE(xbodyact); + + // if(*nbody>0) SFREE(ipobody); + + SFREE(xstiff); + + if(iglob!=0){SFREE(integerglob);SFREE(doubleglob);} + + *irowp=irow;*enerp=ener;*xstatep=xstate;*ipkonp=ipkon;*lakonp=lakon; + *konp=kon;*ielmatp=ielmat;*ielorienp=ielorien;*icolp=icol; + + (*ttime)+=(*tper); + + return; + + +} diff --git a/nonlingeo_precice.c b/nonlingeo_precice.c old mode 100644 new mode 100755 index 01bcc93e..9152fc25 --- a/nonlingeo_precice.c +++ b/nonlingeo_precice.c @@ -1,5 +1,5 @@ /* CalculiX - A 3-dimensional finite element program */ -/* Copyright (C) 1998-2022 Guido Dhondt */ +/* Copyright (C) 1998-2021 Guido Dhondt */ /* This program is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU General Public License as */ @@ -99,7 +99,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l *sideloadref = NULL, *sideload = NULL, stiffmatrix[132] = "", *sideloadf = NULL; - ITG *inum = NULL, k, l, iout = 0, icntrl, iinc = 0, jprint = 0, iit = -1, jnz = 0, + ITG *inum = NULL, k, iout = 0, icntrl, iinc = 0, jprint = 0, iit = -1, jnz = 0, icutb = 0, istab = 0, uncoupled, n1, n2, itruecontact, iperturb_sav[2], ilin, *icol = NULL, *irow = NULL, ielas = 0, icmd = 0, memmpc_, mpcfree, icascade, maxlenmpc, *nodempc = NULL, *iaux = NULL, @@ -123,7 +123,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l coriolis = 0, *ipneigh = NULL, *neigh = NULL, maxprevcontel, nslavs_prev_step, *nelemface = NULL, *ipoface = NULL, *nodface = NULL, *ifreestream = NULL, *isolidsurf = NULL, *neighsolidsurf = NULL, *iponoel = NULL, *inoel = NULL, - nface, nfreestream, nsolidsurf, i, icfd = 0, id, mortarsav = 0, + nface, nfreestream, nsolidsurf, i, icfd = 0, id, node, networknode, iflagact = 0, *nodorig = NULL, *ipivr = NULL, iglob = 0, *inomat = NULL, *ipnei = NULL, ntrimax, *nx = NULL, *ny = NULL, *nz = NULL, idampingwithoutcontact = 0, *nactdoh = NULL, *nactdohinv = NULL, *ipkonf = NULL, @@ -140,9 +140,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l *nelemloadf = NULL, *ipobodyf = NULL, nkf, nkonf, memmpcf, nbounf, nloadf, nmpcf, *ikbounf = NULL, *ilbounf = NULL, *ikmpcf = NULL, *ilmpcf = NULL, *iambounf = NULL, *iamloadf = NULL, *inotrf = NULL, *jqtherm = NULL, *jqw = NULL, *iroww = NULL, nzsw, - *kslav = NULL, *lslav = NULL, *ktot = NULL, *ltot = NULL, nmasts, neqtot, - intpointvarm, calcul_fn, calcul_f, calcul_qa, calcul_cauchy, ikin, - intpointvart; + *kslav = NULL, *lslav = NULL, *ktot = NULL, *ltot = NULL, nmasts, neqslav, neqtot; double *stn = NULL, *v = NULL, *een = NULL, cam[5], *epn = NULL, *cg = NULL, *cdn = NULL, *pslavsurfold = NULL, @@ -179,7 +177,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l *smscale = NULL, dtset, energym = 0., energymold = 0., *voldf = NULL, *coefmpcf = NULL, *xbounf = NULL, *xloadf = NULL, *xbounoldf = NULL, *xbounactf = NULL, *xloadoldf = NULL, *xloadactf = NULL, *auw = NULL, *volddof = NULL, - *qb = NULL, *aloc = NULL, dtmin, *fric = NULL; + *qb = NULL; FILE *f1; @@ -310,47 +308,43 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l /* Adapter: Put all the CalculiX data that is needed for the coupling into an array */ struct SimulationData simulationData = { - .ialset = ialset, - .ielmat = ielmat, - .istartset = istartset, - .iendset = iendset, - .kon = kon, - .ipkon = ipkon, - .lakon = lakon, - .co = co, - .set = set, - .nset = *nset, - .ikboun = ikboun, - .ikforc = ikforc, - .ilboun = ilboun, - .ilforc = ilforc, - .nboun = *nboun, - .nforc = *nforc, - .nelemload = nelemload, - .nload = *nload, - .sideload = sideload, - .mt = mt, - .nk = *nk, - .ne = *ne, - .theta = &theta, - .dtheta = &dtheta, - .tper = tper, - .nmethod = nmethod, - .xload = xload, - .xforc = xforc, - .xboun = xboun, - .ntmat_ = ntmat_, - .vold = vold, - .veold = veold, - .fn = fn, - .cocon = cocon, - .ncocon = ncocon, - .mi = mi, - .isModalDynamic = 0, - .eigenDOFs = NULL, - .eigenDOFsDerivatives = NULL, - .stored_iinc = iinc, - .stored_jprint = jprint}; + .ialset = ialset, + .ielmat = ielmat, + .istartset = istartset, + .iendset = iendset, + .kon = kon, + .ipkon = ipkon, + .lakon = &lakon, + .co = co, + .set = set, + .nset = *nset, + .ikboun = ikboun, + .ikforc = ikforc, + .ilboun = ilboun, + .ilforc = ilforc, + .nboun = *nboun, + .nforc = *nforc, + .nelemload = nelemload, + .nload = *nload, + .sideload = sideload, + .mt = mt, + .nk = *nk, + .theta = &theta, + .dtheta = &dtheta, + .tper = tper, + .nmethod = nmethod, + .xload = xload, + .xforc = xforc, + .xboun = xboun, + .ntmat_ = ntmat_, + .vold = vold, + .veold = veold, + .fn = fn, + .cocon = cocon, + .ncocon = ncocon, + .mi = mi, + .eei = &eei + }; if (*ithermal == 4) { uncoupled = 1; @@ -359,14 +353,6 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l uncoupled = 0; } - /* for massless explicit dynamics a static step in the same - calculation is performed with node-to-face contact */ - - if ((*nmethod == 1) && (*mortar == -1)) { - mortarsav = -1; - *mortar = 0; - } - if (*mortar != 1) { maxprevcontel = *nslavs; } else if (*mortar == 1) { @@ -441,13 +427,12 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l /* explicit dynamics */ - if ((fabs(alpham) > 1.e-30) || ((fabs(betam) > 1.e-30) && (*mortar == -1))) { + if (fabs(alpham) > 1.e-30) { idamping = 1; idampingwithoutcontact = 1; } - if ((fabs(betam) > 1.e-30) && (*mortar != -1)) { - printf(" *ERROR in nonlingeo: in explicit dynamic calculations\n"); - printf(" without massless contact the damping is only\n"); + if (fabs(betam) > 1.e-30) { // TODO cmt adapt to massless: we can take BETA + printf(" *ERROR: in explicit dynamic calculations the damping is only\n"); printf(" allowed to be mass proportional: the coefficient beta\n"); printf(" of the stiffness proportional term must be zero\n"); FORTRAN(stop, ()); @@ -497,11 +482,11 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l /* invert nactdof */ - /* NNEW(nactdofinv,ITG,mt**nk); - MNEW(nodorig,ITG,*nk); - FORTRAN(gennactdofinv,(nactdof,nactdofinv,nk,mi,nodorig, - ipkon,lakon,kon,ne)); - SFREE(nodorig);*/ + NNEW(nactdofinv, ITG, mt * *nk); + MNEW(nodorig, ITG, *nk); + FORTRAN(gennactdofinv, (nactdof, nactdofinv, nk, mi, nodorig, + ipkon, lakon, kon, ne)); + SFREE(nodorig); /* allocating a field for the stiffness matrix */ @@ -577,8 +562,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l nodeboun, nacteq, nboun, ielprop, prop, &nteq, v, network, physcon, shcon, ntmat_, co, vold, set, nshcon, rhcon, nrhcon, mi, nmpc, nodempc, - ipompc, labmpc, ikboun, &nasym, ttime, &time, - iaxial)); + ipompc, labmpc, ikboun, &nasym, ttime, &time, iaxial)); SFREE(v); if ((*mcs > 0) && (ntr > 0)) { @@ -611,8 +595,6 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l if (*network > 0) { FORTRAN(networkelementpernode, (iponoel, inoel, lakon, ipkon, kon, &inoelsize, nflow, ieg, ne, network)); - FORTRAN(checkforhomnet, (ieg, nflow, lakon, ipkon, kon, itg, &ntg, - iponoel, inoel)); } RENEW(inoel, ITG, 2 * inoelsize); } @@ -782,10 +764,11 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l NNEW(inoelf, ITG, 2 * 8 * *nef); NNEW(inomat, ITG, nkftot); FORTRAN(topocfdfem, (nelemface, sideface, &nface, ipoface, nodface, nef, ipkonf, - konf, lakonf, &nkf, isolidsurf, &nsolidsurf, ifreestream, - &nfreestream, neighsolidsurf, iponoelf, inoelf, - &inoelfree, cof, set, istartset, iendset, ialset, nset, - &iturbulent, inomat, ielmatf, ipface, nknew)); + konf, lakonf, &nkf, + isolidsurf, &nsolidsurf, ifreestream, &nfreestream, + neighsolidsurf, iponoelf, inoelf, &inoelfree, cof, + set, istartset, iendset, + ialset, nset, &iturbulent, inomat, ielmatf, ipface)); RENEW(sideface, char, nface); RENEW(nelemface, ITG, nface); SFREE(ipoface); @@ -1024,7 +1007,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l /* initialization of the energy */ - if ((ithermal[0] <= 1) && (*nener == 1)) { + if (ithermal[0] <= 1) { isiz = mi[0] * ne0; cpypardou(enerini, ener, &isiz, &num_cpus); } @@ -1102,7 +1085,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l /* invert nactdof */ - // SFREE(nactdofinv); + SFREE(nactdofinv); NNEW(nactdofinv, ITG, 1); iout = -1; @@ -1180,11 +1163,10 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l nplicon, plkcon, nplkcon, npmat_, mi, &dtime, xstiff, ncmat_, vold, ielmat, t0, t1, matname, lakon, wavespeed, nmat, ipkon, co, kon, &dtvol, - alpha, smscale, &dtset, &mscalmethod, mortar, - jobnamef)); + alpha, smscale, &dtset, &mscalmethod)); //printf("\033[1;33m"); // yellow - printf(" Explicit time integration: Volumetric COURANT initial stable time increment:%e\n\n", dtvol); + printf("Explicit time integration: Volumetric COURANT initial stable time increment:%e\n\n", dtvol); //printf("\033[0m"); // reset color if (dtvol > (*tmax * (*tper))) { @@ -1198,7 +1180,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l dtheta = (*tinc) / (*tper); dthetaref = dtheta; //printf("\033[1;33m"); // yellow - printf(" SELECTED time increment:%e\n\n", *tinc); + printf("SELECTED time increment:%e\n\n", *tinc); //printf("\033[0m"); // reset color } @@ -1278,18 +1260,14 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l NNEW(lslav, ITG, 3 * *nslavs); NNEW(ktot, ITG, 3 * *nslavs + 3 * nmasts); NNEW(ltot, ITG, 3 * *nslavs + 3 * nmasts); - NNEW(fric, double, *nslavs); - /* Create set of slave and slave+master contact DOFS (sorted); - assign a friction coefficient to each slave node */ + /* Create set of slave and slave+master contact DOFS (sorted) */ FORTRAN(create_contactdofs, (kslav, lslav, ktot, ltot, nslavs, islavnode, - &nmasts, imastnode, nactdof, mi, &neqtot, - nslavnode, fric, tieset, tietol, ntie, elcon, - ncmat_, ntmat_)); + &nmasts, imastnode, nactdof, mi, &neqslav, &neqtot)); - RENEW(kslav, ITG, 3 * *nslavs); - RENEW(lslav, ITG, 3 * *nslavs); + RENEW(kslav, ITG, neqslav); + RENEW(lslav, ITG, neqslav); RENEW(ktot, ITG, neqtot); RENEW(ltot, ITG, neqtot); @@ -1366,10 +1344,6 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l #endif } - // Storing contact force vector initial solution - - NNEW(aloc, double, 3 * *nslavs); - } //endif massless /* mass x acceleration = f(external)-f(internal) @@ -1467,7 +1441,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l &symmetryflag, &inputformat, &nzs[2]); spooles_solve(b, &neq[0]); #else - printf(" *ERROR in nonlingeo: the SPOOLES library is not linked\n\n"); + printf("*ERROR in arpack: the SPOOLES library is not linked\n\n"); FORTRAN(stop, ()); #endif } else if (*isolver == 4) { @@ -1476,7 +1450,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l sgi_factor(adb, aub, adb, aub, &sigma, icol, irow, &neq[0], &nzs[0], token); sgi_solve(b, token); #else - printf(" *ERROR in nonlingeo: the SGI library is not linked\n\n"); + printf("*ERROR in arpack: the SGI library is not linked\n\n"); FORTRAN(stop, ()); #endif } else if (*isolver == 5) { @@ -1484,7 +1458,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l tau_factor(adb, &aub, adb, aub, &sigma, icol, &irow, &neq[0], &nzs[0]); tau_solve(b, &neq[0]); #else - printf(" *ERROR in nonlingeo: the TAUCS library is not linked\n\n"); + printf("*ERROR in arpack: the TAUCS library is not linked\n\n"); FORTRAN(stop, ()); #endif } else if (*isolver == 7) { @@ -1494,7 +1468,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l pardiso_solve(b, &neq[0], &symmetryflag, &inputformat, &nrhs); #else - printf(" *ERROR in nonlingeo: the PARDISO library is not linked\n\n"); + printf("*ERROR in arpack: the PARDISO library is not linked\n\n"); FORTRAN(stop, ()); #endif } else if (*isolver == 8) { @@ -1504,7 +1478,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l pastix_solve(b, &neq[0], &symmetryflag, &nrhs); #else - printf(" *ERROR in nonlingeo: the PASTIX library is not linked\n\n"); + printf("*ERROR in arpack: the PASTIX library is not linked\n\n"); FORTRAN(stop, ()); #endif } @@ -1756,7 +1730,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l /* check for max. # of increments */ if (iinc > jmax[0]) { - printf(" *ERROR in nonlingeo: max. # of increments reached\n\n"); + printf(" *ERROR: max. # of increments reached\n\n"); FORTRAN(stop, ()); } @@ -1830,7 +1804,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l iamload, jqrad, irowrad, &nzsrad, icolrad, ne, iaxial, qa, cocon, ncocon, iponoel, - inoel, nprop, amname, namta, amta, iexpl); + inoel, nprop, amname, namta, amta); /* check whether network iterations converged */ @@ -2022,7 +1996,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l contact(&ncont, ntie, tieset, nset, set, istartset, iendset, ialset, itietri, lakon, ipkon, kon, koncont, ne, cg, straight, nkon, co, vold, ielmat, cs, elcon, istep, &iinc, &iit, ncmat_, ntmat_, - &ne0, nmethod, + &ne0, vini, nmethod, iperturb, ikboun, nboun, mi, imastop, nslavnode, islavnode, islavsurf, itiefac, areaslav, iponoels, inoels, springarea, tietol, &reltime, @@ -2064,7 +2038,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l /* dynamic time step estimation for explicit dynamics under penalty contact(CMT) start */ - if ((*iexpl > 1) && (*mortar != -1)) { + if ((*iexpl > 1)) { if ((*ne - ne0) < ncontacts) { @@ -2082,20 +2056,14 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l mortar, adb, alpha, nactdof, springarea, &ne0, ntmat_, ncmat_, &dtcont, smscale, &dtset, &mscalmethod)); - if (dtcont < dtvol) { - dtmin = dtcont; - } else { - dtmin = dtvol; - } - if (dtmin > (*tmax * (*tper))) { + if (dtcont > (*tmax * (*tper))) { *tinc = *tmax * (*tper); - } else if (dtmin < dtset) { + } else if (dtcont < dtset) { *tinc = dtset; } else { - *tinc = dtmin; + *tinc = dtcont; } - dtheta = (*tinc) / (*tper); dthetaref = dtheta; @@ -2139,13 +2107,9 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l cpypardou(coefmpcref, coefmpc, &isiz, &num_cpus); } - /* recalculating the matrix structure; only needed if: - 1) MPC's are cascaded - 2) contact occurs in an implicit calculation - (in penalty explicit no matrices are needed, in massless - explicit no contact elements are generated) */ + /* recalculating the matrix structure */ - if ((icascade > 0) || ((ncont != 0) && (*iexpl <= 1))) + if ((icascade > 0) || (ncont != 0)) remastruct(ipompc, &coefmpc, &nodempc, nmpc, &mpcfree, nodeboun, ndirboun, nboun, ikmpc, ilmpc, ikboun, ilboun, labmpc, nk, &memmpc_, &icascade, &maxlenmpc, @@ -2155,16 +2119,14 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l typeboun, &cv, &cvini, &iit, network, itiefac, &ne0, &nkon0, nintpoint, islavsurf, pmastsurf, tieset, ntie, &num_cpus); - /* invert nactdof (not for dynamic explicit calculations) */ + /* invert nactdof */ - if (*iexpl <= 1) { - SFREE(nactdofinv); - NNEW(nactdofinv, ITG, mt * *nk); - MNEW(nodorig, ITG, *nk); - FORTRAN(gennactdofinv, (nactdof, nactdofinv, nk, mi, nodorig, - ipkon, lakon, kon, ne)); - SFREE(nodorig); - } + SFREE(nactdofinv); + NNEW(nactdofinv, ITG, mt * *nk); + MNEW(nodorig, ITG, *nk); + FORTRAN(gennactdofinv, (nactdof, nactdofinv, nk, mi, nodorig, + ipkon, lakon, kon, ne)); + SFREE(nodorig); /* check whether the forced displacements changed; if so, and if the procedure is static, the first iteration has to be @@ -2423,7 +2385,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l set, mi, istartset, iendset, ialset, nset, ineighe, nmpc, nodempc, ipompc, coefmpc, labmpc, &iemchange, nam, iamload, jqrad, irowrad, &nzsrad, icolrad, ne, iaxial, qa, cocon, ncocon, - iponoel, inoel, nprop, amname, namta, amta, iexpl); + iponoel, inoel, nprop, amname, namta, amta); /* check whether network iterations converged */ @@ -2475,7 +2437,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l ialset, itietri, lakon, ipkon, kon, koncont, ne, cg, straight, nkon, co, vold, ielmat, cs, elcon, istep, &iinc, &iit, ncmat_, ntmat_, &ne0, - nmethod, iperturb, + vini, nmethod, iperturb, ikboun, nboun, mi, imastop, nslavnode, islavnode, islavsurf, itiefac, areaslav, iponoels, inoels, springarea, tietol, &reltime, imastnode, nmastnode, xmastnor, @@ -2735,10 +2697,10 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l npmat_, ttime, &time, istep, &iinc, &dtime, physcon, ibody, xbodyold, &reltime, veold, matname, mi, ikactmech, &nactmech, ielprop, prop, sti, xstateini, xstate, nstate_, - ntrans, inotr, trab, fnext); + ntrans, inotr, trab); } - /* for(k=0;k1)&&(*nener==0)){ - resultsini(nk,v,ithermal,filab,iperturb,f,fn, - nactdof,&iout,qa,vold,b,nodeboun,ndirboun, - xboun,nboun,ipompc,nodempc,coefmpc,labmpc,nmpc,nmethod,cam, - &neq[1],veold,accold,&bet,&gam,&dtime,mi,vini,nprint,prlab, - &intpointvarm,&calcul_fn,&calcul_f,&calcul_qa,&calcul_cauchy, - &ikin,&intpointvart,typeboun,&num_cpus,mortar,nener); - }else{*/ if (ne1d2d == 1) NNEW(inum, ITG, *nk); results(co, nk, kon, ipkon, lakon, ne, v, stn, inum, stx, @@ -3378,7 +3324,6 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l &intscheme); if (ne1d2d == 1) SFREE(inum); - // } /* implicit dynamics (Matteo Pacher) */ @@ -3390,7 +3335,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l /* updating the external work (only for dynamic calculations) */ - if ((*nmethod == 4) && (*ithermal < 2) && (*nener == 1)) { + if ((*nmethod == 4) && (*ithermal < 2)) { allwk = allwkini; worparll(&allwk, fnext, &mt, fnextini, v, vini, nk, &num_cpus); @@ -3487,14 +3432,11 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l /* calculating the residual */ - // next line: change on 19072022 - if ((*iexpl <= 1) || (*nener == 1)) { - calcresidual(nmethod, neq, b, fext, f, iexpl, nactdof, aux2, vold, vini, &dtime, - accold, nk, adb, aub, jq, irow, nzl, alpha, fextini, fini, - islavnode, nslavnode, mortar, ntie, f_cm, f_cs, mi, - nzs, &nasym, &idamping, veold, adc, auc, cvini, cv, &alpham, - &num_cpus); - } + calcresidual(nmethod, neq, b, fext, f, iexpl, nactdof, aux2, vold, + vini, &dtime, accold, nk, adb, aub, jq, irow, nzl, alpha, fextini, fini, + islavnode, nslavnode, mortar, ntie, f_cm, f_cs, mi, + nzs, &nasym, &idamping, veold, adc, auc, cvini, cv, &alpham, + &num_cpus); /* fix residuals for mortar contact, add contact forces */ @@ -3506,9 +3448,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l isiz = mt * *nk; cpypardou(vold, v, &isiz, &num_cpus); - // if(*ithermal!=2){ - // next line: change on 19072022 - if ((*ithermal != 2) && ((*iexpl <= 1) || (*nener == 1))) { + if (*ithermal != 2) { for (k = 0; k < 6 * mi[0] * ne0; ++k) { sti[k] = stx[k]; } @@ -3755,6 +3695,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l /* Adapter: Copy necessary data for coupling */ simulationData.fn = fn; + memcpy(&vold[0], &v[0], sizeof(double) * mt * *nk); Precice_WriteCouplingData(&simulationData); /* Adapter: Advance the coupling */ @@ -3769,8 +3710,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l } /* printing the energies (only for dynamic calculations) */ - if ((icutb == 0) && (*nmethod == 4) && (*ithermal < 2) && (jout[0] == jprint) && - (*nener == 1)) { + if ((icutb == 0) && (*nmethod == 4) && (*ithermal < 2) && (jout[0] == jprint)) { if (*iexpl > 1) { printf(" actual total time=%e\n\n", *ttime + theta * *tper); @@ -4260,7 +4200,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l strcat(stiffmatrix, ".stm"); if ((f1 = fopen(stiffmatrix, "wb")) == NULL) { - printf(" *ERROR in nonlingeo: cannot open stiffness matrix file for writing..."); + printf("*ERROR in linstatic: cannot open stiffness matrix file for writing..."); exit(0); } @@ -4273,31 +4213,31 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l */ if (fwrite(&nasym, sizeof(ITG), 1, f1) != 1) { - printf(" *ERROR in nonlingeo saving the symmetry flag to the stiffness matrix file..."); + printf("*ERROR saving the symmetry flag to the stiffness matrix file..."); exit(0); } if (fwrite(nzs, sizeof(ITG), 3, f1) != 3) { - printf(" *ERROR in nonlingeo saving the number of subdiagonal nonzeros to the stiffness matrix file..."); + printf("*ERROR saving the number of subdiagonal nonzeros to the stiffness matrix file..."); exit(0); } if (fwrite(irow, sizeof(ITG), nzs[2], f1) != nzs[2]) { - printf(" *ERROR in nonlingeo saving irow to the stiffness matrix file..."); + printf("*ERROR saving irow to the stiffness matrix file..."); exit(0); } if (fwrite(jq, sizeof(ITG), neq[1] + 1, f1) != neq[1] + 1) { - printf(" *ERROR in nonlingeo saving jq to the stiffness matrix file..."); + printf("*ERROR saving jq to the stiffness matrix file..."); exit(0); } if (fwrite(icol, sizeof(ITG), neq[1], f1) != neq[1]) { - printf(" *ERROR in nonlingeo saving icol to the stiffness matrix file..."); + printf("*ERROR saving icol to the stiffness matrix file..."); exit(0); } if (fwrite(adcpy, sizeof(double), neq[1], f1) != neq[1]) { - printf(" *ERROR in nonlingeo saving the diagonal of the stiffness matrix to the stiffness matrix file..."); + printf("*ERROR saving the diagonal of the stiffness matrix to the stiffness matrix file..."); exit(0); } if (fwrite(aucpy, sizeof(double), (nasym + 1) * nzs[2], f1) != (nasym + 1) * nzs[2]) { - printf(" *ERROR in nonlingeo saving the off-diagonal terms of the stiffness matrix to the stiffness matrix file..."); + printf("*ERROR saving the off-diagonal terms of the stiffness matrix to the stiffness matrix file..."); exit(0); } fclose(f1); @@ -4631,11 +4571,9 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l SFREE(lslav); SFREE(ktot); SFREE(ltot); - SFREE(aloc); SFREE(adc); SFREE(auc); SFREE(areaslav); - SFREE(fric); } else if (*mortar == 0) { SFREE(areaslav); } else if (*mortar == 1) { @@ -4785,13 +4723,6 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l } // MPADD end - /* restore node-to-face contact to massless contact for massless - explicit dynamic calculations */ - - if ((*nmethod == 1) && (mortarsav == -1)) { - *mortar = -1; - } - (*ttime) += (*tper); /* Adapter: Free the memory */ From 7e1c1b73fb66d360ec7afad1da3328f9f4e3b78f Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 1 Apr 2024 16:27:04 +0200 Subject: [PATCH 02/55] Reintroduce parts that seemed to be deleted unintentionally --- adapter/PreciceInterface.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/adapter/PreciceInterface.h b/adapter/PreciceInterface.h index 5e696d07..6be0139d 100644 --- a/adapter/PreciceInterface.h +++ b/adapter/PreciceInterface.h @@ -11,6 +11,7 @@ #define PRECICEINTERFACE_H #include +#include "2D3DCoupling.h" #include "CCXHelpers.h" #include "ConfigReader.h" @@ -166,6 +167,16 @@ typedef struct SimulationData { double coupling_init_dtheta; double solver_dt; + // Configuration information + int isModalDynamic; // 0 for regular simulations, 1 for modal dynamic + + // Modal dynamic simulation checkpointing buffers + double *eigenDOFs; // Called "bj" or "cd" in CCX code + double *eigenDOFsDerivatives; // Called "bjp" (p for prime) or "cv" in CCX code + int stored_iinc; + int stored_jprint; + int kode_value; + } SimulationData; /** @@ -173,8 +184,6 @@ typedef struct SimulationData { * @param configFilename: YAML config file * @param participantName * @param sim - * @param preciceInterfaces - * @param numPreciceInterfaces */ void Precice_Setup(char *configFilename, char *participantName, SimulationData *sim); From 342df26dd1a0f7d4e0aeccb17b4ccd2f593e69e7 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 1 Apr 2024 16:31:07 +0200 Subject: [PATCH 03/55] Formatting --- adapter/CCXHelpers.c | 77 ++++++++++++++++++---------------------- adapter/CCXHelpers.h | 2 +- adapter/ConfigReader.cpp | 1 - adapter/ConfigReader.h | 2 +- 4 files changed, 37 insertions(+), 45 deletions(-) mode change 100755 => 100644 adapter/CCXHelpers.c mode change 100755 => 100644 adapter/CCXHelpers.h mode change 100755 => 100644 adapter/ConfigReader.cpp diff --git a/adapter/CCXHelpers.c b/adapter/CCXHelpers.c old mode 100755 new mode 100644 index 3493e3f2..4530e797 --- a/adapter/CCXHelpers.c +++ b/adapter/CCXHelpers.c @@ -40,8 +40,6 @@ ITG getSetID(char const *setName, char const *set, ITG nset) } // Set not found: - - if (setName[0] == (char) 'N') { printf("Set ID NOT Found \n"); nodeSetNotFoundError(setName); @@ -96,10 +94,9 @@ void getNodeCoordinates(ITG *nodes, ITG numNodes, int dim, double *co, double *v } //, d -void getElementGaussPointCoordinates(int numElements, int numGPTotal, int *elementIDs, double *co, ITG *kon, char *lakon, ITG *ipkon, int *gp_id, double *gp_coord) +void getElementGaussPointCoordinates(int numElements, int numGPTotal, int *elementIDs, double *co, ITG *kon, char *lakon, ITG *ipkon, int *gp_id, double *gp_coord) { - FORTRAN(getelementgausspointcoords,(&numElements, &numGPTotal, elementIDs, co, &lakon, kon, ipkon, gp_id, gp_coord)); - + FORTRAN(getelementgausspointcoords, (&numElements, &numGPTotal, elementIDs, co, &lakon, kon, ipkon, gp_id, gp_coord)); } void getNodeTemperatures(ITG *nodes, ITG numNodes, double *v, int mt, double *temperatures) @@ -126,62 +123,60 @@ void getNodeForces(ITG *nodes, ITG numNodes, int dim, double *fn, ITG mt, double } } -void getStrainNorm(int numElements, int numGPTotal, int *elementIDs, double *eei, double *strainData){ +void getStrainNorm(int numElements, int numGPTotal, int *elementIDs, double *eei, double *strainData) +{ + + int i, j, numGPPerElement, count, idx; - int i,j, numGPPerElement, count, idx; - count = 0; - for (i=0; i().c_str()); } - if (config["participants"][participantName]["interfaces"][i]["elements"]) { interface.elementsMeshName = strdup(config["participants"][participantName]["interfaces"][i]["elements"].as().c_str()); } diff --git a/adapter/ConfigReader.h b/adapter/ConfigReader.h index 254de2c4..4ffa85b2 100755 --- a/adapter/ConfigReader.h +++ b/adapter/ConfigReader.h @@ -44,7 +44,7 @@ void ConfigReader_Read(char const *configFilename, char const *participantName, * @precondition adapterConfig points to an initialized instance of adapterConfig. * @precondition ConfigReader_Read was called on adapterConfig. * @postcondition all memory held by the struct adapterConfig is freed - * @note This function does not free the pointer adapterConfig + * @note This function does not free the pointer adapterConfig */ void AdapterConfig_Free(AdapterConfig *adapterConfig); From c70bb783830d9917c169cc6104a2b46016d0c568 Mon Sep 17 00:00:00 2001 From: Ibrahim Kaleel Date: Tue, 16 Apr 2024 22:22:09 -0400 Subject: [PATCH 04/55] volumetric coupling update --- .gitignore | 14 + CalculiX.h | 9733 +++++++++-------- CalculiX_precice.h | 106 + Makefile | 37 +- adapter/CCXHelpers.c | 99 +- adapter/CCXHelpers.h | 27 +- adapter/PreciceInterface.c | 442 +- adapter/PreciceInterface.h | 117 +- ccx_2.19.c | 2228 ---- ccx_2.20.c | 2239 ---- ccx_2.21.c | 1954 ++++ examples/ccx-nasmat/ccx/clean.sh | 11 + examples/ccx-nasmat/ccx/config.yml | 9 + examples/ccx-nasmat/ccx/one_element.inp | 51 + examples/ccx-nasmat/ccx/run.sh | 6 + examples/ccx-nasmat/nasmat/clean.sh | 7 + .../nasmat/micro-manager-config.json | 26 + examples/ccx-nasmat/nasmat/ruc_nasmat.py | 113 + .../ccx-nasmat/nasmat/run_micro_manager.py | 21 + .../nasmat/run_micromanager_nasmat.sh | 5 + examples/ccx-nasmat/precice-config.xml | 94 + linstatic_precice.c | 1685 ++- linstatic_precice_.c | 1372 +++ multiscale_routines.f | 84 + 24 files changed, 9862 insertions(+), 10618 deletions(-) create mode 100644 CalculiX_precice.h delete mode 100755 ccx_2.19.c delete mode 100644 ccx_2.20.c create mode 100644 ccx_2.21.c create mode 100644 examples/ccx-nasmat/ccx/clean.sh create mode 100755 examples/ccx-nasmat/ccx/config.yml create mode 100755 examples/ccx-nasmat/ccx/one_element.inp create mode 100755 examples/ccx-nasmat/ccx/run.sh create mode 100755 examples/ccx-nasmat/nasmat/clean.sh create mode 100644 examples/ccx-nasmat/nasmat/micro-manager-config.json create mode 100644 examples/ccx-nasmat/nasmat/ruc_nasmat.py create mode 100644 examples/ccx-nasmat/nasmat/run_micro_manager.py create mode 100755 examples/ccx-nasmat/nasmat/run_micromanager_nasmat.sh create mode 100755 examples/ccx-nasmat/precice-config.xml mode change 100755 => 100644 linstatic_precice.c create mode 100755 linstatic_precice_.c create mode 100644 multiscale_routines.f diff --git a/.gitignore b/.gitignore index ba077a40..bee05410 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,15 @@ +.vscode + bin + +# precice output files +*precice-profiling* +*precice-run* +__pycache__ + +# ccx output files +*.12d +*.cvg +*.dat +*.frd +*.sta diff --git a/CalculiX.h b/CalculiX.h index d0b36f1a..10bbac29 100755 --- a/CalculiX.h +++ b/CalculiX.h @@ -1,5 +1,5 @@ /* CALCULIX - A 3-dimensional finite element program */ -/* Copyright (C) 1998-2021 Guido Dhondt */ +/* Copyright (C) 1998-2023 Guido Dhondt */ /* This program is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU General Public License as */ @@ -7,7 +7,7 @@ /* the License, or (at your option) any later version. */ /* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /* GNU General Public License for more details. */ @@ -23,55 +23,47 @@ #define HP 4 #if ARCH == Linux -#define FORTRAN(A, B) A##_ B +#define FORTRAN(A,B) A##_ B #elif ARCH == IRIX || ARCH == IRIX64 -#define FORTRAN(A, B) A##_##B +#define FORTRAN(A,B) A##_##B #elif ARCH == HP -#define FORTRAN(A, B) A##B +#define FORTRAN(A,B) A##B #endif #if ARCH == Linux -#define CEE(A, B) A##_ B +#define CEE(A,B) A##_ B #elif ARCH == IRIX || ARCH == IRIX64 -#define CEE(A, B) A##_##B +#define CEE(A,B) A##_##B #elif ARCH == HP -#define CEE(A, B) A##B +#define CEE(A,B) A##B #endif /* setting arrays to constant values */ /* serial */ -#define DMEMSET(a, b, c, d) \ - for (im = b; im < c; im++) \ - a[im] = d +#define DMEMSET(a,b,c,d) for(im=b;imtheta = 0; - *sim->tper = 1; - *sim->dtheta = 1; + sim->theta = 0; + sim->tper = 1; + sim->dtheta = 1; // Set the solver time step to be the same as the coupling time step sim->solver_dt = precice_dt; @@ -168,12 +168,14 @@ void Precice_ReadCouplingData(SimulationData *sim) PreciceInterface **interfaces = sim->preciceInterfaces; int numInterfaces = sim->numPreciceInterfaces; - int i, j; + int i, j, idx; for (i = 0; i < numInterfaces; i++) { for (j = 0; j < interfaces[i]->numReadData; j++) { + printf("Read data: %d\n", interfaces[i]->readData[j]); + switch (interfaces[i]->readData[j]) { case TEMPERATURE: // Read and set temperature BC @@ -221,10 +223,10 @@ void Precice_ReadCouplingData(SimulationData *sim) printf("Reading FORCES coupling data.\n"); break; case PRESSURE: - precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->pressure, interfaces[i]->numElements, interfaces[i]->preciceFaceCenterIDs, sim->solver_dt, interfaces[i]->faceCenterData); - setFacePressure(interfaces[i]->faceCenterData, interfaces[i]->numElements, interfaces[i]->xloadIndices, sim->xload); - printf("Reading PRESSURE coupling data.\n"); - break; + // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->pressure, interfaces[i]->numElements, interfaces[i]->preciceFaceCenterIDs, sim->solver_dt, interfaces[i]->faceCenterData); + // setFacePressure(interfaces[i]->faceCenterData, interfaces[i]->numElements, interfaces[i]->xloadIndices, sim->xload); + // printf("Reading PRESSURE coupling data.\n"); + // break; case DISPLACEMENTS: // Read and set displacements as single point constraints (Dirichlet BC) if (isQuasi2D3D(interfaces[i]->quasi2D3D)) { @@ -236,83 +238,125 @@ void Precice_ReadCouplingData(SimulationData *sim) } printf("Reading DISPLACEMENTS coupling data.\n"); break; - case MATERTIAL_TANGENT_1: - interfaces[i]->strainGPData = malloc(interfaces[i]->numGPTotal * 3 * sizeof(double)); - precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent1Data, interfaces[i]->numGPTotal, interfaces[i]->elemGPID, sim->solver_dt, interfaces[i]->strainGPData); - // for (int k = 0; k < interfaces[i]->numGPTotal; k++) { - // printf( " %i, %e, %e, %e \n", k, interfaces[i]->strainGPData[k*3], interfaces[i]->strainGPData[k*3+1], interfaces[i]->strainGPData[k*3+2]); + + // VOLUMETRIC COUPLING - MULTISCALE + case CONV_FLAG: + // READ CONVERGENCE FLAG + // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->macroInputData, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPScalarData); + printf("Reading CONVERGENCE FLAG coupling data.\n"); + break; + + case CMAT1: + // READ MATERIAL MATRIX COMPONENTS - C11, C12, C13 + idx=1; + precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent1Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); + // for (int k = 0; k < interfaces[i]->numIPTotal; k++) { + // printf( " %i, %e, %e, %e \n", k, interfaces[i]->elementIPVectorData[k*3], interfaces[i]->elementIPVectorData[k*3+1], interfaces[i]->elementIPVectorData[k*3+2]); // } - setMaterialTangentMatrix(0, interfaces[i]->numElements, interfaces[i]->numGPTotal, interfaces[i]->elementIDs, interfaces[i]->strainGPData, sim->xstiff); + FORTRAN(precice_multiscale_set_xstiff, (sim->mi, + idx, + interfaces[i]->numElements, + interfaces[i]->elementIPVectorData, + sim->xstiff)); printf("Reading MATERIAL TANGENT 1 coupling data.\n"); - fflush(stdout); - free(interfaces[i]->strainGPData); break; - case MATERTIAL_TANGENT_2: - interfaces[i]->strainGPData = malloc(interfaces[i]->numGPTotal * 3 * sizeof(double)); - precicec_readaces[interfaces[i]->couplingMeshName, i]->couplingMeshName, interfaces[i]materialTangent2Data, interfaces[i]->numGPTotal, inte sim->solver_dt,rfaces[i]->elemGPID, sim->solver_dt, interfaces[i]->strainGPData); - // for (int k = 0; k < interfaces[i]->numGPTotal; k++) { - // printf( " %i, %e, %e, %e \n", k, interfaces[i]->strainGPData[k*3], interfaces[i]->strainGPData[k*3+1], interfaces[i]->strainGPData[k*3+2]); - // } - setMaterialTangentMatrix(3, interfaces[i]->numElements, interfaces[i]->numGPTotal, interfaces[i]->elementIDs, interfaces[i]->strainGPData, sim->xstiff); + + case CMAT2: + // READ MATERIAL MATRIX COMPONENTS - C14, C15, C16 + // idx=4; + // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent2Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); + // FORTRAN(precice_multiscale_set_xstiff, (sim->mi, + // &idx, + // &interfaces[i]->numElements, + // interfaces[i]->elementIPVectorData, + // sim->xstiff)); printf("Reading MATERIAL TANGENT 2 coupling data.\n"); - fflush(stdout); - free(interfaces[i]->strainGPData); break; - case MATERTIAL_TANGENT_3: - interfaces[i]->strainGPData = malloc(interfaces[i]->numGPTotal * 3 * sizeof(double)); - precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent3Data, interfaces[i]->numGPTotal, interfaces[i]->elemGPID, sim->solver_dt, interfaces[i]->strainGPData); - // for (int k = 0; k < interfaces[i]->numGPTotal; k++) { - // printf( " %i, %e, %e, %e \n", k, interfaces[i]->strainGPData[k*3], interfaces[i]->strainGPData[k*3+1], interfaces[i]->strainGPData[k*3+2]); - // } - setMaterialTangentMatrix(6, interfaces[i]->numElements, interfaces[i]->numGPTotal, interfaces[i]->elementIDs, interfaces[i]->strainGPData, sim->xstiff); + + case CMAT3: + // READ MATERIAL MATRIX COMPONENTS - C22, C23, C24 + // idx=7; + // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent3Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); + // FORTRAN(precice_multiscale_set_xstiff, (sim->mi, + // &idx, + // &interfaces[i]->numElements, + // interfaces[i]->elementIPVectorData, + // sim->xstiff)); printf("Reading MATERIAL TANGENT 3 coupling data.\n"); - fflush(stdout); - free(interfaces[i]->strainGPData); break; - case MATERTIAL_TANGENT_4: - interfaces[i]->strainGPData = malloc(interfaces[i]->numGPTotal * 3 * sizeof(double)); - precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent4Data, interfaces[i]->numGPTotal, interfaces[i]->elemGPID, sim->solver_dt, interfaces[i]->strainGPData); - // for (int k = 0; k < interfaces[i]->numGPTotal; k++) { - // printf( " %i, %e, %e, %e \n", k, interfaces[i]->strainGPData[k*3], interfaces[i]->strainGPData[k*3+1], interfaces[i]->strainGPData[k*3+2]); - // } - setMaterialTangentMatrix(9, interfaces[i]->numElements, interfaces[i]->numGPTotal, interfaces[i]->elementIDs, interfaces[i]->strainGPData, sim->xstiff); + + case CMAT4: + // READ MATERIAL MATRIX COMPONENTS - C25, C26, C33 + // idx=10; + // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent4Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); + // FORTRAN(precice_multiscale_set_xstiff, (sim->mi, + // &idx, + // &interfaces[i]->numElements, + // interfaces[i]->elementIPVectorData, + // sim->xstiff)); printf("Reading MATERIAL TANGENT 4 coupling data.\n"); - fflush(stdout); - free(interfaces[i]->strainGPData); break; - case MATERTIAL_TANGENT_5: - interfaces[i]->strainGPData = malloc(interfaces[i]->numGPTotal * 3 * sizeof(double)); - precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent5Data, interfaces[i]->numGPTotal, interfaces[i]->elemGPID, sim->solver_dt, interfaces[i]->strainGPData); - // for (int k = 0; k < interfaces[i]->numGPTotal; k++) { - // printf( " %i, %e, %e, %e \n", k, interfaces[i]->strainGPData[k*3], interfaces[i]->strainGPData[k*3+1], interfaces[i]->strainGPData[k*3+2]); - // } - setMaterialTangentMatrix(12, interfaces[i]->numElements, interfaces[i]->numGPTotal, interfaces[i]->elementIDs, interfaces[i]->strainGPData, sim->xstiff); + + case CMAT5: + // READ MATERIAL MATRIX COMPONENTS - C34, C35, C36 + // idx=13; + // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent5Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); + // FORTRAN(precice_multiscale_set_xstiff, (sim->mi, + // &idx, + // &interfaces[i]->numElements, + // interfaces[i]->elementIPVectorData, + // sim->xstiff)); printf("Reading MATERIAL TANGENT 5 coupling data.\n"); - fflush(stdout); - free(interfaces[i]->strainGPData); break; - case MATERTIAL_TANGENT_6: - interfaces[i]->strainGPData = malloc(interfaces[i]->numGPTotal * 3 * sizeof(double)); - precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent6Data, interfaces[i]->numGPTotal, interfaces[i]->elemGPID, sim->solver_dt, interfaces[i]->strainGPData); - // for (int k = 0; k < interfaces[i]->numGPTotal; k++) { - // printf( " %i, %e, %e, %e \n", k, interfaces[i]->strainGPData[k*3], interfaces[i]->strainGPData[k*3+1], interfaces[i]->strainGPData[k*3+2]); - // } - setMaterialTangentMatrix(15, interfaces[i]->numElements, interfaces[i]->numGPTotal, interfaces[i]->elementIDs, interfaces[i]->strainGPData, sim->xstiff); + + case CMAT6: + // READ MATERIAL MATRIX COMPONENTS - C44, C45, C46 + // idx=16; + // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent6Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); + // FORTRAN(precice_multiscale_set_xstiff, (sim->mi, + // &idx, + // &interfaces[i]->numElements, + // interfaces[i]->elementIPVectorData, + // sim->xstiff)); printf("Reading MATERIAL TANGENT 6 coupling data.\n"); - fflush(stdout); - free(interfaces[i]->strainGPData); break; - case MATERTIAL_TANGENT_7: - interfaces[i]->strainGPData = malloc(interfaces[i]->numGPTotal * 3 * sizeof(double)); - precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent7Data, interfaces[i]->numGPTotal, interfaces[i]->elemGPID, sim->solver_dt, interfaces[i]->strainGPData); - // for (int k = 0; k < interfaces[i]->numGPTotal; k++) { - // printf( " %i, %e, %e, %e \n", k, interfaces[i]->strainGPData[k*3], interfaces[i]->strainGPData[k*3+1], interfaces[i]->strainGPData[k*3+2]); - // } - setMaterialTangentMatrix(18, interfaces[i]->numElements, interfaces[i]->numGPTotal, interfaces[i]->elementIDs, interfaces[i]->strainGPData, sim->xstiff); + + case CMAT7: + // READ MATERIAL MATRIX COMPONENTS - C55, C56, C66 + // idx=19; + // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent7Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); + // FORTRAN(precice_multiscale_set_xstiff, (sim->mi, + // &idx, + // &interfaces[i]->numElements, + // interfaces[i]->elementIPVectorData, + // sim->xstiff)); printf("Reading MATERIAL TANGENT 7 coupling data.\n"); - fflush(stdout); - free(interfaces[i]->strainGPData); break; + + case STRESS1TO3: + // READ STRESS COMPONENTS - S11, S22, S33 + idx=1; + // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->stress1to3Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); + // FORTRAN(precice_multiscale_set_stx, (sim->mi, + // &idx, + // &interfaces[i]->numElements, + // interfaces[i]->elementIPVectorData, + // sim->stx)); + printf("Reading STRESS1TO3 coupling data.\n"); + break; + + case STRESS4TO6: + // READ STRESS COMPONENTS - S23, S13, S12 + // idx=4; + // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->stress4to6Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); + // FORTRAN(precice_multiscale_set_stx, (sim->mi, + // &idx, + // &interfaces[i]->numElements, + // interfaces[i]->elementIPVectorData, + // sim->stx)); + printf("Reading STRESS4TO6 coupling data.\n"); + break; + case DISPLACEMENTDELTAS: printf("DisplacementDeltas cannot be used as read data\n"); fflush(stdout); @@ -328,28 +372,23 @@ void Precice_ReadCouplingData(SimulationData *sim) fflush(stdout); exit(EXIT_FAILURE); break; - case RVE_ID: - printf("RVE ID cannot be used as read data.\n"); + case MACRO_IP_ID: + printf("MACRO IP ID cannot be used as read data.\n"); fflush(stdout); exit(EXIT_FAILURE); break; - case STRAIN_NORM: - printf("Normal Strain cannot be used as read data.\n"); + case INPUT_ID: + printf("Input ID cannot be used as read data.\n"); fflush(stdout); exit(EXIT_FAILURE); break; - case STRAIN_SHEAR: - printf("Shear Strain cannot be used as read data.\n"); + case STRAIN1TO3: + printf("Strain 1to3 cannot be used as read data.\n"); fflush(stdout); exit(EXIT_FAILURE); break; - case STRESS_NORM: - printf("Normal Stress cannot be used as read data.\n"); - fflush(stdout); - exit(EXIT_FAILURE); - break; - case STRESS_SHEAR: - printf("Shear Stress cannot be used as read data.\n"); + case STRAIN4TO6: + printf("Strain 4to6 cannot be used as read data.\n"); fflush(stdout); exit(EXIT_FAILURE); break; @@ -366,9 +405,10 @@ void Precice_WriteCouplingData(SimulationData *sim) PreciceInterface **interfaces = sim->preciceInterfaces; int numInterfaces = sim->numPreciceInterfaces; - int i, j; + int i, j, idx; int iset; + for (i = 0; i < numInterfaces; i++) { // Prepare data double *KDelta = NULL; @@ -402,7 +442,7 @@ void Precice_WriteCouplingData(SimulationData *sim) // Write data for (j = 0; j < interfaces[i]->numWriteData; j++) { - + printf("Write data: %d\n", interfaces[i]->writeData[j]); switch (interfaces[i]->writeData[j]) { case TEMPERATURE: if (isQuasi2D3D(interfaces[i]->quasi2D3D)) { @@ -480,36 +520,26 @@ void Precice_WriteCouplingData(SimulationData *sim) precicec_writeData(interfaces[i]->couplingMeshName, interfaces[i]->forces, interfaces[i]->numNodes, interfaces[i]->preciceNodeIDs, interfaces[i]->nodeVectorData); printf("Writing FORCES coupling data.\n"); break; - case RVE_ID: - interfaces[i]->rveGPData = malloc(interfaces[i]->numGPTotal * sizeof(double)); - // Getting RVE tags - getRVETag(interfaces[i]->numGPTotal, interfaces[i]->rveGPData); - // for (int k = 0; k < interfaces[i]->numGPTotal; k++) { - // printf( "%i, %e \n", k, interfaces[i]->rveGPData[k]); - // } - precicec_writeData(interfaces[i]->couplingMeshName, interfaces[i]->rveIdData, interfaces[i]->numGPTotal, interfaces[i]->elemGPID, interfaces[i]->rveGPData); - printf("Writing RVE ID coupling data.\n"); - free(interfaces[i]->rveGPData); + /* VOLUMETRIC COUPLING - MULTISCALE */ + case INPUT_ID: + // WRITE INPUT ID + for (int k = 0; k < interfaces[i]->numIPTotal; k++) { + interfaces[i]->elementIPScalarData[k] = 1; + }; + precicec_writeData(interfaces[i]->couplingMeshName, interfaces[i]->macroInputData, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, interfaces[i]->elementIPScalarData); + printf("Writing INPUT ID coupling data.\n"); break; - case STRAIN_NORM: - interfaces[i]->strainGPData = malloc(interfaces[i]->numGPTotal * 3 * sizeof(double)); - getStrainNorm(interfaces[i]->numElements, interfaces[i]->numGPTotal, interfaces[i]->elementIDs, sim->eei, interfaces[i]->strainGPData); - // for (int k = 0; k < interfaces[i]->numGPTotal; k++) { - // printf( " %i, %e, %e, %e \n", k, interfaces[i]->strainGPData[k*3], interfaces[i]->strainGPData[k*3+1], interfaces[i]->strainGPData[k*3+2]); - // } - precicec_writeData(interfaces[i]->couplingMeshName, interfaces[i]->strainNormData, interfaces[i]->numGPTotal, interfaces[i]->elemGPID, interfaces[i]->strainGPData); - printf("Writing STRAIN NORMAL coupling data.\n"); - free(interfaces[i]->strainGPData); + case STRAIN1TO3: + idx=0; + getElementStrain(idx, sim->mi, interfaces[i]->numElements, sim->eei, interfaces[i]->elementIPVectorData); + precicec_writeData(interfaces[i]->couplingMeshName, interfaces[i]->strain1to3Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, interfaces[i]->elementIPVectorData); + printf("Writing STRAIN1TO3 coupling data.\n"); break; - case STRAIN_SHEAR: - interfaces[i]->strainGPData = malloc(interfaces[i]->numGPTotal * 3 * sizeof(double)); - getStrainShear(interfaces[i]->numElements, interfaces[i]->numGPTotal, interfaces[i]->elementIDs, sim->eei, interfaces[i]->strainGPData); - // for (int k = 0; k < interfaces[i]->numGPTotal; k++) { - // printf( " %i, %e, %e, %e \n", k, interfaces[i]->strainGPData[k*3], interfaces[i]->strainGPData[k*3+1], interfaces[i]->strainGPData[k*3+2]); - // } - precicec_writeData(interfaces[i]->couplingMeshName, interfaces[i]->strainShearData, interfaces[i]->numGPTotal, interfaces[i]->elemGPID, interfaces[i]->strainGPData); - printf("Writing STRAIN SHEAR coupling data.\n"); - free(interfaces[i]->strainGPData); + case STRAIN4TO6: + idx=3; + getElementStrain(idx, sim->mi, interfaces[i]->numElements, sim->eei, interfaces[i]->elementIPVectorData); + precicec_writeData(interfaces[i]->couplingMeshName, interfaces[i]->strain4to6Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, interfaces[i]->elementIPVectorData); + printf("Writing STRAIN4TO6 coupling data.\n"); break; } } @@ -539,8 +569,8 @@ void Precice_FreeData(SimulationData *sim) void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, InterfaceConfig const *config) { // Deduce configured dimensions - if (config->nodesMeshName == NULL && config->facesMeshName == NULL) { - printf("ERROR: You need to define either a face or a nodes mesh. Check the adapter configuration file.\n"); + if (config->nodesMeshName == NULL && config->facesMeshName == NULL && config->elementsMeshName == NULL) { + printf("ERROR: You need to define a face mesh, nodes mesh or element mesh. Check the adapter configuration file.\n"); exit(EXIT_FAILURE); } if (config->nodesMeshName && config->facesMeshName) { @@ -578,7 +608,6 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I interface->xbounIndices = NULL; interface->xloadIndices = NULL; interface->xforcIndices = NULL; - interface->elementGPData = NULL; // Initialize preCICE mesh name as NULL interface->couplingMeshName = NULL; @@ -596,11 +625,11 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I interface->velocities = NULL; interface->forces = NULL; interface->pressure = NULL; - interface->rveIdData = NULL; - interface->strainNormData = NULL; - interface->strainShearData = NULL; - interface->stressNormData = NULL; - interface->stressShearData = NULL; + interface->macroInputData = NULL; + interface->strain1to3Data = NULL; + interface->strain4to6Data = NULL; + interface->stress1to3Data = NULL; + interface->stress4to6Data = NULL; interface->materialTangent1Data = NULL; interface->materialTangent2Data = NULL; interface->materialTangent3Data = NULL; @@ -630,7 +659,6 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I if (config->nodesMeshName) { interface->nodesMeshName = strdup(config->nodesMeshName); PreciceInterface_ConfigureNodesMesh(interface, sim); - interface->couplingMeshName = interface->nodesMeshName; } @@ -652,6 +680,7 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I interface->elementMeshName = strdup(config->elementsMeshName); // Configuring element mesh PreciceInterface_ConfigureElementsMesh(interface, sim); + interface->couplingMeshName = interface->elementMeshName; } PreciceInterface_ConfigureCouplingData(interface, sim, config); @@ -676,21 +705,21 @@ void PreciceInterface_ConfigureElementsMesh(PreciceInterface *interface, Simulat // Find guass point coordinates of the element -> Serves as mesh for data transfer int numElt = interface->numElements; - interface->numGPTotal = 8 * interface->numElements; // Gauss point mesh coordinate -Each element 8 gauss points - interface->elemGPCoordinates = malloc(interface->numGPTotal * 3 * sizeof(double)); - interface->elemGPID = malloc(interface->numGPTotal * sizeof(int)); - - for (int j = 0; j < interface->numGPTotal; j++) { - // interface->elemGPID[j] = j; - interface->elemGPCoordinates[j * 3] = j; - interface->elemGPCoordinates[j * 3 + 1] = 0.0; - interface->elemGPCoordinates[j * 3 + 2] = 0.0; + interface->numIPTotal = 8 * interface->numElements; // Gauss point mesh coordinate -Each element 8 gauss points + interface->elemIPCoordinates = malloc(interface->numIPTotal * 3 * sizeof(double)); + interface->elemIPID = malloc(interface->numIPTotal * sizeof(int)); + + for (int j = 0; j < interface->numIPTotal; j++) { + interface->elemIPID[j] = j; + interface->elemIPCoordinates[j * 3] = j; + interface->elemIPCoordinates[j * 3 + 1] = 0.0; + interface->elemIPCoordinates[j * 3 + 2] = 0.0; } - // getElementGaussPointCoordinates(interface->numElements, interface->numGPTotal, interface->elementIDs, sim->co, - // sim->kon, sim->lakon, sim->ipkon, interface->elemGPID, interface->elemGPCoordinates); + // getElementGaussPointCoordinates(interface->numElements, interface->numIPTotal, interface->elementIDs, sim->co, + // sim->kon, sim->lakon, sim->ipkon, interface->elemIPID, interface->elemIPCoordinates); - precicec_setMeshVertices(interface->elementMeshName, interface->numGPTotal, interface->elemGPCoordinates, interface->elemGPID); + precicec_setMeshVertices(interface->elementMeshName, interface->numIPTotal, interface->elemIPCoordinates, interface->elemIPID); } void PreciceInterface_ConfigureFaceCentersMesh(PreciceInterface *interface, SimulationData *sim) @@ -744,7 +773,8 @@ void PreciceInterface_ConfigureNodesMesh(PreciceInterface *interface, Simulation // If 2D-3Q coupling is used (for a node mesh) delegate this to the specialized data structure. if (interface->nodesMeshName != NULL) { - count = 0; + int count = 0; + int dimCCX = interface->dimCCX; for (int i = 0; i < interface->numNodes; i++) { for (int ii = 0; ii < interface->numNodes; ii++) { // Compare each node with every other node to find nodes with matching X and Y coordinates @@ -763,7 +793,7 @@ void PreciceInterface_ConfigureNodesMesh(PreciceInterface *interface, Simulation if (interface->nodesMeshName != NULL) { //printf("nodesMeshName is not null \n"); - interface->nodesMeshID = precicec_getMeshID(interface->nodesMeshName); + // interface->nodesMeshID = precicec_getMeshID(interface->nodesMeshName); if (isQuasi2D3D(interface->quasi2D3D)) { interface->mappingQuasi2D3D = createMapping(interface->nodeCoordinates, interface->numNodes, interface->nodesMeshName); } else { @@ -792,8 +822,9 @@ void PreciceInterface_NodeConnectivity(PreciceInterface *interface, SimulationDa PreciceInterface_ConfigureTetraFaces(interface, sim); } -void PreciceInterface_EnsureValidRead(SimulationData *sim, enum CouplingDataType type) +void PreciceInterface_EnsureValidRead(PreciceInterface *interface, enum CouplingDataType type) { + if (interface->elementMeshName == NULL) { printf("Element mesh not provided in YAML config file\n"); fflush(stdout); @@ -803,7 +834,7 @@ void PreciceInterface_EnsureValidRead(SimulationData *sim, enum CouplingDataType void PreciceInterface_ConfigureTetraFaces(PreciceInterface *interface, SimulationData *sim) { - int i; + // int i; printf("Setting node connectivity for nearest projection mapping: \n"); if (interface->nodesMeshName != NULL) { int *triangles = malloc(interface->numElements * 3 * sizeof(ITG)); @@ -833,13 +864,23 @@ void PreciceInterface_ConfigureCouplingData(PreciceInterface *interface, Simulat interface->faceCenterData = malloc(interface->numElements * sizeof(double)); + /* Allocating and initilizing memory for multiscale coupling */ + interface->elementIPScalarData = malloc(interface->numIPTotal * sizeof(double)); + interface->elementIPVectorData = malloc(interface->numIPTotal * 3 * sizeof(double)); + for (int i = 0; i < interface->numIPTotal; i++) { + interface->elementIPScalarData[i] = 0.0; + interface->elementIPVectorData[i * 3] = 0.0; + interface->elementIPVectorData[i * 3 + 1] = 0.0; + interface->elementIPVectorData[i * 3 + 2] = 0.0; + } + int i; interface->numReadData = config->numReadData; if (config->numReadData > 0) interface->readData = malloc(config->numReadData * sizeof(int)); for (i = 0; i < config->numReadData; i++) { if (startsWith(config->readDataNames[i], "Temperature")) { - PreciceInterface_EnsureValidRead(sim, TEMPERATURE); + PreciceInterface_EnsureValidRead(interface, TEMPERATURE); interface->readData[i] = TEMPERATURE; interface->xbounIndices = malloc(interface->numNodes * sizeof(int)); interface->temperature = strdup(config->readDataNames[i]); @@ -849,84 +890,92 @@ void PreciceInterface_ConfigureCouplingData(PreciceInterface *interface, Simulat interface->readData[i] = HEAT_FLUX; interface->xloadIndices = malloc(interface->numElements * sizeof(int)); getXloadIndices("DFLUX", interface->elementIDs, interface->faceIDs, interface->numElements, sim->nload, sim->nelemload, sim->sideload, interface->xloadIndices); - PreciceInterface_EnsureValidRead(sim, HEAT_FLUX); + PreciceInterface_EnsureValidRead(interface, HEAT_FLUX); interface->flux = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", interface->flux); } else if (startsWith(config->readDataNames[i], "Sink-Temperature")) { interface->readData[i] = SINK_TEMPERATURE; interface->xloadIndices = malloc(interface->numElements * sizeof(int)); getXloadIndices("FILM", interface->elementIDs, interface->faceIDs, interface->numElements, sim->nload, sim->nelemload, sim->sideload, interface->xloadIndices); - PreciceInterface_EnsureValidRead(sim, SINK_TEMPERATURE); + PreciceInterface_EnsureValidRead(interface, SINK_TEMPERATURE); interface->kDeltaTemperatureRead = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", interface->kDeltaTemperatureRead); } else if (startsWith(config->readDataNames[i], "Heat-Transfer-Coefficient")) { interface->readData[i] = HEAT_TRANSFER_COEFF; - PreciceInterface_EnsureValidRead(sim, HEAT_TRANSFER_COEFF); + PreciceInterface_EnsureValidRead(interface, HEAT_TRANSFER_COEFF); interface->kDeltaRead = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", interface->kDeltaRead); } else if (startsWith(config->readDataNames[i], "Pressure")) { interface->readData[i] = PRESSURE; interface->xloadIndices = malloc(interface->numElements * sizeof(int)); - PreciceInterface_EnsureValidRead(sim, PRESSURE); + PreciceInterface_EnsureValidRead(interface, PRESSURE); getXloadIndices("PRESSUREDLOAD", interface->elementIDs, interface->faceIDs, interface->numElements, sim->nload, sim->nelemload, sim->sideload, interface->xloadIndices); interface->pressure = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", interface->pressure); } else if (startsWith(config->readDataNames[i], "Force")) { - PreciceInterface_EnsureValidRead(sim, FORCES); + PreciceInterface_EnsureValidRead(interface, FORCES); interface->readData[i] = FORCES; interface->xforcIndices = malloc(interface->numNodes * 3 * sizeof(int)); interface->forces = strdup(config->readDataNames[i]); getXforcIndices(interface->nodeIDs, interface->numNodes, sim->nforc, sim->ikforc, sim->ilforc, interface->xforcIndices); printf("Read data '%s' found.\n", interface->forces); } else if (startsWith(config->readDataNames[i], "Displacement")) { - PreciceInterface_EnsureValidNodesMeshID(interface); + PreciceInterface_EnsureValidRead(interface, DISPLACEMENTS); interface->readData[i] = DISPLACEMENTS; interface->xbounIndices = malloc(interface->numNodes * 3 * sizeof(int)); interface->displacementsData = strdup(config->readDataNames[i]); getXbounIndices(interface->nodeIDs, interface->numNodes, sim->nboun, sim->ikboun, sim->ilboun, interface->xbounIndices, DISPLACEMENTS); printf("Read data '%s' found.\n", config->readDataNames[i]); - } else if (startsWith(config->readDataNames[i], "Material-Tangent-1")) { - PreciceInterface_EnsureValidElementsMeshID(interface); - interface->readData[i] = MATERTIAL_TANGENT_1; - interface->elementGPData = malloc(interface->numGPTotal * 38 * sizeof(double)); // 9 entries per gauss point + /* MICROMANAGER COUPLING */ + } else if (startsWith(config->readDataNames[i], "cmat1")) { + PreciceInterface_EnsureValidRead(interface, CMAT1); + interface->readData[i] = CMAT1; interface->materialTangent1Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); - } else if (startsWith(config->readDataNames[i], "Material-Tangent-2")) { - PreciceInterface_EnsureValidElementsMeshID(interface); - interface->readData[i] = MATERTIAL_TANGENT_2; - // interface->elementGPData = malloc(interface->numGPTotal * 38 * sizeof(double)); // 9 entries per gauss point + } else if (startsWith(config->readDataNames[i], "cmat2")) { + PreciceInterface_EnsureValidRead(interface, CMAT2); + interface->readData[i] = CMAT2; interface->materialTangent2Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); - } else if (startsWith(config->readDataNames[i], "Material-Tangent-3")) { - PreciceInterface_EnsureValidElementsMeshID(interface); - interface->readData[i] = MATERTIAL_TANGENT_3; - // interface->elementGPData = malloc(interface->numGPTotal * 38 * sizeof(double)); // 9 entries per gauss point + } else if (startsWith(config->readDataNames[i], "cmat3")) { + PreciceInterface_EnsureValidRead(interface, CMAT3); + interface->readData[i] = CMAT3; interface->materialTangent3Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); - } else if (startsWith(config->readDataNames[i], "Material-Tangent-4")) { - PreciceInterface_EnsureValidElementsMeshID(interface); - interface->readData[i] = MATERTIAL_TANGENT_4; - // interface->elementGPData = malloc(interface->numGPTotal * 38 * sizeof(double)); // 9 entries per gauss point + } else if (startsWith(config->readDataNames[i], "cmat4")) { + PreciceInterface_EnsureValidRead(interface, CMAT4); + interface->readData[i] = CMAT4; interface->materialTangent4Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); - } else if (startsWith(config->readDataNames[i], "Material-Tangent-5")) { - PreciceInterface_EnsureValidElementsMeshID(interface); - interface->readData[i] = MATERTIAL_TANGENT_5; - // interface->elementGPData = malloc(interface->numGPTotal * 38 * sizeof(double)); // 9 entries per gauss point + } else if (startsWith(config->readDataNames[i], "cmat5")) { + PreciceInterface_EnsureValidRead(interface, CMAT5); + interface->readData[i] = CMAT5; interface->materialTangent5Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); - } else if (startsWith(config->readDataNames[i], "Material-Tangent-6")) { - PreciceInterface_EnsureValidElementsMeshID(interface); - interface->readData[i] = MATERTIAL_TANGENT_6; - // interface->elementGPData = malloc(interface->numGPTotal * 38 * sizeof(double)); // 9 entries per gauss point + } else if (startsWith(config->readDataNames[i], "cmat6")) { + PreciceInterface_EnsureValidRead(interface, CMAT6); + interface->readData[i] = CMAT6; interface->materialTangent6Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); - } else if (startsWith(config->readDataNames[i], "Material-Tangent-7")) { - PreciceInterface_EnsureValidElementsMeshID(interface); - interface->readData[i] = MATERTIAL_TANGENT_7; - // interface->elementGPData = malloc(interface->numGPTotal * 38 * sizeof(double)); // 9 entries per gauss point + } else if (startsWith(config->readDataNames[i], "cmat7")) { + PreciceInterface_EnsureValidRead(interface, CMAT7); + interface->readData[i] = CMAT7; interface->materialTangent7Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); + } else if (startsWith(config->readDataNames[i], "conv_flag")) { + PreciceInterface_EnsureValidRead(interface, CONV_FLAG); + interface->readData[i] = CONV_FLAG; + printf("Read data '%s' found.\n", config->readDataNames[i]); + } else if (startsWith(config->readDataNames[i], "stress1to3")) { + PreciceInterface_EnsureValidRead(interface, STRESS1TO3); + interface->readData[i] = STRESS1TO3; + interface->stress1to3Data = strdup(config->readDataNames[i]); + printf("Read data '%s' found.\n", config->readDataNames[i]); + } else if (startsWith(config->readDataNames[i], "stress4to6")) { + PreciceInterface_EnsureValidRead(interface, STRESS4TO6); + interface->readData[i] = STRESS4TO6; + interface->stress4to6Data = strdup(config->readDataNames[i]); + printf("Read data '%s' found.\n", config->readDataNames[i]); } else { printf("ERROR: Read data '%s' does not exist!\n", config->readDataNames[i]); exit(EXIT_FAILURE); @@ -976,18 +1025,18 @@ void PreciceInterface_ConfigureCouplingData(PreciceInterface *interface, Simulat interface->writeData[i] = FORCES; interface->forces = strdup(config->writeDataNames[i]); printf("Write data '%s' found.\n", interface->forces); - } else if (isEqual(config->writeDataNames[i], "RVE-ID")) { - interface->writeData[i] = RVE_ID; - interface->rveIdData = strdup(config->writeDataNames[i]); + } else if (isEqual(config->writeDataNames[i], "input_id")) { + interface->writeData[i] = INPUT_ID; + interface->macroInputData = strdup(config->writeDataNames[i]); printf("Write data '%s' found.\n", config->writeDataNames[i]); - } else if (isEqual(config->writeDataNames[i], "Strain-Norm")) { - interface->writeData[i] = STRAIN_NORM; - interface->strainNormData = strdup(config->writeDataNames[i]); + } else if (isEqual(config->writeDataNames[i], "strain1to3")) { + interface->writeData[i] = STRAIN1TO3; + interface->strain1to3Data = strdup(config->writeDataNames[i]); + printf("Write data '%s' found.\n", config->writeDataNames[i]); + } else if (isEqual(config->writeDataNames[i], "strain4to6")) { + interface->writeData[i] = STRAIN4TO6; + interface->strain4to6Data = strdup(config->writeDataNames[i]); printf("Write data '%s' found.\n", config->writeDataNames[i]); - } else if (isEqual(config->writeDataNames[i], "Strain-Shear")) { - interface->writeData[i] = STRAIN_SHEAR; - interface->strainShearDataID = strdup(config->writeDataNames[i]) - printf("Write data '%s' found.\n", config->writeDataNames[i]); } else { printf("ERROR: Write data '%s' is not of a known type for the CalculiX-preCICE adapter. Check the adapter configuration file.\n", config->writeDataNames[i]); exit(EXIT_FAILURE); @@ -1033,11 +1082,10 @@ void PreciceInterface_FreeData(PreciceInterface *preciceInterface) free(preciceInterface->pressure); free(preciceInterface->temperature); free(preciceInterface->velocities); - free(preciceInterface->rveIdData); - free(preciceInterface->strainNormData); - free(preciceInterface->strainShearData); - free(preciceInterface->stressNormData); - free(preciceInterface->stressShearData); + free(preciceInterface->strain1to3Data); + free(preciceInterface->strain4to6Data); + free(preciceInterface->stress1to3Data); + free(preciceInterface->stress4to6Data); free(preciceInterface->materialTangent1Data); free(preciceInterface->materialTangent2Data); free(preciceInterface->materialTangent3Data); @@ -1046,3 +1094,19 @@ void PreciceInterface_FreeData(PreciceInterface *preciceInterface) free(preciceInterface->materialTangent6Data); free(preciceInterface->materialTangent7Data); } + +void PreciceInterface_MultiscaleCheckpoint(SimulationData *sim){ + + if( Precice_IsCouplingOngoing()){ + + // Write strain data + Precice_WriteCouplingData(sim); + + // Advance time + Precice_Advance(sim); + + // Read stress, material tangent data + Precice_ReadCouplingData(sim); + + } +} diff --git a/adapter/PreciceInterface.h b/adapter/PreciceInterface.h index 6be0139d..5351b086 100644 --- a/adapter/PreciceInterface.h +++ b/adapter/PreciceInterface.h @@ -21,85 +21,89 @@ */ typedef struct PreciceInterface { - char *name; - int dim; // Dimension received from preCICE configuration - int dimCCX; // Dimension as seen by CalculiX + char * name; + int dim; // Dimension received from preCICE configuration + int dimCCX; // Dimension as seen by CalculiX // Interface nodes int numNodes; + int num2DNodes; // Nodes in a single plane in case of quasi 2D-3D coupling int * nodeIDs; + int * mapping2D3D; // Node IDs to filter out 2D place in quasi 2D-3D coupling Mapping2D3D *mappingQuasi2D3D; double * nodeCoordinates; + double * node2DCoordinates; // 2D coordinates for quasi 2D-3D coupling int nodeSetID; int * preciceNodeIDs; + int nodesMeshID; char * nodesMeshName; // Interface face elements - int numElements; - int * elementIDs; - int * faceIDs; - double *faceCenterCoordinates; - int faceSetID; - char * faceCentersMeshName; - int * preciceFaceCenterIDs; + int numElements; + int * elementIDs; + int * faceIDs; + double * faceCenterCoordinates; + int faceSetID; + char * faceCentersMeshName; + int * preciceFaceCenterIDs; // Interface volumetric elements - int elementMeshID; - char * elementMeshName; - int elementSetID; - int numGPTotal; - double *elemGPCoordinates; - int * elemGPID; + int elementMeshID; + char * elementMeshName; + int elementSetID; + int numIPTotal; + double * elemIPCoordinates; + int * elemIPID; // Arrays to store the coupling data - double *nodeScalarData; - double *node2DScalarData; // Scalar quantities in 2D in case quasi 2D-3D coupling is done - double *nodeVectorData; // Forces, displacements, velocities, positions and displacementDeltas are vector quantities - double *node2DVectorData; // Vector quantities in 2D in case quasi 2D-3D coupling is done - double *faceCenterData; - double *elementGPData; - double *strainGPData; - double *rveGPData; + double * nodeScalarData; + double * node2DScalarData; // Scalar quantities in 2D in case quasi 2D-3D coupling is done + double * nodeVectorData; // Forces, displacements, velocities, positions and displacementDeltas are vector quantities + double * node2DVectorData; // Vector quantities in 2D in case quasi 2D-3D coupling is done + double * faceCenterData; + double * elementIPScalarData; + double * elementIPVectorData; // preCICE mesh name - char *couplingMeshName; + char * couplingMeshName; // preCICE data names - char *temperature; - char *flux; - char *kDeltaWrite; - char *kDeltaTemperatureWrite; - char *kDeltaRead; - char *kDeltaTemperatureRead; - char *displacements; - char *displacementDeltas; - char *positions; - char *velocities; - char *forces; - char *pressure; - char *rveIdData; - char *strainNormData; - char *strainShearData; - char *stressNormData; - char *stressShearData; - char *materialTangent1Data; - char *materialTangent2Data; - char *materialTangent3Data; - char *materialTangent4Data; - char *materialTangent5Data; - char *materialTangent6Data; - char *materialTangent7Data; + char * temperature; + char * flux; + char * kDeltaWrite; + char * kDeltaTemperatureWrite; + char * kDeltaRead; + char * kDeltaTemperatureRead; + char * displacements; + char * displacementsData; + char * displacementDeltas; + char * positions; + char * velocities; + char * forces; + char * pressure; + char * macroInputData; + char * strain1to3Data; + char * strain4to6Data; + char * stress1to3Data; + char * stress4to6Data; + char * materialTangent1Data; + char * materialTangent2Data; + char * materialTangent3Data; + char * materialTangent4Data; + char * materialTangent5Data; + char * materialTangent6Data; + char * materialTangent7Data; // Indices that indicate where to apply the boundary conditions / forces - int *xloadIndices; - int *xbounIndices; - int *xforcIndices; + int * xloadIndices; + int * xbounIndices; + int * xforcIndices; // Mapping type if nearest-projection mapping - int mapNPType; + int mapNPType; // Indicates if pseudo 2D-3D coupling is implemented - int quasi2D3D; + int quasi2D3D; int numReadData; int numWriteData; @@ -154,8 +158,9 @@ typedef struct SimulationData { ITG * mi; ITG * nea; // element bounds in each thread - start ITG * neb; // element bounds in each thread - end - double *eei; // Strain values - double *xstiff; // Strain values + double *eei; // Strain values for multiscale + double *stx; // Stress values for multiscale + double *xstiff; // Strain values for multiscale // Interfaces int numPreciceInterfaces; diff --git a/ccx_2.19.c b/ccx_2.19.c deleted file mode 100755 index 7ae806e4..00000000 --- a/ccx_2.19.c +++ /dev/null @@ -1,2228 +0,0 @@ -/* CalculiX - A 3-dimensional finite element program */ -/* Copyright (C) 1998-2021 Guido Dhondt */ - -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU General Public License as */ -/* published by the Free Software Foundation(version 2); */ -/* */ - -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU General Public License for more details. */ - -/* You should have received a copy of the GNU General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifdef __WIN32 -_set_output_format(_TWO_DIGIT_EXPONENT); -#endif - -#ifdef CALCULIX_MPI -#include -#endif - -#include -#include -#include -#include -#include "CalculiX.h" - -#ifdef CALCULIX_MPI -ITG myid = 0, nproc = 0; -#endif - -struct timespec totalCalculixTimeStart, totalCalculixTimeEnd; - -int main(int argc, char *argv[]) -{ - - FILE *f1; - - char *sideload = NULL, *set = NULL, *matname = NULL, *orname = NULL, *amname = NULL, - *filab = NULL, *lakon = NULL, *labmpc = NULL, *prlab = NULL, *prset = NULL, - jobnamec[792] = "", jobnamef[132] = "", output[5], *typeboun = NULL, - *inpc = NULL, *tieset = NULL, *cbody = NULL, fneig[132], *sideloadtemp = NULL, - kind1[2], kind2[2], *heading = NULL, *objectset = NULL; - - ITG *kon = NULL, *nodeboun = NULL, *ndirboun = NULL, *ipompc = NULL, - *nodempc = NULL, *nodeforc = NULL, *ndirforc = NULL, - *nelemload = NULL, im, *inodesd = NULL, nload1, *idefforc = NULL, - *nactdof = NULL, *icol = NULL, *ics = NULL, itempuser[3], - *jq = NULL, *mast1 = NULL, *irow = NULL, *rig = NULL, *idefbody = NULL, - *ikmpc = NULL, *ilmpc = NULL, *ikboun = NULL, *ilboun = NULL, - *nreorder = NULL, *ipointer = NULL, *idefload = NULL, - *istartset = NULL, *iendset = NULL, *ialset = NULL, *ielmat = NULL, - *ielorien = NULL, *nrhcon = NULL, *nodebounold = NULL, *ndirbounold = NULL, - *nelcon = NULL, *nalcon = NULL, *iamforc = NULL, *iamload = NULL, - *iamt1 = NULL, *namta = NULL, *ipkon = NULL, *iamboun = NULL, - *nplicon = NULL, *nplkcon = NULL, *inotr = NULL, *iponor = NULL, *knor = NULL, - *ikforc = NULL, *ilforc = NULL, *iponoel = NULL, *inoel = NULL, *nshcon = NULL, - *ncocon = NULL, *ibody = NULL, *ielprop = NULL, *islavsurf = NULL, - *ipoinpc = NULL, mt, nxstate, nload0, iload, *iuel = NULL, *ne2boun = NULL, - *irandomtype = NULL, irobustdesign[3], *iparentel = NULL, ifreebody, - *ipobody = NULL, inewton = 0, *iprfn = NULL, *konrfn = NULL; - - ITG nk, ne, nboun, nmpc, nforc, nload, nprint, nset, nalset, nentries = 18, - nmethod, neq[3], i, mpcfree, mei[4] = {0, 0, 0, 0}, j, nzl, nam, nbounold, - nforcold, nloadold, nbody, nbody_, nbodyold, network, nheading_, - k, nzs[3], nmpc_, nload_, nforc_, istep, istat, nboun_, nintpoint, - iperturb[2], nmat, ntmat_, norien, ithermal[2] = {0, 0}, nmpcold, - iprestr, kode, isolver, nslavs, nkon_, ne0, nkon0, mortar, - jout[2], nlabel, nkon, idrct, jmax[2], iexpl, nevtot, ifacecount, - iplas, npmat_, mi[3], ntrans, mpcend, namtot_, iumat, iheading, - icascade, maxlenmpc, mpcinfo[4], ne1d, ne2d, infree[4], - callfrommain, nflow, jin = 0, irstrt[2], nener, jrstrt, nenerold, - nline, *ipoinp = NULL, *inp = NULL, ntie, ntie_, mcs, nprop_, - nprop, itpamp, iviewfile, nkold, nevdamp_, npt_, cyclicsymmetry, - nmethodl, iaxial, inext, icontact, nobject, nobject_, iit, - nzsprevstep[3], memmpcref_, mpcfreeref, maxlenmpcref, *nodempcref = NULL, - *ikmpcref = NULL, isens, namtot, nstam, ndamp, nef, inp_size, - *ipoinp_sav = NULL, *inp_sav = NULL, irefineloop = 0, icoordinate = 0, - *nodedesi = NULL, ndesi = 0, nobjectstart = 0, nfc_, ndc_, nfc, ndc, *ikdc = NULL; - - ITG *meminset = NULL, *rmeminset = NULL; - - ITG nzs_, nk_, ne_, nset_ = 0, nalset_, nmat_, norien_, nam_, - ntrans_, ncs_, nstate_, ncmat_, memmpc_, nprint_, nuel_ = 0; - - double *co = NULL, *xboun = NULL, *coefmpc = NULL, *xforc = NULL, *clearini = NULL, - *xload = NULL, *xbounold = NULL, *xforcold = NULL, *randomval = NULL, - *vold = NULL, *sti = NULL, *xloadold = NULL, *xnor = NULL, - *reorder = NULL, *dcs = NULL, *thickn = NULL, *thicke = NULL, *offset = NULL, - *elcon = NULL, *rhcon = NULL, *alcon = NULL, *alzero = NULL, *t0 = NULL, *t1 = NULL, - *prestr = NULL, *orab = NULL, *amta = NULL, *veold = NULL, *accold = NULL, - *t1old = NULL, *eme = NULL, *plicon = NULL, *pslavsurf = NULL, *plkcon = NULL, - *xstate = NULL, *trab = NULL, *ener = NULL, *shcon = NULL, *cocon = NULL, - *cs = NULL, *tietol = NULL, *fmpc = NULL, *prop = NULL, *t0g = NULL, *t1g = NULL, - *xbody = NULL, *xbodyold = NULL, *coefmpcref = NULL, *dacon = NULL, *vel = NULL, - *velo = NULL, *veloo = NULL, energy[5], *ratiorfn = NULL, *dgdxglob = NULL, - *g0 = NULL, *xdesi = NULL, *coeffc = NULL, *edc = NULL; - - double ctrl[57]; - - double fei[3], *xmodal = NULL, timepar[5], alpha[2], ttime, qaold[2], physcon[14]; - - double totalCalculixTime; - - /* - * Additional variables for the coupling with preCICE - * preCICE is used only if a participant name is provided as a command line argument! - */ - char preciceParticipantName[256] = "", configFilename[256] = "config.yml"; - int preciceUsed = 0; - -#ifdef CALCULIX_MPI - MPI_Init(&argc, &argv); - MPI_Comm_rank(MPI_COMM_WORLD, &myid); - MPI_Comm_size(MPI_COMM_WORLD, &nproc); -#endif - - clock_gettime(CLOCK_MONOTONIC, &totalCalculixTimeStart); - - if (argc == 1) { - printf("Usage: CalculiX.exe -i jobname\n"); - FORTRAN(stop, ()); - } else { - for (i = 1; i < argc; i++) { - if (strcmp1(argv[i], "-i") == 0) { - strcpy(jobnamec, argv[i + 1]); - strcpy1(jobnamef, argv[i + 1], 132); - jin++; - break; - } - if (strcmp1(argv[i], "-v") == 0) { - printf("\nThis is Version 2.19\n\n"); - FORTRAN(stop, ()); - } - } - if (jin == 0) { - strcpy(jobnamec, argv[1]); - strcpy1(jobnamef, argv[1], 132); - } - - /* next lines deactivated on March 18, 2020 */ - - /* for(i=1;i= 0) { - - fflush(stdout); - - /* in order to reduce the number of variables to be transferred to - the subroutines, the max. field sizes are (for most fields) copied - into the real sizes */ - - nzs[1] = nzs_; - - if ((istep == 0) || (irstrt[0] < 0)) { - ne = ne_; - nset = nset_; - nalset = nalset_; - nmat = nmat_; - norien = norien_; - ntrans = ntrans_; - ntie = ntie_; - - /* allocating space before the first step */ - - /* coordinates and topology */ - - NNEW(co, double, 3 * nk_); - NNEW(kon, ITG, nkon_); - NNEW(ipkon, ITG, ne_); - NNEW(lakon, char, 8 * ne_); - - /* property cards */ - - if (nprop_ > 0) { - NNEW(ielprop, ITG, ne_); - for (i = 0; i < ne_; i++) - ielprop[i] = -1; - NNEW(prop, double, nprop_); - } - - /* fields for 1-D and 2-D elements */ - - if ((ne1d != 0) || (ne2d != 0)) { - NNEW(iponor, ITG, 2 * nkon_); - for (i = 0; i < 2 * nkon_; i++) - iponor[i] = -1; - NNEW(xnor, double, 36 * ne1d + 24 * ne2d); - NNEW(knor, ITG, 24 * (ne1d + ne2d) * (mi[2] + 1)); - NNEW(thickn, double, 2 * nk_); - NNEW(thicke, double, mi[2] * nkon_); - NNEW(offset, double, 2 * ne_); - NNEW(iponoel, ITG, nk_); - NNEW(inoel, ITG, 9 * ne1d + 24 * ne2d); - NNEW(rig, ITG, nk_); - NNEW(ne2boun, ITG, 2 * nk_); - if (infree[2] == 0) - infree[2] = 1; - } - - /* SPC's */ - - NNEW(nodeboun, ITG, nboun_); - NNEW(ndirboun, ITG, nboun_); - NNEW(typeboun, char, nboun_ + 1); - if ((istep == 0) || ((irstrt[0] < 0) && (nam_ > 0))) - NNEW(iamboun, ITG, nboun_); - NNEW(xboun, double, nboun_); - NNEW(ikboun, ITG, nboun_); - NNEW(ilboun, ITG, nboun_); - - /* MPC's */ - - NNEW(ipompc, ITG, nmpc_); - NNEW(nodempc, ITG, 3 * memmpc_); - for (i = 0; i < 3 * memmpc_; i += 3) { - nodempc[i + 2] = i / 3 + 2; - } - nodempc[3 * memmpc_ - 1] = 0; - NNEW(coefmpc, double, memmpc_); - NNEW(labmpc, char, 20 * nmpc_ + 1); - NNEW(ikmpc, ITG, nmpc_); - NNEW(ilmpc, ITG, nmpc_); - NNEW(fmpc, double, nmpc_); - - /* coupling, distributed */ - - if (nfc_ > 0) { - NNEW(coeffc, double, 7 * nfc_); - NNEW(ikdc, ITG, ndc_); - NNEW(edc, double, 12 * ndc_); - } - - /* nodal loads */ - - NNEW(nodeforc, ITG, 2 * nforc_); - NNEW(ndirforc, ITG, nforc_); - if ((istep == 0) || ((irstrt[0] < 0) && (nam_ > 0))) - NNEW(iamforc, ITG, nforc_); - NNEW(idefforc, ITG, nforc_); - NNEW(xforc, double, nforc_); - NNEW(ikforc, ITG, nforc_); - NNEW(ilforc, ITG, nforc_); - - /* distributed facial loads */ - - NNEW(nelemload, ITG, 2 * nload_); - if ((istep == 0) || ((irstrt[0] < 0) && (nam_ > 0))) - NNEW(iamload, ITG, 2 * nload_); - NNEW(idefload, ITG, nload_); - NNEW(sideload, char, 20 * nload_); - NNEW(xload, double, 2 * nload_); - - /* distributed volumetric loads */ - - NNEW(cbody, char, 81 * nbody_); - NNEW(idefbody, ITG, nbody_); - NNEW(ibody, ITG, 3 * nbody_); - NNEW(xbody, double, 7 * nbody_); - NNEW(xbodyold, double, 7 * nbody_); - - /* printing output */ - - NNEW(prlab, char, 6 * nprint_); - NNEW(prset, char, 81 * nprint_); - - /* set definitions */ - - RENEW(set, char, 81 * nset); - NNEW(istartset, ITG, nset); - DMEMSET(istartset, 0, nset, 1); - NNEW(iendset, ITG, nset); - NNEW(ialset, ITG, nalset); - - /* (hyper)elastic constants */ - - NNEW(elcon, double, (ncmat_ + 1) * ntmat_ * nmat); - NNEW(nelcon, ITG, 2 * nmat); - - /* density */ - - NNEW(rhcon, double, 2 * ntmat_ * nmat); - NNEW(nrhcon, ITG, nmat); - - /* damping */ - - if (ndamp > 0) { - NNEW(dacon, double, nmat); - } - - /* specific heat */ - - NNEW(shcon, double, 4 * ntmat_ * nmat); - NNEW(nshcon, ITG, nmat); - - /* thermal expansion coefficients */ - - NNEW(alcon, double, 7 * ntmat_ * nmat); - NNEW(nalcon, ITG, 2 * nmat); - NNEW(alzero, double, nmat); - - /* conductivity */ - - NNEW(cocon, double, 7 * ntmat_ * nmat); - NNEW(ncocon, ITG, 2 * nmat); - - /* isotropic and kinematic hardening coefficients*/ - - if (npmat_ > 0) { - NNEW(plicon, double, (2 * npmat_ + 1) * ntmat_ * nmat); - NNEW(nplicon, ITG, (ntmat_ + 1) * nmat); - NNEW(plkcon, double, (2 * npmat_ + 1) * ntmat_ * nmat); - NNEW(nplkcon, ITG, (ntmat_ + 1) * nmat); - } - - /* linear dynamic properties */ - - NNEW(xmodal, double, 11 + nevdamp_); - xmodal[10] = nevdamp_ + 0.5; - - /* internal state variables (nslavs is needed for restart - calculations) */ - - if (mortar != 1) { - NNEW(xstate, double, nstate_ *mi[0] * (ne + nslavs)); - nxstate = nstate_ * mi[0] * (ne + nslavs); - } else if (mortar == 1) { - NNEW(xstate, double, nstate_ *mi[0] * (ne + nintpoint)); - nxstate = nstate_ * mi[0] * (ne + nintpoint); - } - - /* material orientation */ - - if ((istep == 0) || ((irstrt[0] < 0) && (norien > 0))) { - NNEW(orname, char, 80 * norien); - NNEW(orab, double, 7 * norien); - NNEW(ielorien, ITG, mi[2] * ne_); - } - - /* transformations */ - - if ((istep == 0) || ((irstrt[0] < 0) && (ntrans > 0))) { - NNEW(trab, double, 7 * ntrans); - NNEW(inotr, ITG, 2 * nk_); - } - - /* amplitude definitions */ - - if ((istep == 0) || ((irstrt[0] < 0) && (nam_ > 0))) { - NNEW(amname, char, 80 * nam_); - NNEW(amta, double, 2 * namtot_); - NNEW(namta, ITG, 3 * nam_); - } - - if ((istep == 0) || ((irstrt[0] < 0) && (ithermal[0] > 0))) { - NNEW(t0, double, nk_); - NNEW(t1, double, nk_); - if ((ne1d != 0) || (ne2d != 0) || (nuel_ != 0)) { - NNEW(t0g, double, 2 * nk_); - NNEW(t1g, double, 2 * nk_); - } - } - - /* the number in next line is NOT 1.2357111317 -> points - to user input; instead it is a generic nonzero - initialization */ - - if (istep == 0) { - DMEMSET(t0, 0, nk_, 1.2357111319); - DMEMSET(t1, 0, nk_, 1.2357111319); - } - - if ((istep == 0) || ((irstrt[0] < 0) && (ithermal[0] > 0) && (nam_ > 0))) - NNEW(iamt1, ITG, nk_); - - if ((istep == 0) || ((irstrt[0] < 0) && (iprestr > 0))) - NNEW(prestr, double, 6 * mi[0] * ne_); - - NNEW(vold, double, mt *nk_); - NNEW(veold, double, mt *nk_); - - /* CFD-results */ - - NNEW(vel, double, 8 * nef); - NNEW(velo, double, 8 * nef); - NNEW(veloo, double, 8 * nef); - - NNEW(ielmat, ITG, mi[2] * ne_); - - NNEW(matname, char, 80 * nmat); - - NNEW(filab, char, 87 * nlabel); - - /* tied constraints */ - - if (ntie_ > 0) { - NNEW(tieset, char, 243 * ntie_); - NNEW(tietol, double, 4 * ntie_); - NNEW(cs, double, 17 * ntie_); - } - - /* objectives for sensitivity analysis */ - - if (nobject_ > 0) { - NNEW(nodedesi, ITG, nk_); - NNEW(dgdxglob, double, nobject_ * 2 * nk_); - NNEW(g0, double, nobject_); - NNEW(xdesi, double, 3 * nk_); - NNEW(objectset, char, 405 * nobject_); - for (i = 0; i < 405 * nobject_; i++) { - objectset[i] = ' '; - } - } - - /* temporary fields for cyclic symmetry calculations */ - - if ((ncs_ > 0) || (npt_ > 0)) { - if (2 * npt_ > 24 * ncs_) { - NNEW(ics, ITG, 2 * npt_); - } else { - NNEW(ics, ITG, 24 * ncs_); - } - if (npt_ > 30 * ncs_) { - NNEW(dcs, double, npt_); - } else { - NNEW(dcs, double, 30 * ncs_); - } - } - - /* slave faces */ - - NNEW(islavsurf, ITG, 2 * ifacecount + 2); - - /* robustdesign analysis */ - - if (irobustdesign[0] > 0) { - NNEW(irandomtype, ITG, nk_); - NNEW(randomval, double, 2 * nk_); - } - - } else { - - /* allocating and reallocating space for subsequent steps */ - - if ((nmethod != 4) && (nmethod != 5) && (nmethod != 8) && (nmethod != 9) && - ((abs(nmethod) != 1) || (iperturb[0] < 2))) { - NNEW(veold, double, mt *nk_); - } else { - RENEW(veold, double, mt *nk_); - DMEMSET(veold, mt * nk, mt * nk_, 0.); - } - RENEW(vold, double, mt *nk_); - DMEMSET(vold, mt * nk, mt * nk_, 0.); - - RENEW(nodeboun, ITG, nboun_); - RENEW(ndirboun, ITG, nboun_); - RENEW(typeboun, char, nboun_ + 1); - RENEW(xboun, double, nboun_); - RENEW(ikboun, ITG, nboun_); - RENEW(ilboun, ITG, nboun_); - - RENEW(nodeforc, ITG, 2 * nforc_); - RENEW(ndirforc, ITG, nforc_); - NNEW(idefforc, ITG, nforc_); - RENEW(xforc, double, nforc_); - RENEW(ikforc, ITG, nforc_); - RENEW(ilforc, ITG, nforc_); - - RENEW(nelemload, ITG, 2 * nload_); - NNEW(idefload, ITG, nload_); - RENEW(sideload, char, 20 * nload_); - RENEW(xload, double, 2 * nload_); - - RENEW(cbody, char, 81 * nbody_); - NNEW(idefbody, ITG, nbody_); - RENEW(ibody, ITG, 3 * nbody_); - RENEW(xbody, double, 7 * nbody_); - RENEW(xbodyold, double, 7 * nbody_); - for (i = 7 * nbodyold; i < 7 * nbody_; i++) - xbodyold[i] = 0; - - if (nam > 0) { - RENEW(iamforc, ITG, nforc_); - RENEW(iamload, ITG, 2 * nload_); - RENEW(iamboun, ITG, nboun_); - RENEW(amname, char, 80 * nam_); - RENEW(amta, double, 2 * namtot_); - RENEW(namta, ITG, 3 * nam_); - } - - RENEW(ipompc, ITG, nmpc_); - - RENEW(labmpc, char, 20 * nmpc_ + 1); - RENEW(ikmpc, ITG, nmpc_); - RENEW(ilmpc, ITG, nmpc_); - RENEW(fmpc, double, nmpc_); - - if (ntrans > 0) { - RENEW(inotr, ITG, 2 * nk_); - DMEMSET(inotr, 2 * nk, 2 * nk_, 0); - } - - RENEW(co, double, 3 * nk_); - DMEMSET(co, 3 * nk, 3 * nk_, 0.); - - if (ithermal[0] != 0) { - RENEW(t0, double, nk_); - DMEMSET(t0, nk, nk_, 0.); - RENEW(t1, double, nk_); - DMEMSET(t1, nk, nk_, 0.); - if ((ne1d != 0) || (ne2d != 0) || (nuel_ != 0)) { - RENEW(t0g, double, 2 * nk_); - DMEMSET(t0g, 2 * nk, 2 * nk_, 0.); - RENEW(t1g, double, 2 * nk_); - DMEMSET(t1g, 2 * nk, 2 * nk_, 0.); - } - if (nam > 0) { - RENEW(iamt1, ITG, nk_); - } - } - } - - /* allocation of fields in the restart file */ - - if (irstrt[0] < 0) { - NNEW(nodebounold, ITG, nboun_); - NNEW(ndirbounold, ITG, nboun_); - NNEW(xbounold, double, nboun_); - NNEW(xforcold, double, nforc_); - NNEW(xloadold, double, 2 * nload_); - if (ithermal[0] != 0) - NNEW(t1old, double, nk_); - NNEW(sti, double, 6 * mi[0] * ne); - NNEW(eme, double, 6 * mi[0] * ne); - if (nener == 1) - NNEW(ener, double, mi[0] * ne * 2); - if (mcs > ntie_) - RENEW(cs, double, 17 * mcs); - if (mortar == 1) { - NNEW(pslavsurf, double, 3 * nintpoint); - NNEW(clearini, double, 3 * 9 * ifacecount); - } - } - - nenerold = nener; - nkold = nk; - - /* opening the eigenvalue file and checking for cyclic symmetry */ - - strcpy(fneig, jobnamec); - strcat(fneig, ".eig"); - cyclicsymmetry = 0; - if ((f1 = fopen(fneig, "rb")) != NULL) { - if (fread(&cyclicsymmetry, sizeof(ITG), 1, f1) != 1) { - printf("*ERROR reading the information whether cyclic symmetry is involved in the eigenvalue file"); - exit(0); - } - fclose(f1); - } - - nmpcold = nmpc; - - /* reading the input file */ - - // if(istep==0)mortar=-2; - FORTRAN(calinput, (co, &nk, kon, ipkon, lakon, &nkon, &ne, nodeboun, ndirboun, xboun, - &nboun, ipompc, nodempc, coefmpc, &nmpc, &nmpc_, nodeforc, - ndirforc, xforc, &nforc, &nforc_, nelemload, sideload, xload, - &nload, &nload_, &nprint, prlab, prset, &mpcfree, &nboun_, mei, - set, istartset, iendset, ialset, &nset, &nalset, elcon, nelcon, - rhcon, nrhcon, alcon, nalcon, alzero, t0, t1, matname, ielmat, - orname, orab, ielorien, amname, amta, namta, &nam, &nmethod, - iamforc, iamload, iamt1, ithermal, iperturb, &istat, &istep, - &nmat, &ntmat_, &norien, prestr, &iprestr, &isolver, fei, veold, - timepar, xmodal, filab, jout, &nlabel, &idrct, jmax, &iexpl, - alpha, iamboun, plicon, nplicon, plkcon, nplkcon, &iplas, - &npmat_, mi, &nk_, trab, inotr, &ntrans, ikboun, ilboun, ikmpc, - ilmpc, ics, dcs, &ncs_, &namtot_, cs, &nstate_, &ncmat_, &iumat, - &mcs, labmpc, iponor, xnor, knor, thickn, thicke, ikforc, ilforc, - offset, iponoel, inoel, rig, infree, nshcon, shcon, cocon, - ncocon, physcon, &nflow, ctrl, &maxlenmpc, &ne1d, &ne2d, &nener, - vold, nodebounold, ndirbounold, xbounold, xforcold, xloadold, - t1old, eme, sti, ener, xstate, jobnamec, irstrt, &ttime, qaold, - output, typeboun, inpc, ipoinp, inp, tieset, tietol, &ntie, fmpc, - cbody, ibody, xbody, &nbody, &nbody_, xbodyold, &nam_, ielprop, - &nprop, &nprop_, prop, &itpamp, &iviewfile, ipoinpc, &nslavs, - t0g, t1g, &network, &cyclicsymmetry, idefforc, idefload, - idefbody, &mortar, &ifacecount, islavsurf, pslavsurf, - clearini, heading, &iaxial, &nobject, objectset, &nprint_, - iuel, &nuel_, nodempcref, coefmpcref, ikmpcref, &memmpcref_, - &mpcfreeref, &maxlenmpcref, &memmpc_, &isens, &namtot, &nstam, - dacon, vel, &nef, velo, veloo, ne2boun, itempuser, - irobustdesign, irandomtype, randomval, &nfc, &nfc_, coeffc, - ikdc, &ndc, &ndc_, edc)); - - SFREE(idefforc); - SFREE(idefload); - SFREE(idefbody); - - if (istat < 0) - break; - - /* assigning the body forces to the elements */ - - if (nbody > 0) { - ifreebody = ne + 1; - NNEW(ipobody, ITG, 2 * ifreebody * nbody); - for (k = 1; k <= nbody; k++) { - FORTRAN(bodyforce, (cbody, ibody, ipobody, &nbody, set, istartset, - iendset, ialset, &inewton, &nset, &ifreebody, &k)); - RENEW(ipobody, ITG, 2 * (ne + ifreebody)); - } - RENEW(ipobody, ITG, 2 * (ifreebody - 1)); - } - - if (irefineloop == 1) { - - /* in the last step refinement was requested and the mesh - was appropriately refined; this mesh has to be read */ - - readnewmesh(jobnamec, &nboun, nodeboun, iamboun, xboun, &nload, sideload, - iamload, &nforc, nodeforc, iamforc, xforc, ithermal, &nk, &t1, &iamt1, - &ne, &lakon, &ipkon, &kon, istartset, iendset, ialset, set, &nset, - filab, &co, &ipompc, &nodempc, &coefmpc, &nmpc, &nmpc_, &labmpc, - &mpcfree, &memmpc_, &ikmpc, &ilmpc, &nk_, &ne_, &nkon_, &istep, - &nprop_, &ielprop, &ne1d, &ne2d, &iponor, &thickn, &thicke, mi, - &offset, &iponoel, &rig, &ne2boun, &ielorien, &inotr, &t0, &t0g, &t1g, - &prestr, &vold, &veold, &ielmat, irobustdesign, &irandomtype, - &randomval, &nalset, &nalset_, &nkon, xnor, &iaxial, - &network, &nlabel, iuel, iperturb, &iprestr, &ntie, tieset, - &iparentel, ikboun, &ifreebody, &ipobody, &nbody, &iprfn, - &konrfn, &ratiorfn, nodempcref, coefmpcref, &memmpcref_, - &mpcfreeref, &maxlenmpcref, &maxlenmpc, &norien, tietol); - } - -#ifdef CALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT - for (i = 0; i != nmat; ++i) { - calculix_registerExternalBehaviour(matname + 80 * i); - } -#endif /* CALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT */ - - // if((istep==1)&&(mortar==-1)){mortar=0;}else{icontact=1;} - - nload0 = nload; - - if (iheading == 0) { - writeheading(jobnamec, heading, &nheading_); - iheading = 1; - } - - /* if(nheading_>=0){ - writeheading(jobnamec,heading,&nheading_); - SFREE(heading); - nheading_=-1; - }*/ - - if ((abs(nmethod) != 1) || (iperturb[0] < 2)) - icascade = 0; - - // FORTRAN(writeboun,(nodeboun,ndirboun,xboun,typeboun,&nboun)); - - if (istep == 1) { - - SFREE(iuel); - - /* tied contact constraints: generate appropriate MPC's */ - - tiedcontact(&ntie, tieset, &nset, set, istartset, iendset, ialset, - lakon, ipkon, kon, tietol, &nmpc, &mpcfree, &memmpc_, - &ipompc, &labmpc, &ikmpc, &ilmpc, &fmpc, &nodempc, &coefmpc, - ithermal, co, vold, &nef, &nmpc_, mi, &nk, &istep, ikboun, &nboun, - kind1, kind2); - - /* reallocating space in the first step */ - - /* allocating and initializing fields pointing to the previous step */ - - RENEW(vold, double, mt *nk); - NNEW(sti, double, 6 * mi[0] * ne); - - /* strains */ - - NNEW(eme, double, 6 * mi[0] * ne); - - /* residual stresses/strains */ - - if (iprestr == 1) { - RENEW(prestr, double, 6 * mi[0] * ne); - for (i = 0; i < ne; i++) { - for (j = 0; j < mi[0]; j++) { - for (k = 0; k < 6; k++) { - sti[6 * mi[0] * i + 6 * j + k] = prestr[6 * mi[0] * i + 6 * j + k]; - } - } - } - } else if (iprestr == 2) { - RENEW(prestr, double, 6 * mi[0] * ne); - for (i = 0; i < ne; i++) { - for (j = 0; j < mi[0]; j++) { - for (k = 0; k < 6; k++) { - eme[6 * mi[0] * i + 6 * j + k] = prestr[6 * mi[0] * i + 6 * j + k]; - } - } - } - } else { - SFREE(prestr); - } - - NNEW(nodebounold, ITG, nboun); - NNEW(ndirbounold, ITG, nboun); - NNEW(xbounold, double, nboun); - NNEW(xforcold, double, nforc); - NNEW(xloadold, double, 2 * nload); - - /* initial temperatures: store in the "old" boundary conditions */ - - if (ithermal[0] > 1) { - for (i = 0; i < nboun; i++) { - if (strcmp1(&typeboun[i], "F") == 0) - continue; - if (ndirboun[i] == 0) { - xbounold[i] = vold[mt * (nodeboun[i] - 1)]; - } - } - } - - /* initial temperatures: store in the "old" temperature field */ - - if (ithermal[0] != 0) { - NNEW(t1old, double, nk); - for (i = 0; i < nk; i++) - t1old[i] = t0[i]; - } - - /* element definition */ - - RENEW(kon, ITG, nkon); - RENEW(ipkon, ITG, ne); - RENEW(lakon, char, 8 * ne); - - /* property cards */ - - if (nprop_ > 0) { - RENEW(ielprop, ITG, ne); - RENEW(prop, double, nprop); - } else { - SFREE(ielprop); - SFREE(prop); - } - - /* coupling, distributed */ - - if (nfc > 0) { - RENEW(coeffc, double, 7 * nfc); - RENEW(ikdc, ITG, ndc); - RENEW(edc, double, 12 * ndc); - } else { - SFREE(coeffc); - SFREE(ikdc); - SFREE(edc); - } - - /* fields for 1-D and 2-D elements */ - - if ((ne1d != 0) || (ne2d != 0)) { - RENEW(iponor, ITG, 2 * nkon); - RENEW(xnor, double, infree[0]); - RENEW(knor, ITG, infree[1]); - SFREE(thickn); - RENEW(thicke, double, mi[2] * nkon); - RENEW(offset, double, 2 * ne); - RENEW(inoel, ITG, 3 * (infree[2] - 1)); - RENEW(iponoel, ITG, infree[3]); - RENEW(rig, ITG, infree[3]); - RENEW(ne2boun, ITG, 2 * infree[3]); - } - - /* set definitions */ - - RENEW(set, char, 81 * nset); - RENEW(istartset, ITG, nset); - RENEW(iendset, ITG, nset); - RENEW(ialset, ITG, nalset); - - /* material properties */ - - RENEW(elcon, double, (ncmat_ + 1) * ntmat_ * nmat); - RENEW(nelcon, ITG, 2 * nmat); - - RENEW(rhcon, double, 2 * ntmat_ * nmat); - RENEW(nrhcon, ITG, nmat); - - if (ndamp > 0) { - RENEW(dacon, double, nmat); - } - - RENEW(shcon, double, 4 * ntmat_ * nmat); - RENEW(nshcon, ITG, nmat); - - RENEW(cocon, double, 7 * ntmat_ * nmat); - RENEW(ncocon, ITG, 2 * nmat); - - RENEW(alcon, double, 7 * ntmat_ * nmat); - RENEW(nalcon, ITG, 2 * nmat); - RENEW(alzero, double, nmat); - - RENEW(matname, char, 80 * nmat); - RENEW(ielmat, ITG, mi[2] * ne); - - /* allocating space for the state variables */ - - if (mortar != 1) { - RENEW(xstate, double, nstate_ *mi[0] * (ne + nslavs)); - for (i = nxstate; i < nstate_ * mi[0] * (ne + nslavs); i++) { - xstate[i] = 0.; - } - } else if (mortar == 1) { - RENEW(xstate, double, nstate_ *mi[0] * (ne + nintpoint)); - for (i = nxstate; i < nstate_ * mi[0] * (ne + nintpoint); i++) { - xstate[i] = 0.; - } - } - - /* next statements for plastic materials and nonlinear springs */ - - if (npmat_ > 0) { - RENEW(plicon, double, (2 * npmat_ + 1) * ntmat_ * nmat); - RENEW(nplicon, ITG, (ntmat_ + 1) * nmat); - RENEW(plkcon, double, (2 * npmat_ + 1) * ntmat_ * nmat); - RENEW(nplkcon, ITG, (ntmat_ + 1) * nmat); - } - - /* material orientation */ - - if (norien > 0) { - RENEW(orname, char, 80 * norien); - RENEW(ielorien, ITG, mi[2] * ne); - RENEW(orab, double, 7 * norien); - } else { - SFREE(orname); - SFREE(ielorien); - SFREE(orab); - } - - /* amplitude definitions */ - - if (nam > 0) { - RENEW(amname, char, 80 * nam); - RENEW(namta, ITG, 3 * nam); - RENEW(amta, double, 2 * namta[3 * nam - 2]); - } else { - SFREE(amname); - SFREE(amta); - SFREE(namta); - SFREE(iamforc); - SFREE(iamload); - SFREE(iamboun); - } - - if (ntrans > 0) { - RENEW(trab, double, 7 * ntrans); - } else { - SFREE(trab); - SFREE(inotr); - } - - if (ithermal[0] == 0) { - SFREE(t0); - SFREE(t1); - if ((ne1d != 0) || (ne2d != 0) || (nuel_ != 0)) { - SFREE(t0g); - SFREE(t1g); - } - } - - if ((ithermal[0] == 0) || (nam <= 0)) { - SFREE(iamt1); - } - - if (ncs_ > 0) { - RENEW(ics, ITG, ncs_); - } else if (npt_ > 0) { - SFREE(ics); - } - if ((ncs_ > 0) || (npt_ > 0)) { - SFREE(dcs); - } - - if (mcs > 0) { - RENEW(cs, double, 17 * mcs); - } else { - SFREE(cs); - } - - /* check for design variables */ - - for (i = 0; i < ntie; i++) { - if (strcmp1(&tieset[i * 243 + 80], "D") == 0) { - if (strcmp1(&tieset[i * 243], "COORDINATE") == 0) { - icoordinate = 1; - } - } - } - - } else { - - /* reallocating space in all but the first step (>1) */ - - RENEW(vold, double, mt *nk); - - /* if the SPC boundary conditions were changed in the present step, - they have to be rematched with those in the last step. Removed SPC - boundary conditions do not appear any more (this is different from - forces and loads, where removed forces or loads are reset to zero; - a removed SPC constraint does not have a numerical value any more) */ - - NNEW(reorder, double, nboun); - NNEW(nreorder, ITG, nboun); - if (nbounold < nboun) { - RENEW(xbounold, double, nboun); - RENEW(nodebounold, ITG, nboun); - RENEW(ndirbounold, ITG, nboun); - } - FORTRAN(spcmatch, (xboun, nodeboun, ndirboun, &nboun, xbounold, nodebounold, - ndirbounold, &nbounold, ikboun, ilboun, vold, reorder, nreorder, - mi, typeboun)); - RENEW(xbounold, double, nboun); - RENEW(nodebounold, ITG, nboun); - RENEW(ndirbounold, ITG, nboun); - SFREE(reorder); - SFREE(nreorder); - - /* for additional forces or loads in the present step, the - corresponding slots in the force and load fields of the - previous steps are initialized */ - - RENEW(xforcold, double, nforc); - for (i = nforcold; i < nforc; i++) - xforcold[i] = 0; - - RENEW(xloadold, double, 2 * nload); - for (i = 2 * nloadold; i < 2 * nload; i++) - xloadold[i] = 0; - - if (ithermal[0] != 0) { - RENEW(t1old, double, nk); - } - - if (nam > 0) { - RENEW(amname, char, 80 * nam); - RENEW(namta, ITG, 3 * nam); - RENEW(amta, double, 2 * namta[3 * nam - 2]); - } - } - - /* reallocating fields for all steps (>=1) */ - - RENEW(co, double, 3 * nk); - - RENEW(nodeboun, ITG, nboun); - RENEW(ndirboun, ITG, nboun); - RENEW(typeboun, char, nboun + 1); - RENEW(xboun, double, nboun); - RENEW(ikboun, ITG, nboun); - RENEW(ilboun, ITG, nboun); - - RENEW(nodeforc, ITG, 2 * nforc); - RENEW(ndirforc, ITG, nforc); - RENEW(xforc, double, nforc); - RENEW(ikforc, ITG, nforc); - RENEW(ilforc, ITG, nforc); - - /* temperature loading */ - - if (ithermal[0] != 0) { - RENEW(t0, double, nk); - RENEW(t1, double, nk); - if ((ne1d != 0) || (ne2d != 0) || (nuel_ != 0)) { - RENEW(t0g, double, 2 * nk); - RENEW(t1g, double, 2 * nk); - } - if (nam > 0) { - RENEW(iamt1, ITG, nk); - } - } - - RENEW(nelemload, ITG, 2 * nload); - RENEW(sideload, char, 20 * nload); - RENEW(xload, double, 2 * nload); - - RENEW(cbody, char, 81 * nbody); - RENEW(ibody, ITG, 3 * nbody); - RENEW(xbody, double, 7 * nbody); - RENEW(xbodyold, double, 7 * nbody); - - RENEW(ipompc, ITG, nmpc); - RENEW(labmpc, char, 20 * nmpc + 1); - RENEW(ikmpc, ITG, nmpc); - RENEW(ilmpc, ITG, nmpc); - RENEW(fmpc, double, nmpc); - - /* energy */ - - if ((nener == 1) && (nenerold == 0)) { - NNEW(ener, double, mi[0] * ne * 2); - if ((istep > 1) && (iperturb[0] > 1)) { - printf(" *ERROR in CalculiX: in nonlinear calculations\n"); - printf(" energy output must be selected in the first step\n\n"); - FORTRAN(stop, ()); - } - } - - /* initial velocities and accelerations */ - - if ((nmethod == 4) || (nmethod == 5) || (nmethod == 8) || (nmethod == 9) || - ((abs(nmethod) == 1) && (iperturb[0] >= 2))) { - RENEW(veold, double, mt *nk); - } else { - SFREE(veold); - } - - if ((nmethod == 4) && (iperturb[0] > 1)) { - NNEW(accold, double, mt *nk); - } - - if (nam > 0) { - RENEW(iamforc, ITG, nforc); - RENEW(iamload, ITG, 2 * nload); - RENEW(iamboun, ITG, nboun); - } - - /* generate force convection elements */ - - if (network > 0) { - ne0 = ne; - nkon0 = nkon; - nload1 = nload; - RENEW(ipkon, ITG, ne + nload); - RENEW(ielmat, ITG, mi[2] * (ne + nload)); - for (i = mi[2] * ne; i < mi[2] * (ne + nload); i++) - ielmat[i] = 0; - if (norien > 0) { - RENEW(ielorien, ITG, mi[2] * (ne + nload)); - for (i = mi[2] * ne; i < mi[2] * (ne + nload); i++) - ielorien[i] = 0; - } - RENEW(lakon, char, 8 * (ne + nload)); - RENEW(kon, ITG, nkon + 9 * nload); - NNEW(inodesd, ITG, nk); - RENEW(nelemload, ITG, 4 * nload); - RENEW(sideload, char, 40 * nload); - - FORTRAN(genadvecelem, (inodesd, ipkon, &ne, lakon, kon, &nload, - sideload, nelemload, &nkon, &network)); - - SFREE(inodesd); - RENEW(ipkon, ITG, ne); - RENEW(lakon, char, 8 * ne); - RENEW(kon, ITG, nkon); - RENEW(sti, double, 6 * mi[0] * ne); - RENEW(eme, double, 6 * mi[0] * ne); - if (iprestr > 0) - RENEW(prestr, double, 6 * mi[0] * ne); - if (nprop > 0) - RENEW(ielprop, ITG, ne); - if ((ne1d != 0) || (ne2d != 0)) - RENEW(offset, double, 2 * ne); - RENEW(nelemload, ITG, 2 * nload); - RENEW(sideload, char, 20 * nload); - RENEW(xload, double, 2 * nload); - RENEW(xloadold, double, 2 * nload); - if (nam > 0) { - RENEW(iamload, ITG, 2 * nload); - for (i = 2 * nload1; i < 2 * nload; i++) - iamload[i] = 0; - } - if (nener == 1) - RENEW(ener, double, mi[0] * ne * 2); - if (norien > 0) - RENEW(ielorien, ITG, mi[2] * ne); - RENEW(ielmat, ITG, mi[2] * ne); - for (i = mi[2] * ne0; i < mi[2] * ne; i++) - ielmat[i] = 1; - } - - if (ntrans > 0) { - RENEW(inotr, ITG, 2 * nk); - } - - /* calling the user routine ufaceload (can be empty) */ - - if (ithermal[1] >= 2) { - NNEW(sideloadtemp, char, 20 * nload); - for (i = 0; i < nload; i++) { - strcpy1(&sideloadtemp[20 * i], &sideload[20 * i], 20); - if ((strcmp1(&sideload[20 * i], " ") == 0) && - (strcmp1(&sideload[20 * i + 1], " ") != 0)) { - strcpy1(&sideloadtemp[20 * i], "F", 1); - } - } - FORTRAN(ufaceload, (co, ipkon, kon, lakon, &nboun, nodeboun, - nelemload, sideloadtemp, &nload, &ne, &nk)); - SFREE(sideloadtemp); - } - - /* storing the undecascaded MPC's if needed (triggered by - mpcfreeref=-1); this is the case: - 1) in the first step always - 2) in any subsequent step in which the MPC's were changed by - the user in the input deck */ - - if (mpcfreeref == -1) { - if (istep > 1) { - SFREE(nodempcref); - SFREE(coefmpcref); - SFREE(ikmpcref); - } - memmpcref_ = memmpc_; - mpcfreeref = mpcfree; - maxlenmpcref = maxlenmpc; - NNEW(nodempcref, ITG, 3 * memmpc_); - memcpy(nodempcref, nodempc, sizeof(ITG) * 3 * memmpc_); - NNEW(coefmpcref, double, memmpc_); - memcpy(coefmpcref, coefmpc, sizeof(double) * memmpc_); - NNEW(ikmpcref, ITG, nmpc); - memcpy(ikmpcref, ikmpc, sizeof(ITG) * nmpc); - } - - /* decascading MPC's only necessary if MPC's changed */ - - if (((istep == 1) || (ntrans > 0) || (mpcend < 0) || (nk != nkold) || (nmpc != nmpcold)) && (icascade == 0)) { - - /* decascading the MPC's */ - - printf(" Decascading the MPC's\n\n"); - - callfrommain = 1; - cascade(ipompc, &coefmpc, &nodempc, &nmpc, - &mpcfree, nodeboun, ndirboun, &nboun, ikmpc, - ilmpc, ikboun, ilboun, &mpcend, - labmpc, &nk, &memmpc_, &icascade, &maxlenmpc, - &callfrommain, iperturb, ithermal); - } - - /* determining the matrix structure: changes if SPC's have changed */ - - if ((icascade == 0) && (nmethod < 8)) - printf(" Determining the structure of the matrix:\n"); - - NNEW(nactdof, ITG, mt * nk); - NNEW(mast1, ITG, nzs[1]); - NNEW(irow, ITG, 1); - - if ((mcs == 0) || (cs[1] < 0)) { - - NNEW(icol, ITG, mt * nk); - NNEW(jq, ITG, mt * nk + 1); - NNEW(ipointer, ITG, mt * nk); - - if ((icascade == 0) && ((nmethod < 8) || (nmethod > 10))) { - if ((nmethod == 11) || (nmethod == 13)) { - nmethodl = 2; - } else { - nmethodl = nmethod; - } - mastruct(&nk, kon, ipkon, lakon, &ne, nodeboun, ndirboun, &nboun, ipompc, - nodempc, &nmpc, nactdof, icol, jq, &mast1, &irow, &isolver, neq, - ikmpc, ilmpc, ipointer, nzs, &nmethodl, ithermal, - ikboun, ilboun, iperturb, mi, &mortar, typeboun, labmpc, - &iit, &icascade, &network, &iexpl); - } else { - neq[0] = 1; - neq[1] = 1; - neq[2] = 1; - } - } else { - - NNEW(icol, ITG, 8 * nk); - NNEW(jq, ITG, 8 * nk + 1); - NNEW(ipointer, ITG, 8 * nk); - - if (nmethod == 13) { - nmethodl = 2; - } else { - nmethodl = nmethod; - } - mastructcs(&nk, kon, ipkon, lakon, &ne, nodeboun, ndirboun, &nboun, - ipompc, nodempc, &nmpc, nactdof, icol, jq, &mast1, &irow, &isolver, - neq, ikmpc, ilmpc, ipointer, nzs, &nmethodl, - ics, cs, labmpc, &mcs, mi, &mortar); - } - - SFREE(ipointer); - SFREE(mast1); - if ((icascade == 0) && (nmethod < 8)) - RENEW(irow, ITG, nzs[2]); - - /* nmethod=1: static analysis */ - /* nmethod=2: frequency analysis */ - /* nmethod=3: buckling analysis */ - /* nmethod=4: (linear or nonlinear) dynamic analysis */ - /* nmethod=5: steady state dynamics analysis */ - /* nmethod=6: Coriolis frequency calculation */ - /* nmethod=7: flutter frequency calculation */ - /* nmethod=8: magnetostatics */ - /* nmethod=9: magnetodynamics */ - /* nmethod=10: electromagnetic eigenvalue problems */ - /* nmethod=11: superelement creation */ - /* nmethod=12: sensitivity analysis */ - /* nmethod=13: Green function calculation */ - /* nmethod=14: Robustness w.r.t. to geometric tolerances */ - /* nmethod=15: Crack propagation */ - /* nmethod=16: Feasible direction based on sensitivity information */ - if (preciceUsed) { - int isStaticOrDynamic = (nmethod == 1) || (nmethod == 4); - int isDynamic = nmethod == 4; - int isThermalAnalysis = ithermal[0] >= 2; - - if (isStaticOrDynamic && isThermalAnalysis) { - - printf("Starting CHT analysis via preCICE...\n"); - - mpcinfo[0] = memmpc_; - mpcinfo[1] = mpcfree; - mpcinfo[2] = icascade; - mpcinfo[3] = maxlenmpc; - - - nonlingeo_precice(&co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, &nboun, - &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, ndirforc, xforc, - &nforc, &nelemload, &sideload, xload, &nload, - nactdof, &icol, jq, &irow, neq, &nzl, &nmethod, &ikmpc, - &ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, - alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, - t0, t1, t1old, ithermal, prestr, &iprestr, - &vold, iperturb, sti, nzs, &kode, filab, &idrct, jmax, - jout, timepar, eme, xbounold, xforcold, xloadold, - veold, accold, amname, amta, namta, - &nam, iamforc, &iamload, iamt1, alpha, - &iexpl, iamboun, plicon, nplicon, plkcon, nplkcon, - &xstate, &npmat_, &istep, &ttime, matname, qaold, mi, - &isolver, &ncmat_, &nstate_, &iumat, cs, &mcs, &nkon, &ener, - mpcinfo, output, - shcon, nshcon, cocon, ncocon, physcon, &nflow, ctrl, - set, &nset, istartset, iendset, ialset, &nprint, prlab, - prset, &nener, ikforc, ilforc, trab, inotr, &ntrans, &fmpc, - cbody, ibody, xbody, &nbody, xbodyold, ielprop, prop, - &ntie, tieset, &itpamp, &iviewfile, jobnamec, tietol, &nslavs, thicke, - ics, &nintpoint, &mortar, - &ifacecount, typeboun, &islavsurf, &pslavsurf, &clearini, &nmat, - xmodal, &iaxial, &inext, &nprop, &network, orname, vel, &nef, - velo, veloo, energy, itempuser, - /* New args from 2.19 */ - &ipobody, &inewton, &t0g, &t1g, &ifreebody, - /* PreCICE args */ - preciceParticipantName, configFilename); - - memmpc_ = mpcinfo[0]; - mpcfree = mpcinfo[1]; - icascade = mpcinfo[2]; - maxlenmpc = mpcinfo[3]; - - } else if (isDynamic && !isThermalAnalysis) { - - printf("Starting FSI analysis via preCICE"); - - if (iperturb[1] == 0) { - printf(" using the geometrically linear CalculiX solver...\n"); - - mpcinfo[0] = memmpc_; - mpcinfo[1] = mpcfree; - mpcinfo[2] = icascade; - mpcinfo[3] = maxlenmpc; - - nonlingeo_precice(&co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, &nboun, - &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, ndirforc, xforc, - &nforc, &nelemload, &sideload, xload, &nload, - nactdof, &icol, jq, &irow, neq, &nzl, &nmethod, &ikmpc, - &ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, - alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, - t0, t1, t1old, ithermal, prestr, &iprestr, - &vold, iperturb, sti, nzs, &kode, filab, &idrct, jmax, - jout, timepar, eme, xbounold, xforcold, xloadold, - veold, accold, amname, amta, namta, - &nam, iamforc, &iamload, iamt1, alpha, - &iexpl, iamboun, plicon, nplicon, plkcon, nplkcon, - &xstate, &npmat_, &istep, &ttime, matname, qaold, mi, - &isolver, &ncmat_, &nstate_, &iumat, cs, &mcs, &nkon, &ener, - mpcinfo, output, - shcon, nshcon, cocon, ncocon, physcon, &nflow, ctrl, - set, &nset, istartset, iendset, ialset, &nprint, prlab, - prset, &nener, ikforc, ilforc, trab, inotr, &ntrans, &fmpc, - cbody, ibody, xbody, &nbody, xbodyold, ielprop, prop, - &ntie, tieset, &itpamp, &iviewfile, jobnamec, tietol, &nslavs, thicke, - ics, &nintpoint, &mortar, - &ifacecount, typeboun, &islavsurf, &pslavsurf, &clearini, &nmat, - xmodal, &iaxial, &inext, &nprop, &network, orname, vel, &nef, - velo, veloo, energy, itempuser, - /* New args from 2.19 */ - &ipobody, &inewton, &t0g, &t1g, &ifreebody, - /* PreCICE args */ - preciceParticipantName, configFilename); - - memmpc_ = mpcinfo[0]; - mpcfree = mpcinfo[1]; - icascade = mpcinfo[2]; - maxlenmpc = mpcinfo[3]; - } else if (iperturb[1] == 1) { - printf(" using the geometrically non-linear CalculiX solver...\n"); - - mpcinfo[0] = memmpc_; - mpcinfo[1] = mpcfree; - mpcinfo[2] = icascade; - mpcinfo[3] = maxlenmpc; - - nonlingeo_precice(&co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, &nboun, - &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, ndirforc, xforc, - &nforc, &nelemload, &sideload, xload, &nload, - nactdof, &icol, jq, &irow, neq, &nzl, &nmethod, &ikmpc, - &ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, - alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, - t0, t1, t1old, ithermal, prestr, &iprestr, - &vold, iperturb, sti, nzs, &kode, filab, &idrct, jmax, - jout, timepar, eme, xbounold, xforcold, xloadold, - veold, accold, amname, amta, namta, - &nam, iamforc, &iamload, iamt1, alpha, - &iexpl, iamboun, plicon, nplicon, plkcon, nplkcon, - &xstate, &npmat_, &istep, &ttime, matname, qaold, mi, - &isolver, &ncmat_, &nstate_, &iumat, cs, &mcs, &nkon, &ener, - mpcinfo, output, - shcon, nshcon, cocon, ncocon, physcon, &nflow, ctrl, - set, &nset, istartset, iendset, ialset, &nprint, prlab, - prset, &nener, ikforc, ilforc, trab, inotr, &ntrans, &fmpc, - cbody, ibody, xbody, &nbody, xbodyold, ielprop, prop, - &ntie, tieset, &itpamp, &iviewfile, jobnamec, tietol, &nslavs, thicke, - ics, &nintpoint, &mortar, - &ifacecount, typeboun, &islavsurf, &pslavsurf, &clearini, &nmat, - xmodal, &iaxial, &inext, &nprop, &network, orname, vel, &nef, - velo, veloo, energy, itempuser, - /* New args from 2.19 */ - &ipobody, &inewton, &t0g, &t1g, &ifreebody, - /* PreCICE args */ - preciceParticipantName, configFilename); - - memmpc_ = mpcinfo[0]; - mpcfree = mpcinfo[1]; - icascade = mpcinfo[2]; - maxlenmpc = mpcinfo[3]; - } else { - printf("ERROR: This simulation type is not available with preCICE"); - exit(0); - } - } - - else if (isStaticOrDynamic) { - - mpcinfo[0] = memmpc_; - mpcinfo[1] = mpcfree; - mpcinfo[2] = icascade; - mpcinfo[3] = maxlenmpc; - - if (icascade != 0) { - printf(" *ERROR in CalculiX: the matrix structure may"); - printf(" change due to nonlinear equations;"); - printf(" a purely linear calculation is not"); - printf(" feasible; use NLGEOM on the *STEP card."); - FORTRAN(stop, ()); - } - - printf("Starting Multiscale Linear Static Analysis via preCICE...\n"); - - linstatic_precice(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, - &nboun, - ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, ndirforc, xforc, - &nforc, nelemload, sideload, xload, &nload, - nactdof, &icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, - ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, - alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, - t0, t1, t1old, ithermal, prestr, &iprestr, vold, iperturb, sti, nzs, - &kode, filab, eme, &iexpl, plicon, - nplicon, plkcon, nplkcon, &xstate, &npmat_, matname, - &isolver, mi, &ncmat_, &nstate_, cs, &mcs, &nkon, &ener, - xbounold, xforcold, xloadold, amname, amta, namta, - &nam, iamforc, iamload, iamt1, iamboun, &ttime, - output, set, &nset, istartset, iendset, ialset, &nprint, prlab, - prset, &nener, trab, inotr, &ntrans, fmpc, ipobody, ibody, xbody, - &nbody, - xbodyold, timepar, thicke, jobnamec, tieset, &ntie, &istep, &nmat, - ielprop, prop, typeboun, &mortar, mpcinfo, tietol, ics, - orname, itempuser, t0g, t1g, - /* PreCICE args */ - preciceParticipantName, configFilename); - - for (i = 0; i < 3; i++) { - nzsprevstep[i] = nzs[i]; - } - - memmpc_ = mpcinfo[0]; - mpcfree = mpcinfo[1]; - icascade = mpcinfo[2]; - maxlenmpc = mpcinfo[3]; - - } - - else { - printf("ERROR: Only thermal coupling or FSI is available with preCICE"); - exit(0); - } - } else if ((nmethod <= 1) || (nmethod == 11) || ((iperturb[0] > 1) && (nmethod < 8))) { - if (iperturb[0] < 2) { - - mpcinfo[0] = memmpc_; - mpcinfo[1] = mpcfree; - mpcinfo[2] = icascade; - mpcinfo[3] = maxlenmpc; - - if (icascade != 0) { - printf(" *ERROR in CalculiX: the matrix structure may"); - printf(" change due to nonlinear equations;"); - printf(" a purely linear calculation is not"); - printf(" feasible; use NLGEOM on the *STEP card."); - FORTRAN(stop, ()); - } - - linstatic(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, - &nboun, - ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, ndirforc, xforc, - &nforc, nelemload, sideload, xload, &nload, - nactdof, &icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, - ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, - alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, - t0, t1, t1old, ithermal, prestr, &iprestr, vold, iperturb, sti, nzs, - &kode, filab, eme, &iexpl, plicon, - nplicon, plkcon, nplkcon, &xstate, &npmat_, matname, - &isolver, mi, &ncmat_, &nstate_, cs, &mcs, &nkon, &ener, - xbounold, xforcold, xloadold, amname, amta, namta, - &nam, iamforc, iamload, iamt1, iamboun, &ttime, - output, set, &nset, istartset, iendset, ialset, &nprint, prlab, - prset, &nener, trab, inotr, &ntrans, fmpc, ipobody, ibody, xbody, - &nbody, - xbodyold, timepar, thicke, jobnamec, tieset, &ntie, &istep, &nmat, - ielprop, prop, typeboun, &mortar, mpcinfo, tietol, ics, - orname, itempuser, t0g, t1g); - - for (i = 0; i < 3; i++) { - nzsprevstep[i] = nzs[i]; - } - - memmpc_ = mpcinfo[0]; - mpcfree = mpcinfo[1]; - icascade = mpcinfo[2]; - maxlenmpc = mpcinfo[3]; - - } - - else { - - mpcinfo[0] = memmpc_; - mpcinfo[1] = mpcfree; - mpcinfo[2] = icascade; - mpcinfo[3] = maxlenmpc; - - nonlingeo(&co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, - &nboun, &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, - ndirforc, xforc, &nforc, &nelemload, &sideload, xload, &nload, - nactdof, &icol, jq, &irow, neq, &nzl, &nmethod, &ikmpc, &ilmpc, - ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, alcon, nalcon, - alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, t0, t1, t1old, - ithermal, prestr, &iprestr, &vold, iperturb, sti, nzs, &kode, - filab, &idrct, jmax, jout, timepar, eme, xbounold, xforcold, - xloadold, veold, accold, amname, amta, namta, &nam, iamforc, - &iamload, iamt1, alpha, &iexpl, iamboun, plicon, nplicon, plkcon, - nplkcon, &xstate, &npmat_, &istep, &ttime, matname, qaold, mi, - &isolver, &ncmat_, &nstate_, &iumat, cs, &mcs, &nkon, &ener, - mpcinfo, output, shcon, nshcon, cocon, ncocon, physcon, &nflow, - ctrl, set, &nset, istartset, iendset, ialset, &nprint, prlab, - prset, &nener, ikforc, ilforc, trab, inotr, &ntrans, &fmpc, cbody, - ibody, xbody, &nbody, xbodyold, ielprop, prop, &ntie, tieset, - &itpamp, &iviewfile, jobnamec, tietol, &nslavs, thicke, ics, - &nintpoint, &mortar, &ifacecount, typeboun, &islavsurf, - &pslavsurf, &clearini, &nmat, xmodal, &iaxial, &inext, &nprop, - &network, orname, vel, &nef, velo, veloo, energy, itempuser, - ipobody, &inewton, t0g, t1g, &ifreebody); - - memmpc_ = mpcinfo[0]; - mpcfree = mpcinfo[1]; - icascade = mpcinfo[2]; - maxlenmpc = mpcinfo[3]; - - for (i = 0; i < 3; i++) { - nzsprevstep[i] = nzs[i]; - } - } - } else if ((nmethod == 2) || (nmethod == 13)) { - - /* FREQUENCY ANALYSIS */ - - if ((mcs == 0) || (cs[1] < 0)) { -#ifdef ARPACK - - mpcinfo[0] = memmpc_; - mpcinfo[1] = mpcfree; - mpcinfo[2] = icascade; - mpcinfo[3] = maxlenmpc; - - arpack(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, &nboun, - ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, ndirforc, xforc, - &nforc, nelemload, sideload, xload, &nload, - nactdof, icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, - ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, - shcon, nshcon, cocon, ncocon, - alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, - t0, t1, t1old, ithermal, prestr, &iprestr, vold, iperturb, sti, nzs, - &kode, mei, fei, filab, - &iexpl, plicon, nplicon, plkcon, nplkcon, - &xstate, &npmat_, matname, mi, &ncmat_, &nstate_, &ener, jobnamec, - output, set, &nset, istartset, iendset, ialset, &nprint, prlab, - prset, &nener, &isolver, trab, inotr, &ntrans, &ttime, fmpc, ipobody, - ibody, xbody, &nbody, thicke, &nslavs, tietol, &nkon, mpcinfo, - &ntie, &istep, &mcs, ics, tieset, cs, &nintpoint, &mortar, &ifacecount, - &islavsurf, &pslavsurf, &clearini, &nmat, typeboun, ielprop, prop, - orname, &inewton, t0g, t1g); - - memmpc_ = mpcinfo[0]; - mpcfree = mpcinfo[1]; - icascade = mpcinfo[2]; - maxlenmpc = mpcinfo[3]; - - for (i = 0; i < 3; i++) { - nzsprevstep[i] = nzs[i]; - } - -#else - printf("*ERROR in CalculiX: the ARPACK library is not linked\n\n"); - FORTRAN(stop, ()); -#endif - - } else { - -#ifdef ARPACK - - mpcinfo[0] = memmpc_; - mpcinfo[1] = mpcfree; - mpcinfo[2] = icascade; - mpcinfo[3] = maxlenmpc; - - arpackcs(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, - xboun, &nboun, - ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, ndirforc, xforc, - &nforc, nelemload, sideload, xload, &nload, - nactdof, icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, - ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, - alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, - t0, t1, t1old, ithermal, prestr, &iprestr, - vold, iperturb, sti, nzs, &kode, mei, fei, filab, - &iexpl, plicon, nplicon, plkcon, nplkcon, - &xstate, &npmat_, matname, mi, ics, cs, &mpcend, &ncmat_, - &nstate_, &mcs, &nkon, jobnamec, output, set, &nset, istartset, - iendset, ialset, &nprint, prlab, - prset, &nener, &isolver, trab, inotr, &ntrans, &ttime, fmpc, ipobody, - ibody, xbody, &nbody, &nevtot, thicke, &nslavs, tietol, mpcinfo, - &ntie, &istep, tieset, &nintpoint, &mortar, &ifacecount, &islavsurf, - &pslavsurf, &clearini, &nmat, typeboun, ielprop, prop, orname, - &inewton, t0g, t1g); - - memmpc_ = mpcinfo[0]; - mpcfree = mpcinfo[1]; - icascade = mpcinfo[2]; - maxlenmpc = mpcinfo[3]; - - for (i = 0; i < 3; i++) { - nzsprevstep[i] = nzs[i]; - } - -#else - printf("*ERROR in CalculiX: the ARPACK library is not linked\n\n"); - FORTRAN(stop, ()); -#endif - } - } else if (nmethod == 3) { - -#ifdef ARPACK - arpackbu(co, &nk, kon, ipkon, lakon, &ne, nodeboun, ndirboun, xboun, &nboun, - ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, ndirforc, xforc, - &nforc, - nelemload, sideload, xload, &nload, - nactdof, icol, jq, irow, neq, &nzl, &nmethod, ikmpc, - ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, - alcon, nalcon, alzero, ielmat, ielorien, &norien, orab, &ntmat_, - t0, t1, t1old, ithermal, prestr, &iprestr, - vold, iperturb, sti, nzs, &kode, mei, fei, filab, - eme, &iexpl, plicon, nplicon, plkcon, nplkcon, - xstate, &npmat_, matname, mi, &ncmat_, &nstate_, ener, output, - set, &nset, istartset, iendset, ialset, &nprint, prlab, - prset, &nener, &isolver, trab, inotr, &ntrans, &ttime, fmpc, ipobody, - ibody, xbody, &nbody, thicke, jobnamec, &nmat, ielprop, prop, - orname, typeboun, t0g, t1g); -#else - printf("*ERROR in CalculiX: the ARPACK library is not linked\n\n"); - FORTRAN(stop, ()); -#endif - } else if (nmethod == 4) { - if ((ne1d != 0) || (ne2d != 0)) { - printf(" *WARNING: 1-D or 2-D elements may cause problems in modal dynamic calculations\n"); - printf(" ensure that point loads defined in a *MODAL DYNAMIC step\n"); - printf(" and applied to nodes belonging to 1-D or 2-D elements have been\n"); - printf(" applied to the same nodes in the preceding FREQUENCY step with\n"); - printf(" magnitude zero; look at example shellf.inp for a guideline.\n\n"); - } - - printf(" Composing the dynamic response from the eigenmodes\n\n"); - - dyna(&co, &nk, &kon, &ipkon, &lakon, &ne, &nodeboun, &ndirboun, &xboun, &nboun, - &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, ndirforc, xforc, - &nforc, - nelemload, sideload, xload, &nload, - &nactdof, neq, &nzl, icol, irow, &nmethod, &ikmpc, &ilmpc, &ikboun, &ilboun, - elcon, nelcon, rhcon, nrhcon, cocon, ncocon, - alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, &t0, - &t1, ithermal, prestr, &iprestr, &vold, iperturb, &sti, nzs, - timepar, xmodal, &veold, amname, amta, - namta, &nam, iamforc, iamload, &iamt1, - jout, &kode, filab, &eme, xforcold, xloadold, - &t1old, &iamboun, &xbounold, &iexpl, plicon, - nplicon, plkcon, nplkcon, &xstate, &npmat_, matname, - mi, &ncmat_, &nstate_, &ener, jobnamec, &ttime, set, &nset, - istartset, iendset, &ialset, &nprint, prlab, - prset, &nener, trab, &inotr, &ntrans, &fmpc, ipobody, ibody, xbody, &nbody, - xbodyold, &istep, &isolver, jq, output, &mcs, &nkon, &mpcend, ics, cs, - &ntie, tieset, &idrct, jmax, ctrl, &itpamp, tietol, &nalset, - ikforc, ilforc, thicke, &nslavs, &nmat, typeboun, ielprop, prop, orname, - t0g, t1g); - } else if (nmethod == 5) { - if ((ne1d != 0) || (ne2d != 0)) { - printf(" *WARNING: 1-D or 2-D elements may cause problems in steady state calculations\n"); - printf(" ensure that point loads defined in a *STEADY STATE DYNAMICS step\n"); - printf(" and applied to nodes belonging to 1-D or 2-D elements have been\n"); - printf(" applied to the same nodes in the preceding FREQUENCY step with\n"); - printf(" magnitude zero; look at example shellf.inp for a guideline.\n\n"); - } - - printf(" Composing the steady state response from the eigenmodes\n\n"); - - steadystate(&co, &nk, &kon, &ipkon, &lakon, &ne, &nodeboun, &ndirboun, &xboun, - &nboun, - &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, ndirforc, - xforc, &nforc, - nelemload, sideload, xload, &nload, - &nactdof, neq, &nzl, icol, irow, &nmethod, &ikmpc, &ilmpc, &ikboun, - &ilboun, - elcon, nelcon, rhcon, nrhcon, cocon, ncocon, - alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, - &t0, - &t1, ithermal, prestr, &iprestr, &vold, iperturb, sti, nzs, - timepar, xmodal, &veold, amname, amta, - namta, &nam, iamforc, iamload, &iamt1, - jout, &kode, filab, &eme, xforcold, xloadold, - &t1old, &iamboun, &xbounold, &iexpl, plicon, - nplicon, plkcon, nplkcon, xstate, &npmat_, matname, - mi, &ncmat_, &nstate_, &ener, jobnamec, &ttime, set, &nset, - istartset, iendset, ialset, &nprint, prlab, - prset, &nener, trab, &inotr, &ntrans, &fmpc, ipobody, ibody, xbody, - &nbody, - xbodyold, &istep, &isolver, jq, output, &mcs, &nkon, ics, cs, - &mpcend, - ctrl, ikforc, ilforc, thicke, &nmat, typeboun, ielprop, prop, - orname, - &ndamp, dacon, t0g, t1g); - } else if ((nmethod == 6) || (nmethod == 7)) { - - printf(" Composing the complex eigenmodes from the real eigenmodes\n\n"); - - complexfreq(&co, &nk, &kon, &ipkon, &lakon, &ne, &nodeboun, &ndirboun, &xboun, - &nboun, &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, - ndirforc, xforc, &nforc, - nelemload, sideload, xload, &nload, - &nactdof, neq, &nzl, icol, irow, &nmethod, &ikmpc, &ilmpc, &ikboun, - &ilboun, - elcon, nelcon, rhcon, nrhcon, cocon, ncocon, - alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, - &t0, - &t1, ithermal, prestr, &iprestr, &vold, iperturb, &sti, nzs, - timepar, xmodal, &veold, amname, amta, - namta, &nam, iamforc, iamload, &iamt1, - jout, &kode, filab, &eme, xforcold, xloadold, - &t1old, &iamboun, &xbounold, &iexpl, plicon, - nplicon, plkcon, nplkcon, xstate, &npmat_, matname, - mi, &ncmat_, &nstate_, &ener, jobnamec, &ttime, set, &nset, - istartset, iendset, &ialset, &nprint, prlab, - prset, &nener, trab, &inotr, &ntrans, &fmpc, ipobody, ibody, xbody, - &nbody, - xbodyold, &istep, &isolver, jq, output, &mcs, &nkon, &mpcend, ics, - cs, - &ntie, tieset, &idrct, jmax, ctrl, &itpamp, tietol, &nalset, - ikforc, ilforc, thicke, jobnamef, mei, &nmat, ielprop, prop, orname, - typeboun, t0g, t1g); - } else if ((nmethod > 7) && (nmethod < 12)) { - - mpcinfo[0] = memmpc_; - mpcinfo[1] = mpcfree; - mpcinfo[2] = icascade; - mpcinfo[3] = maxlenmpc; - - electromagnetics(&co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, - ndirboun, xboun, &nboun, - &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, - ndirforc, xforc, - &nforc, &nelemload, &sideload, xload, &nload, - nactdof, &icol, &jq, &irow, neq, &nzl, &nmethod, &ikmpc, - &ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, - alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, - &ntmat_, - t0, t1, t1old, ithermal, prestr, &iprestr, - &vold, iperturb, sti, nzs, &kode, filab, &idrct, jmax, - jout, timepar, eme, xbounold, xforcold, xloadold, - veold, accold, amname, amta, namta, - &nam, iamforc, &iamload, iamt1, alpha, - &iexpl, iamboun, plicon, nplicon, plkcon, nplkcon, - &xstate, &npmat_, &istep, &ttime, matname, qaold, mi, - &isolver, &ncmat_, &nstate_, &iumat, cs, &mcs, &nkon, &ener, - mpcinfo, output, - shcon, nshcon, cocon, ncocon, physcon, &nflow, ctrl, - &set, &nset, &istartset, &iendset, &ialset, &nprint, prlab, - prset, &nener, ikforc, ilforc, trab, inotr, &ntrans, &fmpc, - ipobody, ibody, xbody, &nbody, xbodyold, ielprop, prop, - &ntie, &tieset, &itpamp, &iviewfile, jobnamec, &tietol, - &nslavs, thicke, - ics, &nalset, &nmpc_, &nmat, typeboun, &iaxial, &nload_, &nprop, - &network, orname, t0g, t1g); - - memmpc_ = mpcinfo[0]; - mpcfree = mpcinfo[1]; - icascade = mpcinfo[2]; - maxlenmpc = mpcinfo[3]; - } - - else if (nmethod == 12) { - - if (icoordinate == 1) { - sensi_coor(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, - xboun, &nboun, ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, - ndirforc, xforc, &nforc, nelemload, sideload, xload, &nload, - nactdof, icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, - ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, - alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, - t0, t1, t1old, ithermal, prestr, &iprestr, vold, iperturb, sti, nzs, - &kode, filab, eme, &iexpl, plicon, - nplicon, plkcon, nplkcon, &xstate, &npmat_, matname, - &isolver, mi, &ncmat_, &nstate_, cs, &mcs, &nkon, &ener, - xbounold, xforcold, xloadold, amname, amta, namta, - &nam, iamforc, iamload, iamt1, iamboun, &ttime, - output, set, &nset, istartset, iendset, ialset, &nprint, prlab, - prset, &nener, trab, inotr, &ntrans, fmpc, ipobody, ibody, xbody, - &nbody, - xbodyold, timepar, thicke, jobnamec, tieset, &ntie, &istep, &nmat, - ielprop, prop, typeboun, &mortar, mpcinfo, tietol, ics, - &nobject, &objectset, &istat, orname, nzsprevstep, &nlabel, - physcon, - jobnamef, iponor, knor, &ne2d, iponoel, inoel, &mpcend, dgdxglob, - g0, &nodedesi, &ndesi, &nobjectstart, &xdesi); - - } else { - sensi_orien(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, - xboun, &nboun, ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, - ndirforc, xforc, &nforc, nelemload, sideload, xload, &nload, - nactdof, icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, - ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, - alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, - t0, t1, t1old, ithermal, prestr, &iprestr, vold, iperturb, sti, nzs, - &kode, filab, eme, &iexpl, plicon, - nplicon, plkcon, nplkcon, &xstate, &npmat_, matname, - &isolver, mi, &ncmat_, &nstate_, cs, &mcs, &nkon, &ener, - xbounold, xforcold, xloadold, amname, amta, namta, - &nam, iamforc, iamload, iamt1, iamboun, &ttime, - output, set, &nset, istartset, iendset, ialset, &nprint, prlab, - prset, &nener, trab, inotr, &ntrans, fmpc, ipobody, ibody, xbody, - &nbody, - xbodyold, timepar, thicke, jobnamec, tieset, &ntie, &istep, &nmat, - ielprop, prop, typeboun, &mortar, mpcinfo, tietol, ics, - &nobject, &objectset, &istat, orname, nzsprevstep, &nlabel, - physcon, - jobnamef, iponor, knor, &ne2d, iponoel, inoel, &mpcend); - } - - } - - else if (nmethod == 14) { - - robustdesign(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, - &nboun, ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, - ndirforc, xforc, &nforc, nelemload, sideload, xload, &nload, - nactdof, icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, ilmpc, ikboun, - ilboun, elcon, nelcon, rhcon, nrhcon, alcon, nalcon, alzero, - &ielmat, &ielorien, &norien, orab, &ntmat_, t0, t1, t1old, ithermal, - prestr, &iprestr, vold, iperturb, sti, nzs, &kode, filab, eme, - &iexpl, plicon, nplicon, plkcon, nplkcon, &xstate, &npmat_, - matname, &isolver, mi, &ncmat_, &nstate_, cs, &mcs, &nkon, &ener, - xbounold, xforcold, xloadold, amname, amta, namta, &nam, iamforc, - iamload, iamt1, iamboun, &ttime, output, set, &nset, istartset, - iendset, ialset, &nprint, prlab, prset, &nener, trab, inotr, - &ntrans, fmpc, ipobody, ibody, xbody, &nbody, xbodyold, timepar, - thicke, jobnamec, tieset, &ntie, &istep, &nmat, ielprop, prop, - typeboun, &mortar, mpcinfo, tietol, ics, &nobject, - &objectset, &istat, orname, nzsprevstep, &nlabel, physcon, - jobnamef, iponor, knor, &ne2d, iponoel, inoel, &mpcend, - irobustdesign, irandomtype, randomval); - } - - else if (nmethod == 15) { - - crackpropagation(&ipkon, &kon, &lakon, &ne, &nk, jobnamec, &nboun, iamboun, xboun, - &nload, sideload, iamload, &nforc, iamforc, xforc, ithermal, t1, - iamt1, &co, &nkon, mi, &ielmat, matname, output, &nmat, set, - &nset, istartset, iendset, ialset, jmax, timepar, nelcon, - elcon, &ncmat_, &ntmat_, &istep, filab, &nmethod, mei); - } - - else if (nmethod == 16) { - - feasibledirection(&nobject, &objectset, &dgdxglob, g0, &ndesi, nodedesi, &nk, - &isolver, &ipkon, &kon, &lakon, &ne, nelemload, &nload, - nodeboun, &nboun, ndirboun, ithermal, co, vold, mi, &ielmat, - ielprop, prop, &kode, &nmethod, filab, &nstate_, &istep, cs, - set, &nset, istartset, iendset, ialset, jobnamec, output, - &ntrans, inotr, trab, orname, xdesi); - } - - SFREE(nactdof); - SFREE(icol); - SFREE(jq); - SFREE(irow); - SFREE(ipobody); - - /* check whether refinement was active */ - - // if(irefineloop==20){ - if (strcmp1(&filab[4089], "RM") == 0) { - irefineloop++; - - if (irefineloop == 1) { - - /* refinement was requested in the step which was just - finished and a refined mesh was created and stored. - The calculation has to restart from the beginning with - this new mesh */ - - memcpy(ipoinp, ipoinp_sav, sizeof(ITG) * 2 * nentries); - memcpy(inp, inp_sav, sizeof(ITG) * inp_size); - - /* deallocating fields */ - - dealloc_cal(&ncs_, &ics, &mcs, &cs, &tieset, &tietol, &co, - &kon, &ipkon, &lakon, &nodeboun, &ndirboun, &typeboun, &xboun, - &ikboun, &ilboun, &nodebounold, &ndirbounold, &xbounold, &ipompc, - &labmpc, &ikmpc, &ilmpc, &fmpc, &nodempc, &coefmpc, &nodempcref, - &coefmpcref, &ikmpcref, &nodeforc, &ndirforc, &xforc, - &ikforc, &ilforc, &xforcold, &nelemload, &sideload, &xload, - &xloadold, &cbody, &ibody, &xbody, &xbodyold, &nam, - &iamboun, &iamforc, &iamload, &amname, &amta, &namta, &set, - &istartset, &iendset, &ialset, &elcon, &nelcon, &rhcon, - &nrhcon, &shcon, &nshcon, &cocon, &ncocon, &alcon, - &nalcon, &alzero, &nprop, &ielprop, &prop, &npmat_, - &plicon, &nplicon, &plkcon, &nplkcon, &ndamp, &dacon, &norien, - &orname, &orab, &ielorien, &ntrans, &trab, &inotr, &iprestr, - &prestr, ithermal, &t0, &t1, &t1old, &iamt1, &ne1d, - &ne2d, &t0g, &t1g, irobustdesign, &irandomtype, - &randomval, &prlab, &prset, &filab, &xmodal, &ielmat, - &matname, &sti, &eme, &ener, &xstate, &vold, - &veold, &vel, &velo, &veloo, &iponor, &xnor, - &knor, &thicke, &offset, &iponoel, &inoel, &rig, - &ne2boun, &islavsurf, &mortar, &pslavsurf, &clearini, - &nobject_, &objectset, &nmethod, iperturb, &irefineloop, - &iparentel, &iprfn, &konrfn, &ratiorfn, &heading, - &nodedesi, &dgdxglob, &g0, &nuel_, &xdesi, &nfc, &coeffc, - &ikdc, &edc); - - /* closing and reopening the output files */ - - FORTRAN(openfile, (jobnamef)); - - /* initialization of the variables */ - - ini_cal(jobnamec, output, fneig, kind1, kind2, itempuser, irobustdesign, - &nprint, neq, &mpcfree, &nbounold, &nforcold, &nloadold, &nbody_, - &nbodyold, &network, &nheading_, &nmpc_, &nload_, &nforc_, &nboun_, - &nintpoint, iperturb, &ntmat_, ithermal, &isolver, &nslavs, &nkon_, - &mortar, jout, &nkon, &nevtot, &ifacecount, &iplas, &npmat_, mi, - &mpcend, &namtot_, &iumat, &icascade, &ne1d, &ne2d, infree, &nflow, - irstrt, &nener, &jrstrt, &ntie_, &mcs, &nprop_, &nprop, &itpamp, - &nevdamp_, &npt_, &iaxial, &inext, &icontact, &nobject, &nobject_, - &iit, &mpcfreeref, &isens, &namtot, &nstam, &ndamp, &nef, - &nk_, &ne_, &nalset_, &nmat_, &norien_, &nam_, &ntrans_, - &ncs_, &nstate_, &ncmat_, &memmpc_, &nprint_, energy, ctrl, alpha, - qaold, physcon, &istep, &istat, &iprestr, &kode, &nload, &nbody, &nforc, - &nboun, &nk, &nmpc, &nam, &nzs_, &nlabel, &ttime, &iheading, &nfc, - &nfc_, &ndc, &ndc_); - - NNEW(set, char, 81 * nset_); - NNEW(meminset, ITG, nset_); - NNEW(rmeminset, ITG, nset_); - NNEW(iuel, ITG, 4 * nuel_); - - FORTRAN(allocation, (&nload_, &nforc_, &nboun_, &nk_, &ne_, &nmpc_, &nset_, - &nalset_, &nmat_, &ntmat_, &npmat_, &norien_, &nam_, - &nprint_, mi, &ntrans_, set, meminset, rmeminset, &ncs_, - &namtot_, &ncmat_, &memmpc_, &ne1d, &ne2d, &nflow, - jobnamec, irstrt, ithermal, &nener, &nstate_, &istep, - inpc, ipoinp, inp, &ntie_, &nbody_, - &nprop_, ipoinpc, &nevdamp_, &npt_, &nslavs, &nkon_, &mcs, - &mortar, &ifacecount, &nintpoint, infree, &nheading_, - &nobject_, iuel, &iprestr, &nstam, &ndamp, &nef, - &nbounold, &nforcold, &nloadold, &nbodyold, &mpcend, - irobustdesign, &nfc_, &ndc_)); - - // SFREE(set); - SFREE(meminset); - SFREE(rmeminset); - mt = mi[1] + 1; - NNEW(heading, char, 66 * nheading_); - - continue; - } - } - - /* reset tempuserflag */ - - itempuser[0] = 0; - - /* deleting the perturbation loads and temperatures */ - - if ((iperturb[0] == 1) && (nmethod == 3)) { - nforc = 0; - nload = 0; - nbody = 0; - if (ithermal[0] == 1) { - for (k = 0; k < nk; ++k) { - t1[k] = t0[k]; - } - } - } else { - nbounold = nboun; - for (i = 0; i < nboun; i++) { - nodebounold[i] = nodeboun[i]; - ndirbounold[i] = ndirboun[i]; - } - nforcold = nforc; - nloadold = nload; - nbodyold = nbody; - - /* resetting the amplitude to none except for time=total time amplitudes */ - - if (nam > 0) { - for (i = 0; i < nboun; i++) { - if (iamboun[i] > 0) { - if (namta[3 * iamboun[i] - 1] > 0) { - iamboun[i] = 0; - xboun[i] = xbounold[i]; - } - } - } - for (i = 0; i < nforc; i++) { - if (iamforc[i] > 0) { - if (namta[3 * iamforc[i] - 1] > 0) { - iamforc[i] = 0; - xforc[i] = xforcold[i]; - } - } - } - for (i = 0; i < 2 * nload; i++) { - if (iamload[i] > 0) { - if (namta[3 * iamload[i] - 1] > 0) { - iamload[i] = 0; - xload[i] = xloadold[i]; - } - } - } - for (i = 1; i < 3 * nbody; i = i + 3) { - if (ibody[i] > 0) { - if (namta[3 * ibody[i] - 1] > 0) { - ibody[i] = 0; - xbody[7 * (i - 1) / 3] = xbodyold[7 * (i - 1) / 3]; - } - } - } - if (ithermal[0] == 1) { - if (iamt1[i] > 0) { - if (namta[3 * iamt1[i] - 1] > 0) { - iamt1[i] = 0; - t1[i] = t1old[i]; - } - } - } - } - } - - /* removing the advective elements, if any */ - - if (network > 0) { - ne = ne0; - nkon = nkon0; - RENEW(ipkon, ITG, ne); - RENEW(lakon, char, 8 * ne); - RENEW(kon, ITG, nkon); - RENEW(sti, double, 6 * mi[0] * ne); - RENEW(eme, double, 6 * mi[0] * ne); - if (iprestr > 0) - RENEW(prestr, double, 6 * mi[0] * ne); - if (nprop > 0) - RENEW(ielprop, ITG, ne); - if ((ne1d != 0) || (ne2d != 0)) - RENEW(offset, double, 2 * ne); - if (nener == 1) - RENEW(ener, double, mi[0] * ne * 2); - if (norien > 0) - RENEW(ielorien, ITG, mi[2] * ne); - RENEW(ielmat, ITG, mi[2] * ne); - - /* reactivating the original load labels */ - - for (i = nload - 1; i >= nload0; i--) { - if (strcmp2(&sideload[20 * i], " ", 20) == 0) { - iload = nelemload[2 * i + 1]; - strcpy1(&sideload[20 * (iload - 1)], "F", 1); - } - } - } - - nload = nload0; - - if ((nmethod == 4) && (iperturb[0] > 1)) - SFREE(accold); - - if (irstrt[0] > 0) { - jrstrt++; - if (jrstrt >= irstrt[0]) { - jrstrt = 0; - FORTRAN(restartwrite, (&istep, &nset, &nload, &nforc, &nboun, &nk, &ne, &nmpc, - &nalset, &nmat, &ntmat_, &npmat_, &norien, &nam, - &nprint, mi, &ntrans, &ncs_, &namtot, &ncmat_, &mpcend, - &maxlenmpc, &ne1d, &ne2d, &nflow, &nlabel, &iplas, - &nkon, ithermal, &nmethod, iperturb, &nstate_, &nener, - set, istartset, iendset, ialset, co, kon, ipkon, lakon, - nodeboun, ndirboun, iamboun, xboun, ikboun, ilboun, - ipompc, nodempc, coefmpc, labmpc, ikmpc, ilmpc, - nodeforc, ndirforc, iamforc, xforc, ikforc, ilforc, - nelemload, iamload, sideload, xload, elcon, nelcon, - rhcon, nrhcon, alcon, nalcon, alzero, plicon, nplicon, - plkcon, nplkcon, orname, orab, ielorien, trab, inotr, - amname, amta, namta, t0, t1, iamt1, veold, ielmat, - matname, prlab, prset, filab, vold, nodebounold, - ndirbounold, xbounold, xforcold, xloadold, t1old, eme, - iponor, xnor, knor, thicke, offset, iponoel, inoel, rig, - shcon, nshcon, cocon, ncocon, ics, sti, ener, xstate, - jobnamec, infree, prestr, &iprestr, cbody, ibody, - xbody, &nbody, xbodyold, &ttime, qaold, cs, &mcs, - output, physcon, ctrl, typeboun, fmpc, tieset, &ntie, - tietol, &nslavs, t0g, t1g, &nprop, ielprop, prop, - &mortar, &nintpoint, &ifacecount, islavsurf, - pslavsurf, clearini, irstrt, vel, &nef, velo, veloo, - ne2boun, &memmpc_, heading, &nheading_, &network, - &nfc, &ndc, coeffc, ikdc, edc)); - } - } - } - - FORTRAN(closefile, ()); - - strcpy(fneig, jobnamec); - strcat(fneig, ".frd"); - if ((f1 = fopen(fneig, "ab")) == NULL) { - printf("*ERROR in frd: cannot open frd file for writing..."); - exit(0); - } - fprintf(f1, " 9999\n"); - fclose(f1); - - /* deallocating the fields - this section is addressed immediately after leaving calinput */ - - SFREE(ipoinpc); - SFREE(inpc); - SFREE(inp); - SFREE(ipoinp); - SFREE(inp_sav); - SFREE(ipoinp_sav); - - dealloc_cal(&ncs_, &ics, &mcs, &cs, &tieset, &tietol, &co, - &kon, &ipkon, &lakon, &nodeboun, &ndirboun, &typeboun, &xboun, - &ikboun, &ilboun, &nodebounold, &ndirbounold, &xbounold, &ipompc, - &labmpc, &ikmpc, &ilmpc, &fmpc, &nodempc, &coefmpc, - &nodempcref, &coefmpcref, &ikmpcref, &nodeforc, &ndirforc, &xforc, - &ikforc, &ilforc, &xforcold, &nelemload, &sideload, &xload, - &xloadold, &cbody, &ibody, &xbody, &xbodyold, &nam, - &iamboun, &iamforc, &iamload, &amname, &amta, &namta, &set, - &istartset, &iendset, &ialset, &elcon, &nelcon, &rhcon, - &nrhcon, &shcon, &nshcon, &cocon, &ncocon, &alcon, - &nalcon, &alzero, &nprop, &ielprop, &prop, &npmat_, - &plicon, &nplicon, &plkcon, &nplkcon, &ndamp, &dacon, &norien, - &orname, &orab, &ielorien, &ntrans, &trab, &inotr, &iprestr, - &prestr, ithermal, &t0, &t1, &t1old, &iamt1, &ne1d, - &ne2d, &t0g, &t1g, irobustdesign, &irandomtype, - &randomval, &prlab, &prset, &filab, &xmodal, &ielmat, - &matname, &sti, &eme, &ener, &xstate, &vold, - &veold, &vel, &velo, &veloo, &iponor, &xnor, - &knor, &thicke, &offset, &iponoel, &inoel, &rig, - &ne2boun, &islavsurf, &mortar, &pslavsurf, &clearini, - &nobject_, &objectset, &nmethod, iperturb, &irefineloop, - &iparentel, &iprfn, &konrfn, &ratiorfn, &heading, - &nodedesi, &dgdxglob, &g0, &nuel_, &xdesi, &nfc, &coeffc, - &ikdc, &edc); - -#ifdef CALCULIX_MPI - MPI_Finalize(); -#endif - -#ifdef CALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT - calculix_freeExternalBehaviours(); -#endif /* CALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT */ - - clock_gettime(CLOCK_MONOTONIC, &totalCalculixTimeEnd); - - totalCalculixTime = (totalCalculixTimeEnd.tv_sec - totalCalculixTimeStart.tv_sec) * 1e9; - totalCalculixTime = (totalCalculixTime + (totalCalculixTimeEnd.tv_nsec - totalCalculixTimeStart.tv_nsec)) * 1e-9; - - printf("________________________________________\n\n"); - - printf("Total CalculiX Time: %lf\n", totalCalculixTime); - - printf("________________________________________\n"); - - return 0; -} diff --git a/ccx_2.20.c b/ccx_2.20.c deleted file mode 100644 index 84466232..00000000 --- a/ccx_2.20.c +++ /dev/null @@ -1,2239 +0,0 @@ -/* CalculiX - A 3-dimensional finite element program */ -/* Copyright (C) 1998-2022 Guido Dhondt */ - -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU General Public License as */ -/* published by the Free Software Foundation(version 2); */ -/* */ - -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU General Public License for more details. */ - -/* You should have received a copy of the GNU General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifdef __WIN32 -_set_output_format(_TWO_DIGIT_EXPONENT); -#endif - -#ifdef CALCULIX_MPI -#include -#endif - -#include -#include -#include -#include -#include "CalculiX.h" - -#ifdef CALCULIX_MPI -ITG myid = 0, nproc = 0; -#endif - -struct timespec totalCalculixTimeStart, totalCalculixTimeEnd; - -int main(int argc, char *argv[]) -{ - - FILE *f1; - - char *sideload = NULL, *set = NULL, *matname = NULL, *orname = NULL, *amname = NULL, - *filab = NULL, *lakon = NULL, *labmpc = NULL, *prlab = NULL, *prset = NULL, - jobnamec[792] = "", jobnamef[132] = "", output[5], *typeboun = NULL, - *inpc = NULL, *tieset = NULL, *cbody = NULL, fneig[132], *sideloadtemp = NULL, - kind1[2], kind2[2], *heading = NULL, *objectset = NULL; - - ITG *kon = NULL, *nodeboun = NULL, *ndirboun = NULL, *ipompc = NULL, - *nodempc = NULL, *nodeforc = NULL, *ndirforc = NULL, - *nelemload = NULL, im, *inodesd = NULL, nload1, *idefforc = NULL, - *nactdof = NULL, *icol = NULL, *ics = NULL, itempuser[3], - *jq = NULL, *mast1 = NULL, *irow = NULL, *rig = NULL, *idefbody = NULL, - *ikmpc = NULL, *ilmpc = NULL, *ikboun = NULL, *ilboun = NULL, - *nreorder = NULL, *ipointer = NULL, *idefload = NULL, - *istartset = NULL, *iendset = NULL, *ialset = NULL, *ielmat = NULL, - *ielorien = NULL, *nrhcon = NULL, *nodebounold = NULL, *ndirbounold = NULL, - *nelcon = NULL, *nalcon = NULL, *iamforc = NULL, *iamload = NULL, - *iamt1 = NULL, *namta = NULL, *ipkon = NULL, *iamboun = NULL, - *nplicon = NULL, *nplkcon = NULL, *inotr = NULL, *iponor = NULL, *knor = NULL, - *ikforc = NULL, *ilforc = NULL, *iponoel = NULL, *inoel = NULL, *nshcon = NULL, - *ncocon = NULL, *ibody = NULL, *ielprop = NULL, *islavsurf = NULL, - *ipoinpc = NULL, mt, nxstate, nload0, iload, *iuel = NULL, *ne2boun = NULL, - *irandomtype = NULL, irobustdesign[3], *iparentel = NULL, ifreebody, - *ipobody = NULL, inewton = 0, *iprfn = NULL, *konrfn = NULL; - - ITG nk, ne, nboun, nmpc, nforc, nload, nprint, nset, nalset, nentries = 18, - nmethod, neq[3], i, mpcfree, mei[4] = {0, 0, 0, 0}, j, nzl, nam, nbounold, - nforcold, nloadold, nbody, nbody_, nbodyold, network, nheading_, - k, nzs[3], nmpc_, nload_, nforc_, istep, istat, nboun_, nintpoint, - iperturb[2], nmat, ntmat_, norien, ithermal[2] = {0, 0}, nmpcold, - iprestr, kode, isolver, nslavs, nkon_, ne0, nkon0, mortar, - jout[2], nlabel, nkon, idrct, jmax[2], iexpl, nevtot, ifacecount, - iplas, npmat_, mi[3], ntrans, mpcend, namtot_, iumat, iheading, - icascade, maxlenmpc, mpcinfo[4], ne1d, ne2d, infree[4], - callfrommain, nflow, jin = 0, irstrt[2], nener, jrstrt, nenerold, - nline, *ipoinp = NULL, *inp = NULL, ntie, ntie_, mcs, nprop_, - nprop, itpamp, iviewfile, nkold, nevdamp_, npt_, cyclicsymmetry, - nmethodl, iaxial, inext, icontact, nobject, nobject_, iit, - nzsprevstep[3], memmpcref_, mpcfreeref, maxlenmpcref, *nodempcref = NULL, - *ikmpcref = NULL, isens, namtot, nstam, ndamp, nef, inp_size, - *ipoinp_sav = NULL, *inp_sav = NULL, irefineloop = 0, icoordinate = 0, - *nodedesi = NULL, ndesi = 0, nobjectstart = 0, nfc_, ndc_, nfc, ndc, *ikdc = NULL; - - ITG *meminset = NULL, *rmeminset = NULL; - - ITG nzs_, nk_, ne_, nset_ = 0, nalset_, nmat_, norien_, nam_, - ntrans_, ncs_, nstate_, ncmat_, memmpc_, nprint_, nuel_ = 0; - - double *co = NULL, *xboun = NULL, *coefmpc = NULL, *xforc = NULL, *clearini = NULL, - *xload = NULL, *xbounold = NULL, *xforcold = NULL, *randomval = NULL, - *vold = NULL, *sti = NULL, *xloadold = NULL, *xnor = NULL, - *reorder = NULL, *dcs = NULL, *thickn = NULL, *thicke = NULL, *offset = NULL, - *elcon = NULL, *rhcon = NULL, *alcon = NULL, *alzero = NULL, *t0 = NULL, *t1 = NULL, - *prestr = NULL, *orab = NULL, *amta = NULL, *veold = NULL, *accold = NULL, - *t1old = NULL, *eme = NULL, *plicon = NULL, *pslavsurf = NULL, *plkcon = NULL, - *xstate = NULL, *trab = NULL, *ener = NULL, *shcon = NULL, *cocon = NULL, - *cs = NULL, *tietol = NULL, *fmpc = NULL, *prop = NULL, *t0g = NULL, *t1g = NULL, - *xbody = NULL, *xbodyold = NULL, *coefmpcref = NULL, *dacon = NULL, *vel = NULL, - *velo = NULL, *veloo = NULL, energy[5], *ratiorfn = NULL, *dgdxglob = NULL, - *g0 = NULL, *xdesi = NULL, *coeffc = NULL, *edc = NULL; - - double ctrl[57]; - - double fei[3], *xmodal = NULL, timepar[5], alpha[2], ttime, qaold[2], physcon[14]; - - double totalCalculixTime; - - /* - * Additional variables for the coupling with preCICE - * preCICE is used only if a participant name is provided as a command line argument! - */ - char preciceParticipantName[256] = "", configFilename[256] = "config.yml"; - int preciceUsed = 0; - -#ifdef CALCULIX_MPI - MPI_Init(&argc, &argv); - MPI_Comm_rank(MPI_COMM_WORLD, &myid); - MPI_Comm_size(MPI_COMM_WORLD, &nproc); -#endif - - clock_gettime(CLOCK_MONOTONIC, &totalCalculixTimeStart); - - if (argc == 1) { - printf("Usage: CalculiX.exe -i jobname\n"); - FORTRAN(stop, ()); - } else { - for (i = 1; i < argc; i++) { - if (strcmp1(argv[i], "-i") == 0) { - strcpy(jobnamec, argv[i + 1]); - strcpy1(jobnamef, argv[i + 1], 132); - jin++; - break; - } - if (strcmp1(argv[i], "-v") == 0) { - printf("\nThis is Version 2.20\n\n"); - FORTRAN(stop, ()); - } - } - if (jin == 0) { - strcpy(jobnamec, argv[1]); - strcpy1(jobnamef, argv[1], 132); - } - - /* next lines deactivated on March 18, 2020 */ - - /* for(i=1;i= 0) { - - fflush(stdout); - - /* in order to reduce the number of variables to be transferred to - the subroutines, the max. field sizes are (for most fields) copied - into the real sizes */ - - nzs[1] = nzs_; - - if ((istep == 0) || (irstrt[0] < 0)) { - ne = ne_; - nset = nset_; - nalset = nalset_; - nmat = nmat_; - norien = norien_; - ntrans = ntrans_; - ntie = ntie_; - - /* allocating space before the first step */ - - /* coordinates and topology */ - - NNEW(co, double, 3 * nk_); - NNEW(kon, ITG, nkon_); - NNEW(ipkon, ITG, ne_); - NNEW(lakon, char, 8 * ne_); - - /* property cards */ - - if (nprop_ > 0) { - NNEW(ielprop, ITG, ne_); - for (i = 0; i < ne_; i++) - ielprop[i] = -1; - NNEW(prop, double, nprop_); - } - - /* fields for 1-D and 2-D elements */ - - if ((ne1d != 0) || (ne2d != 0)) { - NNEW(iponor, ITG, 2 * nkon_); - for (i = 0; i < 2 * nkon_; i++) - iponor[i] = -1; - NNEW(xnor, double, 36 * ne1d + 24 * ne2d); - NNEW(knor, ITG, 24 * (ne1d + ne2d) * (mi[2] + 1)); - NNEW(thickn, double, 2 * nk_); - NNEW(thicke, double, mi[2] * nkon_); - NNEW(offset, double, 2 * ne_); - NNEW(iponoel, ITG, nk_); - NNEW(inoel, ITG, 9 * ne1d + 24 * ne2d); - NNEW(rig, ITG, nk_); - NNEW(ne2boun, ITG, 2 * nk_); - if (infree[2] == 0) - infree[2] = 1; - } - - /* SPC's */ - - NNEW(nodeboun, ITG, nboun_); - NNEW(ndirboun, ITG, nboun_); - NNEW(typeboun, char, nboun_ + 1); - if ((istep == 0) || ((irstrt[0] < 0) && (nam_ > 0))) - NNEW(iamboun, ITG, nboun_); - NNEW(xboun, double, nboun_); - NNEW(ikboun, ITG, nboun_); - NNEW(ilboun, ITG, nboun_); - - /* MPC's */ - - NNEW(ipompc, ITG, nmpc_); - NNEW(nodempc, ITG, 3 * memmpc_); - for (i = 0; i < 3 * memmpc_; i += 3) { - nodempc[i + 2] = i / 3 + 2; - } - nodempc[3 * memmpc_ - 1] = 0; - NNEW(coefmpc, double, memmpc_); - NNEW(labmpc, char, 20 * nmpc_ + 1); - NNEW(ikmpc, ITG, nmpc_); - NNEW(ilmpc, ITG, nmpc_); - NNEW(fmpc, double, nmpc_); - - /* coupling, distributed */ - - if (nfc_ > 0) { - NNEW(coeffc, double, 7 * nfc_); - NNEW(ikdc, ITG, ndc_); - NNEW(edc, double, 12 * ndc_); - } - - /* nodal loads */ - - NNEW(nodeforc, ITG, 2 * nforc_); - NNEW(ndirforc, ITG, nforc_); - if ((istep == 0) || ((irstrt[0] < 0) && (nam_ > 0))) - NNEW(iamforc, ITG, nforc_); - NNEW(idefforc, ITG, nforc_); - NNEW(xforc, double, nforc_); - NNEW(ikforc, ITG, nforc_); - NNEW(ilforc, ITG, nforc_); - - /* distributed facial loads */ - - NNEW(nelemload, ITG, 2 * nload_); - if ((istep == 0) || ((irstrt[0] < 0) && (nam_ > 0))) - NNEW(iamload, ITG, 2 * nload_); - NNEW(idefload, ITG, nload_); - NNEW(sideload, char, 20 * nload_); - NNEW(xload, double, 2 * nload_); - - /* distributed volumetric loads */ - - NNEW(cbody, char, 81 * nbody_); - NNEW(idefbody, ITG, nbody_); - NNEW(ibody, ITG, 3 * nbody_); - NNEW(xbody, double, 7 * nbody_); - NNEW(xbodyold, double, 7 * nbody_); - - /* printing output */ - - NNEW(prlab, char, 6 * nprint_); - NNEW(prset, char, 81 * nprint_); - - /* set definitions */ - - RENEW(set, char, 81 * nset); - NNEW(istartset, ITG, nset); - DMEMSET(istartset, 0, nset, 1); - NNEW(iendset, ITG, nset); - NNEW(ialset, ITG, nalset); - - /* (hyper)elastic constants */ - - NNEW(elcon, double, (ncmat_ + 1) * ntmat_ * nmat); - NNEW(nelcon, ITG, 2 * nmat); - - /* density */ - - NNEW(rhcon, double, 2 * ntmat_ * nmat); - NNEW(nrhcon, ITG, nmat); - - /* damping */ - - if (ndamp > 0) { - NNEW(dacon, double, nmat); - } - - /* specific heat */ - - NNEW(shcon, double, 4 * ntmat_ * nmat); - NNEW(nshcon, ITG, nmat); - - /* thermal expansion coefficients */ - - NNEW(alcon, double, 7 * ntmat_ * nmat); - NNEW(nalcon, ITG, 2 * nmat); - NNEW(alzero, double, nmat); - - /* conductivity */ - - NNEW(cocon, double, 7 * ntmat_ * nmat); - NNEW(ncocon, ITG, 2 * nmat); - - /* isotropic and kinematic hardening coefficients*/ - - if (npmat_ > 0) { - NNEW(plicon, double, (2 * npmat_ + 1) * ntmat_ * nmat); - NNEW(nplicon, ITG, (ntmat_ + 1) * nmat); - NNEW(plkcon, double, (2 * npmat_ + 1) * ntmat_ * nmat); - NNEW(nplkcon, ITG, (ntmat_ + 1) * nmat); - } - - /* linear dynamic properties */ - - NNEW(xmodal, double, 11 + nevdamp_); - xmodal[10] = nevdamp_ + 0.5; - - /* internal state variables (nslavs is needed for restart - calculations) */ - - if (mortar != 1) { - NNEW(xstate, double, nstate_ *mi[0] * (ne + nslavs)); - nxstate = nstate_ * mi[0] * (ne + nslavs); - } else if (mortar == 1) { - NNEW(xstate, double, nstate_ *mi[0] * (ne + nintpoint)); - nxstate = nstate_ * mi[0] * (ne + nintpoint); - } - - /* material orientation */ - - if ((istep == 0) || ((irstrt[0] < 0) && (norien > 0))) { - NNEW(orname, char, 80 * norien); - NNEW(orab, double, 7 * norien); - NNEW(ielorien, ITG, mi[2] * ne_); - } - - /* transformations */ - - if ((istep == 0) || ((irstrt[0] < 0) && (ntrans > 0))) { - NNEW(trab, double, 7 * ntrans); - NNEW(inotr, ITG, 2 * nk_); - } - - /* amplitude definitions */ - - if ((istep == 0) || ((irstrt[0] < 0) && (nam_ > 0))) { - NNEW(amname, char, 80 * nam_); - NNEW(amta, double, 2 * namtot_); - NNEW(namta, ITG, 3 * nam_); - } - - if ((istep == 0) || ((irstrt[0] < 0) && (ithermal[0] > 0))) { - NNEW(t0, double, nk_); - NNEW(t1, double, nk_); - if ((ne1d != 0) || (ne2d != 0) || (nuel_ != 0)) { - NNEW(t0g, double, 2 * nk_); - NNEW(t1g, double, 2 * nk_); - } - } - - /* the number in next line is NOT 1.2357111317 -> points - to user input; instead it is a generic nonzero - initialization */ - - if (istep == 0) { - DMEMSET(t0, 0, nk_, 1.2357111319); - DMEMSET(t1, 0, nk_, 1.2357111319); - } - - if ((istep == 0) || ((irstrt[0] < 0) && (ithermal[0] > 0) && (nam_ > 0))) - NNEW(iamt1, ITG, nk_); - - if ((istep == 0) || ((irstrt[0] < 0) && (iprestr > 0))) - NNEW(prestr, double, 6 * mi[0] * ne_); - - NNEW(vold, double, mt *nk_); - NNEW(veold, double, mt *nk_); - - /* CFD-results */ - - NNEW(vel, double, 8 * nef); - NNEW(velo, double, 8 * nef); - NNEW(veloo, double, 8 * nef); - - NNEW(ielmat, ITG, mi[2] * ne_); - - NNEW(matname, char, 80 * nmat); - - NNEW(filab, char, 87 * nlabel); - - /* tied constraints */ - - if (ntie_ > 0) { - NNEW(tieset, char, 243 * ntie_); - NNEW(tietol, double, 4 * ntie_); - NNEW(cs, double, 17 * ntie_); - } - - /* objectives for sensitivity analysis */ - - if (nobject_ > 0) { - NNEW(nodedesi, ITG, nk_); - NNEW(dgdxglob, double, nobject_ * 2 * nk_); - NNEW(g0, double, nobject_); - NNEW(xdesi, double, 3 * nk_); - NNEW(objectset, char, 405 * nobject_); - for (i = 0; i < 405 * nobject_; i++) { - objectset[i] = ' '; - } - } - - /* temporary fields for cyclic symmetry calculations */ - - if ((ncs_ > 0) || (npt_ > 0)) { - if (2 * npt_ > 24 * ncs_) { - NNEW(ics, ITG, 2 * npt_); - } else { - NNEW(ics, ITG, 24 * ncs_); - } - if (npt_ > 30 * ncs_) { - NNEW(dcs, double, npt_); - } else { - NNEW(dcs, double, 30 * ncs_); - } - } - - /* slave faces */ - - NNEW(islavsurf, ITG, 2 * ifacecount + 2); - - /* robustdesign analysis */ - - if (irobustdesign[0] > 0) { - NNEW(irandomtype, ITG, nk_); - NNEW(randomval, double, 2 * nk_); - } - - } else { - - /* allocating and reallocating space for subsequent steps */ - - if ((nmethod != 4) && (nmethod != 5) && (nmethod != 8) && (nmethod != 9) && - ((abs(nmethod) != 1) || (iperturb[0] < 2))) { - NNEW(veold, double, mt *nk_); - } else { - RENEW(veold, double, mt *nk_); - DMEMSET(veold, mt * nk, mt * nk_, 0.); - } - RENEW(vold, double, mt *nk_); - DMEMSET(vold, mt * nk, mt * nk_, 0.); - - RENEW(nodeboun, ITG, nboun_); - RENEW(ndirboun, ITG, nboun_); - RENEW(typeboun, char, nboun_ + 1); - RENEW(xboun, double, nboun_); - RENEW(ikboun, ITG, nboun_); - RENEW(ilboun, ITG, nboun_); - - RENEW(nodeforc, ITG, 2 * nforc_); - RENEW(ndirforc, ITG, nforc_); - NNEW(idefforc, ITG, nforc_); - RENEW(xforc, double, nforc_); - RENEW(ikforc, ITG, nforc_); - RENEW(ilforc, ITG, nforc_); - - RENEW(nelemload, ITG, 2 * nload_); - NNEW(idefload, ITG, nload_); - RENEW(sideload, char, 20 * nload_); - RENEW(xload, double, 2 * nload_); - - RENEW(cbody, char, 81 * nbody_); - NNEW(idefbody, ITG, nbody_); - RENEW(ibody, ITG, 3 * nbody_); - RENEW(xbody, double, 7 * nbody_); - RENEW(xbodyold, double, 7 * nbody_); - for (i = 7 * nbodyold; i < 7 * nbody_; i++) - xbodyold[i] = 0; - - if (nam > 0) { - RENEW(iamforc, ITG, nforc_); - RENEW(iamload, ITG, 2 * nload_); - RENEW(iamboun, ITG, nboun_); - RENEW(amname, char, 80 * nam_); - RENEW(amta, double, 2 * namtot_); - RENEW(namta, ITG, 3 * nam_); - } - - RENEW(ipompc, ITG, nmpc_); - - RENEW(labmpc, char, 20 * nmpc_ + 1); - RENEW(ikmpc, ITG, nmpc_); - RENEW(ilmpc, ITG, nmpc_); - RENEW(fmpc, double, nmpc_); - - if (ntrans > 0) { - RENEW(inotr, ITG, 2 * nk_); - DMEMSET(inotr, 2 * nk, 2 * nk_, 0); - } - - RENEW(co, double, 3 * nk_); - DMEMSET(co, 3 * nk, 3 * nk_, 0.); - - if (ithermal[0] != 0) { - RENEW(t0, double, nk_); - DMEMSET(t0, nk, nk_, 0.); - RENEW(t1, double, nk_); - DMEMSET(t1, nk, nk_, 0.); - if ((ne1d != 0) || (ne2d != 0) || (nuel_ != 0)) { - RENEW(t0g, double, 2 * nk_); - DMEMSET(t0g, 2 * nk, 2 * nk_, 0.); - RENEW(t1g, double, 2 * nk_); - DMEMSET(t1g, 2 * nk, 2 * nk_, 0.); - } - if (nam > 0) { - RENEW(iamt1, ITG, nk_); - } - } - } - - /* allocation of fields in the restart file */ - - if (irstrt[0] < 0) { - NNEW(nodebounold, ITG, nboun_); - NNEW(ndirbounold, ITG, nboun_); - NNEW(xbounold, double, nboun_); - NNEW(xforcold, double, nforc_); - NNEW(xloadold, double, 2 * nload_); - if (ithermal[0] != 0) - NNEW(t1old, double, nk_); - NNEW(sti, double, 6 * mi[0] * ne); - NNEW(eme, double, 6 * mi[0] * ne); - if (nener == 1) - NNEW(ener, double, mi[0] * ne * 2); - if (mcs > ntie_) - RENEW(cs, double, 17 * mcs); - if (mortar == 1) { - NNEW(pslavsurf, double, 3 * nintpoint); - NNEW(clearini, double, 3 * 9 * ifacecount); - } - } - - nenerold = nener; - nkold = nk; - - /* opening the eigenvalue file and checking for cyclic symmetry */ - - strcpy(fneig, jobnamec); - strcat(fneig, ".eig"); - cyclicsymmetry = 0; - if ((f1 = fopen(fneig, "rb")) != NULL) { - if (fread(&cyclicsymmetry, sizeof(ITG), 1, f1) != 1) { - printf(" *ERROR reading the information whether cyclic symmetry is involved in the eigenvalue file"); - exit(0); - } - fclose(f1); - } - - nmpcold = nmpc; - - /* reading the input file */ - - // if(istep==0)mortar=-2; - FORTRAN(calinput, (co, &nk, kon, ipkon, lakon, &nkon, &ne, nodeboun, ndirboun, xboun, - &nboun, ipompc, nodempc, coefmpc, &nmpc, &nmpc_, nodeforc, - ndirforc, xforc, &nforc, &nforc_, nelemload, sideload, xload, - &nload, &nload_, &nprint, prlab, prset, &mpcfree, &nboun_, mei, - set, istartset, iendset, ialset, &nset, &nalset, elcon, nelcon, - rhcon, nrhcon, alcon, nalcon, alzero, t0, t1, matname, ielmat, - orname, orab, ielorien, amname, amta, namta, &nam, &nmethod, - iamforc, iamload, iamt1, ithermal, iperturb, &istat, &istep, - &nmat, &ntmat_, &norien, prestr, &iprestr, &isolver, fei, veold, - timepar, xmodal, filab, jout, &nlabel, &idrct, jmax, &iexpl, - alpha, iamboun, plicon, nplicon, plkcon, nplkcon, &iplas, - &npmat_, mi, &nk_, trab, inotr, &ntrans, ikboun, ilboun, ikmpc, - ilmpc, ics, dcs, &ncs_, &namtot_, cs, &nstate_, &ncmat_, &iumat, - &mcs, labmpc, iponor, xnor, knor, thickn, thicke, ikforc, ilforc, - offset, iponoel, inoel, rig, infree, nshcon, shcon, cocon, - ncocon, physcon, &nflow, ctrl, &maxlenmpc, &ne1d, &ne2d, &nener, - vold, nodebounold, ndirbounold, xbounold, xforcold, xloadold, - t1old, eme, sti, ener, xstate, jobnamec, irstrt, &ttime, qaold, - output, typeboun, inpc, ipoinp, inp, tieset, tietol, &ntie, fmpc, - cbody, ibody, xbody, &nbody, &nbody_, xbodyold, &nam_, ielprop, - &nprop, &nprop_, prop, &itpamp, &iviewfile, ipoinpc, &nslavs, - t0g, t1g, &network, &cyclicsymmetry, idefforc, idefload, - idefbody, &mortar, &ifacecount, islavsurf, pslavsurf, - clearini, heading, &iaxial, &nobject, objectset, &nprint_, - iuel, &nuel_, nodempcref, coefmpcref, ikmpcref, &memmpcref_, - &mpcfreeref, &maxlenmpcref, &memmpc_, &isens, &namtot, &nstam, - dacon, vel, &nef, velo, veloo, ne2boun, itempuser, - irobustdesign, irandomtype, randomval, &nfc, &nfc_, coeffc, - ikdc, &ndc, &ndc_, edc)); - - SFREE(idefforc); - SFREE(idefload); - SFREE(idefbody); - - if (istat < 0) - break; - - /* assigning the body forces to the elements */ - - if (nbody > 0) { - ifreebody = ne + 1; - NNEW(ipobody, ITG, 2 * ifreebody * nbody); - for (k = 1; k <= nbody; k++) { - FORTRAN(bodyforce, (cbody, ibody, ipobody, &nbody, set, istartset, - iendset, ialset, &inewton, &nset, &ifreebody, &k)); - RENEW(ipobody, ITG, 2 * (ne + ifreebody)); - } - RENEW(ipobody, ITG, 2 * (ifreebody - 1)); - } - - if (irefineloop == 1) { - - /* in the last step refinement was requested and the mesh - was appropriately refined; this mesh has to be read */ - - readnewmesh(jobnamec, &nboun, nodeboun, iamboun, xboun, &nload, sideload, - iamload, &nforc, nodeforc, iamforc, xforc, ithermal, &nk, &t1, &iamt1, - &ne, &lakon, &ipkon, &kon, istartset, iendset, ialset, set, &nset, - filab, &co, &ipompc, &nodempc, &coefmpc, &nmpc, &nmpc_, &labmpc, - &mpcfree, &memmpc_, &ikmpc, &ilmpc, &nk_, &ne_, &nkon_, &istep, - &nprop_, &ielprop, &ne1d, &ne2d, &iponor, &thickn, &thicke, mi, - &offset, &iponoel, &rig, &ne2boun, &ielorien, &inotr, &t0, &t0g, &t1g, - &prestr, &vold, &veold, &ielmat, irobustdesign, &irandomtype, - &randomval, &nalset, &nalset_, &nkon, xnor, &iaxial, - &network, &nlabel, iuel, iperturb, &iprestr, &ntie, tieset, - &iparentel, ikboun, &ifreebody, &ipobody, &nbody, &iprfn, - &konrfn, &ratiorfn, nodempcref, coefmpcref, &memmpcref_, - &mpcfreeref, &maxlenmpcref, &maxlenmpc, &norien, tietol); - } - -#ifdef CALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT - for (i = 0; i != nmat; ++i) { - calculix_registerExternalBehaviour(matname + 80 * i); - } -#endif /* CALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT */ - - // if((istep==1)&&(mortar==-1)){mortar=0;}else{icontact=1;} - - nload0 = nload; - - if (iheading == 0) { - writeheading(jobnamec, heading, &nheading_); - iheading = 1; - } - - /* if(nheading_>=0){ - writeheading(jobnamec,heading,&nheading_); - SFREE(heading); - nheading_=-1; - }*/ - - if ((abs(nmethod) != 1) || (iperturb[0] < 2)) - icascade = 0; - - // FORTRAN(writeboun,(nodeboun,ndirboun,xboun,typeboun,&nboun)); - - if (istep == 1) { - - SFREE(iuel); - - /* tied contact constraints: generate appropriate MPC's */ - - tiedcontact(&ntie, tieset, &nset, set, istartset, iendset, ialset, - lakon, ipkon, kon, tietol, &nmpc, &mpcfree, &memmpc_, - &ipompc, &labmpc, &ikmpc, &ilmpc, &fmpc, &nodempc, &coefmpc, - ithermal, co, vold, &nef, &nmpc_, mi, &nk, &istep, ikboun, &nboun, - kind1, kind2, jobnamef); - - /* reallocating space in the first step */ - - /* allocating and initializing fields pointing to the previous step */ - - RENEW(vold, double, mt *nk); - NNEW(sti, double, 6 * mi[0] * ne); - - /* strains */ - - NNEW(eme, double, 6 * mi[0] * ne); - - /* residual stresses/strains */ - - if (iprestr == 1) { - RENEW(prestr, double, 6 * mi[0] * ne); - for (i = 0; i < ne; i++) { - for (j = 0; j < mi[0]; j++) { - for (k = 0; k < 6; k++) { - sti[6 * mi[0] * i + 6 * j + k] = prestr[6 * mi[0] * i + 6 * j + k]; - } - } - } - } else if (iprestr == 2) { - RENEW(prestr, double, 6 * mi[0] * ne); - for (i = 0; i < ne; i++) { - for (j = 0; j < mi[0]; j++) { - for (k = 0; k < 6; k++) { - eme[6 * mi[0] * i + 6 * j + k] = prestr[6 * mi[0] * i + 6 * j + k]; - } - } - } - } else { - SFREE(prestr); - } - - NNEW(nodebounold, ITG, nboun); - NNEW(ndirbounold, ITG, nboun); - NNEW(xbounold, double, nboun); - NNEW(xforcold, double, nforc); - NNEW(xloadold, double, 2 * nload); - - /* initial temperatures: store in the "old" boundary conditions */ - - if (ithermal[0] > 1) { - for (i = 0; i < nboun; i++) { - if (strcmp1(&typeboun[i], "F") == 0) - continue; - if (ndirboun[i] == 0) { - xbounold[i] = vold[mt * (nodeboun[i] - 1)]; - } - } - } - - /* initial temperatures: store in the "old" temperature field */ - - if (ithermal[0] != 0) { - NNEW(t1old, double, nk); - for (i = 0; i < nk; i++) - t1old[i] = t0[i]; - } - - /* element definition */ - - RENEW(kon, ITG, nkon); - RENEW(ipkon, ITG, ne); - RENEW(lakon, char, 8 * ne); - - /* property cards */ - - if (nprop_ > 0) { - RENEW(ielprop, ITG, ne); - RENEW(prop, double, nprop); - } else { - SFREE(ielprop); - SFREE(prop); - } - - /* coupling, distributed */ - - if (nfc > 0) { - RENEW(coeffc, double, 7 * nfc); - RENEW(ikdc, ITG, ndc); - RENEW(edc, double, 12 * ndc); - } else { - SFREE(coeffc); - SFREE(ikdc); - SFREE(edc); - } - - /* fields for 1-D and 2-D elements */ - - if ((ne1d != 0) || (ne2d != 0)) { - RENEW(iponor, ITG, 2 * nkon); - RENEW(xnor, double, infree[0]); - RENEW(knor, ITG, infree[1]); - SFREE(thickn); - RENEW(thicke, double, mi[2] * nkon); - RENEW(offset, double, 2 * ne); - RENEW(inoel, ITG, 3 * (infree[2] - 1)); - RENEW(iponoel, ITG, infree[3]); - RENEW(rig, ITG, infree[3]); - RENEW(ne2boun, ITG, 2 * infree[3]); - } - - /* set definitions */ - - RENEW(set, char, 81 * nset); - RENEW(istartset, ITG, nset); - RENEW(iendset, ITG, nset); - RENEW(ialset, ITG, nalset); - - /* material properties */ - - RENEW(elcon, double, (ncmat_ + 1) * ntmat_ * nmat); - RENEW(nelcon, ITG, 2 * nmat); - - RENEW(rhcon, double, 2 * ntmat_ * nmat); - RENEW(nrhcon, ITG, nmat); - - if (ndamp > 0) { - RENEW(dacon, double, nmat); - } - - RENEW(shcon, double, 4 * ntmat_ * nmat); - RENEW(nshcon, ITG, nmat); - - RENEW(cocon, double, 7 * ntmat_ * nmat); - RENEW(ncocon, ITG, 2 * nmat); - - RENEW(alcon, double, 7 * ntmat_ * nmat); - RENEW(nalcon, ITG, 2 * nmat); - RENEW(alzero, double, nmat); - - RENEW(matname, char, 80 * nmat); - RENEW(ielmat, ITG, mi[2] * ne); - - /* allocating space for the state variables */ - - if (mortar != 1) { - RENEW(xstate, double, nstate_ *mi[0] * (ne + nslavs)); - for (i = nxstate; i < nstate_ * mi[0] * (ne + nslavs); i++) { - xstate[i] = 0.; - } - } else if (mortar == 1) { - RENEW(xstate, double, nstate_ *mi[0] * (ne + nintpoint)); - for (i = nxstate; i < nstate_ * mi[0] * (ne + nintpoint); i++) { - xstate[i] = 0.; - } - } - - /* next statements for plastic materials and nonlinear springs */ - - if (npmat_ > 0) { - RENEW(plicon, double, (2 * npmat_ + 1) * ntmat_ * nmat); - RENEW(nplicon, ITG, (ntmat_ + 1) * nmat); - RENEW(plkcon, double, (2 * npmat_ + 1) * ntmat_ * nmat); - RENEW(nplkcon, ITG, (ntmat_ + 1) * nmat); - } - - /* material orientation */ - - if (norien > 0) { - RENEW(orname, char, 80 * norien); - RENEW(ielorien, ITG, mi[2] * ne); - RENEW(orab, double, 7 * norien); - } else { - SFREE(orname); - SFREE(ielorien); - SFREE(orab); - } - - /* amplitude definitions */ - - if (nam > 0) { - RENEW(amname, char, 80 * nam); - RENEW(namta, ITG, 3 * nam); - RENEW(amta, double, 2 * namta[3 * nam - 2]); - } else { - SFREE(amname); - SFREE(amta); - SFREE(namta); - SFREE(iamforc); - SFREE(iamload); - SFREE(iamboun); - } - - if (ntrans > 0) { - RENEW(trab, double, 7 * ntrans); - } else { - SFREE(trab); - SFREE(inotr); - } - - if (ithermal[0] == 0) { - SFREE(t0); - SFREE(t1); - if ((ne1d != 0) || (ne2d != 0) || (nuel_ != 0)) { - SFREE(t0g); - SFREE(t1g); - } - } - - if ((ithermal[0] == 0) || (nam <= 0)) { - SFREE(iamt1); - } - - if (ncs_ > 0) { - RENEW(ics, ITG, ncs_); - } else if (npt_ > 0) { - SFREE(ics); - } - if ((ncs_ > 0) || (npt_ > 0)) { - SFREE(dcs); - } - - if (mcs > 0) { - RENEW(cs, double, 17 * mcs); - } else { - SFREE(cs); - } - - /* check for design variables */ - - for (i = 0; i < ntie; i++) { - if (strcmp1(&tieset[i * 243 + 80], "D") == 0) { - if (strcmp1(&tieset[i * 243], "COORDINATE") == 0) { - icoordinate = 1; - } - } - } - - } else { - - /* reallocating space in all but the first step (>1) */ - - RENEW(vold, double, mt *nk); - - /* if the SPC boundary conditions were changed in the present step, - they have to be rematched with those in the last step. Removed SPC - boundary conditions do not appear any more (this is different from - forces and loads, where removed forces or loads are reset to zero; - a removed SPC constraint does not have a numerical value any more) */ - - NNEW(reorder, double, nboun); - NNEW(nreorder, ITG, nboun); - if (nbounold < nboun) { - RENEW(xbounold, double, nboun); - RENEW(nodebounold, ITG, nboun); - RENEW(ndirbounold, ITG, nboun); - } - FORTRAN(spcmatch, (xboun, nodeboun, ndirboun, &nboun, xbounold, nodebounold, - ndirbounold, &nbounold, ikboun, ilboun, vold, reorder, nreorder, - mi, typeboun)); - RENEW(xbounold, double, nboun); - RENEW(nodebounold, ITG, nboun); - RENEW(ndirbounold, ITG, nboun); - SFREE(reorder); - SFREE(nreorder); - - /* for additional forces or loads in the present step, the - corresponding slots in the force and load fields of the - previous steps are initialized */ - - RENEW(xforcold, double, nforc); - for (i = nforcold; i < nforc; i++) - xforcold[i] = 0; - - RENEW(xloadold, double, 2 * nload); - for (i = 2 * nloadold; i < 2 * nload; i++) - xloadold[i] = 0; - - if (ithermal[0] != 0) { - RENEW(t1old, double, nk); - } - - if (nam > 0) { - RENEW(amname, char, 80 * nam); - RENEW(namta, ITG, 3 * nam); - RENEW(amta, double, 2 * namta[3 * nam - 2]); - } - } - - /* reallocating fields for all steps (>=1) */ - - RENEW(co, double, 3 * nk); - - RENEW(nodeboun, ITG, nboun); - RENEW(ndirboun, ITG, nboun); - RENEW(typeboun, char, nboun + 1); - RENEW(xboun, double, nboun); - RENEW(ikboun, ITG, nboun); - RENEW(ilboun, ITG, nboun); - - RENEW(nodeforc, ITG, 2 * nforc); - RENEW(ndirforc, ITG, nforc); - RENEW(xforc, double, nforc); - RENEW(ikforc, ITG, nforc); - RENEW(ilforc, ITG, nforc); - - /* temperature loading */ - - if (ithermal[0] != 0) { - RENEW(t0, double, nk); - RENEW(t1, double, nk); - if ((ne1d != 0) || (ne2d != 0) || (nuel_ != 0)) { - RENEW(t0g, double, 2 * nk); - RENEW(t1g, double, 2 * nk); - } - if (nam > 0) { - RENEW(iamt1, ITG, nk); - } - } - - RENEW(nelemload, ITG, 2 * nload); - RENEW(sideload, char, 20 * nload); - RENEW(xload, double, 2 * nload); - - RENEW(cbody, char, 81 * nbody); - RENEW(ibody, ITG, 3 * nbody); - RENEW(xbody, double, 7 * nbody); - RENEW(xbodyold, double, 7 * nbody); - - RENEW(ipompc, ITG, nmpc); - RENEW(labmpc, char, 20 * nmpc + 1); - RENEW(ikmpc, ITG, nmpc); - RENEW(ilmpc, ITG, nmpc); - RENEW(fmpc, double, nmpc); - - /* energy */ - - if ((nener == 1) && (nenerold == 0)) { - NNEW(ener, double, mi[0] * ne * 2); - if ((istep > 1) && (iperturb[0] > 1)) { - printf(" *ERROR in CalculiX: in nonlinear calculations\n"); - printf(" energy output must be selected in the first step\n\n"); - FORTRAN(stop, ()); - } - } - - /* initial velocities and accelerations */ - - if ((nmethod == 4) || (nmethod == 5) || (nmethod == 8) || (nmethod == 9) || - ((abs(nmethod) == 1) && (iperturb[0] >= 2))) { - RENEW(veold, double, mt *nk); - } else { - SFREE(veold); - } - - if ((nmethod == 4) && (iperturb[0] > 1)) { - NNEW(accold, double, mt *nk); - } - - if (nam > 0) { - RENEW(iamforc, ITG, nforc); - RENEW(iamload, ITG, 2 * nload); - RENEW(iamboun, ITG, nboun); - } - - /* generate force convection elements */ - - if (network > 0) { - ne0 = ne; - nkon0 = nkon; - nload1 = nload; - RENEW(ipkon, ITG, ne + nload); - RENEW(ielmat, ITG, mi[2] * (ne + nload)); - for (i = mi[2] * ne; i < mi[2] * (ne + nload); i++) - ielmat[i] = 0; - if (norien > 0) { - RENEW(ielorien, ITG, mi[2] * (ne + nload)); - for (i = mi[2] * ne; i < mi[2] * (ne + nload); i++) - ielorien[i] = 0; - } - RENEW(lakon, char, 8 * (ne + nload)); - RENEW(kon, ITG, nkon + 9 * nload); - NNEW(inodesd, ITG, nk); - RENEW(nelemload, ITG, 4 * nload); - RENEW(sideload, char, 40 * nload); - - FORTRAN(genadvecelem, (inodesd, ipkon, &ne, lakon, kon, &nload, - sideload, nelemload, &nkon, &network)); - - SFREE(inodesd); - RENEW(ipkon, ITG, ne); - RENEW(lakon, char, 8 * ne); - RENEW(kon, ITG, nkon); - RENEW(sti, double, 6 * mi[0] * ne); - RENEW(eme, double, 6 * mi[0] * ne); - if (iprestr > 0) - RENEW(prestr, double, 6 * mi[0] * ne); - if (nprop > 0) - RENEW(ielprop, ITG, ne); - if ((ne1d != 0) || (ne2d != 0)) - RENEW(offset, double, 2 * ne); - RENEW(nelemload, ITG, 2 * nload); - RENEW(sideload, char, 20 * nload); - RENEW(xload, double, 2 * nload); - RENEW(xloadold, double, 2 * nload); - if (nam > 0) { - RENEW(iamload, ITG, 2 * nload); - for (i = 2 * nload1; i < 2 * nload; i++) - iamload[i] = 0; - } - if (nener == 1) - RENEW(ener, double, mi[0] * ne * 2); - if (norien > 0) - RENEW(ielorien, ITG, mi[2] * ne); - RENEW(ielmat, ITG, mi[2] * ne); - for (i = mi[2] * ne0; i < mi[2] * ne; i++) - ielmat[i] = 1; - } - - if (ntrans > 0) { - RENEW(inotr, ITG, 2 * nk); - } - - /* calling the user routine ufaceload (can be empty) */ - - if (ithermal[1] >= 2) { - NNEW(sideloadtemp, char, 20 * nload); - for (i = 0; i < nload; i++) { - strcpy1(&sideloadtemp[20 * i], &sideload[20 * i], 20); - if ((strcmp1(&sideload[20 * i], " ") == 0) && - (strcmp1(&sideload[20 * i + 1], " ") != 0)) { - strcpy1(&sideloadtemp[20 * i], "F", 1); - } - } - FORTRAN(ufaceload, (co, ipkon, kon, lakon, &nboun, nodeboun, - nelemload, sideloadtemp, &nload, &ne, &nk)); - SFREE(sideloadtemp); - } - - /* storing the undecascaded MPC's if needed (triggered by - mpcfreeref=-1); this is the case: - 1) in the first step always - 2) in any subsequent step in which the MPC's were changed by - the user in the input deck */ - - if (mpcfreeref == -1) { - if (istep > 1) { - SFREE(nodempcref); - SFREE(coefmpcref); - SFREE(ikmpcref); - } - memmpcref_ = memmpc_; - mpcfreeref = mpcfree; - maxlenmpcref = maxlenmpc; - NNEW(nodempcref, ITG, 3 * memmpc_); - memcpy(nodempcref, nodempc, sizeof(ITG) * 3 * memmpc_); - NNEW(coefmpcref, double, memmpc_); - memcpy(coefmpcref, coefmpc, sizeof(double) * memmpc_); - NNEW(ikmpcref, ITG, nmpc); - memcpy(ikmpcref, ikmpc, sizeof(ITG) * nmpc); - } - - /* decascading MPC's only necessary if MPC's changed */ - - if (((istep == 1) || (ntrans > 0) || (mpcend < 0) || (nk != nkold) || (nmpc != nmpcold)) && (icascade == 0)) { - - /* decascading the MPC's */ - - printf(" Decascading the MPC's\n\n"); - - callfrommain = 1; - cascade(ipompc, &coefmpc, &nodempc, &nmpc, - &mpcfree, nodeboun, ndirboun, &nboun, ikmpc, - ilmpc, ikboun, ilboun, &mpcend, - labmpc, &nk, &memmpc_, &icascade, &maxlenmpc, - &callfrommain, iperturb, ithermal); - } - - /* determining the matrix structure: changes if SPC's have changed */ - - if ((icascade == 0) && (nmethod < 8)) - printf(" Determining the structure of the matrix:\n"); - - NNEW(nactdof, ITG, mt * nk); - NNEW(mast1, ITG, nzs[1]); - NNEW(irow, ITG, 1); - - if ((mcs == 0) || (cs[1] < 0)) { - - NNEW(icol, ITG, mt * nk); - NNEW(jq, ITG, mt * nk + 1); - NNEW(ipointer, ITG, mt * nk); - - if ((icascade == 0) && ((nmethod < 8) || (nmethod > 10))) { - if ((nmethod == 11) || (nmethod == 13)) { - nmethodl = 2; - } else { - nmethodl = nmethod; - } - mastruct(&nk, kon, ipkon, lakon, &ne, nodeboun, ndirboun, &nboun, ipompc, - nodempc, &nmpc, nactdof, icol, jq, &mast1, &irow, &isolver, neq, - ikmpc, ilmpc, ipointer, nzs, &nmethodl, ithermal, - ikboun, ilboun, iperturb, mi, &mortar, typeboun, labmpc, - &iit, &icascade, &network, &iexpl); - } else { - neq[0] = 1; - neq[1] = 1; - neq[2] = 1; - } - } else { - - NNEW(icol, ITG, 8 * nk); - NNEW(jq, ITG, 8 * nk + 1); - NNEW(ipointer, ITG, 8 * nk); - - if (nmethod == 13) { - nmethodl = 2; - } else { - nmethodl = nmethod; - } - mastructcs(&nk, kon, ipkon, lakon, &ne, nodeboun, ndirboun, &nboun, - ipompc, nodempc, &nmpc, nactdof, icol, jq, &mast1, &irow, &isolver, - neq, ikmpc, ilmpc, ipointer, nzs, &nmethodl, - ics, cs, labmpc, &mcs, mi, &mortar); - } - - SFREE(ipointer); - SFREE(mast1); - if ((icascade == 0) && (nmethod < 8)) - RENEW(irow, ITG, nzs[2]); - - /* nmethod=1: static analysis */ - /* nmethod=2: frequency analysis */ - /* nmethod=3: buckling analysis */ - /* nmethod=4: (linear or nonlinear) dynamic analysis */ - /* nmethod=5: steady state dynamics analysis */ - /* nmethod=6: Coriolis frequency calculation */ - /* nmethod=7: flutter frequency calculation */ - /* nmethod=8: magnetostatics */ - /* nmethod=9: magnetodynamics */ - /* nmethod=10: electromagnetic eigenvalue problems */ - /* nmethod=11: superelement creation */ - /* nmethod=12: sensitivity analysis */ - /* nmethod=13: Green function calculation */ - /* nmethod=14: Robustness w.r.t. to geometric tolerances */ - /* nmethod=15: Crack propagation */ - /* nmethod=16: Feasible direction based on sensitivity information */ - if (preciceUsed) { - int isStaticOrDynamic = ((nmethod == 1) || (nmethod == 4)) && (iperturb[0] > 1); - int isDynamic = ((nmethod == 4) && (iperturb[0] > 1)); - int isThermalAnalysis = ithermal[0] >= 2; - int isModalDynamic = ((nmethod == 4) && (iperturb[0] < 2)); - int isStaticNLGEOM = ((nmethod == 1) && (iperturb[0] > 1)); - - if (isStaticOrDynamic && isThermalAnalysis) { - - printf("Starting CHT analysis via preCICE...\n"); - - mpcinfo[0] = memmpc_; - mpcinfo[1] = mpcfree; - mpcinfo[2] = icascade; - mpcinfo[3] = maxlenmpc; - - nonlingeo_precice(&co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, - &nboun, &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, - ndirforc, xforc, &nforc, &nelemload, &sideload, xload, &nload, - nactdof, &icol, jq, &irow, neq, &nzl, &nmethod, &ikmpc, &ilmpc, - ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, alcon, nalcon, - alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, t0, t1, t1old, - ithermal, prestr, &iprestr, &vold, iperturb, sti, nzs, &kode, - filab, &idrct, jmax, jout, timepar, eme, xbounold, xforcold, - xloadold, veold, accold, amname, amta, namta, &nam, iamforc, - &iamload, iamt1, alpha, &iexpl, iamboun, plicon, nplicon, plkcon, - nplkcon, &xstate, &npmat_, &istep, &ttime, matname, qaold, mi, - &isolver, &ncmat_, &nstate_, &iumat, cs, &mcs, &nkon, &ener, - mpcinfo, output, shcon, nshcon, cocon, ncocon, physcon, &nflow, - ctrl, set, &nset, istartset, iendset, ialset, &nprint, prlab, - prset, &nener, ikforc, ilforc, trab, inotr, &ntrans, &fmpc, cbody, - ibody, xbody, &nbody, xbodyold, ielprop, prop, &ntie, tieset, - &itpamp, &iviewfile, jobnamec, tietol, &nslavs, thicke, ics, - &nintpoint, &mortar, &ifacecount, typeboun, &islavsurf, - &pslavsurf, &clearini, &nmat, xmodal, &iaxial, &inext, &nprop, - &network, orname, vel, &nef, velo, veloo, energy, itempuser, - ipobody, &inewton, t0g, t1g, &ifreebody, - /* PreCICE args */ - preciceParticipantName, configFilename); - - memmpc_ = mpcinfo[0]; - mpcfree = mpcinfo[1]; - icascade = mpcinfo[2]; - maxlenmpc = mpcinfo[3]; - - } else if (isDynamic && !isThermalAnalysis) { - - printf("Starting FSI analysis via preCICE"); - - if (iperturb[1] == 0) { - printf(" using the geometrically linear CalculiX solver...\n"); - - mpcinfo[0] = memmpc_; - mpcinfo[1] = mpcfree; - mpcinfo[2] = icascade; - mpcinfo[3] = maxlenmpc; - - nonlingeo_precice(&co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, - &nboun, &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, - ndirforc, xforc, &nforc, &nelemload, &sideload, xload, &nload, - nactdof, &icol, jq, &irow, neq, &nzl, &nmethod, &ikmpc, &ilmpc, - ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, alcon, nalcon, - alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, t0, t1, t1old, - ithermal, prestr, &iprestr, &vold, iperturb, sti, nzs, &kode, - filab, &idrct, jmax, jout, timepar, eme, xbounold, xforcold, - xloadold, veold, accold, amname, amta, namta, &nam, iamforc, - &iamload, iamt1, alpha, &iexpl, iamboun, plicon, nplicon, plkcon, - nplkcon, &xstate, &npmat_, &istep, &ttime, matname, qaold, mi, - &isolver, &ncmat_, &nstate_, &iumat, cs, &mcs, &nkon, &ener, - mpcinfo, output, shcon, nshcon, cocon, ncocon, physcon, &nflow, - ctrl, set, &nset, istartset, iendset, ialset, &nprint, prlab, - prset, &nener, ikforc, ilforc, trab, inotr, &ntrans, &fmpc, cbody, - ibody, xbody, &nbody, xbodyold, ielprop, prop, &ntie, tieset, - &itpamp, &iviewfile, jobnamec, tietol, &nslavs, thicke, ics, - &nintpoint, &mortar, &ifacecount, typeboun, &islavsurf, - &pslavsurf, &clearini, &nmat, xmodal, &iaxial, &inext, &nprop, - &network, orname, vel, &nef, velo, veloo, energy, itempuser, - ipobody, &inewton, t0g, t1g, &ifreebody, - /* PreCICE args */ - preciceParticipantName, configFilename); - - memmpc_ = mpcinfo[0]; - mpcfree = mpcinfo[1]; - icascade = mpcinfo[2]; - maxlenmpc = mpcinfo[3]; - } else if (iperturb[1] == 1) { - printf(" using the geometrically non-linear CalculiX solver...\n"); - - mpcinfo[0] = memmpc_; - mpcinfo[1] = mpcfree; - mpcinfo[2] = icascade; - mpcinfo[3] = maxlenmpc; - - nonlingeo_precice(&co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, - &nboun, &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, - ndirforc, xforc, &nforc, &nelemload, &sideload, xload, &nload, - nactdof, &icol, jq, &irow, neq, &nzl, &nmethod, &ikmpc, &ilmpc, - ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, alcon, nalcon, - alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, t0, t1, t1old, - ithermal, prestr, &iprestr, &vold, iperturb, sti, nzs, &kode, - filab, &idrct, jmax, jout, timepar, eme, xbounold, xforcold, - xloadold, veold, accold, amname, amta, namta, &nam, iamforc, - &iamload, iamt1, alpha, &iexpl, iamboun, plicon, nplicon, plkcon, - nplkcon, &xstate, &npmat_, &istep, &ttime, matname, qaold, mi, - &isolver, &ncmat_, &nstate_, &iumat, cs, &mcs, &nkon, &ener, - mpcinfo, output, shcon, nshcon, cocon, ncocon, physcon, &nflow, - ctrl, set, &nset, istartset, iendset, ialset, &nprint, prlab, - prset, &nener, ikforc, ilforc, trab, inotr, &ntrans, &fmpc, cbody, - ibody, xbody, &nbody, xbodyold, ielprop, prop, &ntie, tieset, - &itpamp, &iviewfile, jobnamec, tietol, &nslavs, thicke, ics, - &nintpoint, &mortar, &ifacecount, typeboun, &islavsurf, - &pslavsurf, &clearini, &nmat, xmodal, &iaxial, &inext, &nprop, - &network, orname, vel, &nef, velo, veloo, energy, itempuser, - ipobody, &inewton, t0g, t1g, &ifreebody, - /* PreCICE args */ - preciceParticipantName, configFilename); - - memmpc_ = mpcinfo[0]; - mpcfree = mpcinfo[1]; - icascade = mpcinfo[2]; - maxlenmpc = mpcinfo[3]; - } else { - printf("ERROR: This simulation type is not available with preCICE"); - exit(0); - } - } else if (isStaticNLGEOM) { - - printf("Starting STATIC analysis via preCICE...\n"); - - mpcinfo[0] = memmpc_; - mpcinfo[1] = mpcfree; - mpcinfo[2] = icascade; - mpcinfo[3] = maxlenmpc; - - nonlingeo_precice(&co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, - &nboun, &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, - ndirforc, xforc, &nforc, &nelemload, &sideload, xload, &nload, - nactdof, &icol, jq, &irow, neq, &nzl, &nmethod, &ikmpc, &ilmpc, - ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, alcon, nalcon, - alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, t0, t1, t1old, - ithermal, prestr, &iprestr, &vold, iperturb, sti, nzs, &kode, - filab, &idrct, jmax, jout, timepar, eme, xbounold, xforcold, - xloadold, veold, accold, amname, amta, namta, &nam, iamforc, - &iamload, iamt1, alpha, &iexpl, iamboun, plicon, nplicon, plkcon, - nplkcon, &xstate, &npmat_, &istep, &ttime, matname, qaold, mi, - &isolver, &ncmat_, &nstate_, &iumat, cs, &mcs, &nkon, &ener, - mpcinfo, output, shcon, nshcon, cocon, ncocon, physcon, &nflow, - ctrl, set, &nset, istartset, iendset, ialset, &nprint, prlab, - prset, &nener, ikforc, ilforc, trab, inotr, &ntrans, &fmpc, cbody, - ibody, xbody, &nbody, xbodyold, ielprop, prop, &ntie, tieset, - &itpamp, &iviewfile, jobnamec, tietol, &nslavs, thicke, ics, - &nintpoint, &mortar, &ifacecount, typeboun, &islavsurf, - &pslavsurf, &clearini, &nmat, xmodal, &iaxial, &inext, &nprop, - &network, orname, vel, &nef, velo, veloo, energy, itempuser, - ipobody, &inewton, t0g, t1g, &ifreebody, - /* PreCICE args */ - preciceParticipantName, configFilename); - - memmpc_ = mpcinfo[0]; - mpcfree = mpcinfo[1]; - icascade = mpcinfo[2]; - maxlenmpc = mpcinfo[3]; - - } else if (isModalDynamic) { - - printf("Starting FSI analysis via preCICE\n"); - - if ((ne1d != 0) || (ne2d != 0)) { - printf(" *WARNING: 1-D or 2-D elements may cause problems in modal dynamic calculations\n"); - printf(" ensure that point loads defined in a *MODAL DYNAMIC step\n"); - printf(" and applied to nodes belonging to 1-D or 2-D elements have been\n"); - printf(" applied to the same nodes in the preceding FREQUENCY step with\n"); - printf(" magnitude zero; look at example shellf.inp for a guideline.\n\n"); - } - - printf(" Composing the dynamic response from the eigenmodes\n\n"); - - dyna_precice(&co, &nk, &kon, &ipkon, &lakon, &ne, &nodeboun, &ndirboun, &xboun, &nboun, - &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, ndirforc, xforc, - &nforc, - nelemload, sideload, xload, &nload, - &nactdof, neq, &nzl, icol, irow, &nmethod, &ikmpc, &ilmpc, &ikboun, &ilboun, - elcon, nelcon, rhcon, nrhcon, cocon, ncocon, - alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, &t0, - &t1, ithermal, prestr, &iprestr, &vold, iperturb, &sti, nzs, - timepar, xmodal, &veold, amname, amta, - namta, &nam, iamforc, iamload, &iamt1, - jout, &kode, filab, &eme, xforcold, xloadold, - &t1old, &iamboun, &xbounold, &iexpl, plicon, - nplicon, plkcon, nplkcon, &xstate, &npmat_, matname, - mi, &ncmat_, &nstate_, &ener, jobnamec, &ttime, set, &nset, - istartset, iendset, &ialset, &nprint, prlab, - prset, &nener, trab, &inotr, &ntrans, &fmpc, ipobody, ibody, xbody, &nbody, - xbodyold, &istep, &isolver, jq, output, &mcs, &nkon, &mpcend, ics, cs, - &ntie, tieset, &idrct, jmax, ctrl, &itpamp, tietol, &nalset, - ikforc, ilforc, thicke, &nslavs, &nmat, typeboun, ielprop, prop, orname, - t0g, t1g, - preciceParticipantName, configFilename); - } else { - printf("ERROR: Only thermal coupling or FSI is available with preCICE"); - exit(0); - } - } else if ((nmethod <= 1) || (nmethod == 11) || ((iperturb[0] > 1) && (nmethod < 8))) { - if (iperturb[0] < 2) { - - mpcinfo[0] = memmpc_; - mpcinfo[1] = mpcfree; - mpcinfo[2] = icascade; - mpcinfo[3] = maxlenmpc; - - if (icascade != 0) { - printf(" *ERROR in CalculiX: the matrix structure may"); - printf(" change due to nonlinear equations;"); - printf(" a purely linear calculation is not"); - printf(" feasible; use NLGEOM on the *STEP card."); - FORTRAN(stop, ()); - } - - linstatic(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, - &nboun, - ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, ndirforc, xforc, - &nforc, nelemload, sideload, xload, &nload, - nactdof, &icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, - ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, - alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, - t0, t1, t1old, ithermal, prestr, &iprestr, vold, iperturb, sti, nzs, - &kode, filab, eme, &iexpl, plicon, - nplicon, plkcon, nplkcon, &xstate, &npmat_, matname, - &isolver, mi, &ncmat_, &nstate_, cs, &mcs, &nkon, &ener, - xbounold, xforcold, xloadold, amname, amta, namta, - &nam, iamforc, iamload, iamt1, iamboun, &ttime, - output, set, &nset, istartset, iendset, ialset, &nprint, prlab, - prset, &nener, trab, inotr, &ntrans, fmpc, ipobody, ibody, xbody, - &nbody, - xbodyold, timepar, thicke, jobnamec, tieset, &ntie, &istep, &nmat, - ielprop, prop, typeboun, &mortar, mpcinfo, tietol, ics, - orname, itempuser, t0g, t1g); - - for (i = 0; i < 3; i++) { - nzsprevstep[i] = nzs[i]; - } - - memmpc_ = mpcinfo[0]; - mpcfree = mpcinfo[1]; - icascade = mpcinfo[2]; - maxlenmpc = mpcinfo[3]; - - } - - else { - - mpcinfo[0] = memmpc_; - mpcinfo[1] = mpcfree; - mpcinfo[2] = icascade; - mpcinfo[3] = maxlenmpc; - - nonlingeo(&co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, - &nboun, &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, - ndirforc, xforc, &nforc, &nelemload, &sideload, xload, &nload, - nactdof, &icol, jq, &irow, neq, &nzl, &nmethod, &ikmpc, &ilmpc, - ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, alcon, nalcon, - alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, t0, t1, t1old, - ithermal, prestr, &iprestr, &vold, iperturb, sti, nzs, &kode, - filab, &idrct, jmax, jout, timepar, eme, xbounold, xforcold, - xloadold, veold, accold, amname, amta, namta, &nam, iamforc, - &iamload, iamt1, alpha, &iexpl, iamboun, plicon, nplicon, plkcon, - nplkcon, &xstate, &npmat_, &istep, &ttime, matname, qaold, mi, - &isolver, &ncmat_, &nstate_, &iumat, cs, &mcs, &nkon, &ener, - mpcinfo, output, shcon, nshcon, cocon, ncocon, physcon, &nflow, - ctrl, set, &nset, istartset, iendset, ialset, &nprint, prlab, - prset, &nener, ikforc, ilforc, trab, inotr, &ntrans, &fmpc, cbody, - ibody, xbody, &nbody, xbodyold, ielprop, prop, &ntie, tieset, - &itpamp, &iviewfile, jobnamec, tietol, &nslavs, thicke, ics, - &nintpoint, &mortar, &ifacecount, typeboun, &islavsurf, - &pslavsurf, &clearini, &nmat, xmodal, &iaxial, &inext, &nprop, - &network, orname, vel, &nef, velo, veloo, energy, itempuser, - ipobody, &inewton, t0g, t1g, &ifreebody); - - memmpc_ = mpcinfo[0]; - mpcfree = mpcinfo[1]; - icascade = mpcinfo[2]; - maxlenmpc = mpcinfo[3]; - - for (i = 0; i < 3; i++) { - nzsprevstep[i] = nzs[i]; - } - } - } else if ((nmethod == 2) || (nmethod == 13)) { - - /* FREQUENCY ANALYSIS */ - - if ((mcs == 0) || (cs[1] < 0)) { -#ifdef ARPACK - - mpcinfo[0] = memmpc_; - mpcinfo[1] = mpcfree; - mpcinfo[2] = icascade; - mpcinfo[3] = maxlenmpc; - - arpack(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, &nboun, - ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, ndirforc, xforc, - &nforc, nelemload, sideload, xload, &nload, - nactdof, icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, - ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, - shcon, nshcon, cocon, ncocon, - alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, - t0, t1, t1old, ithermal, prestr, &iprestr, vold, iperturb, sti, nzs, - &kode, mei, fei, filab, - &iexpl, plicon, nplicon, plkcon, nplkcon, - &xstate, &npmat_, matname, mi, &ncmat_, &nstate_, &ener, jobnamec, - output, set, &nset, istartset, iendset, ialset, &nprint, prlab, - prset, &nener, &isolver, trab, inotr, &ntrans, &ttime, fmpc, ipobody, - ibody, xbody, &nbody, thicke, &nslavs, tietol, &nkon, mpcinfo, - &ntie, &istep, &mcs, ics, tieset, cs, &nintpoint, &mortar, &ifacecount, - &islavsurf, &pslavsurf, &clearini, &nmat, typeboun, ielprop, prop, - orname, &inewton, t0g, t1g); - - memmpc_ = mpcinfo[0]; - mpcfree = mpcinfo[1]; - icascade = mpcinfo[2]; - maxlenmpc = mpcinfo[3]; - - for (i = 0; i < 3; i++) { - nzsprevstep[i] = nzs[i]; - } - -#else - printf(" *ERROR in CalculiX: the ARPACK library is not linked\n\n"); - FORTRAN(stop, ()); -#endif - - } else { - -#ifdef ARPACK - - mpcinfo[0] = memmpc_; - mpcinfo[1] = mpcfree; - mpcinfo[2] = icascade; - mpcinfo[3] = maxlenmpc; - - arpackcs(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, - xboun, &nboun, - ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, ndirforc, xforc, - &nforc, nelemload, sideload, xload, &nload, - nactdof, icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, - ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, - alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, - t0, t1, t1old, ithermal, prestr, &iprestr, - vold, iperturb, sti, nzs, &kode, mei, fei, filab, - &iexpl, plicon, nplicon, plkcon, nplkcon, - &xstate, &npmat_, matname, mi, ics, cs, &mpcend, &ncmat_, - &nstate_, &mcs, &nkon, jobnamec, output, set, &nset, istartset, - iendset, ialset, &nprint, prlab, - prset, &nener, &isolver, trab, inotr, &ntrans, &ttime, fmpc, ipobody, - ibody, xbody, &nbody, &nevtot, thicke, &nslavs, tietol, mpcinfo, - &ntie, &istep, tieset, &nintpoint, &mortar, &ifacecount, &islavsurf, - &pslavsurf, &clearini, &nmat, typeboun, ielprop, prop, orname, - &inewton, t0g, t1g); - - memmpc_ = mpcinfo[0]; - mpcfree = mpcinfo[1]; - icascade = mpcinfo[2]; - maxlenmpc = mpcinfo[3]; - - for (i = 0; i < 3; i++) { - nzsprevstep[i] = nzs[i]; - } - -#else - printf(" *ERROR in CalculiX: the ARPACK library is not linked\n\n"); - FORTRAN(stop, ()); -#endif - } - } else if (nmethod == 3) { - -#ifdef ARPACK - arpackbu(co, &nk, kon, ipkon, lakon, &ne, nodeboun, ndirboun, xboun, &nboun, - ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, ndirforc, xforc, - &nforc, - nelemload, sideload, xload, &nload, - nactdof, icol, jq, irow, neq, &nzl, &nmethod, ikmpc, - ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, - alcon, nalcon, alzero, ielmat, ielorien, &norien, orab, &ntmat_, - t0, t1, t1old, ithermal, prestr, &iprestr, - vold, iperturb, sti, nzs, &kode, mei, fei, filab, - eme, &iexpl, plicon, nplicon, plkcon, nplkcon, - xstate, &npmat_, matname, mi, &ncmat_, &nstate_, ener, output, - set, &nset, istartset, iendset, ialset, &nprint, prlab, - prset, &nener, &isolver, trab, inotr, &ntrans, &ttime, fmpc, ipobody, - ibody, xbody, &nbody, thicke, jobnamec, &nmat, ielprop, prop, - orname, typeboun, t0g, t1g); -#else - printf(" *ERROR in CalculiX: the ARPACK library is not linked\n\n"); - FORTRAN(stop, ()); -#endif - } else if (nmethod == 4) { - if ((ne1d != 0) || (ne2d != 0)) { - printf(" *WARNING: 1-D or 2-D elements may cause problems in modal dynamic calculations\n"); - printf(" ensure that point loads defined in a *MODAL DYNAMIC step\n"); - printf(" and applied to nodes belonging to 1-D or 2-D elements have been\n"); - printf(" applied to the same nodes in the preceding FREQUENCY step with\n"); - printf(" magnitude zero; look at example shellf.inp for a guideline.\n\n"); - } - - printf(" Composing the dynamic response from the eigenmodes\n\n"); - - dyna(&co, &nk, &kon, &ipkon, &lakon, &ne, &nodeboun, &ndirboun, &xboun, &nboun, - &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, ndirforc, xforc, - &nforc, - nelemload, sideload, xload, &nload, - &nactdof, neq, &nzl, icol, irow, &nmethod, &ikmpc, &ilmpc, &ikboun, &ilboun, - elcon, nelcon, rhcon, nrhcon, cocon, ncocon, - alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, &t0, - &t1, ithermal, prestr, &iprestr, &vold, iperturb, &sti, nzs, - timepar, xmodal, &veold, amname, amta, - namta, &nam, iamforc, iamload, &iamt1, - jout, &kode, filab, &eme, xforcold, xloadold, - &t1old, &iamboun, &xbounold, &iexpl, plicon, - nplicon, plkcon, nplkcon, &xstate, &npmat_, matname, - mi, &ncmat_, &nstate_, &ener, jobnamec, &ttime, set, &nset, - istartset, iendset, &ialset, &nprint, prlab, - prset, &nener, trab, &inotr, &ntrans, &fmpc, ipobody, ibody, xbody, &nbody, - xbodyold, &istep, &isolver, jq, output, &mcs, &nkon, &mpcend, ics, cs, - &ntie, tieset, &idrct, jmax, ctrl, &itpamp, tietol, &nalset, - ikforc, ilforc, thicke, &nslavs, &nmat, typeboun, ielprop, prop, orname, - t0g, t1g); - } else if (nmethod == 5) { - if ((ne1d != 0) || (ne2d != 0)) { - printf(" *WARNING: 1-D or 2-D elements may cause problems in steady state calculations\n"); - printf(" ensure that point loads defined in a *STEADY STATE DYNAMICS step\n"); - printf(" and applied to nodes belonging to 1-D or 2-D elements have been\n"); - printf(" applied to the same nodes in the preceding FREQUENCY step with\n"); - printf(" magnitude zero; look at example shellf.inp for a guideline.\n\n"); - } - - printf(" Composing the steady state response from the eigenmodes\n\n"); - - steadystate(&co, &nk, &kon, &ipkon, &lakon, &ne, &nodeboun, &ndirboun, &xboun, - &nboun, - &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, ndirforc, - xforc, &nforc, - nelemload, sideload, xload, &nload, - &nactdof, neq, &nzl, icol, irow, &nmethod, &ikmpc, &ilmpc, &ikboun, - &ilboun, - elcon, nelcon, rhcon, nrhcon, cocon, ncocon, - alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, - &t0, - &t1, ithermal, prestr, &iprestr, &vold, iperturb, sti, nzs, - timepar, xmodal, &veold, amname, amta, - namta, &nam, iamforc, iamload, &iamt1, - jout, &kode, filab, &eme, xforcold, xloadold, - &t1old, &iamboun, &xbounold, &iexpl, plicon, - nplicon, plkcon, nplkcon, xstate, &npmat_, matname, - mi, &ncmat_, &nstate_, &ener, jobnamec, &ttime, set, &nset, - istartset, iendset, ialset, &nprint, prlab, - prset, &nener, trab, &inotr, &ntrans, &fmpc, ipobody, ibody, xbody, - &nbody, - xbodyold, &istep, &isolver, jq, output, &mcs, &nkon, ics, cs, - &mpcend, - ctrl, ikforc, ilforc, thicke, &nmat, typeboun, ielprop, prop, - orname, - &ndamp, dacon, t0g, t1g); - } else if ((nmethod == 6) || (nmethod == 7)) { - - printf(" Composing the complex eigenmodes from the real eigenmodes\n\n"); - - complexfreq(&co, &nk, &kon, &ipkon, &lakon, &ne, &nodeboun, &ndirboun, &xboun, - &nboun, &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, - ndirforc, xforc, &nforc, - nelemload, sideload, xload, &nload, - &nactdof, neq, &nzl, icol, irow, &nmethod, &ikmpc, &ilmpc, &ikboun, - &ilboun, - elcon, nelcon, rhcon, nrhcon, cocon, ncocon, - alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, - &t0, - &t1, ithermal, prestr, &iprestr, &vold, iperturb, &sti, nzs, - timepar, xmodal, &veold, amname, amta, - namta, &nam, iamforc, iamload, &iamt1, - jout, &kode, filab, &eme, xforcold, xloadold, - &t1old, &iamboun, &xbounold, &iexpl, plicon, - nplicon, plkcon, nplkcon, xstate, &npmat_, matname, - mi, &ncmat_, &nstate_, &ener, jobnamec, &ttime, set, &nset, - istartset, iendset, &ialset, &nprint, prlab, - prset, &nener, trab, &inotr, &ntrans, &fmpc, ipobody, ibody, xbody, - &nbody, - xbodyold, &istep, &isolver, jq, output, &mcs, &nkon, &mpcend, ics, - cs, - &ntie, tieset, &idrct, jmax, ctrl, &itpamp, tietol, &nalset, - ikforc, ilforc, thicke, jobnamef, mei, &nmat, ielprop, prop, orname, - typeboun, t0g, t1g); - } else if ((nmethod > 7) && (nmethod < 12)) { - - mpcinfo[0] = memmpc_; - mpcinfo[1] = mpcfree; - mpcinfo[2] = icascade; - mpcinfo[3] = maxlenmpc; - - electromagnetics(&co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, - ndirboun, xboun, &nboun, - &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, - ndirforc, xforc, - &nforc, &nelemload, &sideload, xload, &nload, - nactdof, &icol, &jq, &irow, neq, &nzl, &nmethod, &ikmpc, - &ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, - alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, - &ntmat_, - t0, t1, t1old, ithermal, prestr, &iprestr, - &vold, iperturb, sti, nzs, &kode, filab, &idrct, jmax, - jout, timepar, eme, xbounold, xforcold, xloadold, - veold, accold, amname, amta, namta, - &nam, iamforc, &iamload, iamt1, alpha, - &iexpl, iamboun, plicon, nplicon, plkcon, nplkcon, - &xstate, &npmat_, &istep, &ttime, matname, qaold, mi, - &isolver, &ncmat_, &nstate_, &iumat, cs, &mcs, &nkon, &ener, - mpcinfo, output, - shcon, nshcon, cocon, ncocon, physcon, &nflow, ctrl, - &set, &nset, &istartset, &iendset, &ialset, &nprint, prlab, - prset, &nener, ikforc, ilforc, trab, inotr, &ntrans, &fmpc, - ipobody, ibody, xbody, &nbody, xbodyold, ielprop, prop, - &ntie, &tieset, &itpamp, &iviewfile, jobnamec, &tietol, - &nslavs, thicke, - ics, &nalset, &nmpc_, &nmat, typeboun, &iaxial, &nload_, &nprop, - &network, orname, t0g, t1g); - - memmpc_ = mpcinfo[0]; - mpcfree = mpcinfo[1]; - icascade = mpcinfo[2]; - maxlenmpc = mpcinfo[3]; - } - - else if (nmethod == 12) { - - if (icoordinate == 1) { - sensi_coor(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, - xboun, &nboun, ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, - ndirforc, xforc, &nforc, nelemload, sideload, xload, &nload, - nactdof, icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, - ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, - alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, - t0, t1, t1old, ithermal, prestr, &iprestr, vold, iperturb, sti, nzs, - &kode, filab, eme, &iexpl, plicon, - nplicon, plkcon, nplkcon, &xstate, &npmat_, matname, - &isolver, mi, &ncmat_, &nstate_, cs, &mcs, &nkon, &ener, - xbounold, xforcold, xloadold, amname, amta, namta, - &nam, iamforc, iamload, iamt1, iamboun, &ttime, - output, set, &nset, istartset, iendset, ialset, &nprint, prlab, - prset, &nener, trab, inotr, &ntrans, fmpc, ipobody, ibody, xbody, - &nbody, - xbodyold, timepar, thicke, jobnamec, tieset, &ntie, &istep, &nmat, - ielprop, prop, typeboun, &mortar, mpcinfo, tietol, ics, - &nobject, &objectset, &istat, orname, nzsprevstep, &nlabel, - physcon, - jobnamef, iponor, knor, &ne2d, iponoel, inoel, &mpcend, dgdxglob, - g0, &nodedesi, &ndesi, &nobjectstart, &xdesi); - - } else { - sensi_orien(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, - xboun, &nboun, ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, - ndirforc, xforc, &nforc, nelemload, sideload, xload, &nload, - nactdof, icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, - ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, - alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, - t0, t1, t1old, ithermal, prestr, &iprestr, vold, iperturb, sti, nzs, - &kode, filab, eme, &iexpl, plicon, - nplicon, plkcon, nplkcon, &xstate, &npmat_, matname, - &isolver, mi, &ncmat_, &nstate_, cs, &mcs, &nkon, &ener, - xbounold, xforcold, xloadold, amname, amta, namta, - &nam, iamforc, iamload, iamt1, iamboun, &ttime, - output, set, &nset, istartset, iendset, ialset, &nprint, prlab, - prset, &nener, trab, inotr, &ntrans, fmpc, ipobody, ibody, xbody, - &nbody, - xbodyold, timepar, thicke, jobnamec, tieset, &ntie, &istep, &nmat, - ielprop, prop, typeboun, &mortar, mpcinfo, tietol, ics, - &nobject, &objectset, &istat, orname, nzsprevstep, &nlabel, - physcon, - jobnamef, iponor, knor, &ne2d, iponoel, inoel, &mpcend); - } - - } - - else if (nmethod == 14) { - - robustdesign(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, - &nboun, ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, - ndirforc, xforc, &nforc, nelemload, sideload, xload, &nload, - nactdof, icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, ilmpc, ikboun, - ilboun, elcon, nelcon, rhcon, nrhcon, alcon, nalcon, alzero, - &ielmat, &ielorien, &norien, orab, &ntmat_, t0, t1, t1old, ithermal, - prestr, &iprestr, vold, iperturb, sti, nzs, &kode, filab, eme, - &iexpl, plicon, nplicon, plkcon, nplkcon, &xstate, &npmat_, - matname, &isolver, mi, &ncmat_, &nstate_, cs, &mcs, &nkon, &ener, - xbounold, xforcold, xloadold, amname, amta, namta, &nam, iamforc, - iamload, iamt1, iamboun, &ttime, output, set, &nset, istartset, - iendset, ialset, &nprint, prlab, prset, &nener, trab, inotr, - &ntrans, fmpc, ipobody, ibody, xbody, &nbody, xbodyold, timepar, - thicke, jobnamec, tieset, &ntie, &istep, &nmat, ielprop, prop, - typeboun, &mortar, mpcinfo, tietol, ics, &nobject, - &objectset, &istat, orname, nzsprevstep, &nlabel, physcon, - jobnamef, iponor, knor, &ne2d, iponoel, inoel, &mpcend, - irobustdesign, irandomtype, randomval); - } - - else if (nmethod == 15) { - - crackpropagation(&ipkon, &kon, &lakon, &ne, &nk, jobnamec, &nboun, iamboun, xboun, - &nload, sideload, iamload, &nforc, iamforc, xforc, ithermal, - &t1, &iamt1, &co, &nkon, mi, &ielmat, matname, output, &nmat, set, - &nset, istartset, iendset, ialset, jmax, timepar, nelcon, - elcon, &ncmat_, &ntmat_, &istep, filab, &nmethod, mei, &ntrans, - &inotr, &t0, &ne1d, &ne2d, &t0g, &t1g, &nam, &t1old, &vold, - iperturb, &iprestr, &prestr, &norien, &ielorien, &nprop, - &ielprop, &offset, &sti, &eme, &nener, &ener, &nstate_, - &mortar, &nslavs, &nintpoint, &xstate, &iponor, &thicke); - } - - else if (nmethod == 16) { - - feasibledirection(&nobject, &objectset, &dgdxglob, g0, &ndesi, nodedesi, &nk, - &isolver, &ipkon, &kon, &lakon, &ne, nelemload, &nload, - nodeboun, &nboun, ndirboun, ithermal, co, vold, mi, &ielmat, - ielprop, prop, &kode, &nmethod, filab, &nstate_, &istep, cs, - set, &nset, istartset, iendset, ialset, jobnamec, output, - &ntrans, inotr, trab, orname, xdesi); - } - - SFREE(nactdof); - SFREE(icol); - SFREE(jq); - SFREE(irow); - SFREE(ipobody); - - /* check whether refinement was active */ - - // if(irefineloop==20){ - if (strcmp1(&filab[4089], "RM") == 0) { - irefineloop++; - - if (irefineloop == 1) { - - /* refinement was requested in the step which was just - finished and a refined mesh was created and stored. - The calculation has to restart from the beginning with - this new mesh */ - - memcpy(ipoinp, ipoinp_sav, sizeof(ITG) * 2 * nentries); - memcpy(inp, inp_sav, sizeof(ITG) * inp_size); - - /* deallocating fields */ - - dealloc_cal(&ncs_, &ics, &mcs, &cs, &tieset, &tietol, &co, - &kon, &ipkon, &lakon, &nodeboun, &ndirboun, &typeboun, &xboun, - &ikboun, &ilboun, &nodebounold, &ndirbounold, &xbounold, &ipompc, - &labmpc, &ikmpc, &ilmpc, &fmpc, &nodempc, &coefmpc, &nodempcref, - &coefmpcref, &ikmpcref, &nodeforc, &ndirforc, &xforc, - &ikforc, &ilforc, &xforcold, &nelemload, &sideload, &xload, - &xloadold, &cbody, &ibody, &xbody, &xbodyold, &nam, - &iamboun, &iamforc, &iamload, &amname, &amta, &namta, &set, - &istartset, &iendset, &ialset, &elcon, &nelcon, &rhcon, - &nrhcon, &shcon, &nshcon, &cocon, &ncocon, &alcon, - &nalcon, &alzero, &nprop, &ielprop, &prop, &npmat_, - &plicon, &nplicon, &plkcon, &nplkcon, &ndamp, &dacon, &norien, - &orname, &orab, &ielorien, &ntrans, &trab, &inotr, &iprestr, - &prestr, ithermal, &t0, &t1, &t1old, &iamt1, &ne1d, - &ne2d, &t0g, &t1g, irobustdesign, &irandomtype, - &randomval, &prlab, &prset, &filab, &xmodal, &ielmat, - &matname, &sti, &eme, &ener, &xstate, &vold, - &veold, &vel, &velo, &veloo, &iponor, &xnor, - &knor, &thicke, &offset, &iponoel, &inoel, &rig, - &ne2boun, &islavsurf, &mortar, &pslavsurf, &clearini, - &nobject_, &objectset, &nmethod, iperturb, &irefineloop, - &iparentel, &iprfn, &konrfn, &ratiorfn, &heading, - &nodedesi, &dgdxglob, &g0, &nuel_, &xdesi, &nfc, &coeffc, - &ikdc, &edc); - - /* closing and reopening the output files */ - - FORTRAN(openfile, (jobnamef)); - - /* initialization of the variables */ - - ini_cal(jobnamec, output, fneig, kind1, kind2, itempuser, irobustdesign, - &nprint, neq, &mpcfree, &nbounold, &nforcold, &nloadold, &nbody_, - &nbodyold, &network, &nheading_, &nmpc_, &nload_, &nforc_, &nboun_, - &nintpoint, iperturb, &ntmat_, ithermal, &isolver, &nslavs, &nkon_, - &mortar, jout, &nkon, &nevtot, &ifacecount, &iplas, &npmat_, mi, - &mpcend, &namtot_, &iumat, &icascade, &ne1d, &ne2d, infree, &nflow, - irstrt, &nener, &jrstrt, &ntie_, &mcs, &nprop_, &nprop, &itpamp, - &nevdamp_, &npt_, &iaxial, &inext, &icontact, &nobject, &nobject_, - &iit, &mpcfreeref, &isens, &namtot, &nstam, &ndamp, &nef, - &nk_, &ne_, &nalset_, &nmat_, &norien_, &nam_, &ntrans_, - &ncs_, &nstate_, &ncmat_, &memmpc_, &nprint_, energy, ctrl, alpha, - qaold, physcon, &istep, &istat, &iprestr, &kode, &nload, &nbody, &nforc, - &nboun, &nk, &nmpc, &nam, &nzs_, &nlabel, &ttime, &iheading, &nfc, - &nfc_, &ndc, &ndc_); - - NNEW(set, char, 81 * nset_); - NNEW(meminset, ITG, nset_); - NNEW(rmeminset, ITG, nset_); - NNEW(iuel, ITG, 4 * nuel_); - - FORTRAN(allocation, (&nload_, &nforc_, &nboun_, &nk_, &ne_, &nmpc_, &nset_, - &nalset_, &nmat_, &ntmat_, &npmat_, &norien_, &nam_, - &nprint_, mi, &ntrans_, set, meminset, rmeminset, &ncs_, - &namtot_, &ncmat_, &memmpc_, &ne1d, &ne2d, &nflow, - jobnamec, irstrt, ithermal, &nener, &nstate_, &istep, - inpc, ipoinp, inp, &ntie_, &nbody_, - &nprop_, ipoinpc, &nevdamp_, &npt_, &nslavs, &nkon_, &mcs, - &mortar, &ifacecount, &nintpoint, infree, &nheading_, - &nobject_, iuel, &iprestr, &nstam, &ndamp, &nef, - &nbounold, &nforcold, &nloadold, &nbodyold, &mpcend, - irobustdesign, &nfc_, &ndc_)); - - // SFREE(set); - SFREE(meminset); - SFREE(rmeminset); - mt = mi[1] + 1; - NNEW(heading, char, 66 * nheading_); - - continue; - } - } - - /* reset tempuserflag */ - - itempuser[0] = 0; - - /* deleting the perturbation loads and temperatures */ - - if ((iperturb[0] == 1) && (nmethod == 3)) { - nforc = 0; - nload = 0; - nbody = 0; - if (ithermal[0] == 1) { - for (k = 0; k < nk; ++k) { - t1[k] = t0[k]; - } - } - } else { - nbounold = nboun; - for (i = 0; i < nboun; i++) { - nodebounold[i] = nodeboun[i]; - ndirbounold[i] = ndirboun[i]; - } - nforcold = nforc; - nloadold = nload; - nbodyold = nbody; - - /* resetting the amplitude to none except for time=total time amplitudes */ - - if (nam > 0) { - for (i = 0; i < nboun; i++) { - if (iamboun[i] > 0) { - if (namta[3 * iamboun[i] - 1] > 0) { - iamboun[i] = 0; - xboun[i] = xbounold[i]; - } - } - } - for (i = 0; i < nforc; i++) { - if (iamforc[i] > 0) { - if (namta[3 * iamforc[i] - 1] > 0) { - iamforc[i] = 0; - xforc[i] = xforcold[i]; - } - } - } - for (i = 0; i < 2 * nload; i++) { - if (iamload[i] > 0) { - if (namta[3 * iamload[i] - 1] > 0) { - iamload[i] = 0; - xload[i] = xloadold[i]; - } - } - } - for (i = 1; i < 3 * nbody; i = i + 3) { - if (ibody[i] > 0) { - if (namta[3 * ibody[i] - 1] > 0) { - ibody[i] = 0; - xbody[7 * (i - 1) / 3] = xbodyold[7 * (i - 1) / 3]; - } - } - } - if (ithermal[0] == 1) { - if (iamt1[i] > 0) { - if (namta[3 * iamt1[i] - 1] > 0) { - iamt1[i] = 0; - t1[i] = t1old[i]; - } - } - } - } - } - - /* removing the advective elements, if any */ - - if (network > 0) { - ne = ne0; - nkon = nkon0; - RENEW(ipkon, ITG, ne); - RENEW(lakon, char, 8 * ne); - RENEW(kon, ITG, nkon); - RENEW(sti, double, 6 * mi[0] * ne); - RENEW(eme, double, 6 * mi[0] * ne); - if (iprestr > 0) - RENEW(prestr, double, 6 * mi[0] * ne); - if (nprop > 0) - RENEW(ielprop, ITG, ne); - if ((ne1d != 0) || (ne2d != 0)) - RENEW(offset, double, 2 * ne); - if (nener == 1) - RENEW(ener, double, mi[0] * ne * 2); - if (norien > 0) - RENEW(ielorien, ITG, mi[2] * ne); - RENEW(ielmat, ITG, mi[2] * ne); - - /* reactivating the original load labels */ - - for (i = nload - 1; i >= nload0; i--) { - if (strcmp2(&sideload[20 * i], " ", 20) == 0) { - iload = nelemload[2 * i + 1]; - strcpy1(&sideload[20 * (iload - 1)], "F", 1); - } - } - } - - nload = nload0; - - if ((nmethod == 4) && (iperturb[0] > 1)) - SFREE(accold); - - if (irstrt[0] > 0) { - jrstrt++; - if (jrstrt >= irstrt[0]) { - jrstrt = 0; - FORTRAN(restartwrite, (&istep, &nset, &nload, &nforc, &nboun, &nk, &ne, &nmpc, - &nalset, &nmat, &ntmat_, &npmat_, &norien, &nam, - &nprint, mi, &ntrans, &ncs_, &namtot, &ncmat_, &mpcend, - &maxlenmpc, &ne1d, &ne2d, &nflow, &nlabel, &iplas, - &nkon, ithermal, &nmethod, iperturb, &nstate_, &nener, - set, istartset, iendset, ialset, co, kon, ipkon, lakon, - nodeboun, ndirboun, iamboun, xboun, ikboun, ilboun, - ipompc, nodempc, coefmpc, labmpc, ikmpc, ilmpc, - nodeforc, ndirforc, iamforc, xforc, ikforc, ilforc, - nelemload, iamload, sideload, xload, elcon, nelcon, - rhcon, nrhcon, alcon, nalcon, alzero, plicon, nplicon, - plkcon, nplkcon, orname, orab, ielorien, trab, inotr, - amname, amta, namta, t0, t1, iamt1, veold, ielmat, - matname, prlab, prset, filab, vold, nodebounold, - ndirbounold, xbounold, xforcold, xloadold, t1old, eme, - iponor, xnor, knor, thicke, offset, iponoel, inoel, rig, - shcon, nshcon, cocon, ncocon, ics, sti, ener, xstate, - jobnamec, infree, prestr, &iprestr, cbody, ibody, - xbody, &nbody, xbodyold, &ttime, qaold, cs, &mcs, - output, physcon, ctrl, typeboun, fmpc, tieset, &ntie, - tietol, &nslavs, t0g, t1g, &nprop, ielprop, prop, - &mortar, &nintpoint, &ifacecount, islavsurf, - pslavsurf, clearini, irstrt, vel, &nef, velo, veloo, - ne2boun, &memmpc_, heading, &nheading_, &network, - &nfc, &ndc, coeffc, ikdc, edc)); - } - } - } - - FORTRAN(closefile, ()); - - strcpy(fneig, jobnamec); - strcat(fneig, ".frd"); - if ((f1 = fopen(fneig, "ab")) == NULL) { - printf(" *ERROR in frd: cannot open frd file for writing..."); - exit(0); - } - fprintf(f1, " 9999\n"); - fclose(f1); - - /* deallocating the fields - this section is addressed immediately after leaving calinput */ - - SFREE(ipoinpc); - SFREE(inpc); - SFREE(inp); - SFREE(ipoinp); - SFREE(inp_sav); - SFREE(ipoinp_sav); - - dealloc_cal(&ncs_, &ics, &mcs, &cs, &tieset, &tietol, &co, - &kon, &ipkon, &lakon, &nodeboun, &ndirboun, &typeboun, &xboun, - &ikboun, &ilboun, &nodebounold, &ndirbounold, &xbounold, &ipompc, - &labmpc, &ikmpc, &ilmpc, &fmpc, &nodempc, &coefmpc, - &nodempcref, &coefmpcref, &ikmpcref, &nodeforc, &ndirforc, &xforc, - &ikforc, &ilforc, &xforcold, &nelemload, &sideload, &xload, - &xloadold, &cbody, &ibody, &xbody, &xbodyold, &nam, - &iamboun, &iamforc, &iamload, &amname, &amta, &namta, &set, - &istartset, &iendset, &ialset, &elcon, &nelcon, &rhcon, - &nrhcon, &shcon, &nshcon, &cocon, &ncocon, &alcon, - &nalcon, &alzero, &nprop, &ielprop, &prop, &npmat_, - &plicon, &nplicon, &plkcon, &nplkcon, &ndamp, &dacon, &norien, - &orname, &orab, &ielorien, &ntrans, &trab, &inotr, &iprestr, - &prestr, ithermal, &t0, &t1, &t1old, &iamt1, &ne1d, - &ne2d, &t0g, &t1g, irobustdesign, &irandomtype, - &randomval, &prlab, &prset, &filab, &xmodal, &ielmat, - &matname, &sti, &eme, &ener, &xstate, &vold, - &veold, &vel, &velo, &veloo, &iponor, &xnor, - &knor, &thicke, &offset, &iponoel, &inoel, &rig, - &ne2boun, &islavsurf, &mortar, &pslavsurf, &clearini, - &nobject_, &objectset, &nmethod, iperturb, &irefineloop, - &iparentel, &iprfn, &konrfn, &ratiorfn, &heading, - &nodedesi, &dgdxglob, &g0, &nuel_, &xdesi, &nfc, &coeffc, - &ikdc, &edc); - -#ifdef CALCULIX_MPI - MPI_Finalize(); -#endif - -#ifdef CALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT - calculix_freeExternalBehaviours(); -#endif /* CALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT */ - - clock_gettime(CLOCK_MONOTONIC, &totalCalculixTimeEnd); - - totalCalculixTime = (totalCalculixTimeEnd.tv_sec - totalCalculixTimeStart.tv_sec) * 1e9; - totalCalculixTime = (totalCalculixTime + (totalCalculixTimeEnd.tv_nsec - totalCalculixTimeStart.tv_nsec)) * 1e-9; - - printf("________________________________________\n\n"); - - printf("Total CalculiX Time: %lf\n", totalCalculixTime); - - printf("________________________________________\n"); - - return 0; -} diff --git a/ccx_2.21.c b/ccx_2.21.c new file mode 100644 index 00000000..85653b2b --- /dev/null +++ b/ccx_2.21.c @@ -0,0 +1,1954 @@ +/* CalculiX - A 3-dimensional finite element program */ +/* Copyright (C) 1998-2023 Guido Dhondt */ + +/* This program is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License as */ +/* published by the Free Software Foundation(version 2); */ +/* */ + +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU General Public License for more details. */ + +/* You should have received a copy of the GNU General Public License */ +/* along with this program; if not, write to the Free Software */ +/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifdef __WIN32 +_set_output_format(_TWO_DIGIT_EXPONENT); +#endif + +#ifdef CALCULIX_MPI +#include +#endif + +#include +#include +#include +#include +#include "CalculiX.h" +#include "CalculiX_precice.h" + +#ifdef CALCULIX_MPI +ITG myid = 0,nproc = 0; +#endif + +struct timespec totalCalculixTimeStart,totalCalculixTimeEnd; + +int main(int argc,char *argv[]) +{ + + FILE *f1; + + char *sideload=NULL,*set=NULL,*matname=NULL,*orname=NULL,*amname=NULL, + *filab=NULL,*lakon=NULL,*labmpc=NULL,*prlab=NULL,*prset=NULL, + jobnamec[792]="",jobnamef[132]="",output[5],*typeboun=NULL, + *inpc=NULL,*tieset=NULL,*cbody=NULL,fneig[132],*sideloadtemp=NULL, + kind1[2],kind2[2],*heading=NULL,*objectset=NULL; + + ITG *kon=NULL,*nodeboun=NULL,*ndirboun=NULL,*ipompc=NULL, + *nodempc=NULL,*nodeforc=NULL,*ndirforc=NULL, + *nelemload=NULL,im,*inodesd=NULL,nload1,*idefforc=NULL, + *nactdof=NULL,*icol=NULL,*ics=NULL,itempuser[3], + *jq=NULL,*mast1=NULL,*irow=NULL,*rig=NULL,*idefbody=NULL, + *ikmpc=NULL,*ilmpc=NULL,*ikboun=NULL,*ilboun=NULL, + *nreorder=NULL,*ipointer=NULL,*idefload=NULL, + *istartset=NULL,*iendset=NULL,*ialset=NULL,*ielmat=NULL, + *ielorien=NULL,*nrhcon=NULL,*nodebounold=NULL,*ndirbounold=NULL, + *nelcon=NULL,*nalcon=NULL,*iamforc=NULL,*iamload=NULL, + *iamt1=NULL,*namta=NULL,*ipkon=NULL,*iamboun=NULL, + *nplicon=NULL,*nplkcon=NULL,*inotr=NULL,*iponor=NULL,*knor=NULL, + *ikforc=NULL,*ilforc=NULL,*iponoel=NULL,*inoel=NULL,*nshcon=NULL, + *ncocon=NULL,*ibody=NULL,*ielprop=NULL,*islavsurf=NULL, + *ipoinpc=NULL,mt,nxstate,nload0,iload,*iuel=NULL,*ne2boun=NULL, + *irandomtype=NULL,irobustdesign[3],*iparentel=NULL,ifreebody, + *ipobody=NULL,inewton=0,*iprfn=NULL,*konrfn=NULL; + + ITG nk,ne,nboun,nmpc,nforc,nload,nprint,nset,nalset,nentries=19, + nmethod,neq[3],i,mpcfree,mei[4]={0,0,0,0},j,nzl,nam,nbounold, + nforcold,nloadold,nbody,nbody_,nbodyold,network,nheading_, + k,nzs[3],nmpc_,nload_,nforc_,istep,istat,nboun_,nintpoint, + iperturb[2],nmat,ntmat_,norien,ithermal[2]={0,0},nmpcold, + iprestr,kode,isolver,nslavs,nkon_,ne1,nkon0,mortar, + jout[2],nlabel,nkon,idrct,jmax[2],iexpl,nevtot,ifacecount, + iplas,npmat_,mi[3],ntrans,mpcend,namtot_,iheading, + icascade,maxlenmpc,mpcinfo[4],ne1d,ne2d,infree[4], + callfrommain,nflow,jin=0,irstrt[2],nener,jrstrt,nenerold, + nline,*ipoinp=NULL,*inp=NULL,ntie,ntie_,mcs,nprop_, + nprop,itpamp,iviewfile,nkold,nevdamp_,npt_,cyclicsymmetry, + nmethodl,iaxial,inext,icontact,nobject,nobject_,iit, + nzsprevstep[3],memmpcref_,mpcfreeref,maxlenmpcref,*nodempcref=NULL, + *ikmpcref=NULL,isens,namtot,nstam,ndamp,nef,inp_size, + *ipoinp_sav=NULL,*inp_sav=NULL,irefineloop=0,icoordinate=0, + *nodedesi=NULL,ndesi=0,nobjectstart=0,nfc_,ndc_,nfc,ndc,*ikdc=NULL; + + ITG *meminset=NULL,*rmeminset=NULL; + + ITG nzs_,nk_,ne_,nset_=0,nalset_,nmat_,norien_,nam_, + ntrans_,ncs_,nstate_,ncmat_,memmpc_,nprint_,nuel_=0; + + double *co=NULL,*xboun=NULL,*coefmpc=NULL,*xforc=NULL,*clearini=NULL, + *xload=NULL,*xbounold=NULL,*xforcold=NULL,*randomval=NULL, + *vold=NULL,*sti=NULL,*xloadold=NULL,*xnor=NULL, + *reorder=NULL,*dcs=NULL,*thickn=NULL,*thicke=NULL,*offset=NULL, + *elcon=NULL,*rhcon=NULL,*alcon=NULL,*alzero=NULL,*t0=NULL,*t1=NULL, + *prestr=NULL,*orab=NULL,*amta=NULL,*veold=NULL,*accold=NULL, + *t1old=NULL,*eme=NULL,*plicon=NULL,*pslavsurf=NULL,*plkcon=NULL, + *xstate=NULL,*trab=NULL,*ener=NULL,*shcon=NULL,*cocon=NULL, + *cs=NULL,*tietol=NULL,*fmpc=NULL,*prop=NULL,*t0g=NULL,*t1g=NULL, + *xbody=NULL,*xbodyold=NULL,*coefmpcref=NULL,*dacon=NULL,*vel=NULL, + *velo=NULL,*veloo=NULL,energy[5],*ratiorfn=NULL,*dgdxglob=NULL, + *g0=NULL,*xdesi=NULL,*coeffc=NULL,*edc=NULL,*coini=NULL; + + double ctrl[57]; + + double fei[3],*xmodal=NULL,timepar[5],alpha[2],ttime,qaold[2],physcon[14]; + + double totalCalculixTime; + +/* + * Additional variables for the coupling with preCICE + * preCICE is used only if a participant name is provided as a command line argument! + */ + char preciceParticipantName[256] = "", configFilename[256] = "config.yml"; + int preciceUsed = 0; + +#ifdef CALCULIX_MPI + MPI_Init(&argc, &argv) ; + MPI_Comm_rank(MPI_COMM_WORLD, &myid) ; + MPI_Comm_size(MPI_COMM_WORLD, &nproc) ; +#endif + + clock_gettime(CLOCK_MONOTONIC, &totalCalculixTimeStart); + + if(argc==1){printf("Usage: CalculiX.exe -i jobname\n");FORTRAN(stop,());} + else{ + for(i=1;i127){ + printf(" *ERROR in CalculiX: the number of characters in the name of the input deck (without .inp) exceeds 127 characters\n"); + FORTRAN(stop,()); + } + strcpy2(jobnamec,argv[i+1],132); + strcpy1(jobnamef,argv[i+1],132);jin++;break;} + if(strcmp1(argv[i],"-v")==0){ + printf("\nThis is Version 2.21\n\n"); + FORTRAN(stop,()); + } + } + if(jin==0){ + if(strlen(argv[1])>127){ + printf(" *ERROR in CalculiX: the number of characters in the name of the input deck (without .inp) exceeds 127 characters\n"); + FORTRAN(stop,()); + } + strcpy2(jobnamec,argv[1],132); + strcpy1(jobnamef,argv[1],132);} + + /* preCICE information*/ + for (i = 1; i < argc; i++) { + + // Get preCICE participantName + if (strcmp1(argv[i], "-precice-participant") == 0) { + strcpy(preciceParticipantName, argv[i + 1]); + preciceUsed = 1; + } + // Overwrite YAML config file name in case a specific file name is given on the command line + if (strcmp1(argv[i], "-precice-config") == 0) { + strcpy(configFilename, argv[i + 1]); + } + } + } + + if (preciceUsed) { + } else { + printf(" *ERROR reading the preCICE participant name. \n"); + exit(0); + } + + putenv("CCX_JOBNAME_GETJOBNAME=jobnamec"); + +#ifdef BAM + ITG lop=0,lrestart=0,kstep=1,kinc=1; + double time[2],dtime; + FORTRAN(uexternaldb,(&lop,&lrestart,time,&dtime,&kstep,&kinc)); +#endif + + FORTRAN(openfile,(jobnamef)); + + printf("\n************************************************************\n\n"); +#ifdef INTSIZE64 + printf("CalculiX Version 2.21 i8, Copyright(C) 1998-2023 Guido Dhondt\n"); +#else + printf("CalculiX Version 2.21, Copyright(C) 1998-2023 Guido Dhondt\n"); +#endif + printf("CalculiX comes with ABSOLUTELY NO WARRANTY. This is free\n"); + printf("software, and you are welcome to redistribute it under\n"); + printf("certain conditions, see gpl.htm\n\n"); + printf("************************************************************\n\n"); + printf("You are using an executable made on Thu Apr 11 03:24:54 PM EDT 2024\n\n"); + printf("CalculiX is used with preCICE participant: %s\n\n", preciceParticipantName); + fflush(stdout); + + NNEW(ipoinp,ITG,2*nentries); + + /* conservative estimate of the fields to be allocated */ + + readinput(jobnamec,&inpc,&nline,&nset_,ipoinp,&inp,&ipoinpc,ithermal,&nuel_, + &inp_size); + + /* saving the original input deck reading pointers */ + + NNEW(ipoinp_sav,ITG,2*nentries); + memcpy(ipoinp_sav,ipoinp,sizeof(ITG)*2*nentries); + NNEW(inp_sav,ITG,inp_size); + memcpy(inp_sav,inp,sizeof(ITG)*inp_size); + + /* initialization of the variables */ + + ini_cal(jobnamec,output,fneig,kind1,kind2,itempuser,irobustdesign,&nprint, + neq,&mpcfree,&nbounold,&nforcold,&nloadold,&nbody_, + &nbodyold,&network,&nheading_,&nmpc_,&nload_,&nforc_,&nboun_, + &nintpoint,iperturb,&ntmat_,ithermal,&isolver,&nslavs,&nkon_,&mortar, + jout,&nkon,&nevtot,&ifacecount,&iplas,&npmat_,mi,&mpcend,&namtot_, + &icascade,&ne1d,&ne2d,infree,&nflow,irstrt,&nener,&jrstrt, + &ntie_,&mcs,&nprop_,&nprop,&itpamp,&nevdamp_,&npt_,&iaxial,&inext, + &icontact,&nobject,&nobject_,&iit,&mpcfreeref,&isens,&namtot,&nstam, + &ndamp,&nef,&nk_,&ne_,&nalset_,&nmat_,&norien_,&nam_, + &ntrans_,&ncs_,&nstate_,&ncmat_,&memmpc_,&nprint_,energy,ctrl,alpha, + qaold,physcon,&istep,&istat,&iprestr,&kode,&nload,&nbody,&nforc, + &nboun,&nk,&nmpc,&nam,&nzs_,&nlabel,&ttime,&iheading,&nfc,&nfc_,&ndc, + &ndc_); + + NNEW(set,char,81*nset_); + NNEW(meminset,ITG,nset_); + NNEW(rmeminset,ITG,nset_); + NNEW(iuel,ITG,4*nuel_); + + FORTRAN(allocation,(&nload_,&nforc_,&nboun_,&nk_,&ne_,&nmpc_,&nset_,&nalset_, + &nmat_,&ntmat_,&npmat_,&norien_,&nam_,&nprint_,mi, + &ntrans_,set,meminset,rmeminset,&ncs_,&namtot_,&ncmat_, + &memmpc_,&ne1d,&ne2d,&nflow,jobnamec,irstrt,ithermal, + &nener,&nstate_,&istep,inpc,ipoinp,inp,&ntie_,&nbody_, + &nprop_,ipoinpc,&nevdamp_,&npt_,&nslavs,&nkon_,&mcs, + &mortar,&ifacecount,&nintpoint,infree,&nheading_, + &nobject_,iuel,&iprestr,&nstam,&ndamp,&nef,&nbounold, + &nforcold,&nloadold,&nbodyold,&mpcend,irobustdesign, + &nfc_,&ndc_)); + + SFREE(meminset);SFREE(rmeminset);mt=mi[1]+1; + NNEW(heading,char,66*nheading_); + + while(istat>=0){ + + fflush(stdout); + + /* in order to reduce the number of variables to be transferred to + the subroutines, the max. field sizes are (for most fields) copied + into the real sizes */ + + nzs[1]=nzs_; + + if((istep==0)||(irstrt[0]<0)){ + ne=ne_; + nset=nset_; + nalset=nalset_; + nmat=nmat_; + norien=norien_; + ntrans=ntrans_; + ntie=ntie_; + + /* allocating space before the first step */ + + /* coordinates and topology */ + + NNEW(co,double,3*nk_); + NNEW(kon,ITG,nkon_); + NNEW(ipkon,ITG,ne_); + NNEW(lakon,char,8*ne_); + + /* property cards */ + + if(nprop_>0){ + NNEW(ielprop,ITG,ne_); + for(i=0;i0)))NNEW(iamboun,ITG,nboun_); + NNEW(xboun,double,nboun_); + NNEW(ikboun,ITG,nboun_); + NNEW(ilboun,ITG,nboun_); + + /* MPC's */ + + NNEW(ipompc,ITG,nmpc_); + NNEW(nodempc,ITG,3*memmpc_); + for(i=0;i<3*memmpc_;i+=3){nodempc[i+2]=i/3+2;} + nodempc[3*memmpc_-1]=0; + NNEW(coefmpc,double,memmpc_); + NNEW(labmpc,char,20*nmpc_+1); + NNEW(ikmpc,ITG,nmpc_); + NNEW(ilmpc,ITG,nmpc_); + NNEW(fmpc,double,nmpc_); + + /* coupling, distributed */ + + if(nfc_>0){ + NNEW(coeffc,double,7*nfc_); + NNEW(ikdc,ITG,ndc_); + NNEW(edc,double,12*ndc_); + } + + /* nodal loads */ + + NNEW(nodeforc,ITG,2*nforc_); + NNEW(ndirforc,ITG,nforc_); + if((istep==0)||((irstrt[0]<0)&&(nam_>0)))NNEW(iamforc,ITG,nforc_); + NNEW(idefforc,ITG,nforc_); + NNEW(xforc,double,nforc_); + NNEW(ikforc,ITG,nforc_); + NNEW(ilforc,ITG,nforc_); + + /* distributed facial loads */ + + NNEW(nelemload,ITG,2*nload_); + if((istep==0)||((irstrt[0]<0)&&(nam_>0)))NNEW(iamload,ITG,2*nload_); + NNEW(idefload,ITG,nload_); + NNEW(sideload,char,20*nload_); + NNEW(xload,double,2*nload_); + + /* distributed volumetric loads */ + + NNEW(cbody,char,81*nbody_); + NNEW(idefbody,ITG,nbody_); + NNEW(ibody,ITG,3*nbody_); + NNEW(xbody,double,7*nbody_); + NNEW(xbodyold,double,7*nbody_); + + /* printing output */ + + NNEW(prlab,char,6*nprint_); + NNEW(prset,char,81*nprint_); + + /* set definitions */ + + RENEW(set,char,81*nset); + NNEW(istartset,ITG,nset);DMEMSET(istartset,0,nset,1); + NNEW(iendset,ITG,nset); + NNEW(ialset,ITG,nalset); + + /* (hyper)elastic constants */ + + NNEW(elcon,double,(ncmat_+1)*ntmat_*nmat); + NNEW(nelcon,ITG,2*nmat); + + /* density */ + + NNEW(rhcon,double,2*ntmat_*nmat); + NNEW(nrhcon,ITG,nmat); + + /* damping */ + + if(ndamp>0){NNEW(dacon,double,nmat);} + + /* specific heat */ + + NNEW(shcon,double,4*ntmat_*nmat); + NNEW(nshcon,ITG,nmat); + + /* thermal expansion coefficients */ + + NNEW(alcon,double,7*ntmat_*nmat); + NNEW(nalcon,ITG,2*nmat); + NNEW(alzero,double,nmat); + + /* conductivity */ + + NNEW(cocon,double,7*ntmat_*nmat); + NNEW(ncocon,ITG,2*nmat); + + /* isotropic and kinematic hardening coefficients*/ + + if(npmat_>0){ + NNEW(plicon,double,(2*npmat_+1)*ntmat_*nmat); + NNEW(nplicon,ITG,(ntmat_+1)*nmat); + NNEW(plkcon,double,(2*npmat_+1)*ntmat_*nmat); + NNEW(nplkcon,ITG,(ntmat_+1)*nmat); + } + + /* linear dynamic properties */ + + NNEW(xmodal,double,11+nevdamp_); + xmodal[10]=nevdamp_+0.5; + + /* internal state variables (nslavs is needed for restart + calculations) */ + + if(mortar!=1){ + NNEW(xstate,double,nstate_*mi[0]*(ne+nslavs)); + nxstate=nstate_*mi[0]*(ne+nslavs); + }else if(mortar==1){ + NNEW(xstate,double,nstate_*mi[0]*(ne+nintpoint)); + nxstate=nstate_*mi[0]*(ne+nintpoint); + } + + /* material orientation */ + + if((istep==0)||((irstrt[0]<0)&&(norien>0))){ + NNEW(orname,char,80*norien); + NNEW(orab,double,7*norien); + NNEW(ielorien,ITG,mi[2]*ne_); + } + + /* transformations */ + + if((istep==0)||((irstrt[0]<0)&&(ntrans>0))){ + NNEW(trab,double,7*ntrans); + NNEW(inotr,ITG,2*nk_); + } + + /* amplitude definitions */ + + if((istep==0)||((irstrt[0]<0)&&(nam_>0))){ + NNEW(amname,char,80*nam_); + NNEW(amta,double,2*namtot_); + NNEW(namta,ITG,3*nam_); + } + + if((istep==0)||((irstrt[0]<0)&&(ithermal[0]>0))){ + NNEW(t0,double,nk_); + NNEW(t1,double,nk_); + if((ne1d!=0)||(ne2d!=0)||(nuel_!=0)){ + NNEW(t0g,double,2*nk_); + NNEW(t1g,double,2*nk_); + } + } + + /* the number in next line is NOT 1.2357111317 -> points + to user input; instead it is a generic nonzero + initialization */ + + if(istep==0){ + DMEMSET(t0,0,nk_,1.2357111319); + DMEMSET(t1,0,nk_,1.2357111319); + } + + if((istep==0)||((irstrt[0]<0)&&(ithermal[0]>0)&&(nam_>0)))NNEW(iamt1,ITG,nk_); + + if((istep==0)||((irstrt[0]<0)&&(iprestr>0)))NNEW(prestr,double,6*mi[0]*ne_); + + NNEW(vold,double,mt*nk_); + NNEW(veold,double,mt*nk_); + + /* CFD-results */ + + NNEW(vel,double,8*nef); + NNEW(velo,double,8*nef); + NNEW(veloo,double,8*nef); + + NNEW(ielmat,ITG,mi[2]*ne_); + + NNEW(matname,char,80*nmat); + + NNEW(filab,char,87*nlabel); + + /* tied constraints */ + + if(ntie_>0){ + NNEW(tieset,char,243*ntie_); + NNEW(tietol,double,4*ntie_); + NNEW(cs,double,17*ntie_); + } + + /* objectives for sensitivity analysis */ + + if(nobject_>0){ + NNEW(nodedesi,ITG,nk_); + NNEW(dgdxglob,double,nobject_*2*nk_); + NNEW(g0,double,nobject_); + NNEW(xdesi,double,3*nk_); + NNEW(objectset,char,405*nobject_); + for(i=0;i<405*nobject_;i++){objectset[i]=' ';} + NNEW(coini,double,3*nk_); + } + + /* temporary fields for cyclic symmetry calculations */ + + if((ncs_>0)||(npt_>0)){ + if(2*npt_>24*ncs_){ + NNEW(ics,ITG,2*npt_); + }else{ + NNEW(ics,ITG,24*ncs_); + } + if(npt_>30*ncs_){ + NNEW(dcs,double,npt_); + }else{ + NNEW(dcs,double,30*ncs_); + } + } + + /* slave faces */ + + NNEW(islavsurf,ITG,2*ifacecount+2); + + /* robustdesign analysis */ + + if(irobustdesign[0]>0){ + NNEW(irandomtype,ITG,nk_); + NNEW(randomval,double,2*nk_); + } + + } + else { + + /* allocating and reallocating space for subsequent steps */ + + if((nmethod!=4)&&(nmethod!=5)&&(nmethod!=8)&&(nmethod!=9)&& + ((abs(nmethod)!=1)||(iperturb[0]<2))){ + NNEW(veold,double,mt*nk_); + } + else{ + RENEW(veold,double,mt*nk_); + DMEMSET(veold,mt*nk,mt*nk_,0.); + } + RENEW(vold,double,mt*nk_); + DMEMSET(vold,mt*nk,mt*nk_,0.); + + RENEW(nodeboun,ITG,nboun_); + RENEW(ndirboun,ITG,nboun_); + RENEW(typeboun,char,nboun_+1); + RENEW(xboun,double,nboun_); + RENEW(ikboun,ITG,nboun_); + RENEW(ilboun,ITG,nboun_); + + RENEW(nodeforc,ITG,2*nforc_); + RENEW(ndirforc,ITG,nforc_); + NNEW(idefforc,ITG,nforc_); + RENEW(xforc,double,nforc_); + RENEW(ikforc,ITG,nforc_); + RENEW(ilforc,ITG,nforc_); + + RENEW(nelemload,ITG,2*nload_); + NNEW(idefload,ITG,nload_); + RENEW(sideload,char,20*nload_); + RENEW(xload,double,2*nload_); + + RENEW(cbody,char,81*nbody_); + NNEW(idefbody,ITG,nbody_); + RENEW(ibody,ITG,3*nbody_); + RENEW(xbody,double,7*nbody_); + RENEW(xbodyold,double,7*nbody_); + for(i=7*nbodyold;i<7*nbody_;i++) xbodyold[i]=0; + + if(nam>0){ + RENEW(iamforc,ITG,nforc_); + RENEW(iamload,ITG,2*nload_); + RENEW(iamboun,ITG,nboun_); + RENEW(amname,char,80*nam_); + RENEW(amta,double,2*namtot_); + RENEW(namta,ITG,3*nam_); + } + + RENEW(ipompc,ITG,nmpc_); + + RENEW(labmpc,char,20*nmpc_+1); + RENEW(ikmpc,ITG,nmpc_); + RENEW(ilmpc,ITG,nmpc_); + RENEW(fmpc,double,nmpc_); + + if(ntrans>0){ + RENEW(inotr,ITG,2*nk_);DMEMSET(inotr,2*nk,2*nk_,0); + } + + RENEW(co,double,3*nk_);DMEMSET(co,3*nk,3*nk_,0.); + + if(ithermal[0] != 0){ + RENEW(t0,double,nk_);DMEMSET(t0,nk,nk_,0.); + RENEW(t1,double,nk_);DMEMSET(t1,nk,nk_,0.); + if((ne1d!=0)||(ne2d!=0)||(nuel_!=0)){ + RENEW(t0g,double,2*nk_);DMEMSET(t0g,2*nk,2*nk_,0.); + RENEW(t1g,double,2*nk_);DMEMSET(t1g,2*nk,2*nk_,0.); + } + if(nam>0){RENEW(iamt1,ITG,nk_);} + } + + } + + /* allocation of fields in the restart file */ + + if(irstrt[0]<0){ + NNEW(nodebounold,ITG,nboun_); + NNEW(ndirbounold,ITG,nboun_); + NNEW(xbounold,double,nboun_); + NNEW(xforcold,double,nforc_); + NNEW(xloadold,double,2*nload_); + if(ithermal[0]!=0) NNEW(t1old,double,nk_); + NNEW(sti,double,6*mi[0]*ne); + NNEW(eme,double,6*mi[0]*ne); + if(nener==1)NNEW(ener,double,2*mi[0]*ne); + if(mcs>ntie_) RENEW(cs,double,17*mcs); + if(mortar==1){ + NNEW(pslavsurf,double,3*nintpoint); + NNEW(clearini,double,3*9*ifacecount); + } + + } + + nenerold=nener; + nkold=nk; + + /* opening the eigenvalue file and checking for cyclic symmetry */ + + strcpy2(fneig,jobnamec,132); + strcat(fneig,".eig"); + cyclicsymmetry=0; + if((f1=fopen(fneig,"rb"))!=NULL){ + if(fread(&cyclicsymmetry,sizeof(ITG),1,f1)!=1){ + printf(" *ERROR reading the information whether cyclic symmetry is involved in the eigenvalue file"); + exit(0); + } + fclose(f1); + } + + nmpcold=nmpc; + + /* reading the input file */ + + FORTRAN(calinput,(co,&nk,kon,ipkon,lakon,&nkon,&ne,nodeboun,ndirboun,xboun, + &nboun,ipompc,nodempc,coefmpc,&nmpc,&nmpc_,nodeforc, + ndirforc,xforc,&nforc,&nforc_,nelemload,sideload,xload, + &nload,&nload_,&nprint,prlab,prset,&mpcfree,&nboun_,mei, + set,istartset,iendset,ialset,&nset,&nalset,elcon,nelcon, + rhcon,nrhcon,alcon,nalcon,alzero,t0,t1,matname,ielmat, + orname,orab,ielorien,amname,amta,namta,&nam,&nmethod, + iamforc,iamload,iamt1,ithermal,iperturb,&istat,&istep, + &nmat,&ntmat_,&norien,prestr,&iprestr,&isolver,fei,veold, + timepar,xmodal,filab,jout,&nlabel,&idrct,jmax,&iexpl, + alpha,iamboun,plicon,nplicon,plkcon,nplkcon,&iplas, + &npmat_,mi,&nk_,trab,inotr,&ntrans,ikboun,ilboun,ikmpc, + ilmpc,ics,dcs,&ncs_,&namtot_,cs,&nstate_,&ncmat_, + &mcs,labmpc,iponor,xnor,knor,thickn,thicke,ikforc,ilforc, + offset,iponoel,inoel,rig,infree,nshcon,shcon,cocon, + ncocon,physcon,&nflow,ctrl,&maxlenmpc,&ne1d,&ne2d,&nener, + vold,nodebounold,ndirbounold,xbounold,xforcold,xloadold, + t1old,eme,sti,ener,xstate,jobnamec,irstrt,&ttime,qaold, + output,typeboun,inpc,ipoinp,inp,tieset,tietol,&ntie,fmpc, + cbody,ibody,xbody,&nbody,&nbody_,xbodyold,&nam_,ielprop, + &nprop,&nprop_,prop,&itpamp,&iviewfile,ipoinpc,&nslavs, + t0g,t1g,&network,&cyclicsymmetry,idefforc,idefload, + idefbody,&mortar,&ifacecount,islavsurf,pslavsurf, + clearini,heading,&iaxial,&nobject,objectset,&nprint_, + iuel,&nuel_,nodempcref,coefmpcref,ikmpcref,&memmpcref_, + &mpcfreeref,&maxlenmpcref,&memmpc_,&isens,&namtot,&nstam, + dacon,vel,&nef,velo,veloo,ne2boun,itempuser, + irobustdesign,irandomtype,randomval,&nfc,&nfc_,coeffc, + ikdc,&ndc,&ndc_,edc,coini)); + + SFREE(idefforc);SFREE(idefload);SFREE(idefbody); + + if(istat<0) break; + + /* assigning the body forces to the elements */ + + if(nbody>0){ + ifreebody=ne+1; + NNEW(ipobody,ITG,2*ifreebody*nbody); + for(k=1;k<=nbody;k++){ + FORTRAN(bodyforce,(cbody,ibody,ipobody,&nbody,set,istartset, + iendset,ialset,&inewton,&nset,&ifreebody,&k)); + RENEW(ipobody,ITG,2*(ne+ifreebody)); + } + RENEW(ipobody,ITG,2*(ifreebody-1)); + } + + if(irefineloop==1){ + + /* in the last step refinement was requested and the mesh + was appropriately refined; this mesh has to be read */ + + readnewmesh(jobnamec,&nboun,nodeboun,iamboun,xboun,&nload,sideload, + iamload,&nforc,nodeforc,iamforc,xforc,ithermal,&nk,&t1,&iamt1, + &ne,&lakon,&ipkon,&kon,istartset,iendset,ialset,set,&nset, + filab,&co,&ipompc,&nodempc,&coefmpc,&nmpc,&nmpc_,&labmpc, + &mpcfree,&memmpc_,&ikmpc,&ilmpc,&nk_,&ne_,&nkon_,&istep, + &nprop_,&ielprop,&ne1d,&ne2d,&iponor,&thickn,&thicke,mi, + &offset,&iponoel,&rig,&ne2boun,&ielorien,&inotr,&t0,&t0g,&t1g, + &prestr,&vold,&veold,&ielmat,irobustdesign,&irandomtype, + &randomval,&nalset,&nalset_,&nkon,xnor,&iaxial, + &network,&nlabel,iuel,iperturb,&iprestr,&ntie,tieset, + &iparentel,ikboun,&ifreebody,&ipobody,&nbody,&iprfn, + &konrfn,&ratiorfn,nodempcref,coefmpcref,&memmpcref_, + &mpcfreeref,&maxlenmpcref,&maxlenmpc,&norien,tietol); + } + +#ifdef CALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT + for(i=0;i!=nmat;++i){ + calculix_registerExternalBehaviour(matname+80*i); + } +#endif /* CALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT */ + + nload0=nload; + + if(iheading==0){ + writeheading(jobnamec,heading,&nheading_); + iheading=1; + } + + if((abs(nmethod)!=1)||(iperturb[0]<2))icascade=0; + + // FORTRAN(writeboun,(nodeboun,ndirboun,xboun,typeboun,&nboun)); + + if(istep==1){ + + SFREE(iuel); + + /* tied contact constraints: generate appropriate MPC's */ + + tiedcontact(&ntie,tieset,&nset,set,istartset,iendset,ialset, + lakon,ipkon,kon,tietol,&nmpc,&mpcfree,&memmpc_, + &ipompc,&labmpc,&ikmpc,&ilmpc,&fmpc,&nodempc,&coefmpc, + ithermal,co,vold,&nef,&nmpc_,mi,&nk,&istep,ikboun,&nboun, + kind1,kind2,jobnamef); + + /* reallocating space in the first step */ + + /* allocating and initializing fields pointing to the previous step */ + + RENEW(vold,double,mt*nk); + NNEW(sti,double,6*mi[0]*ne); + + /* strains */ + + NNEW(eme,double,6*mi[0]*ne); + + /* residual stresses/strains */ + + if(iprestr==1){ + RENEW(prestr,double,6*mi[0]*ne); + for(i=0;i1){ + for(i=0;i0){ + RENEW(ielprop,ITG,ne); + RENEW(prop,double,nprop); + }else{ + SFREE(ielprop);SFREE(prop); + } + + /* coupling, distributed */ + + if(nfc>0){ + RENEW(coeffc,double,7*nfc); + RENEW(ikdc,ITG,ndc); + RENEW(edc,double,12*ndc); + }else{ + SFREE(coeffc);SFREE(ikdc);SFREE(edc); + } + + /* fields for 1-D and 2-D elements */ + + if((ne1d!=0)||(ne2d!=0)){ + RENEW(iponor,ITG,2*nkon); + RENEW(xnor,double,infree[0]); + RENEW(knor,ITG,infree[1]); + SFREE(thickn); + RENEW(thicke,double,mi[2]*nkon); + RENEW(offset,double,2*ne); + RENEW(inoel,ITG,3*(infree[2]-1)); + RENEW(iponoel,ITG,infree[3]); + RENEW(rig,ITG,infree[3]); + RENEW(ne2boun,ITG,2*infree[3]); + } + + /* set definitions */ + + RENEW(set,char,81*nset); + RENEW(istartset,ITG,nset); + RENEW(iendset,ITG,nset); + RENEW(ialset,ITG,nalset); + + /* material properties */ + + RENEW(elcon,double,(ncmat_+1)*ntmat_*nmat); + RENEW(nelcon,ITG,2*nmat); + + RENEW(rhcon,double,2*ntmat_*nmat); + RENEW(nrhcon,ITG,nmat); + + if(ndamp>0){RENEW(dacon,double,nmat);} + + RENEW(shcon,double,4*ntmat_*nmat); + RENEW(nshcon,ITG,nmat); + + RENEW(cocon,double,7*ntmat_*nmat); + RENEW(ncocon,ITG,2*nmat); + + RENEW(alcon,double,7*ntmat_*nmat); + RENEW(nalcon,ITG,2*nmat); + RENEW(alzero,double,nmat); + + RENEW(matname,char,80*nmat); + RENEW(ielmat,ITG,mi[2]*ne); + + /* allocating space for the state variables */ + + if(mortar!=1){ + RENEW(xstate,double,nstate_*mi[0]*(ne+nslavs)); + for(i=nxstate;i0){ + RENEW(plicon,double,(2*npmat_+1)*ntmat_*nmat); + RENEW(nplicon,ITG,(ntmat_+1)*nmat); + RENEW(plkcon,double,(2*npmat_+1)*ntmat_*nmat); + RENEW(nplkcon,ITG,(ntmat_+1)*nmat); + } + + /* material orientation */ + + if(norien>0){ + RENEW(orname,char,80*norien); + RENEW(ielorien,ITG,mi[2]*ne); + RENEW(orab,double,7*norien); + } + else { + SFREE(orname); + SFREE(ielorien); + SFREE(orab); + } + + /* amplitude definitions */ + + if(nam>0){ + RENEW(amname,char,80*nam); + RENEW(namta,ITG,3*nam); + RENEW(amta,double,2*namta[3*nam-2]); + } + else { + SFREE(amname); + SFREE(amta); + SFREE(namta); + SFREE(iamforc); + SFREE(iamload); + SFREE(iamboun); + } + + if(ntrans>0){ + RENEW(trab,double,7*ntrans); + } + else{SFREE(trab);SFREE(inotr);} + + if(ithermal[0]==0){ + SFREE(t0);SFREE(t1); + if((ne1d!=0)||(ne2d!=0)||(nuel_!=0)){ + SFREE(t0g);SFREE(t1g); + } + } + + if((ithermal[0]==0)||(nam<=0)){SFREE(iamt1);} + + if(ncs_>0){ + RENEW(ics,ITG,ncs_); + }else if(npt_>0){ + SFREE(ics); + } + if((ncs_>0)||(npt_>0)){ + SFREE(dcs); + } + + if(mcs>0){ + RENEW(cs,double,17*mcs); + }else{ + SFREE(cs); + } + + /* check for design variables */ + + for(i=0;i1) */ + + RENEW(vold,double,mt*nk); + + /* if the SPC boundary conditions were changed in the present step, + they have to be rematched with those in the last step. Removed SPC + boundary conditions do not appear any more (this is different from + forces and loads, where removed forces or loads are reset to zero; + a removed SPC constraint does not have a numerical value any more) */ + + NNEW(reorder,double,nboun); + NNEW(nreorder,ITG,nboun); + if(nbounold0){ + RENEW(amname,char,80*nam); + RENEW(namta,ITG,3*nam); + RENEW(amta,double,2*namta[3*nam-2]); + } + + } + + /* reallocating fields for all steps (>=1) */ + + RENEW(co,double,3*nk); + + RENEW(nodeboun,ITG,nboun); + RENEW(ndirboun,ITG,nboun); + RENEW(typeboun,char,nboun+1); + RENEW(xboun,double,nboun); + RENEW(ikboun,ITG,nboun); + RENEW(ilboun,ITG,nboun); + + RENEW(nodeforc,ITG,2*nforc); + RENEW(ndirforc,ITG,nforc); + RENEW(xforc,double,nforc); + RENEW(ikforc,ITG,nforc); + RENEW(ilforc,ITG,nforc); + + /* temperature loading */ + + if(ithermal[0] != 0){ + RENEW(t0,double,nk); + RENEW(t1,double,nk); + if((ne1d!=0)||(ne2d!=0)||(nuel_!=0)){ + RENEW(t0g,double,2*nk); + RENEW(t1g,double,2*nk); + } + if(nam>0){RENEW(iamt1,ITG,nk);} + } + + RENEW(nelemload,ITG,2*nload); + RENEW(sideload,char,20*nload); + RENEW(xload,double,2*nload); + + RENEW(cbody,char,81*nbody); + RENEW(ibody,ITG,3*nbody); + RENEW(xbody,double,7*nbody); + RENEW(xbodyold,double,7*nbody); + + RENEW(ipompc,ITG,nmpc); + RENEW(labmpc,char,20*nmpc+1); + RENEW(ikmpc,ITG,nmpc); + RENEW(ilmpc,ITG,nmpc); + RENEW(fmpc,double,nmpc); + + /* energy */ + + if((nener==1)&&(nenerold==0)){ + NNEW(ener,double,2*mi[0]*ne); + if((istep>1)&&(iperturb[0]>1)){ + printf(" *ERROR in CalculiX: in nonlinear calculations\n"); + printf(" energy output requests, if any,\n"); + printf(" must be specified in the first step\n\n"); + FORTRAN(stop,()); + } + } + + /* initial velocities and accelerations */ + + if((nmethod==4)||(nmethod==5)||(nmethod==8)||(nmethod==9)|| + ((abs(nmethod)==1)&&(iperturb[0]>=2))){ + RENEW(veold,double,mt*nk); + } + else{ + SFREE(veold); + } + + if((nmethod==4)&&(iperturb[0]>1)){ + NNEW(accold,double,mt*nk); + } + + if(nam>0){ + RENEW(iamforc,ITG,nforc); + RENEW(iamload,ITG,2*nload); + RENEW(iamboun,ITG,nboun); + } + + /* generate force convection elements */ + + if(network>0){ + ne1=ne;nkon0=nkon;nload1=nload; + RENEW(ipkon,ITG,ne+nload); + RENEW(ielmat,ITG,mi[2]*(ne+nload)); + for(i=mi[2]*ne;i0){ + RENEW(ielorien,ITG,mi[2]*(ne+nload)); + for(i=mi[2]*ne;i0) RENEW(prestr,double,6*mi[0]*ne); + if(nprop>0) RENEW(ielprop,ITG,ne); + if((ne1d!=0)||(ne2d!=0)) RENEW(offset,double,2*ne); + RENEW(nelemload,ITG,2*nload); + RENEW(sideload,char,20*nload); + RENEW(xload,double,2*nload); + RENEW(xloadold,double,2*nload); + if(nam>0){ + RENEW(iamload,ITG,2*nload); + for(i=2*nload1;i<2*nload;i++)iamload[i]=0; + } + if(nener==1)RENEW(ener,double,2*mi[0]*ne); + + /* moving the contact state variables forward by (ne-ne1) + element blocks (because of the advective elements) */ + + if(mortar!=1){ + RENEW(xstate,double,nstate_*mi[0]*(ne+nslavs)); + for(i=nstate_*mi[0]*(ne+nslavs)-1;i>=nstate_*mi[0]*ne;i--){ + xstate[i]=xstate[i-nstate_*mi[0]*(ne-ne1)]; + } + }else if(mortar==1){ + RENEW(xstate,double,nstate_*mi[0]*(ne+nintpoint)); + for(i=nstate_*mi[0]*(ne+nintpoint)-1;i>=nstate_*mi[0]*ne;i--){ + xstate[i]=xstate[i-nstate_*mi[0]*(ne-ne1)]; + } + } + + if(norien>0)RENEW(ielorien,ITG,mi[2]*ne); + RENEW(ielmat,ITG,mi[2]*ne); + for(i=mi[2]*ne1;i0){ + RENEW(inotr,ITG,2*nk); + } + + /* calling the user routine ufaceload (can be empty) */ + + if(ithermal[1]>=2){ + NNEW(sideloadtemp,char,20*nload); + for(i=0;i1){SFREE(nodempcref);SFREE(coefmpcref);SFREE(ikmpcref);} + memmpcref_=memmpc_;mpcfreeref=mpcfree;maxlenmpcref=maxlenmpc; + NNEW(nodempcref,ITG,3*memmpc_); + memcpy(nodempcref,nodempc,sizeof(ITG)*3*memmpc_); + NNEW(coefmpcref,double,memmpc_); + memcpy(coefmpcref,coefmpc,sizeof(double)*memmpc_); + NNEW(ikmpcref,ITG,nmpc);memcpy(ikmpcref,ikmpc,sizeof(ITG)*nmpc); + } + + /* decascading MPC's only necessary if MPC's changed */ + + if(((istep==1)||(ntrans>0)||(mpcend<0)||(nk!=nkold)||(nmpc!=nmpcold))&&(icascade==0)){ + + /* decascading the MPC's */ + + printf(" Decascading the MPC's\n\n"); + + callfrommain=1; + cascade(ipompc,&coefmpc,&nodempc,&nmpc, + &mpcfree,nodeboun,ndirboun,&nboun,ikmpc, + ilmpc,ikboun,ilboun,&mpcend, + labmpc,&nk,&memmpc_,&icascade,&maxlenmpc, + &callfrommain,iperturb,ithermal); + } + + /* determining the matrix structure: changes if SPC's have changed */ + + if((icascade==0)&&(nmethod<8)) printf(" Determining the structure of the matrix:\n"); + + NNEW(nactdof,ITG,mt*nk); + NNEW(mast1,ITG,nzs[1]); + NNEW(irow,ITG,1); + + if((mcs==0)||(cs[1]<0)){ + + NNEW(icol,ITG,mt*nk); + NNEW(jq,ITG,mt*nk+1); + NNEW(ipointer,ITG,mt*nk); + + if((icascade==0)&&((nmethod<8)||(nmethod>10))){ + if((nmethod==11)||(nmethod==13)){nmethodl=2;}else{nmethodl=nmethod;} + mastruct(&nk,kon,ipkon,lakon,&ne,nodeboun,ndirboun,&nboun,ipompc, + nodempc,&nmpc,nactdof,icol,jq,&mast1,&irow,&isolver,neq, + ikmpc,ilmpc,ipointer,nzs,&nmethodl,ithermal, + ikboun,ilboun,iperturb,mi,&mortar,typeboun,labmpc, + &iit,&icascade,&network,&iexpl,ielmat,matname); + } + else{neq[0]=1;neq[1]=1;neq[2]=1;} + } + else{ + + NNEW(icol,ITG,8*nk); + NNEW(jq,ITG,8*nk+1); + NNEW(ipointer,ITG,8*nk); + + if(nmethod==13){nmethodl=2;}else{nmethodl=nmethod;} + mastructcs(&nk,kon,ipkon,lakon,&ne,nodeboun,ndirboun,&nboun, + ipompc,nodempc,&nmpc,nactdof,icol,jq,&mast1,&irow,&isolver, + neq,ikmpc,ilmpc,ipointer,nzs,&nmethodl, + ics,cs,labmpc,&mcs,mi,&mortar,ielmat,matname); + } + + SFREE(ipointer);SFREE(mast1); + if((icascade==0)&&(nmethod<8))RENEW(irow,ITG,nzs[2]); + + /* nmethod=1: static analysis */ + /* nmethod=2: frequency analysis */ + /* nmethod=3: buckling analysis */ + /* nmethod=4: (linear or nonlinear) dynamic analysis */ + /* nmethod=5: steady state dynamics analysis */ + /* nmethod=6: Coriolis frequency calculation */ + /* nmethod=7: flutter frequency calculation */ + /* nmethod=8: magnetostatics */ + /* nmethod=9: magnetodynamics */ + /* nmethod=10: electromagnetic eigenvalue problems */ + /* nmethod=11: superelement creation */ + /* nmethod=12: sensitivity analysis */ + /* nmethod=13: Green function calculation */ + /* nmethod=14: Robustness w.r.t. to geometric tolerances */ + /* nmethod=15: Crack propagation */ + /* nmethod=16: Feasible direction based on sensitivity information */ + + if((nmethod<=1)||(nmethod==11)||((iperturb[0]>1)&&(nmethod<8))){ + if(iperturb[0]<2){ + + mpcinfo[0]=memmpc_;mpcinfo[1]=mpcfree;mpcinfo[2]=icascade; + mpcinfo[3]=maxlenmpc; + + if(icascade!=0){ + printf(" *ERROR in CalculiX: the matrix structure may"); + printf(" change due to nonlinear equations;"); + printf(" a purely linear calculation is not"); + printf(" feasible; use NLGEOM on the *STEP card."); + FORTRAN(stop,()); + } + + linstatic_precice(co,&nk,&kon,&ipkon,&lakon,&ne,nodeboun,ndirboun,xboun, + &nboun, + ipompc,nodempc,coefmpc,labmpc,&nmpc,nodeforc,ndirforc,xforc, + &nforc,nelemload,sideload,xload,&nload, + nactdof,&icol,jq,&irow,neq,&nzl,&nmethod,ikmpc, + ilmpc,ikboun,ilboun,elcon,nelcon,rhcon,nrhcon, + alcon,nalcon,alzero,&ielmat,&ielorien,&norien,orab,&ntmat_, + t0,t1,t1old,ithermal,prestr,&iprestr,vold,iperturb,sti,nzs, + &kode,filab,eme,&iexpl,plicon, + nplicon,plkcon,nplkcon,&xstate,&npmat_,matname, + &isolver,mi,&ncmat_,&nstate_,cs,&mcs,&nkon,&ener, + xbounold,xforcold,xloadold,amname,amta,namta, + &nam,iamforc,iamload,iamt1,iamboun,&ttime, + output,set,&nset,istartset,iendset,ialset,&nprint,prlab, + prset,&nener,trab,inotr,&ntrans,fmpc,ipobody,ibody,xbody, + &nbody, + xbodyold,timepar,thicke,jobnamec,tieset,&ntie,&istep,&nmat, + ielprop,prop,typeboun,&mortar,mpcinfo,tietol,ics, + orname,itempuser,t0g,t1g,jmax, + /* PreCICE args */ + preciceParticipantName, configFilename); + + for(i=0;i<3;i++){nzsprevstep[i]=nzs[i];} + + memmpc_=mpcinfo[0];mpcfree=mpcinfo[1];icascade=mpcinfo[2]; + maxlenmpc=mpcinfo[3]; + + } + + // else{ + + // mpcinfo[0]=memmpc_;mpcinfo[1]=mpcfree;mpcinfo[2]=icascade; + // mpcinfo[3]=maxlenmpc; + + // nonlingeo(&co,&nk,&kon,&ipkon,&lakon,&ne,nodeboun,ndirboun,xboun, + // &nboun,&ipompc,&nodempc,&coefmpc,&labmpc,&nmpc,nodeforc, + // ndirforc,xforc,&nforc,&nelemload,&sideload,xload,&nload, + // nactdof,&icol,jq,&irow,neq,&nzl,&nmethod,&ikmpc,&ilmpc, + // ikboun,ilboun,elcon,nelcon,rhcon,nrhcon,alcon,nalcon, + // alzero,&ielmat,&ielorien,&norien,orab,&ntmat_,t0,t1,t1old, + // ithermal,prestr,&iprestr,&vold,iperturb,sti,nzs,&kode, + // filab,&idrct,jmax,jout,timepar,eme,xbounold,xforcold, + // xloadold,veold,accold,amname,amta,namta,&nam,iamforc, + // &iamload,iamt1,alpha,&iexpl,iamboun,plicon,nplicon,plkcon, + // nplkcon,&xstate,&npmat_,&istep,&ttime,matname,qaold,mi, + // &isolver,&ncmat_,&nstate_,cs,&mcs,&nkon,&ener, + // mpcinfo,output,shcon,nshcon,cocon,ncocon,physcon,&nflow, + // ctrl,set,&nset,istartset,iendset,ialset,&nprint,prlab, + // prset,&nener,ikforc,ilforc,trab,inotr,&ntrans,&fmpc,cbody, + // ibody,xbody,&nbody,xbodyold,ielprop,prop,&ntie,tieset, + // &itpamp,&iviewfile,jobnamec,tietol,&nslavs,thicke,ics, + // &nintpoint,&mortar,&ifacecount,typeboun,&islavsurf, + // &pslavsurf,&clearini,&nmat,xmodal,&iaxial,&inext,&nprop, + // &network,orname,vel,&nef,velo,veloo,energy,itempuser, + // ipobody,&inewton,t0g,t1g,&ifreebody); + + // memmpc_=mpcinfo[0];mpcfree=mpcinfo[1];icascade=mpcinfo[2]; + // maxlenmpc=mpcinfo[3]; + + // for(i=0;i<3;i++){nzsprevstep[i]=nzs[i];} + + // } + } +// else if((nmethod==2)||(nmethod==13)){ + +// /* FREQUENCY ANALYSIS */ + +// if((mcs==0)||(cs[1]<0)){ +// #ifdef ARPACK + +// mpcinfo[0]=memmpc_;mpcinfo[1]=mpcfree;mpcinfo[2]=icascade; +// mpcinfo[3]=maxlenmpc; + +// arpack(co,&nk,&kon,&ipkon,&lakon,&ne,nodeboun,ndirboun,xboun,&nboun, +// ipompc,nodempc,coefmpc,labmpc,&nmpc,nodeforc,ndirforc,xforc, +// &nforc,nelemload,sideload,xload,&nload, +// nactdof,icol,jq,&irow,neq,&nzl,&nmethod,ikmpc, +// ilmpc,ikboun,ilboun,elcon,nelcon,rhcon,nrhcon, +// shcon,nshcon,cocon,ncocon, +// alcon,nalcon,alzero,&ielmat,&ielorien,&norien,orab,&ntmat_, +// t0,t1,t1old,ithermal,prestr,&iprestr,vold,iperturb,sti,nzs, +// &kode,mei,fei,filab, +// &iexpl,plicon,nplicon,plkcon,nplkcon, +// &xstate,&npmat_,matname,mi,&ncmat_,&nstate_,&ener,jobnamec, +// output,set,&nset,istartset,iendset,ialset,&nprint,prlab, +// prset,&nener,&isolver,trab,inotr,&ntrans,&ttime,fmpc,ipobody, +// ibody,xbody,&nbody,thicke,&nslavs,tietol,&nkon,mpcinfo, +// &ntie,&istep,&mcs,ics,tieset,cs,&nintpoint,&mortar,&ifacecount, +// &islavsurf,&pslavsurf,&clearini,&nmat,typeboun,ielprop,prop, +// orname,&inewton,t0g,t1g); + +// memmpc_=mpcinfo[0];mpcfree=mpcinfo[1];icascade=mpcinfo[2]; +// maxlenmpc=mpcinfo[3]; + +// for(i=0;i<3;i++){nzsprevstep[i]=nzs[i];} + +// #else +// printf(" *ERROR in CalculiX: the ARPACK library is not linked\n\n"); +// FORTRAN(stop,()); +// #endif + +// }else{ + +// #ifdef ARPACK + +// mpcinfo[0]=memmpc_;mpcinfo[1]=mpcfree;mpcinfo[2]=icascade; +// mpcinfo[3]=maxlenmpc; + +// arpackcs(co,&nk,&kon,&ipkon,&lakon,&ne,nodeboun,ndirboun, +// xboun,&nboun, +// ipompc,nodempc,coefmpc,labmpc,&nmpc,nodeforc,ndirforc,xforc, +// &nforc,nelemload,sideload,xload,&nload, +// nactdof,icol,jq,&irow,neq,&nzl,&nmethod,ikmpc, +// ilmpc,ikboun,ilboun,elcon,nelcon,rhcon,nrhcon, +// alcon,nalcon,alzero,&ielmat,&ielorien,&norien,orab,&ntmat_, +// t0,t1,t1old,ithermal,prestr,&iprestr, +// vold,iperturb,sti,nzs,&kode,mei,fei,filab, +// &iexpl,plicon,nplicon,plkcon,nplkcon, +// &xstate,&npmat_,matname,mi,ics,cs,&mpcend,&ncmat_, +// &nstate_,&mcs,&nkon,jobnamec,output,set,&nset,istartset, +// iendset,ialset,&nprint,prlab, +// prset,&nener,&isolver,trab,inotr,&ntrans,&ttime,fmpc,ipobody, +// ibody,xbody,&nbody,&nevtot,thicke,&nslavs,tietol,mpcinfo, +// &ntie,&istep,tieset,&nintpoint,&mortar,&ifacecount,&islavsurf, +// &pslavsurf,&clearini,&nmat,typeboun,ielprop,prop,orname, +// &inewton,t0g,t1g); + +// memmpc_=mpcinfo[0];mpcfree=mpcinfo[1];icascade=mpcinfo[2]; +// maxlenmpc=mpcinfo[3]; + +// for(i=0;i<3;i++){nzsprevstep[i]=nzs[i];} + +// #else +// printf(" *ERROR in CalculiX: the ARPACK library is not linked\n\n"); +// FORTRAN(stop,()); +// #endif + +// } +// }else if(nmethod==3){ + +// #ifdef ARPACK +// arpackbu(co,&nk,kon,ipkon,lakon,&ne,nodeboun,ndirboun,xboun,&nboun, +// ipompc,nodempc,coefmpc,labmpc,&nmpc,nodeforc,ndirforc,xforc, +// &nforc, +// nelemload,sideload,xload,&nload, +// nactdof,icol,jq,irow,neq,&nzl,&nmethod,ikmpc, +// ilmpc,ikboun,ilboun,elcon,nelcon,rhcon,nrhcon, +// alcon,nalcon,alzero,ielmat,ielorien,&norien,orab,&ntmat_, +// t0,t1,t1old,ithermal,prestr,&iprestr, +// vold,iperturb,sti,nzs,&kode,mei,fei,filab, +// eme,&iexpl,plicon,nplicon,plkcon,nplkcon, +// xstate,&npmat_,matname,mi,&ncmat_,&nstate_,ener,output, +// set,&nset,istartset,iendset,ialset,&nprint,prlab, +// prset,&nener,&isolver,trab,inotr,&ntrans,&ttime,fmpc,ipobody, +// ibody,xbody,&nbody,thicke,jobnamec,&nmat,ielprop,prop, +// orname,typeboun,t0g,t1g,&mcs,&istep); +// #else +// printf(" *ERROR in CalculiX: the ARPACK library is not linked\n\n"); +// FORTRAN(stop,()); +// #endif +// } +// else if(nmethod==4) +// { +// if((ne1d!=0)||(ne2d!=0)){ +// printf(" *WARNING: 1-D or 2-D elements may cause problems in modal dynamic calculations\n"); +// printf(" ensure that point loads defined in a *MODAL DYNAMIC step\n"); +// printf(" and applied to nodes belonging to 1-D or 2-D elements have been\n"); +// printf(" applied to the same nodes in the preceding FREQUENCY step with\n"); +// printf(" magnitude zero; look at example shellf.inp for a guideline.\n\n");} + +// printf(" Composing the dynamic response from the eigenmodes\n\n"); + +// dyna(&co,&nk,&kon,&ipkon,&lakon,&ne,&nodeboun,&ndirboun,&xboun,&nboun, +// &ipompc,&nodempc,&coefmpc,&labmpc,&nmpc,nodeforc,ndirforc,xforc, +// &nforc, +// nelemload,sideload,xload,&nload, +// &nactdof,neq,&nzl,icol,irow,&nmethod,&ikmpc,&ilmpc,&ikboun,&ilboun, +// elcon,nelcon,rhcon,nrhcon,cocon,ncocon, +// alcon,nalcon,alzero,&ielmat,&ielorien,&norien,orab,&ntmat_,&t0, +// &t1,ithermal,prestr,&iprestr,&vold,iperturb,&sti,nzs, +// timepar,xmodal,&veold,amname,amta, +// namta,&nam,iamforc,iamload,&iamt1, +// jout,&kode,filab,&eme,xforcold,xloadold, +// &t1old,&iamboun,&xbounold,&iexpl,plicon, +// nplicon,plkcon,nplkcon,&xstate,&npmat_,matname, +// mi,&ncmat_,&nstate_,&ener,jobnamec,&ttime,set,&nset, +// istartset,iendset,&ialset,&nprint,prlab, +// prset,&nener,trab,&inotr,&ntrans,&fmpc,ipobody,ibody,xbody,&nbody, +// xbodyold,&istep,&isolver,jq,output,&mcs,&nkon,&mpcend,ics,cs, +// &ntie,tieset,&idrct,jmax,ctrl,&itpamp,tietol,&nalset, +// ikforc,ilforc,thicke,&nslavs,&nmat,typeboun,ielprop,prop,orname, +// t0g,t1g); +// } +// else if(nmethod==5) +// { +// if((ne1d!=0)||(ne2d!=0)){ +// printf(" *WARNING: 1-D or 2-D elements may cause problems in steady state calculations\n"); +// printf(" ensure that point loads defined in a *STEADY STATE DYNAMICS step\n"); +// printf(" and applied to nodes belonging to 1-D or 2-D elements have been\n"); +// printf(" applied to the same nodes in the preceding FREQUENCY step with\n"); +// printf(" magnitude zero; look at example shellf.inp for a guideline.\n\n");} + +// printf(" Composing the steady state response from the eigenmodes\n\n"); + +// steadystate(&co,&nk,&kon,&ipkon,&lakon,&ne,&nodeboun,&ndirboun,&xboun, +// &nboun, +// &ipompc,&nodempc,&coefmpc,&labmpc,&nmpc,nodeforc,ndirforc, +// xforc,&nforc, +// nelemload,sideload,xload,&nload, +// &nactdof,neq,&nzl,icol,irow,&nmethod,&ikmpc,&ilmpc,&ikboun, +// &ilboun, +// elcon,nelcon,rhcon,nrhcon,cocon,ncocon, +// alcon,nalcon,alzero,&ielmat,&ielorien,&norien,orab,&ntmat_, +// &t0, +// &t1,ithermal,prestr,&iprestr,&vold,iperturb,sti,nzs, +// timepar,xmodal,&veold,amname,amta, +// namta,&nam,iamforc,iamload,&iamt1, +// jout,&kode,filab,&eme,xforcold,xloadold, +// &t1old,&iamboun,&xbounold,&iexpl,plicon, +// nplicon,plkcon,nplkcon,xstate,&npmat_,matname, +// mi,&ncmat_,&nstate_,&ener,jobnamec,&ttime,set,&nset, +// istartset,iendset,ialset,&nprint,prlab, +// prset,&nener,trab,&inotr,&ntrans,&fmpc,ipobody,ibody,xbody, +// &nbody, +// xbodyold,&istep,&isolver,jq,output,&mcs,&nkon,ics,cs, +// &mpcend, +// ctrl,ikforc,ilforc,thicke,&nmat,typeboun,ielprop,prop, +// orname, +// &ndamp,dacon,t0g,t1g); +// } +// else if((nmethod==6)||(nmethod==7)) +// { + +// printf(" Composing the complex eigenmodes from the real eigenmodes\n\n"); + +// complexfreq(&co,&nk,&kon,&ipkon,&lakon,&ne,&nodeboun,&ndirboun,&xboun, +// &nboun,&ipompc,&nodempc,&coefmpc,&labmpc,&nmpc,nodeforc, +// ndirforc,xforc,&nforc, +// nelemload,sideload,xload,&nload, +// &nactdof,neq,&nzl,icol,irow,&nmethod,&ikmpc,&ilmpc,&ikboun, +// &ilboun, +// elcon,nelcon,rhcon,nrhcon,cocon,ncocon, +// alcon,nalcon,alzero,&ielmat,&ielorien,&norien,orab,&ntmat_, +// &t0, +// &t1,ithermal,prestr,&iprestr,&vold,iperturb,&sti,nzs, +// timepar,xmodal,&veold,amname,amta, +// namta,&nam,iamforc,iamload,&iamt1, +// jout,&kode,filab,&eme,xforcold,xloadold, +// &t1old,&iamboun,&xbounold,&iexpl,plicon, +// nplicon,plkcon,nplkcon,xstate,&npmat_,matname, +// mi,&ncmat_,&nstate_,&ener,jobnamec,&ttime,set,&nset, +// istartset,iendset,&ialset,&nprint,prlab, +// prset,&nener,trab,&inotr,&ntrans,&fmpc,ipobody,ibody,xbody, +// &nbody, +// xbodyold,&istep,&isolver,jq,output,&mcs,&nkon,&mpcend,ics, +// cs, +// &ntie,tieset,&idrct,jmax,ctrl,&itpamp,tietol,&nalset, +// ikforc,ilforc,thicke,jobnamef,mei,&nmat,ielprop,prop,orname, +// typeboun,t0g,t1g); +// } +// else if((nmethod>7)&&(nmethod<12)){ + +// mpcinfo[0]=memmpc_;mpcinfo[1]=mpcfree;mpcinfo[2]=icascade; +// mpcinfo[3]=maxlenmpc; + +// electromagnetics(&co,&nk,&kon,&ipkon,&lakon,&ne,nodeboun, +// ndirboun,xboun,&nboun, +// &ipompc,&nodempc,&coefmpc,&labmpc,&nmpc,nodeforc, +// ndirforc,xforc, +// &nforc,&nelemload,&sideload,xload,&nload, +// nactdof,&icol,&jq,&irow,neq,&nzl,&nmethod,&ikmpc, +// &ilmpc,ikboun,ilboun,elcon,nelcon,rhcon,nrhcon, +// alcon,nalcon,alzero,&ielmat,&ielorien,&norien,orab, +// &ntmat_, +// t0,t1,t1old,ithermal,prestr,&iprestr, +// &vold,iperturb,sti,nzs,&kode,filab,&idrct,jmax, +// jout,timepar,eme,xbounold,xforcold,xloadold, +// veold,accold,amname,amta,namta, +// &nam,iamforc,&iamload,iamt1,alpha, +// &iexpl,iamboun,plicon,nplicon,plkcon,nplkcon, +// &xstate,&npmat_,&istep,&ttime,matname,qaold,mi, +// &isolver,&ncmat_,&nstate_,cs,&mcs,&nkon,&ener, +// mpcinfo,output, +// shcon,nshcon,cocon,ncocon,physcon,&nflow,ctrl, +// &set,&nset,&istartset,&iendset,&ialset,&nprint,prlab, +// prset,&nener,ikforc,ilforc,trab,inotr,&ntrans,&fmpc, +// ipobody,ibody,xbody,&nbody,xbodyold,ielprop,prop, +// &ntie,&tieset,&itpamp,&iviewfile,jobnamec,&tietol, +// &nslavs,thicke, +// ics,&nalset,&nmpc_,&nmat,typeboun,&iaxial,&nload_,&nprop, +// &network,orname,t0g,t1g); + +// memmpc_=mpcinfo[0];mpcfree=mpcinfo[1];icascade=mpcinfo[2]; +// maxlenmpc=mpcinfo[3]; +// } + +// else if(nmethod==12){ + +// if(icoordinate==1){ +// sensi_coor(co,&nk,&kon,&ipkon,&lakon,&ne,nodeboun,ndirboun, +// xboun,&nboun,ipompc,nodempc,coefmpc,labmpc,&nmpc,nodeforc, +// ndirforc,xforc,&nforc,nelemload,sideload,xload,&nload, +// nactdof,icol,jq,&irow,neq,&nzl,&nmethod,ikmpc, +// ilmpc,ikboun,ilboun,elcon,nelcon,rhcon,nrhcon, +// alcon,nalcon,alzero,&ielmat,&ielorien,&norien,orab,&ntmat_, +// t0,t1,t1old,ithermal,prestr,&iprestr,vold,iperturb,sti,nzs, +// &kode,filab,eme,&iexpl,plicon, +// nplicon,plkcon,nplkcon,&xstate,&npmat_,matname, +// &isolver,mi,&ncmat_,&nstate_,cs,&mcs,&nkon,&ener, +// xbounold,xforcold,xloadold,amname,amta,namta, +// &nam,iamforc,iamload,iamt1,iamboun,&ttime, +// output,set,&nset,istartset,iendset,ialset,&nprint,prlab, +// prset,&nener,trab,inotr,&ntrans,fmpc,ipobody,ibody,xbody, +// &nbody, +// xbodyold,timepar,thicke,jobnamec,tieset,&ntie,&istep,&nmat, +// ielprop,prop,typeboun,&mortar,mpcinfo,tietol,ics, +// &nobject,&objectset,&istat,orname,nzsprevstep,&nlabel, +// physcon, +// jobnamef,iponor,knor,&ne2d,iponoel,inoel,&mpcend,dgdxglob, +// g0,&nodedesi,&ndesi,&nobjectstart,&xdesi,rig); + +// }else{ +// sensi_orien(co,&nk,&kon,&ipkon,&lakon,&ne,nodeboun,ndirboun, +// xboun,&nboun,ipompc,nodempc,coefmpc,labmpc,&nmpc,nodeforc, +// ndirforc,xforc,&nforc,nelemload,sideload,xload,&nload, +// nactdof,icol,jq,&irow,neq,&nzl,&nmethod,ikmpc, +// ilmpc,ikboun,ilboun,elcon,nelcon,rhcon,nrhcon, +// alcon,nalcon,alzero,&ielmat,&ielorien,&norien,orab,&ntmat_, +// t0,t1,t1old,ithermal,prestr,&iprestr,vold,iperturb,sti,nzs, +// &kode,filab,eme,&iexpl,plicon, +// nplicon,plkcon,nplkcon,&xstate,&npmat_,matname, +// &isolver,mi,&ncmat_,&nstate_,cs,&mcs,&nkon,&ener, +// xbounold,xforcold,xloadold,amname,amta,namta, +// &nam,iamforc,iamload,iamt1,iamboun,&ttime, +// output,set,&nset,istartset,iendset,ialset,&nprint,prlab, +// prset,&nener,trab,inotr,&ntrans,fmpc,ipobody,ibody,xbody, +// &nbody, +// xbodyold,timepar,thicke,jobnamec,tieset,&ntie,&istep,&nmat, +// ielprop,prop,typeboun,&mortar,mpcinfo,tietol,ics, +// &nobject,&objectset,&istat,orname,nzsprevstep,&nlabel, +// physcon, +// jobnamef,iponor,knor,&ne2d,iponoel,inoel,&mpcend); +// } + +// } + +// else if(nmethod==14){ + +// robustdesign(co,&nk,&kon,&ipkon,&lakon,&ne,nodeboun,ndirboun,xboun, +// &nboun,ipompc,nodempc,coefmpc,labmpc,&nmpc,nodeforc, +// ndirforc,xforc,&nforc,nelemload,sideload,xload,&nload, +// nactdof,icol,jq,&irow,neq,&nzl,&nmethod,ikmpc,ilmpc,ikboun, +// ilboun,elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero, +// &ielmat,&ielorien,&norien,orab,&ntmat_,t0,t1,t1old,ithermal, +// prestr,&iprestr,vold,iperturb,sti,nzs,&kode,filab,eme, +// &iexpl,plicon,nplicon,plkcon,nplkcon,&xstate,&npmat_, +// matname,&isolver,mi,&ncmat_,&nstate_,cs,&mcs,&nkon,&ener, +// xbounold,xforcold,xloadold,amname,amta,namta,&nam,iamforc, +// iamload,iamt1,iamboun,&ttime,output,set,&nset,istartset, +// iendset,ialset,&nprint,prlab,prset,&nener,trab,inotr, +// &ntrans,fmpc,ipobody,ibody,xbody,&nbody,xbodyold,timepar, +// thicke,jobnamec,tieset,&ntie,&istep,&nmat,ielprop,prop, +// typeboun,&mortar,mpcinfo,tietol,ics,&nobject, +// &objectset,&istat,orname,nzsprevstep,&nlabel,physcon, +// jobnamef,iponor,knor,&ne2d,iponoel,inoel,&mpcend, +// irobustdesign,irandomtype,randomval,rig); +// } + +// else if(nmethod==15){ + +// crackpropagation(&ipkon,&kon,&lakon,&ne,&nk,jobnamec,&nboun,iamboun,xboun, +// &nload,sideload,iamload,&nforc,iamforc,xforc,ithermal, +// &t1,&iamt1,&co,&nkon,mi,&ielmat,matname,output,&nmat,set, +// &nset,istartset,iendset,ialset,jmax,timepar,nelcon, +// elcon,&ncmat_,&ntmat_,&istep,filab,&nmethod,mei,&ntrans, +// &inotr,&t0,&ne1d,&ne2d,&t0g,&t1g,&nam,&t1old,&vold, +// iperturb,&iprestr,&prestr,&norien,&ielorien,&nprop, +// &ielprop,&offset,&sti,&eme,&nener,&ener,&nstate_, +// &mortar,&nslavs,&nintpoint,&xstate,&iponor,&thicke); +// } + +// else if(nmethod==16){ + +// feasibledirection(&nobject,&objectset,&dgdxglob,g0,&ndesi,nodedesi,&nk, +// &isolver,&ipkon,&kon,&lakon,&ne,nelemload,&nload, +// nodeboun,&nboun,ndirboun,ithermal,co,vold,mi,&ielmat, +// ielprop,prop,&kode,&nmethod,filab,&nstate_,&istep,cs, +// set,&nset,istartset,iendset,ialset,jobnamec,output, +// &ntrans,inotr,trab,orname,xdesi,timepar,coini,ikboun, +// nactdof,&ne2d,&nkon); + +// } + + SFREE(nactdof);SFREE(icol);SFREE(jq);SFREE(irow);SFREE(ipobody); + + /* check whether refinement was active */ + + // if(irefineloop==20){ + if(strcmp1(&filab[4089],"RM")==0){ + irefineloop++; + + if(irefineloop==1){ + + /* refinement was requested in the step which was just + finished and a refined mesh was created and stored. + The calculation has to restart from the beginning with + this new mesh */ + + memcpy(ipoinp,ipoinp_sav,sizeof(ITG)*2*nentries); + memcpy(inp,inp_sav,sizeof(ITG)*inp_size); + + /* deallocating fields */ + + dealloc_cal(&ncs_,&ics,&mcs,&cs,&tieset,&tietol,&co, + &kon,&ipkon,&lakon,&nodeboun,&ndirboun,&typeboun,&xboun, + &ikboun,&ilboun,&nodebounold,&ndirbounold,&xbounold,&ipompc, + &labmpc,&ikmpc,&ilmpc,&fmpc,&nodempc,&coefmpc,&nodempcref, + &coefmpcref,&ikmpcref,&nodeforc,&ndirforc,&xforc, + &ikforc,&ilforc,&xforcold,&nelemload,&sideload,&xload, + &xloadold,&cbody,&ibody,&xbody,&xbodyold,&nam, + &iamboun,&iamforc,&iamload,&amname,&amta,&namta,&set, + &istartset,&iendset,&ialset,&elcon,&nelcon,&rhcon, + &nrhcon,&shcon,&nshcon,&cocon,&ncocon,&alcon, + &nalcon,&alzero,&nprop,&ielprop,&prop,&npmat_, + &plicon,&nplicon,&plkcon,&nplkcon,&ndamp,&dacon,&norien, + &orname,&orab,&ielorien,&ntrans,&trab,&inotr,&iprestr, + &prestr,ithermal,&t0,&t1,&t1old,&iamt1,&ne1d, + &ne2d,&t0g,&t1g,irobustdesign,&irandomtype, + &randomval,&prlab,&prset,&filab,&xmodal,&ielmat, + &matname,&sti,&eme,&ener,&xstate,&vold, + &veold,&vel,&velo,&veloo,&iponor,&xnor, + &knor,&thicke,&offset,&iponoel,&inoel,&rig, + &ne2boun,&islavsurf,&mortar,&pslavsurf,&clearini, + &nobject_,&objectset,&nmethod,iperturb,&irefineloop, + &iparentel,&iprfn,&konrfn,&ratiorfn,&heading, + &nodedesi,&dgdxglob,&g0,&nuel_,&xdesi,&nfc,&coeffc, + &ikdc,&edc,&coini); + + /* closing and reopening the output files */ + + FORTRAN(openfile,(jobnamef)); + + /* initialization of the variables */ + + ini_cal(jobnamec,output,fneig,kind1,kind2,itempuser,irobustdesign, + &nprint,neq,&mpcfree,&nbounold,&nforcold,&nloadold,&nbody_, + &nbodyold,&network,&nheading_,&nmpc_,&nload_,&nforc_,&nboun_, + &nintpoint,iperturb,&ntmat_,ithermal,&isolver,&nslavs,&nkon_, + &mortar,jout,&nkon,&nevtot,&ifacecount,&iplas,&npmat_,mi, + &mpcend,&namtot_,&icascade,&ne1d,&ne2d,infree,&nflow, + irstrt,&nener,&jrstrt,&ntie_,&mcs,&nprop_,&nprop,&itpamp, + &nevdamp_,&npt_,&iaxial,&inext,&icontact,&nobject,&nobject_, + &iit,&mpcfreeref,&isens,&namtot,&nstam,&ndamp,&nef, + &nk_,&ne_,&nalset_,&nmat_,&norien_,&nam_,&ntrans_, + &ncs_,&nstate_,&ncmat_,&memmpc_,&nprint_,energy,ctrl,alpha, + qaold,physcon,&istep,&istat,&iprestr,&kode,&nload,&nbody,&nforc, + &nboun,&nk,&nmpc,&nam,&nzs_,&nlabel,&ttime,&iheading,&nfc, + &nfc_,&ndc,&ndc_); + + NNEW(set,char,81*nset_); + NNEW(meminset,ITG,nset_); + NNEW(rmeminset,ITG,nset_); + NNEW(iuel,ITG,4*nuel_); + + FORTRAN(allocation,(&nload_,&nforc_,&nboun_,&nk_,&ne_,&nmpc_,&nset_, + &nalset_,&nmat_,&ntmat_,&npmat_,&norien_,&nam_, + &nprint_,mi,&ntrans_,set,meminset,rmeminset,&ncs_, + &namtot_,&ncmat_,&memmpc_,&ne1d,&ne2d,&nflow, + jobnamec,irstrt,ithermal,&nener,&nstate_,&istep, + inpc,ipoinp,inp,&ntie_,&nbody_, + &nprop_,ipoinpc,&nevdamp_,&npt_,&nslavs,&nkon_,&mcs, + &mortar,&ifacecount,&nintpoint,infree,&nheading_, + &nobject_,iuel,&iprestr,&nstam,&ndamp,&nef, + &nbounold,&nforcold,&nloadold,&nbodyold,&mpcend, + irobustdesign,&nfc_,&ndc_)); + + SFREE(meminset);SFREE(rmeminset);mt=mi[1]+1; + NNEW(heading,char,66*nheading_); + + continue; + } + } + + /* reset tempuserflag */ + + itempuser[0]=0; + + /* deleting the perturbation loads and temperatures */ + + if((iperturb[0]==1)&&(nmethod==3)){ + nforc=0; + nload=0; + nbody=0; + if(ithermal[0]==1){ + for(k=0;k0){ + for(i=0;i0){ + if(namta[3*iamboun[i]-1]>0){ + iamboun[i]=0; + xboun[i]=xbounold[i];} + } + } + for(i=0;i0){ + if(namta[3*iamforc[i]-1]>0){ + iamforc[i]=0; + xforc[i]=xforcold[i];} + } + } + for(i=0;i<2*nload;i++){ + if(iamload[i]>0){ + if(namta[3*iamload[i]-1]>0){ + iamload[i]=0; + xload[i]=xloadold[i];} + } + } + for(i=1;i<3*nbody;i=i+3){ + if(ibody[i]>0){ + if(namta[3*ibody[i]-1]>0){ + ibody[i]=0; + xbody[7*(i-1)/3]=xbodyold[7*(i-1)/3];} + } + } + if(ithermal[0]==1){ + if(iamt1[i]>0){ + if(namta[3*iamt1[i]-1]>0){ + iamt1[i]=0; + t1[i]=t1old[i];} + } + } + } + } + + /* removing the advective elements, if any */ + + if(network>0){ + RENEW(ipkon,ITG,ne1); + RENEW(lakon,char,8*ne1); + RENEW(kon,ITG,nkon0); + RENEW(sti,double,6*mi[0]*ne1); + RENEW(eme,double,6*mi[0]*ne1); + if(iprestr>0) RENEW(prestr,double,6*mi[0]*ne1); + if(nprop>0) RENEW(ielprop,ITG,ne1); + if((ne1d!=0)||(ne2d!=0)) RENEW(offset,double,2*ne1); + if(nener==1)RENEW(ener,double,2*mi[0]*ne1); + + /* moving the contact state variables back by (ne-ne1) + element blocks */ + + if(mortar!=1){ + for(i=nstate_*mi[0]*ne1;i0)RENEW(ielorien,ITG,mi[2]*ne1); + RENEW(ielmat,ITG,mi[2]*ne1); + + /* reactivating the original load labels */ + + for(i=nload-1;i>=nload0;i--){ + if(strcmp2(&sideload[20*i]," ",20)==0){ + iload=nelemload[2*i+1]; + strcpy1(&sideload[20*(iload-1)],"F",1); + } + } + ne=ne1;nkon=nkon0; + + } + + nload=nload0; + + if((nmethod==4)&&(iperturb[0]>1)) SFREE(accold); + + if(irstrt[0]>0){ + jrstrt++; + if(jrstrt>=irstrt[0]){ + jrstrt=0; + FORTRAN(restartwrite,(&istep,&nset,&nload,&nforc,&nboun,&nk,&ne,&nmpc, + &nalset,&nmat,&ntmat_,&npmat_,&norien,&nam, + &nprint,mi,&ntrans,&ncs_,&namtot,&ncmat_,&mpcend, + &maxlenmpc,&ne1d,&ne2d,&nflow,&nlabel,&iplas, + &nkon,ithermal,&nmethod,iperturb,&nstate_,&nener, + set,istartset,iendset,ialset,co,kon,ipkon,lakon, + nodeboun,ndirboun,iamboun,xboun,ikboun,ilboun, + ipompc,nodempc,coefmpc,labmpc,ikmpc,ilmpc, + nodeforc,ndirforc,iamforc,xforc,ikforc,ilforc, + nelemload,iamload,sideload,xload,elcon,nelcon, + rhcon,nrhcon,alcon,nalcon,alzero,plicon,nplicon, + plkcon,nplkcon,orname,orab,ielorien,trab,inotr, + amname,amta,namta,t0,t1,iamt1,veold,ielmat, + matname,prlab,prset,filab,vold,nodebounold, + ndirbounold,xbounold,xforcold,xloadold,t1old,eme, + iponor,xnor,knor,thicke,offset,iponoel,inoel,rig, + shcon,nshcon,cocon,ncocon,ics,sti,ener,xstate, + jobnamec,infree,prestr,&iprestr,cbody,ibody, + xbody,&nbody,xbodyold,&ttime,qaold,cs,&mcs, + output,physcon,ctrl,typeboun,fmpc,tieset,&ntie, + tietol,&nslavs,t0g,t1g,&nprop,ielprop,prop, + &mortar,&nintpoint,&ifacecount,islavsurf, + pslavsurf,clearini,irstrt,vel,&nef,velo,veloo, + ne2boun,&memmpc_,heading,&nheading_,&network, + &nfc,&ndc,coeffc,ikdc,edc)); + } + } + + } + + FORTRAN(closefile,()); + + strcpy2(fneig,jobnamec,132); + strcat(fneig,".frd"); + if((f1=fopen(fneig,"ab"))==NULL){ + printf(" *ERROR in frd: cannot open frd file for writing..."); + exit(0); + } + fprintf(f1," 9999\n"); + fclose(f1); + + /* deallocating the fields + this section is addressed immediately after leaving calinput */ + + SFREE(ipoinpc);SFREE(inpc);SFREE(inp);SFREE(ipoinp);SFREE(inp_sav); + SFREE(ipoinp_sav); + + dealloc_cal(&ncs_,&ics,&mcs,&cs,&tieset,&tietol,&co, + &kon,&ipkon,&lakon,&nodeboun,&ndirboun,&typeboun,&xboun, + &ikboun,&ilboun,&nodebounold,&ndirbounold,&xbounold,&ipompc, + &labmpc,&ikmpc,&ilmpc,&fmpc,&nodempc,&coefmpc, + &nodempcref,&coefmpcref,&ikmpcref,&nodeforc,&ndirforc,&xforc, + &ikforc,&ilforc,&xforcold,&nelemload,&sideload,&xload, + &xloadold,&cbody,&ibody,&xbody,&xbodyold,&nam, + &iamboun,&iamforc,&iamload,&amname,&amta,&namta,&set, + &istartset,&iendset,&ialset,&elcon,&nelcon,&rhcon, + &nrhcon,&shcon,&nshcon,&cocon,&ncocon,&alcon, + &nalcon,&alzero,&nprop,&ielprop,&prop,&npmat_, + &plicon,&nplicon,&plkcon,&nplkcon,&ndamp,&dacon,&norien, + &orname,&orab,&ielorien,&ntrans,&trab,&inotr,&iprestr, + &prestr,ithermal,&t0,&t1,&t1old,&iamt1,&ne1d, + &ne2d,&t0g,&t1g,irobustdesign,&irandomtype, + &randomval,&prlab,&prset,&filab,&xmodal,&ielmat, + &matname,&sti,&eme,&ener,&xstate,&vold, + &veold,&vel,&velo,&veloo,&iponor,&xnor, + &knor,&thicke,&offset,&iponoel,&inoel,&rig, + &ne2boun,&islavsurf,&mortar,&pslavsurf,&clearini, + &nobject_,&objectset,&nmethod,iperturb,&irefineloop, + &iparentel,&iprfn,&konrfn,&ratiorfn,&heading, + &nodedesi,&dgdxglob,&g0,&nuel_,&xdesi,&nfc,&coeffc, + &ikdc,&edc,&coini); + +#ifdef CALCULIX_MPI + MPI_Finalize(); +#endif + +#ifdef CALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT + calculix_freeExternalBehaviours(); +#endif /* CALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT */ + + clock_gettime(CLOCK_MONOTONIC, &totalCalculixTimeEnd); + + totalCalculixTime = (totalCalculixTimeEnd.tv_sec - totalCalculixTimeStart.tv_sec) * 1e9; + totalCalculixTime = (totalCalculixTime + (totalCalculixTimeEnd.tv_nsec - totalCalculixTimeStart.tv_nsec)) * 1e-9; + + printf("________________________________________\n\n"); + + printf("Total CalculiX Time: %lf\n", totalCalculixTime); + + printf("________________________________________\n"); + + return 0; + +} diff --git a/examples/ccx-nasmat/ccx/clean.sh b/examples/ccx-nasmat/ccx/clean.sh new file mode 100644 index 00000000..ad8cdce7 --- /dev/null +++ b/examples/ccx-nasmat/ccx/clean.sh @@ -0,0 +1,11 @@ +#!/bin/sh +set -e -u + +# ccx files +rm -rf *.12d *.cvg *.dat *.frd *.sta + +#precice files +rm -rf precice-profiling* ../precice-run* + +clear + diff --git a/examples/ccx-nasmat/ccx/config.yml b/examples/ccx-nasmat/ccx/config.yml new file mode 100755 index 00000000..15bfde49 --- /dev/null +++ b/examples/ccx-nasmat/ccx/config.yml @@ -0,0 +1,9 @@ +participants: + macro_ccx: + interfaces: + - elements: Eall + patch: Eall + read-data: [conv_flag, stress1to3, stress4to6, cmat1, cmat2, cmat3, cmat4, cmat5, cmat6, cmat7] + write-data: [input_id, strain1to3, strain4to6] + +precice-config-file: ../precice-config.xml diff --git a/examples/ccx-nasmat/ccx/one_element.inp b/examples/ccx-nasmat/ccx/one_element.inp new file mode 100755 index 00000000..46d725ed --- /dev/null +++ b/examples/ccx-nasmat/ccx/one_element.inp @@ -0,0 +1,51 @@ +** +** Structure: One element test (Corner BC) +** Test objective: user beam element U1 +** +*NODE, NSET=Nall +1, 0.000, 1.000, 0.000 +2, 0.000, 1.000, 1.000 +3, 0.000, 0.000, 1.000 +4, 0.000, 0.000, 0.000 +5, 1.000, 1.000, 0.000 +6, 1.000, 1.000, 1.000 +7, 1.000, 0.000, 1.000 +8, 1.000, 0.000, 0.000 +*ELEMENT, TYPE=C3D8, ELSET=Eall + 1, 1, 2, 3, 4, 5, 6, 7, 8 +*MATERIAL, NAME=EL +*ELASTIC, TYPE=ANISOTROPIC +1.85e5, 40.75, 269.36e2, 5.6e1, 4.07e1, 1.84e2, 0.0, 0.0 +0.0, 1.36e2, 0.0, 0.0, 0.0, 0.0, 1.3e2, 0.0 +0.0, 0.0, 0.0,0.0, 135e0 +*SOLID SECTION,ELSET=Eall,MATERIAL=EL +*NSET, NSET=CX + 1, 2, 3, 4 +*NSET, NSET=CY + 3, 4, 7, 8 +*NSET, NSET=CZ + 2, 3, 6, 7 +*NSET, NSET=CXD + 5, 6, 7, 8 +*BOUNDARY +CX, 1 +*BOUNDARY +CY, 2 +*BOUNDARY +CZ, 3 +*STEP +*STATIC, SOLVER=PARDISO +*BOUNDARY +CXD, 1,1, 0.1 +*NODE PRINT,NSET=Nall +U +*EL PRINT,ELSET=Eall +S +*NODE FILE +U +*EL FILE +S, E +*END STEP + + + diff --git a/examples/ccx-nasmat/ccx/run.sh b/examples/ccx-nasmat/ccx/run.sh new file mode 100755 index 00000000..3b4bebad --- /dev/null +++ b/examples/ccx-nasmat/ccx/run.sh @@ -0,0 +1,6 @@ +#!/bin/sh +set -e -u + +export OMP_NUM_THREADS=1 +export CCX_NPROC_EQUATION_SOLVER=1 +../../../bin/ccx_preCICE -i one_element -precice-participant macro_ccx diff --git a/examples/ccx-nasmat/nasmat/clean.sh b/examples/ccx-nasmat/nasmat/clean.sh new file mode 100755 index 00000000..f406faba --- /dev/null +++ b/examples/ccx-nasmat/nasmat/clean.sh @@ -0,0 +1,7 @@ +rm -rfv output/ +rm -fv *.log +rm -rfv __pycache__ +rm -rfv precice-profiling/ +rm -fv .nfs* + +clear diff --git a/examples/ccx-nasmat/nasmat/micro-manager-config.json b/examples/ccx-nasmat/nasmat/micro-manager-config.json new file mode 100644 index 00000000..b441dc2c --- /dev/null +++ b/examples/ccx-nasmat/nasmat/micro-manager-config.json @@ -0,0 +1,26 @@ +{ + "micro_file_name": "ruc_nasmat", + "coupling_params": { + "config_file_name": "../precice-config.xml", + "macro_mesh_name": "Eall", + "read_data_names": {"input_id":"scalar", + "strain1to3": "vector", + "strain4to6": "vector" + }, + "write_data_names": {"conv_flag": "scalar", + "stress1to3": "vector", + "stress4to6": "vector", + "cmat1":"vector", + "cmat2":"vector", + "cmat3":"vector", + "cmat4":"vector", + "cmat5":"vector", + "cmat6":"vector", + "cmat7":"vector" + } + }, + "simulation_params": { + "macro_domain_bounds": [0, 10000, 0, 10000, 0, 100000], + "decomposition": [1, 1, 1] + } +} diff --git a/examples/ccx-nasmat/nasmat/ruc_nasmat.py b/examples/ccx-nasmat/nasmat/ruc_nasmat.py new file mode 100644 index 00000000..71887bdd --- /dev/null +++ b/examples/ccx-nasmat/nasmat/ruc_nasmat.py @@ -0,0 +1,113 @@ +""" +Solve RVE using NASMAT: https://software.nasa.gov/software/LEW-20244-1 +""" +import numpy as np +from ctypes import cdll, byref, c_double, POINTER +import time + +from pynasmat import Model, Constituent, Ruc +from pynasmat.constants import MAT_TRANSVERSE_ISOTROPIC, RUC_ARCHID_SQPACK_1FIBER, RUC_MODID_GMC_2D + +class MicroSimulation: + + def __init__(self, sim_id): + """ + Constructor of MicroSimulation class. + """ + self._dims = 3 + self._sim_id = sim_id + + print("MicroSimulation object created with ID: ", sim_id) + + def solve(self, macro_data, dt): + assert dt != 0 + + print(macro_data) + + # Processing input data + rve_id = int(macro_data["input_id"]) + mod_id = 102 + ruc_size = 16 + input_strain = np.zeros((6)) + for i in range(3): + input_strain[i] = float(macro_data["strain1to3"][i]) + input_strain[i + 3] = float(macro_data["strain4to6"][i]) + + # Building NASMAT Model + model = self.build_nasmat_model(rve_id, mod_id, ruc_size) + + # Solving RVE using NASMAT + cmat = model.homogenize(print_output=0) + print("Homogenization completed for RVE ID: ", self._sim_id) + + print(cmat) + + + # Stress calculation + stresses = np.zeros((6)) + stresses = np.dot(cmat, input_strain) + + + return {"stress1to3": stresses[0:3], "stress4to6": stresses[3:6], + "cmat1": cmat[0][0:3], "cmat2": cmat[0][3:6], + "cmat3": cmat[1][1:4], "cmat4": np.array(list(cmat[1][4:6])+list(cmat[2][2:3])), + "cmat5": cmat[2][3:6], "cmat6": cmat[3][3:6], + "cmat7": np.array(list(cmat[4][4:6])+list(cmat[5][5:6])), + "conv_flag": 1} + + def get_state(self): + # ID is returned as it is trivial. In real case, this method should return the state of the simulation. + return self._sim_id + + def set_state(self, state): + # ID is set as it is trivial. In real case, this method should set the state of the simulation. + self._sim_id = state + + def build_nasmat_model(self, rve_id, mod_id, ruc_size): + + # Building NASMAT Model + model = Model(name='example_01', id=rve_id) + + # Adding constituents + const1 = Constituent(name='Fiber', + model=MAT_TRANSVERSE_ISOTROPIC, + id=1, + data=[388.2E3, 7.6E3,0.41,0.45, 14.9E3,-0.68E-6,9.74E-6], # Units in MPa + comments='Fiber') + model.add_constituent(const1) + const2 = Constituent(name='Matrix', + model=MAT_TRANSVERSE_ISOTROPIC, + id=2, + data=[388.2E3, 7.6E3,0.41,0.45, 14.9E3,-0.68E-6,9.74E-6], # Units in MPa + comments='Matrix') + model.add_constituent(const2) + + # Adding RUC + if (mod_id%10 == 2): # 2D Model + ruc1 = Ruc( arch_id=RUC_ARCHID_SQPACK_1FIBER, + mod_id=mod_id, + nb=ruc_size, ng=ruc_size, + fiber_id=1, matrix_id=2, vf=0.6, + lh=1.0, ll=1.0) + elif (mod_id%10 == 3): # #D Model + ruc1 = Ruc(arch_id=RUC_ARCHID_SQPACK_1FIBER, + mod_id=mod_id, + na = ruc_size, nb=ruc_size, ng=ruc_size, + fiber_id=1, matrix_id=2, vf=0.6, + ld = 1.0, lh=1.0, ll=1.0) + model.add_ruc(ruc1) + return model + +def main(): + for i in range(1, 3): + sim = MicroSimulation(i) + strains = { "rve_id": i, + "mod_id": RUC_MODID_GMC_2D, + "ruc_size": 32, + "strains1to3": [0.1, 0.2, 0.3], + "strains4to6": [0.4, 0.5, 0.6]} + dt = 0.1 + print(sim.solve(strains, dt)) + +if __name__ == "__main__": + main() diff --git a/examples/ccx-nasmat/nasmat/run_micro_manager.py b/examples/ccx-nasmat/nasmat/run_micro_manager.py new file mode 100644 index 00000000..3cea5db3 --- /dev/null +++ b/examples/ccx-nasmat/nasmat/run_micro_manager.py @@ -0,0 +1,21 @@ +""" +Script to run the Micro Manager +""" + +from micro_manager import MicroManager +from argparse import ArgumentParser + +print("Entered the Python scrip to run the Micro Manager") + +parser = ArgumentParser() +parser.add_argument("--config", help="Path to the micro manager configuration file") +args = parser.parse_args() + +print("Accepted the config file") +print(args.config) + +manager = MicroManager(args.config) + +print("Micro Manager object created") + +manager.solve() diff --git a/examples/ccx-nasmat/nasmat/run_micromanager_nasmat.sh b/examples/ccx-nasmat/nasmat/run_micromanager_nasmat.sh new file mode 100755 index 00000000..8608545d --- /dev/null +++ b/examples/ccx-nasmat/nasmat/run_micromanager_nasmat.sh @@ -0,0 +1,5 @@ +MKL_FOLDER=/opt/intel/oneapi/mkl/2023.1.0/lib/intel64 +PETSC_DIR=/usr/lib/petsc +export LD_PRELOAD=$MKL_FOLDER/libmkl_def.so.2:$MKL_FOLDER/libmkl_avx2.so.2:$MKL_FOLDER/libmkl_core.so:$MKL_FOLDER/libmkl_intel_lp64.so:$MKL_FOLDER/libmkl_intel_thread.so:/usr/lib/x86_64-linux-gnu/libomp5.so:$PETSC_DIR/lib/libpetsc_real.so:$LD_PRELOAD + +python3 run_micro_manager.py --config micro-manager-config.json diff --git a/examples/ccx-nasmat/precice-config.xml b/examples/ccx-nasmat/precice-config.xml new file mode 100755 index 00000000..ed7eed07 --- /dev/null +++ b/examples/ccx-nasmat/precice-config.xml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/linstatic_precice.c b/linstatic_precice.c old mode 100755 new mode 100644 index d18e27b1..b2a59217 --- a/linstatic_precice.c +++ b/linstatic_precice.c @@ -1,5 +1,5 @@ /* CalculiX - A 3-dimensional finite element program */ -/* Copyright (C) 1998-2021 Guido Dhondt */ +/* Copyright (C) 1998-2023 Guido Dhondt */ /* This program is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU General Public License as */ @@ -38,7 +38,6 @@ /* Adapter: Add header */ #include "adapter/PreciceInterface.h" - void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, ITG *ne, ITG *nodeboun,ITG *ndirboun,double *xboun,ITG *nboun, @@ -75,8 +74,9 @@ void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, ITG *istep,ITG *nmat,ITG *ielprop,double *prop,char *typeboun, ITG *mortar,ITG *mpcinfo,double *tietol,ITG *ics, char *orname,ITG *itempuser,double *t0g,double *t1g, - /* Adapter: Add variables for the participant name and the config file */ - char *preciceParticipantName, char *configFilename){ + ITG *jmax, + /* Adapter: Add variables for the participant name and the config file */ + char *preciceParticipantName, char *configFilename){ char description[13]=" ",*lakon=NULL,stiffmatrix[132]="", fneig[132]="",jobnamef[396]="",*labmpc2=NULL; @@ -97,11 +97,10 @@ void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, *ielorien=NULL,network=0,nrhs=1,iperturbsav,mscalmethod=0,*jqw=NULL, *iroww=NULL,nzsw,*islavelinv=NULL,*irowtloc=NULL,*jqtloc=NULL,nboun2, *ndirboun2=NULL,*nodeboun2=NULL,nmpc2,*ipompc2=NULL,*nodempc2=NULL, - *ikboun2=NULL,*ilboun2=NULL,*ikmpc2=NULL,*ilmpc2=NULL,mortartrafoflag=0, - *ikforc=NULL, *ilforc=NULL; + *ikboun2=NULL,*ilboun2=NULL,*ikmpc2=NULL,*ilmpc2=NULL,mortartrafoflag=0; double *stn=NULL,*v=NULL,*een=NULL,cam[5],*xstiff=NULL,*stiini=NULL,*tper, - *f=NULL,*fn=NULL,qa[4],*fext=NULL,*epn=NULL,*xstateini=NULL,dtheta, + *f=NULL,*fn=NULL,qa[4],*fext=NULL,*epn=NULL,*xstateini=NULL, *vini=NULL,*stx=NULL,*enern=NULL,*xbounact=NULL,*xforcact=NULL, *xloadact=NULL,*t1act=NULL,*ampli=NULL,*xstaten=NULL,*eei=NULL, *enerini=NULL,*cocon=NULL,*shcon=NULL,*physcon=NULL,*qfx=NULL, @@ -139,8 +138,7 @@ void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, ne0=*ne; - - /* Adapter: Put all the CalculiX data that is needed for the coupling into an array */ + /* preCICE Adapter: Initialize the Calculix data structure */ struct SimulationData simulationData = { .ialset = ialset, .ielmat = ielmat, @@ -153,9 +151,9 @@ void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, .set = set, .nset = *nset, .ikboun = ikboun, - .ikforc = ikforc, + // .ikforc = ikforc, .ilboun = ilboun, - .ilforc = ilforc, + // .ilforc = ilforc, .nboun = *nboun, .nforc = *nforc, .nelemload = nelemload, @@ -164,7 +162,7 @@ void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, .mt = mt, .nk = *nk, .theta = &theta, - .dtheta = &dtheta, + // .dtheta = &dtheta, .tper = tper, .nmethod = nmethod, .xload = xload, @@ -177,10 +175,15 @@ void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, .cocon = cocon, .ncocon = ncocon, .mi = mi, - // .eei = &eei, - // .xstiff = &xstiff + // .eei = &eei, + // .stx = &stx, + // .xstiff = xstiff }; + /* preCICE Adapter: Initialize */ + Precice_Setup(configFilename, preciceParticipantName, &simulationData); + Precice_AdjustSolverTimestep(&simulationData); + /* determining the global values to be used as boundary conditions for a submodel */ @@ -216,15 +219,15 @@ void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, /* assigning the body forces to the elements */ /* if(*nbody>0){ - ifreebody=*ne+1; - NNEW(ipobody,ITG,2*ifreebody**nbody); - for(k=1;k<=*nbody;k++){ + ifreebody=*ne+1; + NNEW(ipobody,ITG,2*ifreebody**nbody); + for(k=1;k<=*nbody;k++){ FORTRAN(bodyforce,(cbody,ibody,ipobody,nbody,set,istartset, - iendset,ialset,&inewton,nset,&ifreebody,&k)); + iendset,ialset,&inewton,nset,&ifreebody,&k)); RENEW(ipobody,ITG,2*(*ne+ifreebody)); - } - RENEW(ipobody,ITG,2*(ifreebody-1)); - }*/ + } + RENEW(ipobody,ITG,2*(ifreebody-1)); + }*/ /* contact conditions */ @@ -253,7 +256,8 @@ void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, RENEW(kon,ITG,*nkon+11*nslavs); NNEW(springarea,double,2*nslavs); if(*nener==1){ - RENEW(ener,double,mi[0]*(*ne+nslavs)*2); + RENEW(ener,double,2*mi[0]*(*ne+nslavs)); + DMEMSET(ener,2*mi[0]**ne,2*mi[0]*(*ne+nslavs),0.); } RENEW(ipkon,ITG,*ne+nslavs); RENEW(lakon,char,8*(*ne+nslavs)); @@ -299,7 +303,8 @@ void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, RENEW(pmastsurf,double,6*nintpoint); if(*nener==1){ - RENEW(ener,double,mi[0]*(*ne+nintpoint)*2); + RENEW(ener,double,2*mi[0]*(*ne+nintpoint)); + DMEMSET(ener,2*mi[0]**ne,2*mi[0]*(*ne+nintpoint),0.); } RENEW(ipkon,ITG,*ne+nintpoint); RENEW(lakon,char,8*(*ne+nintpoint)); @@ -332,7 +337,7 @@ void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, contact(&ncont,ntie,tieset,nset,set,istartset,iendset, ialset,itietri,lakon,ipkon,kon,koncont,ne,cg,straight,nkon, co,vold,ielmat,cs,elcon,istep,&iinc,&iit,ncmat_,ntmat_, - &ne0,vini,nmethod, + &ne0,nmethod, iperturb,ikboun,nboun,mi,imastop,nslavnode,islavnode,islavsurf, itiefac,areaslav,iponoels,inoels,springarea,tietol,&reltime, imastnode,nmastnode,xmastnor,filab,mcs,ics,&nasym, @@ -349,7 +354,7 @@ void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, labmpc,nk,&memmpc_,&icascade,&maxlenmpc, kon,ipkon,lakon,ne,nactdof,icol,jq,&irow,isolver, neq,nzs,nmethod,ithermal,iperturb,mass,mi,ics,cs, - mcs,mortar,typeboun,&iit,&network,iexpl); + mcs,mortar,typeboun,&iit,&network,iexpl,ielmat,matname); } /* field for initial values of state variables (needed for contact */ @@ -383,990 +388,654 @@ void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, NNEW(f,double,*neq); - /* allocating a field for the stiffness matrix */ - - NNEW(xstiff,double,(long long)27*mi[0]**ne); - - theta = 1.0; - dtheta = 1.0; - - /* Adapter: Copy necessary data for coupling */ - simulationData.fn = fn; - // memcpy(&vold[0], &v[0], sizeof(double) * mt * *nk); - - /* Adapter: Create the interfaces and initialize the coupling */ - Precice_Setup(configFilename, preciceParticipantName, &simulationData); - - Precice_AdjustSolverTimestep(&simulationData); - - Precice_Advance(&simulationData); - - while (Precice_IsCouplingOngoing()) { - - - // STRAIN CALCULATION - iout=-1; - NNEW(v,double,mt**nk); - NNEW(fn,double,mt**nk); - NNEW(stx,double,6*mi[0]**ne); - NNEW(inum,ITG,*nk); - NNEW(eei,double,6*mi[0]**ne); - results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, - elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, - ielorien,norien,orab,ntmat_,t0,t1act,ithermal, - prestr,iprestr,filab,eme,emn,een,iperturb, - f,fn,nactdof,&iout,qa,vold,b,nodeboun, - ndirboun,xbounact,nboun,ipompc, - nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold,accold, - &bet,&gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, - xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas, - &icmd,ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern, - emeini,xstaten,eei,enerini,cocon,ncocon,set,nset,istartset, - iendset,ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans, - fmpc,nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea, - &reltime,&ne0,thicke,shcon,nshcon, - sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, - mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, - islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, - inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, - itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, - islavelinv,autloc,irowtloc,jqtloc,&nboun2, - ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, - labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, - &intscheme); - - - // SENDING DATA TO NASMAT - simulationData.eei = &eei; - Precice_WriteCouplingData(&simulationData); - SFREE(eei); - SFREE(v);SFREE(fn);SFREE(stx);SFREE(inum); - iout=1; - - Precice_Advance(&simulationData); - - /* for a *STATIC,PERTURBATION analysis with submodel boundary - conditions from a *FREQUENCY analysis iperturb[0]=1 has to be - temporarily set to iperturb[0]=0 in order for f to be calculated in - resultsini and subsequent results* routines */ - - if((*nmethod==1)&&(iglob<0)&&(iperturb[0]>0)){ - iperturbsav=iperturb[0]; - iperturb[0]=0; - } - - iout=-1; - NNEW(v,double,mt**nk); - NNEW(fn,double,mt**nk); - NNEW(stx,double,6*mi[0]**ne); - NNEW(inum,ITG,*nk); - results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, - elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, - ielorien,norien,orab,ntmat_,t0,t1act,ithermal, - prestr,iprestr,filab,eme,emn,een,iperturb, - f,fn,nactdof,&iout,qa,vold,b,nodeboun, - ndirboun,xbounact,nboun,ipompc, - nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold,accold, - &bet,&gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, - xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas, - &icmd,ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern, - emeini,xstaten,eei,enerini,cocon,ncocon,set,nset,istartset, - iendset,ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans, - fmpc,nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea, - &reltime,&ne0,thicke,shcon,nshcon, - sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, - mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, - islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, - inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, - itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, - islavelinv,autloc,irowtloc,jqtloc,&nboun2, - ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, - labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, - &intscheme); - SFREE(v);SFREE(fn);SFREE(stx);SFREE(inum); - iout=1; - - // RECIEVING MATERIAL TANGENT FROM NASMAT - simulationData.xstiff = xstiff; - Precice_ReadCouplingData(&simulationData); + /* allocating a field for the stiffness matrix */ + + NNEW(xstiff,double,(long long)27*mi[0]**ne); + + /* for a *STATIC,PERTURBATION analysis with submodel boundary + conditions from a *FREQUENCY analysis iperturb[0]=1 has to be + temporarily set to iperturb[0]=0 in order for f to be calculated in + resultsini and subsequent results* routines */ + + if((*nmethod==1)&&(iglob<0)&&(iperturb[0]>0)){ + iperturbsav=iperturb[0]; + iperturb[0]=0; + } + + iout=-1; + NNEW(v,double,mt**nk); + NNEW(fn,double,mt**nk); + NNEW(stx,double,6*mi[0]**ne); + NNEW(inum,ITG,*nk); + NNEW(eei,double,6*mi[0]**ne); + results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, + elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, + ielorien,norien,orab,ntmat_,t0,t1act,ithermal, + prestr,iprestr,filab,eme,emn,een,iperturb, + f,fn,nactdof,&iout,qa,vold,b,nodeboun, + ndirboun,xbounact,nboun,ipompc, + nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold,accold, + &bet,&gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, + xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas, + &icmd,ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern, + emeini,xstaten,eei,enerini,cocon,ncocon,set,nset,istartset, + iendset,ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans, + fmpc,nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea, + &reltime,&ne0,thicke,shcon,nshcon, + sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, + mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, + islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, + inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, + itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, + islavelinv,autloc,irowtloc,jqtloc,&nboun2, + ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, + labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, + &intscheme,physcon); + + + /* preCICE Adapter: Multiscale checkpoint*/ + simulationData.xstiff = &xstiff; + simulationData.eei = &eei; + simulationData.stx = &stx; + PreciceInterface_MultiscaleCheckpoint(&simulationData); + + SFREE(v);SFREE(fn);SFREE(stx);SFREE(inum); SFREE(eei); + iout=1; + + if((*nmethod==1)&&(iglob<0)&&(iperturb[0]>0)){ + iperturb[0]=iperturbsav; + } + + /* determining the system matrix and the external forces */ + + NNEW(ad,double,*neq); + NNEW(fext,double,*neq); + + if(*nmethod==11){ + + /* determining the nodes and the degrees of freedom in those nodes + belonging to the substructure */ + + NNEW(iretain,ITG,*nk); + NNEW(noderetain,ITG,*nk); + NNEW(ndirretain,ITG,*nk); + nretain=0; + + for(i=0;i<*nboun;i++){ + if(strcmp1(&typeboun[i],"C")==0){ + iretain[nretain]=i+1; + noderetain[nretain]=nodeboun[i]; + ndirretain[nretain]=ndirboun[i]; + nretain++; + } + } + + /* nretain!=0: substructure application */ + + RENEW(iretain,ITG,nretain); + RENEW(noderetain,ITG,nretain); + RENEW(ndirretain,ITG,nretain); + + /* creating the right size au */ + + NNEW(au,double,nzs[2]); + rhsi=0; + nmethodl=2; + + }else{ + + /* linear static calculation */ + + NNEW(au,double,*nzs); + nmethodl=*nmethod; + + /* if submodel calculation with a global model obtained by + a *FREQUENCY calculation: replace stiffness matrix K by + K-sigma*M */ + + if(iglob<0){ + mass[0]=1; + NNEW(adb,double,*neq); + NNEW(aub,double,nzs[1]); + } + + } + + mafillsmmain(co,nk,kon,ipkon,lakon,ne,nodeboun,ndirboun,xbounact,nboun, + ipompc,nodempc,coefmpc,nmpc,nodeforc,ndirforc,xforcact, + nforc,nelemload,sideload,xloadact,nload,xbodyact,ipobody, + nbody,cgr,ad,au,fext,nactdof,icol,jq,irow,neq,nzl,&nmethodl, + ikmpc,ilmpc,ikboun,ilboun, + elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, + ielorien,norien,orab,ntmat_, + t0,t1act,ithermal,prestr,iprestr,vold,iperturb,sti, + nzs,stx,adb,aub,iexpl,plicon,nplicon,plkcon,nplkcon, + xstiff,npmat_,&dtime,matname,mi, + ncmat_,mass,&stiffness,&buckling,&rhsi,&intscheme,physcon, + shcon,nshcon,cocon,ncocon,ttime,&time,istep,&iinc,&coriolis, + ibody,xloadold,&reltime,veold,springarea,nstate_, + xstateini,xstate,thicke,integerglob,doubleglob, + tieset,istartset,iendset,ialset,ntie,&nasym,pslavsurf, + pmastsurf,mortar,clearini,ielprop,prop,&ne0,fnext,&kscale, + iponoel,inoel,&network,ntrans,inotr,trab,smscale,&mscalmethod, + set,nset,islavelinv,autloc,irowtloc,jqtloc,&mortartrafoflag); + + /* check for negative Jacobians */ + + if(nmethodl==0) *nmethod=0; + + if(nasym==1){ + RENEW(au,double,2*nzs[1]); + symmetryflag=2; + inputformat=1; + + mafillsmasmain(co,nk,kon,ipkon,lakon,ne,nodeboun, + ndirboun,xbounact,nboun, + ipompc,nodempc,coefmpc,nmpc,nodeforc,ndirforc,xforcact, + nforc,nelemload,sideload,xloadact,nload,xbodyact,ipobody, + nbody,cgr,ad,au,fext,nactdof,icol,jq,irow,neq,nzl, + nmethod,ikmpc,ilmpc,ikboun,ilboun, + elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero, + ielmat,ielorien,norien,orab,ntmat_, + t0,t1act,ithermal,prestr,iprestr,vold,iperturb,sti, + nzs,stx,adb,aub,iexpl,plicon,nplicon,plkcon,nplkcon, + xstiff,npmat_,&dtime,matname,mi, + ncmat_,mass,&stiffness,&buckling,&rhsi,&intscheme, + physcon,shcon,nshcon,cocon,ncocon,ttime,&time,istep,&iinc, + &coriolis,ibody,xloadold,&reltime,veold,springarea,nstate_, + xstateini,xstate,thicke, + integerglob,doubleglob,tieset,istartset,iendset, + ialset,ntie,&nasym,pslavsurf,pmastsurf,mortar,clearini, + ielprop,prop,&ne0,&kscale,iponoel,inoel,&network,set,nset); + } + + /* determining the right hand side */ + + NNEW(b,double,*neq); + for(k=0;k<*neq;++k){ + b[k]=fext[k]-f[k]; + } + SFREE(fext);SFREE(f); + + /* generation of a substructure stiffness matrix */ + + if(*nmethod==11){ + + /* factorizing the matrix */ + + if(*neq>0){ + if(*isolver==0){ +#ifdef SPOOLES + spooles_factor(ad,au,adb,aub,&sigma,icol,irow,neq,nzs,&symmetryflag, + &inputformat,&nzs[2]); +#else + printf(" *ERROR in linstatic: the SPOOLES library is not linked\n\n"); + FORTRAN(stop,()); +#endif + } + else if(*isolver==7){ +#ifdef PARDISO + pardiso_factor(ad,au,adb,aub,&sigma,icol,irow,neq,nzs, + &symmetryflag,&inputformat,jq,&nzs[2]); +#else + printf(" *ERROR in linstatic: the PARDISO library is not linked\n\n"); + FORTRAN(stop,()); +#endif + } + else if(*isolver==8){ +#ifdef PASTIX + pastix_factor_main(ad,au,adb,aub,&sigma,icol,irow,neq,nzs, + &symmetryflag,&inputformat,jq,&nzs[2]); +#else + printf(" *ERROR in linstatic: the PASTIX library is not linked\n\n"); + FORTRAN(stop,()); +#endif + } + } + + /* solving the system of equations with appropriate rhs */ + + /* substructure calculations */ + NNEW(submatrix,double,nretain*nretain); + + for(i=0;i0){ + if(*isolver==0){ +#ifdef SPOOLES + spooles_solve(b,neq); +#endif + } + else if(*isolver==7){ +#ifdef PARDISO + pardiso_solve(b,neq,&symmetryflag,&inputformat,&nrhs); +#endif + + } + else if(*isolver==8){ +#ifdef PASTIX + pastix_solve(b,neq,&symmetryflag,&nrhs); +#endif + } + } + + /* calculating the internal forces */ + + NNEW(v,double,mt**nk); + NNEW(fn,double,mt**nk); + NNEW(stn,double,6**nk); + NNEW(inum,ITG,*nk); + NNEW(stx,double,6*mi[0]**ne); + + if(strcmp1(&filab[261],"E ")==0) NNEW(een,double,6**nk); + if(strcmp1(&filab[2697],"ME ")==0) NNEW(emn,double,6**nk); + if(strcmp1(&filab[522],"ENER")==0) NNEW(enern,double,*nk); + + NNEW(eei,double,6*mi[0]**ne); + if(*nener==1){ + NNEW(stiini,double,6*mi[0]**ne); + NNEW(emeini,double,6*mi[0]**ne); + NNEW(enerini,double,2*mi[0]**ne);} + + /* replacing the appropriate boundary value by unity */ + + xbounact[iretain[i]-1]=1.; + + results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, + elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, + ielorien,norien,orab,ntmat_,t0,t1act,ithermal, + prestr,iprestr,filab,eme,emn,een,iperturb, + f,fn,nactdof,&iout,qa,vold,b,nodeboun,ndirboun, + xbounact,nboun,ipompc, + nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold, + accold,&bet, + &gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, + xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas,&icmd, + ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern,emeini, + xstaten,eei,enerini,cocon,ncocon,set,nset,istartset,iendset, + ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans,fmpc, + nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea,&reltime, + &ne0,thicke,shcon,nshcon, + sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, + mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, + islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, + inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, + itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, + islavelinv,autloc,irowtloc,jqtloc,&nboun2, + ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, + labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, + &intscheme,physcon); + + xbounact[iretain[i]-1]=0.; + + SFREE(v);SFREE(stn);SFREE(inum);SFREE(stx); + + if(strcmp1(&filab[261],"E ")==0) SFREE(een); + if(strcmp1(&filab[2697],"ME ")==0) SFREE(emn); + if(strcmp1(&filab[522],"ENER")==0) SFREE(enern); + + SFREE(eei);if(*nener==1){SFREE(stiini);SFREE(emeini);SFREE(enerini);} + + /* storing the internal forces in the substructure + stiffness matrix */ + + for(j=0;j0){ + if(*isolver==0){ +#ifdef SPOOLES + spooles_cleanup(); +#endif + } + else if(*isolver==7){ +#ifdef PARDISO + pardiso_cleanup(&neq[0],&symmetryflag,&inputformat); +#endif + } + else if(*isolver==8){ +#ifdef PASTIX +#endif + } + } + + SFREE(iretain); + + FORTRAN(writesubmatrix,(submatrix,noderetain,ndirretain,&nretain,jobnamec, + jmax)); + + SFREE(submatrix);SFREE(noderetain);SFREE(ndirretain); + + SFREE(au);SFREE(ad);SFREE(b); + + SFREE(xbounact);SFREE(xforcact);SFREE(xloadact);SFREE(t1act);SFREE(ampli); + SFREE(xbodyact); + + // if(*nbody>0) SFREE(ipobody); + + SFREE(xstiff); + + if(iglob!=0){SFREE(integerglob);SFREE(doubleglob);} + + return; + + + }else if(*nmethod!=0){ + + /* linear static applications */ + + if(*isolver==0){ +#ifdef SPOOLES + spooles(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs,&symmetryflag, + &inputformat,&nzs[2]); +#else + printf(" *ERROR in linstatic: the SPOOLES library is not linked\n\n"); + FORTRAN(stop,()); +#endif + } + else if((*isolver==2)||(*isolver==3)){ + if(nasym>0){ + printf(" *ERROR in nonlingeo: the iterative solver cannot be used for asymmetric matrices\n\n"); + FORTRAN(stop,()); + } + preiter(ad,&au,b,&icol,&irow,neq,nzs,isolver,iperturb); + } + else if(*isolver==4){ +#ifdef SGI + if(nasym>0){ + printf(" *ERROR in nonlingeo: the SGI solver cannot be used for asymmetric matrices\n\n"); + FORTRAN(stop,()); + } + token=1; + sgi_main(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs,token); +#else + printf(" *ERROR in linstatic: the SGI library is not linked\n\n"); + FORTRAN(stop,()); +#endif + } + else if(*isolver==5){ +#ifdef TAUCS + if(nasym>0){ + printf(" *ERROR in nonlingeo: the TAUCS solver cannot be used for asymmetric matrices\n\n"); + FORTRAN(stop,()); + } + tau(ad,&au,adb,aub,&sigma,b,icol,&irow,neq,nzs); +#else + printf(" *ERROR in linstatic: the TAUCS library is not linked\n\n"); + FORTRAN(stop,()); +#endif + } + else if(*isolver==7){ +#ifdef PARDISO + pardiso_main(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs, + &symmetryflag,&inputformat,jq,&nzs[2],&nrhs); +#else + printf(" *ERROR in linstatic: the PARDISO library is not linked\n\n"); + FORTRAN(stop,()); +#endif + } + else if(*isolver==8){ +#ifdef PASTIX + pastix_main(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs, + &symmetryflag,&inputformat,jq,&nzs[2],&nrhs); +#else + printf(" *ERROR in linstatic: the PASTIX library is not linked\n\n"); + FORTRAN(stop,()); +#endif + } + + /* saving of ad and au for sensitivity analysis */ + + for(i=0;i<*ntie;i++){ + if(strcmp1(&tieset[i*243+80],"D")==0){ + + strcpy2(stiffmatrix,jobnamec,132); + strcat(stiffmatrix,".stm"); + + if((f1=fopen(stiffmatrix,"wb"))==NULL){ + printf(" *ERROR in linstatic: cannot open stiffness matrix file for writing..."); + exit(0); + } + + /* storing the stiffness matrix */ + + /* nzs,irow,jq and icol have to be stored too, since the static analysis + can involve contact, whereas in the sensitivity analysis contact is not + taken into account while determining the structure of the stiffness + matrix (in mastruct.c) + */ + + if(fwrite(&nasym,sizeof(ITG),1,f1)!=1){ + printf(" *ERROR saving the symmetry flag to the stiffness matrix file..."); + exit(0); + } + if(fwrite(nzs,sizeof(ITG),3,f1)!=3){ + printf(" *ERROR saving the number of subdiagonal nonzeros to the stiffness matrix file..."); + exit(0); + } + if(fwrite(irow,sizeof(ITG),nzs[2],f1)!=nzs[2]){ + printf(" *ERROR saving irow to the stiffness matrix file..."); + exit(0); + } + if(fwrite(jq,sizeof(ITG),neq[1]+1,f1)!=neq[1]+1){ + printf(" *ERROR saving jq to the stiffness matrix file..."); + exit(0); + } + if(fwrite(icol,sizeof(ITG),neq[1],f1)!=neq[1]){ + printf(" *ERROR saving icol to the stiffness matrix file..."); + exit(0); + } + if(fwrite(ad,sizeof(double),neq[1],f1)!=neq[1]){ + printf(" *ERROR saving the diagonal of the stiffness matrix to the stiffness matrix file..."); + exit(0); + } + if(fwrite(au,sizeof(double),nzs[2],f1)!=nzs[2]){ + printf(" *ERROR saving the off-diagonal terms of the stiffness matrix to the tiffness matrix file..."); + exit(0); + } + fclose(f1); + + break; + } + } + + SFREE(ad);SFREE(au); + if(iglob<0){SFREE(adb);SFREE(aub);} + + /* calculating the displacements and the stresses and storing */ + /* the results in frd format for each valid eigenmode */ + + NNEW(v,double,mt**nk); + NNEW(fn,double,mt**nk); + NNEW(stn,double,6**nk); + NNEW(inum,ITG,*nk); + NNEW(stx,double,6*mi[0]**ne); + + if(strcmp1(&filab[261],"E ")==0) NNEW(een,double,6**nk); + if(strcmp1(&filab[2697],"ME ")==0) NNEW(emn,double,6**nk); + if(strcmp1(&filab[522],"ENER")==0) NNEW(enern,double,*nk); + if(strcmp1(&filab[2175],"CONT")==0) NNEW(cdn,double,6**nk); + + NNEW(eei,double,6*mi[0]**ne); + if(*nener==1){ + NNEW(stiini,double,6*mi[0]**ne); + NNEW(emeini,double,6*mi[0]**ne); + NNEW(enerini,double,2*mi[0]**ne);} + + results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, + elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, + ielorien,norien,orab,ntmat_,t0,t1act,ithermal, + prestr,iprestr,filab,eme,emn,een,iperturb, + f,fn,nactdof,&iout,qa,vold,b,nodeboun,ndirboun,xbounact,nboun, + ipompc, + nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold,accold,&bet, + &gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, + xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas,&icmd, + ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern,emeini, + xstaten,eei,enerini,cocon,ncocon,set,nset,istartset,iendset, + ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans,fmpc, + nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea,&reltime, + &ne0,thicke,shcon,nshcon, + sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, + mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, + islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, + inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, + itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, + islavelinv,autloc,irowtloc,jqtloc,&nboun2, + ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, + labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, + &intscheme,physcon); + + SFREE(eei); + if(*nener==1){ + SFREE(stiini);SFREE(emeini);SFREE(enerini);} + + memcpy(&vold[0],&v[0],sizeof(double)*mt**nk); + memcpy(&sti[0],&stx[0],sizeof(double)*6*mi[0]*ne0); + + ++*kode; + + /* for cyclic symmetric sectors: duplicating the results */ + + if(*mcs>0){ + ptime=*ttime+time; + frdcyc(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod,kode,filab,een,t1act, + fn,&ptime,epn,ielmat,matname,cs,mcs,nkon,enern,xstaten, + nstate_,istep,&iinc,iperturb,ener,mi,output,ithermal, + qfn,ialset,istartset,iendset,trab,inotr,ntrans,orab, + ielorien,norien,sti,veold,&noddiam,set,nset,emn,thicke, + jobnamec,&ne0,cdn,mortar,nmat,qfx,ielprop,prop); + } + else{ + if(strcmp1(&filab[1044],"ZZS")==0){ + NNEW(neigh,ITG,40**ne); + NNEW(ipneigh,ITG,*nk); + } + ptime=*ttime+time; + frd(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod, + kode,filab,een,t1act,fn,&ptime,epn,ielmat,matname,enern,xstaten, + nstate_,istep,&iinc,ithermal,qfn,&mode,&noddiam,trab,inotr, + ntrans,orab,ielorien,norien,description,ipneigh,neigh, + mi,stx,vr,vi,stnr,stni,vmax,stnmax,&ngraph,veold,ener,ne, + cs,set,nset,istartset,iendset,ialset,eenmax,fnr,fni,emn, + thicke,jobnamec,output,qfx,cdn,mortar,cdnr,cdni,nmat,ielprop, + prop,sti); + if(strcmp1(&filab[1044],"ZZS")==0){SFREE(ipneigh);SFREE(neigh);} + } + + /* updating the .sta file */ + + iitsta=1; + FORTRAN(writesta,(istep,&iinc,&icutb,&iitsta,ttime,&time,&dtime)); + + SFREE(v);SFREE(stn);SFREE(inum); + SFREE(b);SFREE(stx);SFREE(fn); + + if(strcmp1(&filab[261],"E ")==0) SFREE(een); + if(strcmp1(&filab[2697],"ME ")==0) SFREE(emn); + if(strcmp1(&filab[522],"ENER")==0) SFREE(enern); + if(strcmp1(&filab[2175],"CONT")==0) SFREE(cdn); + + } + else { + + /* error occurred in mafill: storing the geometry in frd format */ + + ++*kode; + NNEW(inum,ITG,*nk);for(k=0;k<*nk;k++) inum[k]=1; + if(strcmp1(&filab[1044],"ZZS")==0){ + NNEW(neigh,ITG,40**ne); + NNEW(ipneigh,ITG,*nk); + } + ptime=*ttime+time; + frd(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod, + kode,filab,een,t1,fn,&ptime,epn,ielmat,matname,enern,xstaten, + nstate_,istep,&iinc,ithermal,qfn,&mode,&noddiam,trab,inotr, + ntrans,orab,ielorien,norien,description,ipneigh,neigh, + mi,sti,vr,vi,stnr,stni,vmax,stnmax,&ngraph,veold,ener,ne, + cs,set,nset,istartset,iendset,ialset,eenmax,fnr,fni,emn, + thicke,jobnamec,output,qfx,cdn,mortar,cdnr,cdni,nmat,ielprop, + prop,sti); + if(strcmp1(&filab[1044],"ZZS")==0){SFREE(ipneigh);SFREE(neigh);} + SFREE(inum);FORTRAN(stop,()); + + } + + if(*mortar>-2){ + if(ncont!=0){ + *ne=ne0; + if(*nener==1) RENEW(ener,double,2*mi[0]**ne); + RENEW(ipkon,ITG,*ne); + RENEW(lakon,char,8**ne); + RENEW(kon,ITG,*nkon); + if(*norien>0){ + RENEW(ielorien,ITG,mi[2]**ne); + } + RENEW(ielmat,ITG,mi[2]**ne); + SFREE(cg);SFREE(straight); + SFREE(imastop);SFREE(itiefac);SFREE(islavnode);SFREE(islavsurf); + SFREE(nslavnode);SFREE(iponoels);SFREE(inoels);SFREE(imastnode); + SFREE(nmastnode);SFREE(itietri);SFREE(koncont);SFREE(xnoels); + SFREE(springarea);SFREE(xmastnor); + + if(*mortar==0){ + SFREE(areaslav); + }else if(*mortar==1){ + SFREE(pmastsurf);SFREE(ipe);SFREE(ime);SFREE(pslavsurf); + SFREE(islavact);SFREE(clearini); + } + } + mpcinfo[0]=memmpc_;mpcinfo[1]=mpcfree;mpcinfo[2]=icascade; + mpcinfo[3]=maxlenmpc; + } + + /* updating the loading at the end of the step; + important in case the amplitude at the end of the step + is not equal to one */ + + for(k=0;k<*nboun;++k){xbounold[k]=xbounact[k];} + for(k=0;k<*nforc;++k){xforcold[k]=xforcact[k];} + for(k=0;k<2**nload;++k){xloadold[k]=xloadact[k];} + for(k=0;k<7**nbody;k=k+7){xbodyold[k]=xbodyact[k];} + if(*ithermal==1){ + for(k=0;k<*nk;++k){t1old[k]=t1act[k];} + for(k=0;k<*nk;++k){vold[mt*k]=t1act[k];} + } + + SFREE(xbounact);SFREE(xforcact);SFREE(xloadact);SFREE(t1act);SFREE(ampli); + SFREE(xbodyact); + + // if(*nbody>0) SFREE(ipobody); + + SFREE(xstiff); + + if(iglob!=0){SFREE(integerglob);SFREE(doubleglob);} + + *irowp=irow;*enerp=ener;*xstatep=xstate;*ipkonp=ipkon;*lakonp=lakon; + *konp=kon;*ielmatp=ielmat;*ielorienp=ielorien;*icolp=icol; - precicec_finalize(); - - if((*nmethod==1)&&(iglob<0)&&(iperturb[0]>0)){ - iperturb[0]=iperturbsav; - } - - /* determining the system matrix and the external forces */ - - NNEW(ad,double,*neq); - NNEW(fext,double,*neq); - - if(*nmethod==11){ - - /* determining the nodes and the degrees of freedom in those nodes - belonging to the substructure */ - - NNEW(iretain,ITG,*nk); - NNEW(noderetain,ITG,*nk); - NNEW(ndirretain,ITG,*nk); - nretain=0; - - for(i=0;i<*nboun;i++){ - if(strcmp1(&typeboun[i],"C")==0){ - iretain[nretain]=i+1; - noderetain[nretain]=nodeboun[i]; - ndirretain[nretain]=ndirboun[i]; - nretain++; - } - } - - /* nretain!=0: submatrix application - nretain==0: Green function application */ - - if(nretain>0){ - RENEW(iretain,ITG,nretain); - RENEW(noderetain,ITG,nretain); - RENEW(ndirretain,ITG,nretain); - }else{ - SFREE(iretain);SFREE(noderetain);SFREE(ndirretain); - } - - /* creating the right size au */ - - NNEW(au,double,nzs[2]); - rhsi=0; - // nmethodl=2; - nmethodl=*nmethod; - - /* providing for the mass matrix in case of Green functions */ - - if(nretain==0){ - mass[0]=1.; - NNEW(adb,double,*neq); - NNEW(aub,double,nzs[1]); - } - - }else{ - - /* linear static calculation */ - - NNEW(au,double,*nzs); - nmethodl=*nmethod; - - /* if submodel calculation with a global model obtained by - a *FREQUENCY calculation: replace stiffness matrix K by - K-sigma*M */ - - if(iglob<0){ - mass[0]=1; - NNEW(adb,double,*neq); - NNEW(aub,double,nzs[1]); - } - - } - - - mafillsmmain(co,nk,kon,ipkon,lakon,ne,nodeboun,ndirboun,xbounact,nboun, - ipompc,nodempc,coefmpc,nmpc,nodeforc,ndirforc,xforcact, - nforc,nelemload,sideload,xloadact,nload,xbodyact,ipobody, - nbody,cgr,ad,au,fext,nactdof,icol,jq,irow,neq,nzl,&nmethodl, - ikmpc,ilmpc,ikboun,ilboun, - elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, - ielorien,norien,orab,ntmat_, - t0,t1act,ithermal,prestr,iprestr,vold,iperturb,sti, - nzs,stx,adb,aub,iexpl,plicon,nplicon,plkcon,nplkcon, - xstiff,npmat_,&dtime,matname,mi, - ncmat_,mass,&stiffness,&buckling,&rhsi,&intscheme,physcon, - shcon,nshcon,cocon,ncocon,ttime,&time,istep,&iinc,&coriolis, - ibody,xloadold,&reltime,veold,springarea,nstate_, - xstateini,xstate,thicke,integerglob,doubleglob, - tieset,istartset,iendset,ialset,ntie,&nasym,pslavsurf, - pmastsurf,mortar,clearini,ielprop,prop,&ne0,fnext,&kscale, - iponoel,inoel,&network,ntrans,inotr,trab,smscale,&mscalmethod, - set,nset,islavelinv,autloc,irowtloc,jqtloc,&mortartrafoflag); - - /* check for negative Jacobians */ - - if(nmethodl==0) *nmethod=0; - - if(nasym==1){ - RENEW(au,double,2*nzs[1]); - symmetryflag=2; - inputformat=1; - - mafillsmasmain(co,nk,kon,ipkon,lakon,ne,nodeboun, - ndirboun,xbounact,nboun, - ipompc,nodempc,coefmpc,nmpc,nodeforc,ndirforc,xforcact, - nforc,nelemload,sideload,xloadact,nload,xbodyact,ipobody, - nbody,cgr,ad,au,fext,nactdof,icol,jq,irow,neq,nzl, - nmethod,ikmpc,ilmpc,ikboun,ilboun, - elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero, - ielmat,ielorien,norien,orab,ntmat_, - t0,t1act,ithermal,prestr,iprestr,vold,iperturb,sti, - nzs,stx,adb,aub,iexpl,plicon,nplicon,plkcon,nplkcon, - xstiff,npmat_,&dtime,matname,mi, - ncmat_,mass,&stiffness,&buckling,&rhsi,&intscheme, - physcon,shcon,nshcon,cocon,ncocon,ttime,&time,istep,&iinc, - &coriolis,ibody,xloadold,&reltime,veold,springarea,nstate_, - xstateini,xstate,thicke, - integerglob,doubleglob,tieset,istartset,iendset, - ialset,ntie,&nasym,pslavsurf,pmastsurf,mortar,clearini, - ielprop,prop,&ne0,&kscale,iponoel,inoel,&network,set,nset); - - /* FORTRAN(mafillsmas,(co,nk,kon,ipkon,lakon,ne,nodeboun, - ndirboun,xbounact,nboun, - ipompc,nodempc,coefmpc,nmpc,nodeforc,ndirforc,xforcact, - nforc,nelemload,sideload,xloadact,nload,xbodyact,ipobody, - nbody,cgr,ad,au,fext,nactdof,icol,jq,irow,neq,nzl, - nmethod,ikmpc,ilmpc,ikboun,ilboun, - elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero, - ielmat,ielorien,norien,orab,ntmat_, - t0,t1act,ithermal,prestr,iprestr,vold,iperturb,sti, - nzs,stx,adb,aub,iexpl,plicon,nplicon,plkcon,nplkcon, - xstiff,npmat_,&dtime,matname,mi, - ncmat_,mass,&stiffness,&buckling,&rhsi,&intscheme, - physcon,shcon,nshcon,cocon,ncocon,ttime,&time,istep,&iinc, - &coriolis,ibody,xloadold,&reltime,veold,springarea,nstate_, - xstateini,xstate,thicke, - integerglob,doubleglob,tieset,istartset,iendset, - ialset,ntie,&nasym,pslavsurf,pmastsurf,mortar,clearini, - ielprop,prop,&ne0,&kscale,iponoel,inoel,&network));*/ - } - - /* determining the right hand side */ - - NNEW(b,double,*neq); - for(k=0;k<*neq;++k){ - b[k]=fext[k]-f[k]; - } - SFREE(fext);SFREE(f); - - - /* generation of a substructure stiffness matrix (nretain>0) or treating - Green functions (nretain=0) */ - - if(*nmethod==11){ - - /* recovering omega_0^2 for Green applications */ - - if(nretain==0){ - if(*nforc>0){sigma=xforc[0];} - } - - /* factorizing the matrix */ - - if(*neq>0){ - if(*isolver==0){ - #ifdef SPOOLES - spooles_factor(ad,au,adb,aub,&sigma,icol,irow,neq,nzs,&symmetryflag, - &inputformat,&nzs[2]); - #else - printf("*ERROR in linstatic: the SPOOLES library is not linked\n\n"); - FORTRAN(stop,()); - #endif - } - else if(*isolver==7){ - #ifdef PARDISO - pardiso_factor(ad,au,adb,aub,&sigma,icol,irow,neq,nzs, - &symmetryflag,&inputformat,jq,&nzs[2]); - #else - printf("*ERROR in linstatic: the PARDISO library is not linked\n\n"); - FORTRAN(stop,()); - #endif - } - else if(*isolver==8){ - #ifdef PASTIX - pastix_factor_main(ad,au,adb,aub,&sigma,icol,irow,neq,nzs, - &symmetryflag,&inputformat,jq,&nzs[2]); - #else - printf("*ERROR in linstatic: the PASTIX library is not linked\n\n"); - FORTRAN(stop,()); - #endif - } - } - - - /* solving the system of equations with appropriate rhs */ - - if(nretain>0){ - - /* substructure calculations */ - - NNEW(submatrix,double,nretain*nretain); - - for(i=0;i0){ - if(*isolver==0){ - #ifdef SPOOLES - spooles_solve(b,neq); - #endif - } - else if(*isolver==7){ - #ifdef PARDISO - pardiso_solve(b,neq,&symmetryflag,&inputformat,&nrhs); - #endif - - } - else if(*isolver==8){ - #ifdef PASTIX - pastix_solve(b,neq,&symmetryflag,&nrhs); - #endif - - } - } - - /* calculating the internal forces */ - - - - NNEW(v,double,mt**nk); - NNEW(fn,double,mt**nk); - NNEW(stn,double,6**nk); - NNEW(inum,ITG,*nk); - NNEW(stx,double,6*mi[0]**ne); - - if(strcmp1(&filab[261],"E ")==0) NNEW(een,double,6**nk); - if(strcmp1(&filab[2697],"ME ")==0) NNEW(emn,double,6**nk); - if(strcmp1(&filab[522],"ENER")==0) NNEW(enern,double,*nk); - - NNEW(eei,double,6*mi[0]**ne); - if(*nener==1){ - NNEW(stiini,double,6*mi[0]**ne); - NNEW(emeini,double,6*mi[0]**ne); - NNEW(enerini,double,mi[0]**ne);} - - /* replacing the appropriate boundary value by unity */ - - xbounact[iretain[i]-1]=1.; - - - - results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, - elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, - ielorien,norien,orab,ntmat_,t0,t1act,ithermal, - prestr,iprestr,filab,eme,emn,een,iperturb, - f,fn,nactdof,&iout,qa,vold,b,nodeboun,ndirboun, - xbounact,nboun,ipompc, - nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold, - accold,&bet, - &gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, - xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas,&icmd, - ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern,emeini, - xstaten,eei,enerini,cocon,ncocon,set,nset,istartset,iendset, - ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans,fmpc, - nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea,&reltime, - &ne0,thicke,shcon,nshcon, - sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, - mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, - islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, - inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, - itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, - islavelinv,autloc,irowtloc,jqtloc,&nboun2, - ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, - labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, - &intscheme); - - xbounact[iretain[i]-1]=0.; - - SFREE(v);SFREE(stn);SFREE(inum);SFREE(stx); - - if(strcmp1(&filab[261],"E ")==0) SFREE(een); - if(strcmp1(&filab[2697],"ME ")==0) SFREE(emn); - if(strcmp1(&filab[522],"ENER")==0) SFREE(enern); - - SFREE(eei);if(*nener==1){SFREE(stiini);SFREE(emeini);SFREE(enerini);} - - /* storing the internal forces in the substructure - stiffness matrix */ - - for(j=0;j0){ - if(*isolver==0){ - #ifdef SPOOLES - spooles_solve(b,neq); - #endif - } - else if(*isolver==7){ - #ifdef PARDISO - pardiso_solve(b,neq,&symmetryflag,&inputformat,&nrhs); - #endif - - } - else if(*isolver==8){ - #ifdef PASTIX - pastix_solve(b,neq,&symmetryflag,&nrhs); - #endif - - } - } - - /* storing the Green function */ - - if(fwrite(b,sizeof(double),*neq,f2)!=*neq){ - printf("*ERROR saving data to the eigenvalue file..."); - exit(0); - } - - /* calculating the displacements and the stresses and storing */ - /* the results in frd format for each valid eigenmode */ - - NNEW(v,double,mt**nk); - NNEW(fn,double,mt**nk); - NNEW(stn,double,6**nk); - NNEW(inum,ITG,*nk); - NNEW(stx,double,6*mi[0]**ne); - - if(strcmp1(&filab[261],"E ")==0) NNEW(een,double,6**nk); - if(strcmp1(&filab[2697],"ME ")==0) NNEW(emn,double,6**nk); - if(strcmp1(&filab[522],"ENER")==0) NNEW(enern,double,*nk); - if(strcmp1(&filab[2175],"CONT")==0) NNEW(cdn,double,6**nk); - - NNEW(eei,double,6*mi[0]**ne); - if(*nener==1){ - NNEW(stiini,double,6*mi[0]**ne); - NNEW(emeini,double,6*mi[0]**ne); - NNEW(enerini,double,mi[0]**ne);} - - - results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, - elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, - ielorien,norien,orab,ntmat_,t0,t1act,ithermal, - prestr,iprestr,filab,eme,emn,een,iperturb, - f,fn,nactdof,&iout,qa,vold,b,nodeboun,ndirboun, - xbounact,nboun,ipompc, - nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold, - accold,&bet, - &gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, - xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas,&icmd, - ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern,emeini, - xstaten,eei,enerini,cocon,ncocon,set,nset,istartset,iendset, - ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans,fmpc, - nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea,&reltime, - &ne0,thicke,shcon,nshcon, - sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, - mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, - islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, - inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, - itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, - islavelinv,autloc,irowtloc,jqtloc,&nboun2, - ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, - labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, - &intscheme); - - SFREE(eei); - if(*nener==1){ - SFREE(stiini);SFREE(emeini);SFREE(enerini);} - - /* memcpy(&vold[0],&v[0],sizeof(double)*mt**nk); - memcpy(&sti[0],&stx[0],sizeof(double)*6*mi[0]*ne0);*/ - - ++*kode; - time=1.*i; - - /* for cyclic symmetric sectors: duplicating the results */ - - if(*mcs>0){ - ptime=*ttime+time; - frdcyc(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod,kode,filab,een,t1act, - fn,&ptime,epn,ielmat,matname,cs,mcs,nkon,enern,xstaten, - nstate_,istep,&iinc,iperturb,ener,mi,output,ithermal, - qfn,ialset,istartset,iendset,trab,inotr,ntrans,orab, - ielorien,norien,sti,veold,&noddiam,set,nset,emn,thicke, - jobnamec,&ne0,cdn,mortar,nmat,qfx,ielprop,prop); - } - else{ - if(strcmp1(&filab[1044],"ZZS")==0){ - NNEW(neigh,ITG,40**ne); - NNEW(ipneigh,ITG,*nk); - } - ptime=*ttime+time; - frd(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod, - kode,filab,een,t1act,fn,&ptime,epn,ielmat,matname,enern,xstaten, - nstate_,istep,&iinc,ithermal,qfn,&mode,&noddiam,trab,inotr, - ntrans,orab,ielorien,norien,description,ipneigh,neigh, - mi,stx,vr,vi,stnr,stni,vmax,stnmax,&ngraph,veold,ener,ne, - cs,set,nset,istartset,iendset,ialset,eenmax,fnr,fni,emn, - thicke,jobnamec,output,qfx,cdn,mortar,cdnr,cdni,nmat, - ielprop,prop,sti); - if(strcmp1(&filab[1044],"ZZS")==0){SFREE(ipneigh);SFREE(neigh);} - } - - SFREE(v);SFREE(stn);SFREE(inum); - SFREE(stx);SFREE(fn); - - if(strcmp1(&filab[261],"E ")==0) SFREE(een); - if(strcmp1(&filab[2697],"ME ")==0) SFREE(emn); - if(strcmp1(&filab[522],"ENER")==0) SFREE(enern); - if(strcmp1(&filab[2175],"CONT")==0) SFREE(cdn); - - } - - - fclose(f2); - - } - - SFREE(au);SFREE(ad);SFREE(b); - - SFREE(xbounact);SFREE(xforcact);SFREE(xloadact);SFREE(t1act);SFREE(ampli); - SFREE(xbodyact); - - // if(*nbody>0) SFREE(ipobody); - - SFREE(xstiff); - - if(iglob!=0){SFREE(integerglob);SFREE(doubleglob);} - - return; - - - }else if(*nmethod!=0){ - - /* linear static applications */ - - if(*isolver==0){ - #ifdef SPOOLES - spooles(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs,&symmetryflag, - &inputformat,&nzs[2]); - #else - printf("*ERROR in linstatic: the SPOOLES library is not linked\n\n"); - FORTRAN(stop,()); - #endif - } - else if((*isolver==2)||(*isolver==3)){ - if(nasym>0){ - printf(" *ERROR in nonlingeo: the iterative solver cannot be used for asymmetric matrices\n\n"); - FORTRAN(stop,()); - } - preiter(ad,&au,b,&icol,&irow,neq,nzs,isolver,iperturb); - } - else if(*isolver==4){ - #ifdef SGI - if(nasym>0){ - printf(" *ERROR in nonlingeo: the SGI solver cannot be used for asymmetric matrices\n\n"); - FORTRAN(stop,()); - } - token=1; - sgi_main(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs,token); - #else - printf("*ERROR in linstatic: the SGI library is not linked\n\n"); - FORTRAN(stop,()); - #endif - } - else if(*isolver==5){ - #ifdef TAUCS - if(nasym>0){ - printf(" *ERROR in nonlingeo: the TAUCS solver cannot be used for asymmetric matrices\n\n"); - FORTRAN(stop,()); - } - tau(ad,&au,adb,aub,&sigma,b,icol,&irow,neq,nzs); - #else - printf("*ERROR in linstatic: the TAUCS library is not linked\n\n"); - FORTRAN(stop,()); - #endif - } - else if(*isolver==7){ - #ifdef PARDISO - pardiso_main(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs, - &symmetryflag,&inputformat,jq,&nzs[2],&nrhs); - #else - printf("*ERROR in linstatic: the PARDISO library is not linked\n\n"); - FORTRAN(stop,()); - #endif - } - else if(*isolver==8){ - #ifdef PASTIX - pastix_main(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs, - &symmetryflag,&inputformat,jq,&nzs[2],&nrhs); - #else - printf("*ERROR in linstatic: the PASTIX library is not linked\n\n"); - FORTRAN(stop,()); - #endif - } - - /* saving of ad and au for sensitivity analysis */ - - for(i=0;i<*ntie;i++){ - if(strcmp1(&tieset[i*243+80],"D")==0){ - - strcpy(stiffmatrix,jobnamec); - strcat(stiffmatrix,".stm"); - - if((f1=fopen(stiffmatrix,"wb"))==NULL){ - printf("*ERROR in linstatic: cannot open stiffness matrix file for writing..."); - exit(0); - } - - /* storing the stiffness matrix */ - - /* nzs,irow,jq and icol have to be stored too, since the static analysis - can involve contact, whereas in the sensitivity analysis contact is not - taken into account while determining the structure of the stiffness - matrix (in mastruct.c) - */ - - if(fwrite(&nasym,sizeof(ITG),1,f1)!=1){ - printf("*ERROR saving the symmetry flag to the stiffness matrix file..."); - exit(0); - } - if(fwrite(nzs,sizeof(ITG),3,f1)!=3){ - printf("*ERROR saving the number of subdiagonal nonzeros to the stiffness matrix file..."); - exit(0); - } - if(fwrite(irow,sizeof(ITG),nzs[2],f1)!=nzs[2]){ - printf("*ERROR saving irow to the stiffness matrix file..."); - exit(0); - } - if(fwrite(jq,sizeof(ITG),neq[1]+1,f1)!=neq[1]+1){ - printf("*ERROR saving jq to the stiffness matrix file..."); - exit(0); - } - if(fwrite(icol,sizeof(ITG),neq[1],f1)!=neq[1]){ - printf("*ERROR saving icol to the stiffness matrix file..."); - exit(0); - } - if(fwrite(ad,sizeof(double),neq[1],f1)!=neq[1]){ - printf("*ERROR saving the diagonal of the stiffness matrix to the stiffness matrix file..."); - exit(0); - } - if(fwrite(au,sizeof(double),nzs[2],f1)!=nzs[2]){ - printf("*ERROR saving the off-diagonal terms of the stiffness matrix to the tiffness matrix file..."); - exit(0); - } - fclose(f1); - - break; - } - } - - SFREE(ad);SFREE(au); - if(iglob<0){SFREE(adb);SFREE(aub);} - - /* calculating the displacements and the stresses and storing */ - /* the results in frd format for each valid eigenmode */ - - NNEW(v,double,mt**nk); - NNEW(fn,double,mt**nk); - NNEW(stn,double,6**nk); - NNEW(inum,ITG,*nk); - NNEW(stx,double,6*mi[0]**ne); - - if(strcmp1(&filab[261],"E ")==0) NNEW(een,double,6**nk); - if(strcmp1(&filab[2697],"ME ")==0) NNEW(emn,double,6**nk); - if(strcmp1(&filab[522],"ENER")==0) NNEW(enern,double,*nk); - if(strcmp1(&filab[2175],"CONT")==0) NNEW(cdn,double,6**nk); - - NNEW(eei,double,6*mi[0]**ne); - if(*nener==1){ - NNEW(stiini,double,6*mi[0]**ne); - NNEW(emeini,double,6*mi[0]**ne); - NNEW(enerini,double,mi[0]**ne);} - - - results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, - elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, - ielorien,norien,orab,ntmat_,t0,t1act,ithermal, - prestr,iprestr,filab,eme,emn,een,iperturb, - f,fn,nactdof,&iout,qa,vold,b,nodeboun,ndirboun,xbounact,nboun,ipompc, - nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold,accold,&bet, - &gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, - xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas,&icmd, - ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern,emeini, - xstaten,eei,enerini,cocon,ncocon,set,nset,istartset,iendset, - ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans,fmpc, - nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea,&reltime, - &ne0,thicke,shcon,nshcon, - sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, - mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, - islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, - inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, - itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, - islavelinv,autloc,irowtloc,jqtloc,&nboun2, - ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, - labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, - &intscheme); - - SFREE(eei); - if(*nener==1){ - SFREE(stiini);SFREE(emeini);SFREE(enerini);} - - memcpy(&vold[0],&v[0],sizeof(double)*mt**nk); - memcpy(&sti[0],&stx[0],sizeof(double)*6*mi[0]*ne0); - - ++*kode; - - /* for cyclic symmetric sectors: duplicating the results */ - - if(*mcs>0){ - ptime=*ttime+time; - frdcyc(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod,kode,filab,een,t1act, - fn,&ptime,epn,ielmat,matname,cs,mcs,nkon,enern,xstaten, - nstate_,istep,&iinc,iperturb,ener,mi,output,ithermal, - qfn,ialset,istartset,iendset,trab,inotr,ntrans,orab, - ielorien,norien,sti,veold,&noddiam,set,nset,emn,thicke, - jobnamec,&ne0,cdn,mortar,nmat,qfx,ielprop,prop); - } - else{ - if(strcmp1(&filab[1044],"ZZS")==0){ - NNEW(neigh,ITG,40**ne); - NNEW(ipneigh,ITG,*nk); - } - ptime=*ttime+time; - frd(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod, - kode,filab,een,t1act,fn,&ptime,epn,ielmat,matname,enern,xstaten, - nstate_,istep,&iinc,ithermal,qfn,&mode,&noddiam,trab,inotr, - ntrans,orab,ielorien,norien,description,ipneigh,neigh, - mi,stx,vr,vi,stnr,stni,vmax,stnmax,&ngraph,veold,ener,ne, - cs,set,nset,istartset,iendset,ialset,eenmax,fnr,fni,emn, - thicke,jobnamec,output,qfx,cdn,mortar,cdnr,cdni,nmat,ielprop, - prop,sti); - if(strcmp1(&filab[1044],"ZZS")==0){SFREE(ipneigh);SFREE(neigh);} - } - - /* updating the .sta file */ - - iitsta=1; - FORTRAN(writesta,(istep,&iinc,&icutb,&iitsta,ttime,&time,&dtime)); - - SFREE(v);SFREE(stn);SFREE(inum); - SFREE(b);SFREE(stx);SFREE(fn); - - if(strcmp1(&filab[261],"E ")==0) SFREE(een); - if(strcmp1(&filab[2697],"ME ")==0) SFREE(emn); - if(strcmp1(&filab[522],"ENER")==0) SFREE(enern); - if(strcmp1(&filab[2175],"CONT")==0) SFREE(cdn); - - } - else { - - /* error occurred in mafill: storing the geometry in frd format */ - - ++*kode; - NNEW(inum,ITG,*nk);for(k=0;k<*nk;k++) inum[k]=1; - if(strcmp1(&filab[1044],"ZZS")==0){ - NNEW(neigh,ITG,40**ne); - NNEW(ipneigh,ITG,*nk); - } - ptime=*ttime+time; - frd(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod, - kode,filab,een,t1,fn,&ptime,epn,ielmat,matname,enern,xstaten, - nstate_,istep,&iinc,ithermal,qfn,&mode,&noddiam,trab,inotr, - ntrans,orab,ielorien,norien,description,ipneigh,neigh, - mi,sti,vr,vi,stnr,stni,vmax,stnmax,&ngraph,veold,ener,ne, - cs,set,nset,istartset,iendset,ialset,eenmax,fnr,fni,emn, - thicke,jobnamec,output,qfx,cdn,mortar,cdnr,cdni,nmat,ielprop, - prop,sti); - if(strcmp1(&filab[1044],"ZZS")==0){SFREE(ipneigh);SFREE(neigh);} - SFREE(inum);FORTRAN(stop,()); - - } - - if(*mortar>-2){ - if(ncont!=0){ - *ne=ne0; - if(*nener==1){ - RENEW(ener,double,mi[0]**ne*2); - } - RENEW(ipkon,ITG,*ne); - RENEW(lakon,char,8**ne); - RENEW(kon,ITG,*nkon); - if(*norien>0){ - RENEW(ielorien,ITG,mi[2]**ne); - } - RENEW(ielmat,ITG,mi[2]**ne); - SFREE(cg);SFREE(straight); - SFREE(imastop);SFREE(itiefac);SFREE(islavnode);SFREE(islavsurf); - SFREE(nslavnode);SFREE(iponoels);SFREE(inoels);SFREE(imastnode); - SFREE(nmastnode);SFREE(itietri);SFREE(koncont);SFREE(xnoels); - SFREE(springarea);SFREE(xmastnor); - - if(*mortar==0){ - SFREE(areaslav); - }else if(*mortar==1){ - SFREE(pmastsurf);SFREE(ipe);SFREE(ime);SFREE(pslavsurf); - SFREE(islavact);SFREE(clearini); - } - } - mpcinfo[0]=memmpc_;mpcinfo[1]=mpcfree;mpcinfo[2]=icascade; - mpcinfo[3]=maxlenmpc; - } - - /* updating the loading at the end of the step; - important in case the amplitude at the end of the step - is not equal to one */ - - for(k=0;k<*nboun;++k){xbounold[k]=xbounact[k];} - for(k=0;k<*nforc;++k){xforcold[k]=xforcact[k];} - for(k=0;k<2**nload;++k){xloadold[k]=xloadact[k];} - for(k=0;k<7**nbody;k=k+7){xbodyold[k]=xbodyact[k];} - if(*ithermal==1){ - for(k=0;k<*nk;++k){t1old[k]=t1act[k];} - for(k=0;k<*nk;++k){vold[mt*k]=t1act[k];} - } - - SFREE(xbounact);SFREE(xforcact);SFREE(xloadact);SFREE(t1act);SFREE(ampli); - SFREE(xbodyact); - - // if(*nbody>0) SFREE(ipobody); - - SFREE(xstiff); - - if(iglob!=0){SFREE(integerglob);SFREE(doubleglob);} - - *irowp=irow;*enerp=ener;*xstatep=xstate;*ipkonp=ipkon;*lakonp=lakon; - *konp=kon;*ielmatp=ielmat;*ielorienp=ielorien;*icolp=icol; - - (*ttime)+=(*tper); - - return; - - + (*ttime)+=(*tper); + + return; } diff --git a/linstatic_precice_.c b/linstatic_precice_.c new file mode 100755 index 00000000..d18e27b1 --- /dev/null +++ b/linstatic_precice_.c @@ -0,0 +1,1372 @@ +/* CalculiX - A 3-dimensional finite element program */ +/* Copyright (C) 1998-2021 Guido Dhondt */ + +/* This program is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License as */ +/* published by the Free Software Foundation(version 2); */ +/* */ + +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU General Public License for more details. */ + +/* You should have received a copy of the GNU General Public License */ +/* along with this program; if not, write to the Free Software */ +/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include "CalculiX.h" +#ifdef SPOOLES +#include "spooles.h" +#endif +#ifdef SGI +#include "sgi.h" +#endif +#ifdef TAUCS +#include "tau.h" +#endif +#ifdef PARDISO +#include "pardiso.h" +#endif +#ifdef PASTIX +#include "pastix.h" +#endif + +/* Adapter: Add header */ +#include "adapter/PreciceInterface.h" + + +void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, + ITG *ne, + ITG *nodeboun,ITG *ndirboun,double *xboun,ITG *nboun, + ITG *ipompc,ITG *nodempc,double *coefmpc,char *labmpc, + ITG *nmpc, + ITG *nodeforc,ITG *ndirforc,double *xforc,ITG *nforc, + ITG *nelemload,char *sideload,double *xload, + ITG *nload,ITG *nactdof, + ITG **icolp,ITG *jq,ITG **irowp,ITG *neq,ITG *nzl, + ITG *nmethod,ITG *ikmpc,ITG *ilmpc,ITG *ikboun, + ITG *ilboun, + double *elcon,ITG *nelcon,double *rhcon,ITG *nrhcon, + double *alcon,ITG *nalcon,double *alzero,ITG **ielmatp, + ITG **ielorienp,ITG *norien,double *orab,ITG *ntmat_, + double *t0,double *t1,double *t1old, + ITG *ithermal,double *prestr,ITG *iprestr, + double *vold,ITG *iperturb,double *sti,ITG *nzs, + ITG *kode,char *filab,double *eme, + ITG *iexpl,double *plicon,ITG *nplicon,double *plkcon, + ITG *nplkcon, + double **xstatep,ITG *npmat_,char *matname,ITG *isolver, + ITG *mi,ITG *ncmat_,ITG *nstate_,double *cs,ITG *mcs, + ITG *nkon,double **enerp,double *xbounold, + double *xforcold,double *xloadold, + char *amname,double *amta,ITG *namta, + ITG *nam,ITG *iamforc,ITG *iamload, + ITG *iamt1,ITG *iamboun,double *ttime,char *output, + char *set,ITG *nset,ITG *istartset, + ITG *iendset,ITG *ialset,ITG *nprint,char *prlab, + char *prset,ITG *nener,double *trab, + ITG *inotr,ITG *ntrans,double *fmpc,ITG *ipobody,ITG *ibody, + double *xbody,ITG *nbody,double *xbodyold,double *timepar, + double *thicke,char *jobnamec,char *tieset,ITG *ntie, + ITG *istep,ITG *nmat,ITG *ielprop,double *prop,char *typeboun, + ITG *mortar,ITG *mpcinfo,double *tietol,ITG *ics, + char *orname,ITG *itempuser,double *t0g,double *t1g, + /* Adapter: Add variables for the participant name and the config file */ + char *preciceParticipantName, char *configFilename){ + + char description[13]=" ",*lakon=NULL,stiffmatrix[132]="", + fneig[132]="",jobnamef[396]="",*labmpc2=NULL; + + ITG *inum=NULL,k,*icol=NULL,*irow=NULL,ielas=0,icmd=0,iinc=1,nasym=0,i,j,ic,ir, + mass[2]={0,0},stiffness=1,buckling=0,rhsi=1,intscheme=0,*ncocon=NULL, + *nshcon=NULL,mode=-1,noddiam=-1,coriolis=0,iout, + *itg=NULL,ntg=0,symmetryflag=0,inputformat=0,ngraph=1,im, + mt=mi[1]+1,ne0,*integerglob=NULL,iglob=0,*ipneigh=NULL,*neigh=NULL, + icfd=0,*inomat=NULL,*islavact=NULL,*islavnode=NULL,*nslavnode=NULL, + *islavsurf=NULL,nretain,*iretain=NULL,*noderetain=NULL,*ndirretain=NULL, + nmethodl,nintpoint,ifacecount,memmpc_,mpcfree,icascade,maxlenmpc, + ncont=0,*itietri=NULL,*koncont=NULL,nslavs=0,ismallsliding=0, + *itiefac=NULL,*imastnode=NULL,*nmastnode=NULL,*imastop=NULL,iitsta, + *iponoels=NULL,*inoels=NULL,*ipe=NULL,*ime=NULL,iit=-1,iflagact=0, + icutb=0,*kon=NULL,*ipkon=NULL,*ielmat=NULL,ialeatoric=0,kscale=1, + *iponoel=NULL,*inoel=NULL,zero=0,nherm=1,nev=*nforc,node,idir, + *ielorien=NULL,network=0,nrhs=1,iperturbsav,mscalmethod=0,*jqw=NULL, + *iroww=NULL,nzsw,*islavelinv=NULL,*irowtloc=NULL,*jqtloc=NULL,nboun2, + *ndirboun2=NULL,*nodeboun2=NULL,nmpc2,*ipompc2=NULL,*nodempc2=NULL, + *ikboun2=NULL,*ilboun2=NULL,*ikmpc2=NULL,*ilmpc2=NULL,mortartrafoflag=0, + *ikforc=NULL, *ilforc=NULL; + + double *stn=NULL,*v=NULL,*een=NULL,cam[5],*xstiff=NULL,*stiini=NULL,*tper, + *f=NULL,*fn=NULL,qa[4],*fext=NULL,*epn=NULL,*xstateini=NULL,dtheta, + *vini=NULL,*stx=NULL,*enern=NULL,*xbounact=NULL,*xforcact=NULL, + *xloadact=NULL,*t1act=NULL,*ampli=NULL,*xstaten=NULL,*eei=NULL, + *enerini=NULL,*cocon=NULL,*shcon=NULL,*physcon=NULL,*qfx=NULL, + *qfn=NULL,sigma=0.,*cgr=NULL,*xbodyact=NULL,*vr=NULL,*vi=NULL, + *stnr=NULL,*stni=NULL,*vmax=NULL,*stnmax=NULL,*springarea=NULL, + *eenmax=NULL,*fnr=NULL,*fni=NULL,*emn=NULL,*clearini=NULL,ptime, + *emeini=NULL,*doubleglob=NULL,*au=NULL,*ad=NULL,*b=NULL,*aub=NULL, + *adb=NULL,*pslavsurf=NULL,*pmastsurf=NULL,*cdn=NULL,*cdnr=NULL, + *cdni=NULL,*submatrix=NULL,*xnoels=NULL,*cg=NULL,*straight=NULL, + *areaslav=NULL,*xmastnor=NULL,theta=0.,*ener=NULL,*xstate=NULL, + *fnext=NULL,*energyini=NULL,*energy=NULL,*d=NULL,alea=0.1,*smscale=NULL, + *auw=NULL,*autloc=NULL,*xboun2=NULL,*coefmpc2=NULL; + + FILE *f1,*f2; + +#ifdef SGI + ITG token; +#endif + + /* dummy arguments for the results call */ + + double *veold=NULL,*accold=NULL,bet,gam,dtime,time,reltime=1.; + + irow=*irowp;ener=*enerp;xstate=*xstatep;ipkon=*ipkonp;lakon=*lakonp; + kon=*konp;ielmat=*ielmatp;ielorien=*ielorienp;icol=*icolp; + + for(k=0;k<3;k++){ + strcpy1(&jobnamef[k*132],&jobnamec[k*132],132); + } + + tper=&timepar[1]; + + time=*tper; + dtime=*tper; + + ne0=*ne; + + + /* Adapter: Put all the CalculiX data that is needed for the coupling into an array */ + struct SimulationData simulationData = { + .ialset = ialset, + .ielmat = ielmat, + .istartset = istartset, + .iendset = iendset, + .kon = kon, + .ipkon = ipkon, + .lakon = &lakon, + .co = co, + .set = set, + .nset = *nset, + .ikboun = ikboun, + .ikforc = ikforc, + .ilboun = ilboun, + .ilforc = ilforc, + .nboun = *nboun, + .nforc = *nforc, + .nelemload = nelemload, + .nload = *nload, + .sideload = sideload, + .mt = mt, + .nk = *nk, + .theta = &theta, + .dtheta = &dtheta, + .tper = tper, + .nmethod = nmethod, + .xload = xload, + .xforc = xforc, + .xboun = xboun, + .ntmat_ = ntmat_, + .vold = vold, + .veold = veold, + .fn = fn, + .cocon = cocon, + .ncocon = ncocon, + .mi = mi, + // .eei = &eei, + // .xstiff = &xstiff + }; + + /* determining the global values to be used as boundary conditions + for a submodel */ + + /* iglob=-1 if global results are from a *FREQUENCY calculation + iglob=0 if no global results are used by boundary conditions + iglob=1 if global results are from a *STATIC calculation */ + + ITG irefine=0; + getglobalresults(&jobnamec[396],&integerglob,&doubleglob,nboun,iamboun,xboun, + nload,sideload,iamload,&iglob,nforc,iamforc,xforc, + ithermal,nk,t1,iamt1,&sigma,&irefine); + + /* reading temperatures from frd-file */ + + if((itempuser[0]==2)&&(itempuser[1]!=itempuser[2])) { + utempread(t1,&itempuser[2],jobnamec); + } + + /* allocating fields for the actual external loading */ + + NNEW(xbounact,double,*nboun); + for(k=0;k<*nboun;++k){xbounact[k]=xbounold[k];} + NNEW(xforcact,double,*nforc); + NNEW(xloadact,double,2**nload); + NNEW(xbodyact,double,7**nbody); + /* copying the rotation axis and/or acceleration vector */ + for(k=0;k<7**nbody;k++){xbodyact[k]=xbody[k];} + if(*ithermal==1){ + NNEW(t1act,double,*nk); + for(k=0;k<*nk;++k){t1act[k]=t1old[k];} + } + + /* assigning the body forces to the elements */ + + /* if(*nbody>0){ + ifreebody=*ne+1; + NNEW(ipobody,ITG,2*ifreebody**nbody); + for(k=1;k<=*nbody;k++){ + FORTRAN(bodyforce,(cbody,ibody,ipobody,nbody,set,istartset, + iendset,ialset,&inewton,nset,&ifreebody,&k)); + RENEW(ipobody,ITG,2*(*ne+ifreebody)); + } + RENEW(ipobody,ITG,2*(ifreebody-1)); + }*/ + + /* contact conditions */ + + // if(*icontact==1){ + if(*mortar>-2){ + + memmpc_=mpcinfo[0];mpcfree=mpcinfo[1];icascade=mpcinfo[2]; + maxlenmpc=mpcinfo[3]; + + inicont(nk,&ncont,ntie,tieset,nset,set,istartset,iendset,ialset,&itietri, + lakon,ipkon,kon,&koncont,&nslavs,tietol,&ismallsliding,&itiefac, + &islavsurf,&islavnode,&imastnode,&nslavnode,&nmastnode, + mortar,&imastop,nkon,&iponoels,&inoels,&ipe,&ime,ne,&ifacecount, + iperturb,ikboun,nboun,co,istep,&xnoels); + + if(ncont!=0){ + + NNEW(cg,double,3*ncont); + NNEW(straight,double,16*ncont); + + /* 11 instead of 10: last position is reserved for the + local contact spring element number; needed as + pointer into springarea */ + + if(*mortar==0){ + RENEW(kon,ITG,*nkon+11*nslavs); + NNEW(springarea,double,2*nslavs); + if(*nener==1){ + RENEW(ener,double,mi[0]*(*ne+nslavs)*2); + } + RENEW(ipkon,ITG,*ne+nslavs); + RENEW(lakon,char,8*(*ne+nslavs)); + + if(*norien>0){ + RENEW(ielorien,ITG,mi[2]*(*ne+nslavs)); + for(k=mi[2]**ne;k0){ + RENEW(ielorien,ITG,mi[2]*(*ne+nintpoint)); + for(k=mi[2]**ne;k0)){ + iperturbsav=iperturb[0]; + iperturb[0]=0; + } + + iout=-1; + NNEW(v,double,mt**nk); + NNEW(fn,double,mt**nk); + NNEW(stx,double,6*mi[0]**ne); + NNEW(inum,ITG,*nk); + results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, + elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, + ielorien,norien,orab,ntmat_,t0,t1act,ithermal, + prestr,iprestr,filab,eme,emn,een,iperturb, + f,fn,nactdof,&iout,qa,vold,b,nodeboun, + ndirboun,xbounact,nboun,ipompc, + nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold,accold, + &bet,&gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, + xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas, + &icmd,ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern, + emeini,xstaten,eei,enerini,cocon,ncocon,set,nset,istartset, + iendset,ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans, + fmpc,nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea, + &reltime,&ne0,thicke,shcon,nshcon, + sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, + mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, + islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, + inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, + itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, + islavelinv,autloc,irowtloc,jqtloc,&nboun2, + ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, + labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, + &intscheme); + SFREE(v);SFREE(fn);SFREE(stx);SFREE(inum); + iout=1; + + // RECIEVING MATERIAL TANGENT FROM NASMAT + simulationData.xstiff = xstiff; + Precice_ReadCouplingData(&simulationData); + + } + + precicec_finalize(); + + if((*nmethod==1)&&(iglob<0)&&(iperturb[0]>0)){ + iperturb[0]=iperturbsav; + } + + /* determining the system matrix and the external forces */ + + NNEW(ad,double,*neq); + NNEW(fext,double,*neq); + + if(*nmethod==11){ + + /* determining the nodes and the degrees of freedom in those nodes + belonging to the substructure */ + + NNEW(iretain,ITG,*nk); + NNEW(noderetain,ITG,*nk); + NNEW(ndirretain,ITG,*nk); + nretain=0; + + for(i=0;i<*nboun;i++){ + if(strcmp1(&typeboun[i],"C")==0){ + iretain[nretain]=i+1; + noderetain[nretain]=nodeboun[i]; + ndirretain[nretain]=ndirboun[i]; + nretain++; + } + } + + /* nretain!=0: submatrix application + nretain==0: Green function application */ + + if(nretain>0){ + RENEW(iretain,ITG,nretain); + RENEW(noderetain,ITG,nretain); + RENEW(ndirretain,ITG,nretain); + }else{ + SFREE(iretain);SFREE(noderetain);SFREE(ndirretain); + } + + /* creating the right size au */ + + NNEW(au,double,nzs[2]); + rhsi=0; + // nmethodl=2; + nmethodl=*nmethod; + + /* providing for the mass matrix in case of Green functions */ + + if(nretain==0){ + mass[0]=1.; + NNEW(adb,double,*neq); + NNEW(aub,double,nzs[1]); + } + + }else{ + + /* linear static calculation */ + + NNEW(au,double,*nzs); + nmethodl=*nmethod; + + /* if submodel calculation with a global model obtained by + a *FREQUENCY calculation: replace stiffness matrix K by + K-sigma*M */ + + if(iglob<0){ + mass[0]=1; + NNEW(adb,double,*neq); + NNEW(aub,double,nzs[1]); + } + + } + + + mafillsmmain(co,nk,kon,ipkon,lakon,ne,nodeboun,ndirboun,xbounact,nboun, + ipompc,nodempc,coefmpc,nmpc,nodeforc,ndirforc,xforcact, + nforc,nelemload,sideload,xloadact,nload,xbodyact,ipobody, + nbody,cgr,ad,au,fext,nactdof,icol,jq,irow,neq,nzl,&nmethodl, + ikmpc,ilmpc,ikboun,ilboun, + elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, + ielorien,norien,orab,ntmat_, + t0,t1act,ithermal,prestr,iprestr,vold,iperturb,sti, + nzs,stx,adb,aub,iexpl,plicon,nplicon,plkcon,nplkcon, + xstiff,npmat_,&dtime,matname,mi, + ncmat_,mass,&stiffness,&buckling,&rhsi,&intscheme,physcon, + shcon,nshcon,cocon,ncocon,ttime,&time,istep,&iinc,&coriolis, + ibody,xloadold,&reltime,veold,springarea,nstate_, + xstateini,xstate,thicke,integerglob,doubleglob, + tieset,istartset,iendset,ialset,ntie,&nasym,pslavsurf, + pmastsurf,mortar,clearini,ielprop,prop,&ne0,fnext,&kscale, + iponoel,inoel,&network,ntrans,inotr,trab,smscale,&mscalmethod, + set,nset,islavelinv,autloc,irowtloc,jqtloc,&mortartrafoflag); + + /* check for negative Jacobians */ + + if(nmethodl==0) *nmethod=0; + + if(nasym==1){ + RENEW(au,double,2*nzs[1]); + symmetryflag=2; + inputformat=1; + + mafillsmasmain(co,nk,kon,ipkon,lakon,ne,nodeboun, + ndirboun,xbounact,nboun, + ipompc,nodempc,coefmpc,nmpc,nodeforc,ndirforc,xforcact, + nforc,nelemload,sideload,xloadact,nload,xbodyact,ipobody, + nbody,cgr,ad,au,fext,nactdof,icol,jq,irow,neq,nzl, + nmethod,ikmpc,ilmpc,ikboun,ilboun, + elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero, + ielmat,ielorien,norien,orab,ntmat_, + t0,t1act,ithermal,prestr,iprestr,vold,iperturb,sti, + nzs,stx,adb,aub,iexpl,plicon,nplicon,plkcon,nplkcon, + xstiff,npmat_,&dtime,matname,mi, + ncmat_,mass,&stiffness,&buckling,&rhsi,&intscheme, + physcon,shcon,nshcon,cocon,ncocon,ttime,&time,istep,&iinc, + &coriolis,ibody,xloadold,&reltime,veold,springarea,nstate_, + xstateini,xstate,thicke, + integerglob,doubleglob,tieset,istartset,iendset, + ialset,ntie,&nasym,pslavsurf,pmastsurf,mortar,clearini, + ielprop,prop,&ne0,&kscale,iponoel,inoel,&network,set,nset); + + /* FORTRAN(mafillsmas,(co,nk,kon,ipkon,lakon,ne,nodeboun, + ndirboun,xbounact,nboun, + ipompc,nodempc,coefmpc,nmpc,nodeforc,ndirforc,xforcact, + nforc,nelemload,sideload,xloadact,nload,xbodyact,ipobody, + nbody,cgr,ad,au,fext,nactdof,icol,jq,irow,neq,nzl, + nmethod,ikmpc,ilmpc,ikboun,ilboun, + elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero, + ielmat,ielorien,norien,orab,ntmat_, + t0,t1act,ithermal,prestr,iprestr,vold,iperturb,sti, + nzs,stx,adb,aub,iexpl,plicon,nplicon,plkcon,nplkcon, + xstiff,npmat_,&dtime,matname,mi, + ncmat_,mass,&stiffness,&buckling,&rhsi,&intscheme, + physcon,shcon,nshcon,cocon,ncocon,ttime,&time,istep,&iinc, + &coriolis,ibody,xloadold,&reltime,veold,springarea,nstate_, + xstateini,xstate,thicke, + integerglob,doubleglob,tieset,istartset,iendset, + ialset,ntie,&nasym,pslavsurf,pmastsurf,mortar,clearini, + ielprop,prop,&ne0,&kscale,iponoel,inoel,&network));*/ + } + + /* determining the right hand side */ + + NNEW(b,double,*neq); + for(k=0;k<*neq;++k){ + b[k]=fext[k]-f[k]; + } + SFREE(fext);SFREE(f); + + + /* generation of a substructure stiffness matrix (nretain>0) or treating + Green functions (nretain=0) */ + + if(*nmethod==11){ + + /* recovering omega_0^2 for Green applications */ + + if(nretain==0){ + if(*nforc>0){sigma=xforc[0];} + } + + /* factorizing the matrix */ + + if(*neq>0){ + if(*isolver==0){ + #ifdef SPOOLES + spooles_factor(ad,au,adb,aub,&sigma,icol,irow,neq,nzs,&symmetryflag, + &inputformat,&nzs[2]); + #else + printf("*ERROR in linstatic: the SPOOLES library is not linked\n\n"); + FORTRAN(stop,()); + #endif + } + else if(*isolver==7){ + #ifdef PARDISO + pardiso_factor(ad,au,adb,aub,&sigma,icol,irow,neq,nzs, + &symmetryflag,&inputformat,jq,&nzs[2]); + #else + printf("*ERROR in linstatic: the PARDISO library is not linked\n\n"); + FORTRAN(stop,()); + #endif + } + else if(*isolver==8){ + #ifdef PASTIX + pastix_factor_main(ad,au,adb,aub,&sigma,icol,irow,neq,nzs, + &symmetryflag,&inputformat,jq,&nzs[2]); + #else + printf("*ERROR in linstatic: the PASTIX library is not linked\n\n"); + FORTRAN(stop,()); + #endif + } + } + + + /* solving the system of equations with appropriate rhs */ + + if(nretain>0){ + + /* substructure calculations */ + + NNEW(submatrix,double,nretain*nretain); + + for(i=0;i0){ + if(*isolver==0){ + #ifdef SPOOLES + spooles_solve(b,neq); + #endif + } + else if(*isolver==7){ + #ifdef PARDISO + pardiso_solve(b,neq,&symmetryflag,&inputformat,&nrhs); + #endif + + } + else if(*isolver==8){ + #ifdef PASTIX + pastix_solve(b,neq,&symmetryflag,&nrhs); + #endif + + } + } + + /* calculating the internal forces */ + + + + NNEW(v,double,mt**nk); + NNEW(fn,double,mt**nk); + NNEW(stn,double,6**nk); + NNEW(inum,ITG,*nk); + NNEW(stx,double,6*mi[0]**ne); + + if(strcmp1(&filab[261],"E ")==0) NNEW(een,double,6**nk); + if(strcmp1(&filab[2697],"ME ")==0) NNEW(emn,double,6**nk); + if(strcmp1(&filab[522],"ENER")==0) NNEW(enern,double,*nk); + + NNEW(eei,double,6*mi[0]**ne); + if(*nener==1){ + NNEW(stiini,double,6*mi[0]**ne); + NNEW(emeini,double,6*mi[0]**ne); + NNEW(enerini,double,mi[0]**ne);} + + /* replacing the appropriate boundary value by unity */ + + xbounact[iretain[i]-1]=1.; + + + + results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, + elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, + ielorien,norien,orab,ntmat_,t0,t1act,ithermal, + prestr,iprestr,filab,eme,emn,een,iperturb, + f,fn,nactdof,&iout,qa,vold,b,nodeboun,ndirboun, + xbounact,nboun,ipompc, + nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold, + accold,&bet, + &gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, + xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas,&icmd, + ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern,emeini, + xstaten,eei,enerini,cocon,ncocon,set,nset,istartset,iendset, + ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans,fmpc, + nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea,&reltime, + &ne0,thicke,shcon,nshcon, + sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, + mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, + islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, + inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, + itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, + islavelinv,autloc,irowtloc,jqtloc,&nboun2, + ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, + labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, + &intscheme); + + xbounact[iretain[i]-1]=0.; + + SFREE(v);SFREE(stn);SFREE(inum);SFREE(stx); + + if(strcmp1(&filab[261],"E ")==0) SFREE(een); + if(strcmp1(&filab[2697],"ME ")==0) SFREE(emn); + if(strcmp1(&filab[522],"ENER")==0) SFREE(enern); + + SFREE(eei);if(*nener==1){SFREE(stiini);SFREE(emeini);SFREE(enerini);} + + /* storing the internal forces in the substructure + stiffness matrix */ + + for(j=0;j0){ + if(*isolver==0){ + #ifdef SPOOLES + spooles_solve(b,neq); + #endif + } + else if(*isolver==7){ + #ifdef PARDISO + pardiso_solve(b,neq,&symmetryflag,&inputformat,&nrhs); + #endif + + } + else if(*isolver==8){ + #ifdef PASTIX + pastix_solve(b,neq,&symmetryflag,&nrhs); + #endif + + } + } + + /* storing the Green function */ + + if(fwrite(b,sizeof(double),*neq,f2)!=*neq){ + printf("*ERROR saving data to the eigenvalue file..."); + exit(0); + } + + /* calculating the displacements and the stresses and storing */ + /* the results in frd format for each valid eigenmode */ + + NNEW(v,double,mt**nk); + NNEW(fn,double,mt**nk); + NNEW(stn,double,6**nk); + NNEW(inum,ITG,*nk); + NNEW(stx,double,6*mi[0]**ne); + + if(strcmp1(&filab[261],"E ")==0) NNEW(een,double,6**nk); + if(strcmp1(&filab[2697],"ME ")==0) NNEW(emn,double,6**nk); + if(strcmp1(&filab[522],"ENER")==0) NNEW(enern,double,*nk); + if(strcmp1(&filab[2175],"CONT")==0) NNEW(cdn,double,6**nk); + + NNEW(eei,double,6*mi[0]**ne); + if(*nener==1){ + NNEW(stiini,double,6*mi[0]**ne); + NNEW(emeini,double,6*mi[0]**ne); + NNEW(enerini,double,mi[0]**ne);} + + + results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, + elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, + ielorien,norien,orab,ntmat_,t0,t1act,ithermal, + prestr,iprestr,filab,eme,emn,een,iperturb, + f,fn,nactdof,&iout,qa,vold,b,nodeboun,ndirboun, + xbounact,nboun,ipompc, + nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold, + accold,&bet, + &gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, + xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas,&icmd, + ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern,emeini, + xstaten,eei,enerini,cocon,ncocon,set,nset,istartset,iendset, + ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans,fmpc, + nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea,&reltime, + &ne0,thicke,shcon,nshcon, + sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, + mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, + islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, + inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, + itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, + islavelinv,autloc,irowtloc,jqtloc,&nboun2, + ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, + labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, + &intscheme); + + SFREE(eei); + if(*nener==1){ + SFREE(stiini);SFREE(emeini);SFREE(enerini);} + + /* memcpy(&vold[0],&v[0],sizeof(double)*mt**nk); + memcpy(&sti[0],&stx[0],sizeof(double)*6*mi[0]*ne0);*/ + + ++*kode; + time=1.*i; + + /* for cyclic symmetric sectors: duplicating the results */ + + if(*mcs>0){ + ptime=*ttime+time; + frdcyc(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod,kode,filab,een,t1act, + fn,&ptime,epn,ielmat,matname,cs,mcs,nkon,enern,xstaten, + nstate_,istep,&iinc,iperturb,ener,mi,output,ithermal, + qfn,ialset,istartset,iendset,trab,inotr,ntrans,orab, + ielorien,norien,sti,veold,&noddiam,set,nset,emn,thicke, + jobnamec,&ne0,cdn,mortar,nmat,qfx,ielprop,prop); + } + else{ + if(strcmp1(&filab[1044],"ZZS")==0){ + NNEW(neigh,ITG,40**ne); + NNEW(ipneigh,ITG,*nk); + } + ptime=*ttime+time; + frd(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod, + kode,filab,een,t1act,fn,&ptime,epn,ielmat,matname,enern,xstaten, + nstate_,istep,&iinc,ithermal,qfn,&mode,&noddiam,trab,inotr, + ntrans,orab,ielorien,norien,description,ipneigh,neigh, + mi,stx,vr,vi,stnr,stni,vmax,stnmax,&ngraph,veold,ener,ne, + cs,set,nset,istartset,iendset,ialset,eenmax,fnr,fni,emn, + thicke,jobnamec,output,qfx,cdn,mortar,cdnr,cdni,nmat, + ielprop,prop,sti); + if(strcmp1(&filab[1044],"ZZS")==0){SFREE(ipneigh);SFREE(neigh);} + } + + SFREE(v);SFREE(stn);SFREE(inum); + SFREE(stx);SFREE(fn); + + if(strcmp1(&filab[261],"E ")==0) SFREE(een); + if(strcmp1(&filab[2697],"ME ")==0) SFREE(emn); + if(strcmp1(&filab[522],"ENER")==0) SFREE(enern); + if(strcmp1(&filab[2175],"CONT")==0) SFREE(cdn); + + } + + + fclose(f2); + + } + + SFREE(au);SFREE(ad);SFREE(b); + + SFREE(xbounact);SFREE(xforcact);SFREE(xloadact);SFREE(t1act);SFREE(ampli); + SFREE(xbodyact); + + // if(*nbody>0) SFREE(ipobody); + + SFREE(xstiff); + + if(iglob!=0){SFREE(integerglob);SFREE(doubleglob);} + + return; + + + }else if(*nmethod!=0){ + + /* linear static applications */ + + if(*isolver==0){ + #ifdef SPOOLES + spooles(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs,&symmetryflag, + &inputformat,&nzs[2]); + #else + printf("*ERROR in linstatic: the SPOOLES library is not linked\n\n"); + FORTRAN(stop,()); + #endif + } + else if((*isolver==2)||(*isolver==3)){ + if(nasym>0){ + printf(" *ERROR in nonlingeo: the iterative solver cannot be used for asymmetric matrices\n\n"); + FORTRAN(stop,()); + } + preiter(ad,&au,b,&icol,&irow,neq,nzs,isolver,iperturb); + } + else if(*isolver==4){ + #ifdef SGI + if(nasym>0){ + printf(" *ERROR in nonlingeo: the SGI solver cannot be used for asymmetric matrices\n\n"); + FORTRAN(stop,()); + } + token=1; + sgi_main(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs,token); + #else + printf("*ERROR in linstatic: the SGI library is not linked\n\n"); + FORTRAN(stop,()); + #endif + } + else if(*isolver==5){ + #ifdef TAUCS + if(nasym>0){ + printf(" *ERROR in nonlingeo: the TAUCS solver cannot be used for asymmetric matrices\n\n"); + FORTRAN(stop,()); + } + tau(ad,&au,adb,aub,&sigma,b,icol,&irow,neq,nzs); + #else + printf("*ERROR in linstatic: the TAUCS library is not linked\n\n"); + FORTRAN(stop,()); + #endif + } + else if(*isolver==7){ + #ifdef PARDISO + pardiso_main(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs, + &symmetryflag,&inputformat,jq,&nzs[2],&nrhs); + #else + printf("*ERROR in linstatic: the PARDISO library is not linked\n\n"); + FORTRAN(stop,()); + #endif + } + else if(*isolver==8){ + #ifdef PASTIX + pastix_main(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs, + &symmetryflag,&inputformat,jq,&nzs[2],&nrhs); + #else + printf("*ERROR in linstatic: the PASTIX library is not linked\n\n"); + FORTRAN(stop,()); + #endif + } + + /* saving of ad and au for sensitivity analysis */ + + for(i=0;i<*ntie;i++){ + if(strcmp1(&tieset[i*243+80],"D")==0){ + + strcpy(stiffmatrix,jobnamec); + strcat(stiffmatrix,".stm"); + + if((f1=fopen(stiffmatrix,"wb"))==NULL){ + printf("*ERROR in linstatic: cannot open stiffness matrix file for writing..."); + exit(0); + } + + /* storing the stiffness matrix */ + + /* nzs,irow,jq and icol have to be stored too, since the static analysis + can involve contact, whereas in the sensitivity analysis contact is not + taken into account while determining the structure of the stiffness + matrix (in mastruct.c) + */ + + if(fwrite(&nasym,sizeof(ITG),1,f1)!=1){ + printf("*ERROR saving the symmetry flag to the stiffness matrix file..."); + exit(0); + } + if(fwrite(nzs,sizeof(ITG),3,f1)!=3){ + printf("*ERROR saving the number of subdiagonal nonzeros to the stiffness matrix file..."); + exit(0); + } + if(fwrite(irow,sizeof(ITG),nzs[2],f1)!=nzs[2]){ + printf("*ERROR saving irow to the stiffness matrix file..."); + exit(0); + } + if(fwrite(jq,sizeof(ITG),neq[1]+1,f1)!=neq[1]+1){ + printf("*ERROR saving jq to the stiffness matrix file..."); + exit(0); + } + if(fwrite(icol,sizeof(ITG),neq[1],f1)!=neq[1]){ + printf("*ERROR saving icol to the stiffness matrix file..."); + exit(0); + } + if(fwrite(ad,sizeof(double),neq[1],f1)!=neq[1]){ + printf("*ERROR saving the diagonal of the stiffness matrix to the stiffness matrix file..."); + exit(0); + } + if(fwrite(au,sizeof(double),nzs[2],f1)!=nzs[2]){ + printf("*ERROR saving the off-diagonal terms of the stiffness matrix to the tiffness matrix file..."); + exit(0); + } + fclose(f1); + + break; + } + } + + SFREE(ad);SFREE(au); + if(iglob<0){SFREE(adb);SFREE(aub);} + + /* calculating the displacements and the stresses and storing */ + /* the results in frd format for each valid eigenmode */ + + NNEW(v,double,mt**nk); + NNEW(fn,double,mt**nk); + NNEW(stn,double,6**nk); + NNEW(inum,ITG,*nk); + NNEW(stx,double,6*mi[0]**ne); + + if(strcmp1(&filab[261],"E ")==0) NNEW(een,double,6**nk); + if(strcmp1(&filab[2697],"ME ")==0) NNEW(emn,double,6**nk); + if(strcmp1(&filab[522],"ENER")==0) NNEW(enern,double,*nk); + if(strcmp1(&filab[2175],"CONT")==0) NNEW(cdn,double,6**nk); + + NNEW(eei,double,6*mi[0]**ne); + if(*nener==1){ + NNEW(stiini,double,6*mi[0]**ne); + NNEW(emeini,double,6*mi[0]**ne); + NNEW(enerini,double,mi[0]**ne);} + + + results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, + elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, + ielorien,norien,orab,ntmat_,t0,t1act,ithermal, + prestr,iprestr,filab,eme,emn,een,iperturb, + f,fn,nactdof,&iout,qa,vold,b,nodeboun,ndirboun,xbounact,nboun,ipompc, + nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold,accold,&bet, + &gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, + xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas,&icmd, + ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern,emeini, + xstaten,eei,enerini,cocon,ncocon,set,nset,istartset,iendset, + ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans,fmpc, + nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea,&reltime, + &ne0,thicke,shcon,nshcon, + sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, + mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, + islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, + inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, + itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, + islavelinv,autloc,irowtloc,jqtloc,&nboun2, + ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, + labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, + &intscheme); + + SFREE(eei); + if(*nener==1){ + SFREE(stiini);SFREE(emeini);SFREE(enerini);} + + memcpy(&vold[0],&v[0],sizeof(double)*mt**nk); + memcpy(&sti[0],&stx[0],sizeof(double)*6*mi[0]*ne0); + + ++*kode; + + /* for cyclic symmetric sectors: duplicating the results */ + + if(*mcs>0){ + ptime=*ttime+time; + frdcyc(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod,kode,filab,een,t1act, + fn,&ptime,epn,ielmat,matname,cs,mcs,nkon,enern,xstaten, + nstate_,istep,&iinc,iperturb,ener,mi,output,ithermal, + qfn,ialset,istartset,iendset,trab,inotr,ntrans,orab, + ielorien,norien,sti,veold,&noddiam,set,nset,emn,thicke, + jobnamec,&ne0,cdn,mortar,nmat,qfx,ielprop,prop); + } + else{ + if(strcmp1(&filab[1044],"ZZS")==0){ + NNEW(neigh,ITG,40**ne); + NNEW(ipneigh,ITG,*nk); + } + ptime=*ttime+time; + frd(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod, + kode,filab,een,t1act,fn,&ptime,epn,ielmat,matname,enern,xstaten, + nstate_,istep,&iinc,ithermal,qfn,&mode,&noddiam,trab,inotr, + ntrans,orab,ielorien,norien,description,ipneigh,neigh, + mi,stx,vr,vi,stnr,stni,vmax,stnmax,&ngraph,veold,ener,ne, + cs,set,nset,istartset,iendset,ialset,eenmax,fnr,fni,emn, + thicke,jobnamec,output,qfx,cdn,mortar,cdnr,cdni,nmat,ielprop, + prop,sti); + if(strcmp1(&filab[1044],"ZZS")==0){SFREE(ipneigh);SFREE(neigh);} + } + + /* updating the .sta file */ + + iitsta=1; + FORTRAN(writesta,(istep,&iinc,&icutb,&iitsta,ttime,&time,&dtime)); + + SFREE(v);SFREE(stn);SFREE(inum); + SFREE(b);SFREE(stx);SFREE(fn); + + if(strcmp1(&filab[261],"E ")==0) SFREE(een); + if(strcmp1(&filab[2697],"ME ")==0) SFREE(emn); + if(strcmp1(&filab[522],"ENER")==0) SFREE(enern); + if(strcmp1(&filab[2175],"CONT")==0) SFREE(cdn); + + } + else { + + /* error occurred in mafill: storing the geometry in frd format */ + + ++*kode; + NNEW(inum,ITG,*nk);for(k=0;k<*nk;k++) inum[k]=1; + if(strcmp1(&filab[1044],"ZZS")==0){ + NNEW(neigh,ITG,40**ne); + NNEW(ipneigh,ITG,*nk); + } + ptime=*ttime+time; + frd(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod, + kode,filab,een,t1,fn,&ptime,epn,ielmat,matname,enern,xstaten, + nstate_,istep,&iinc,ithermal,qfn,&mode,&noddiam,trab,inotr, + ntrans,orab,ielorien,norien,description,ipneigh,neigh, + mi,sti,vr,vi,stnr,stni,vmax,stnmax,&ngraph,veold,ener,ne, + cs,set,nset,istartset,iendset,ialset,eenmax,fnr,fni,emn, + thicke,jobnamec,output,qfx,cdn,mortar,cdnr,cdni,nmat,ielprop, + prop,sti); + if(strcmp1(&filab[1044],"ZZS")==0){SFREE(ipneigh);SFREE(neigh);} + SFREE(inum);FORTRAN(stop,()); + + } + + if(*mortar>-2){ + if(ncont!=0){ + *ne=ne0; + if(*nener==1){ + RENEW(ener,double,mi[0]**ne*2); + } + RENEW(ipkon,ITG,*ne); + RENEW(lakon,char,8**ne); + RENEW(kon,ITG,*nkon); + if(*norien>0){ + RENEW(ielorien,ITG,mi[2]**ne); + } + RENEW(ielmat,ITG,mi[2]**ne); + SFREE(cg);SFREE(straight); + SFREE(imastop);SFREE(itiefac);SFREE(islavnode);SFREE(islavsurf); + SFREE(nslavnode);SFREE(iponoels);SFREE(inoels);SFREE(imastnode); + SFREE(nmastnode);SFREE(itietri);SFREE(koncont);SFREE(xnoels); + SFREE(springarea);SFREE(xmastnor); + + if(*mortar==0){ + SFREE(areaslav); + }else if(*mortar==1){ + SFREE(pmastsurf);SFREE(ipe);SFREE(ime);SFREE(pslavsurf); + SFREE(islavact);SFREE(clearini); + } + } + mpcinfo[0]=memmpc_;mpcinfo[1]=mpcfree;mpcinfo[2]=icascade; + mpcinfo[3]=maxlenmpc; + } + + /* updating the loading at the end of the step; + important in case the amplitude at the end of the step + is not equal to one */ + + for(k=0;k<*nboun;++k){xbounold[k]=xbounact[k];} + for(k=0;k<*nforc;++k){xforcold[k]=xforcact[k];} + for(k=0;k<2**nload;++k){xloadold[k]=xloadact[k];} + for(k=0;k<7**nbody;k=k+7){xbodyold[k]=xbodyact[k];} + if(*ithermal==1){ + for(k=0;k<*nk;++k){t1old[k]=t1act[k];} + for(k=0;k<*nk;++k){vold[mt*k]=t1act[k];} + } + + SFREE(xbounact);SFREE(xforcact);SFREE(xloadact);SFREE(t1act);SFREE(ampli); + SFREE(xbodyact); + + // if(*nbody>0) SFREE(ipobody); + + SFREE(xstiff); + + if(iglob!=0){SFREE(integerglob);SFREE(doubleglob);} + + *irowp=irow;*enerp=ener;*xstatep=xstate;*ipkonp=ipkon;*lakonp=lakon; + *konp=kon;*ielmatp=ielmat;*ielorienp=ielorien;*icolp=icol; + + (*ttime)+=(*tper); + + return; + + +} diff --git a/multiscale_routines.f b/multiscale_routines.f new file mode 100644 index 00000000..28d6b485 --- /dev/null +++ b/multiscale_routines.f @@ -0,0 +1,84 @@ + SUBROUTINE PRECICE_MULTISCALE_GET_STRAIN() + + + + END SUBROUTINE PRECICE_MULTISCALE_GET_STRAIN + + + + SUBROUTINE PRECICE_MULTISCALE_SET_STX(MI, + & INTPT, NUM_ELEM, PDATA, STX) + + IMPLICIT NONE + + ! IO VARIABLES + INTEGER :: MI(*) ! MAXIMUM VALUE OF INTEGRATION POINT PER ELEMENT (MI[0]) + INTEGER :: NUM_ELEM ! NUMBER OF ELEMENTS + INTEGER :: INTPT ! INTERCEPT ADDED TO STX + REAL(8) :: PDATA(*) ! DATA RECEIVED FROM PRECICE + REAL(8) :: STX(6, MI(1),*) ! STRESS VECTOR USED BY CALCULIX + + + ! LOCAL VARIABLES + INTEGER :: I, J, K, NGP_MAX, COUNT + + + NGP_MAX = MI(1) + + + COUNT= 1 + DO I = 1, NUM_ELEM + DO J = 1, NGP_MAX + STX(INTPT, J, I) = PDATA(COUNT) + STX(INTPT+1, J, I) = PDATA(COUNT+1) + STX(INTPT+2, J, I) = PDATA(COUNT+2) + COUNT = COUNT + 3 + ENDDO + ENDDO + + + END SUBROUTINE PRECICE_MULTISCALE_SET_STX + + + + SUBROUTINE PRECICE_MULTISCALE_SET_XSTIFF(MAX_NGP, + & INTPT, NUM_ELEM, pdata, XSTIFF) + + IMPLICIT NONE + + ! IO VARIABLES + INTEGER :: MAX_NGP ! MAXIMUM VALUE OF INTEGRATION POINT PER ELEMENT (MI[0]) + INTEGER :: NUM_ELEM ! NUMBER OF ELEMENTS + INTEGER :: INTPT ! INTERCEPT ADDED TO XSTIFF + REAL(8) :: PDATA(:) ! DATA RECEIVED FROM PRECICE + REAL(8) :: XSTIFF(:) ! MATERIAL STIFFNESS MATRIX USED BY CALCULIX + + + ! LOCAL VARIABLES + INTEGER :: I, J, K, NGP_MAX, COUNT + + + NGP_MAX = MI(1) + + COUNT= 1 + DO I = 1, NUM_ELEM + DO J = 1, NGP_MAX +! XSTIFF(INTPT, J, I) = PDATA(COUNT) +! XSTIFF(INTPT+1, J, I) = PDATA(COUNT+1) +! XSTIFF(INTPT+2, J, I) = PDATA(COUNT+2) + COUNT = COUNT + 3 + ENDDO + ENDDO + + ! IF(INTPT == 19) THEN + DO I = 1, NUM_ELEM + DO J = 1, NGP_MAX + write(*,*) XSTIFF(1:3, J, I) + ENDDO + ENDDO + ! ENDIF + + + + END SUBROUTINE PRECICE_MULTISCALE_SET_XSTIFF + From 32fc350f098448d09fa945487a2d0d87acf6e103 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Thu, 11 Jul 2024 16:54:31 +0200 Subject: [PATCH 05/55] Revert .gitignore because make clean takes care of it, and move example to another repo --- .gitignore | 14 --- examples/ccx-nasmat/ccx/clean.sh | 11 -- examples/ccx-nasmat/ccx/config.yml | 9 -- examples/ccx-nasmat/ccx/one_element.inp | 51 -------- examples/ccx-nasmat/ccx/run.sh | 6 - examples/ccx-nasmat/nasmat/clean.sh | 7 -- .../nasmat/micro-manager-config.json | 26 ---- examples/ccx-nasmat/nasmat/ruc_nasmat.py | 113 ------------------ .../ccx-nasmat/nasmat/run_micro_manager.py | 21 ---- .../nasmat/run_micromanager_nasmat.sh | 5 - examples/ccx-nasmat/precice-config.xml | 94 --------------- 11 files changed, 357 deletions(-) delete mode 100644 examples/ccx-nasmat/ccx/clean.sh delete mode 100755 examples/ccx-nasmat/ccx/config.yml delete mode 100755 examples/ccx-nasmat/ccx/one_element.inp delete mode 100755 examples/ccx-nasmat/ccx/run.sh delete mode 100755 examples/ccx-nasmat/nasmat/clean.sh delete mode 100644 examples/ccx-nasmat/nasmat/micro-manager-config.json delete mode 100644 examples/ccx-nasmat/nasmat/ruc_nasmat.py delete mode 100644 examples/ccx-nasmat/nasmat/run_micro_manager.py delete mode 100755 examples/ccx-nasmat/nasmat/run_micromanager_nasmat.sh delete mode 100755 examples/ccx-nasmat/precice-config.xml diff --git a/.gitignore b/.gitignore index bee05410..ba077a40 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1 @@ -.vscode - bin - -# precice output files -*precice-profiling* -*precice-run* -__pycache__ - -# ccx output files -*.12d -*.cvg -*.dat -*.frd -*.sta diff --git a/examples/ccx-nasmat/ccx/clean.sh b/examples/ccx-nasmat/ccx/clean.sh deleted file mode 100644 index ad8cdce7..00000000 --- a/examples/ccx-nasmat/ccx/clean.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -set -e -u - -# ccx files -rm -rf *.12d *.cvg *.dat *.frd *.sta - -#precice files -rm -rf precice-profiling* ../precice-run* - -clear - diff --git a/examples/ccx-nasmat/ccx/config.yml b/examples/ccx-nasmat/ccx/config.yml deleted file mode 100755 index 15bfde49..00000000 --- a/examples/ccx-nasmat/ccx/config.yml +++ /dev/null @@ -1,9 +0,0 @@ -participants: - macro_ccx: - interfaces: - - elements: Eall - patch: Eall - read-data: [conv_flag, stress1to3, stress4to6, cmat1, cmat2, cmat3, cmat4, cmat5, cmat6, cmat7] - write-data: [input_id, strain1to3, strain4to6] - -precice-config-file: ../precice-config.xml diff --git a/examples/ccx-nasmat/ccx/one_element.inp b/examples/ccx-nasmat/ccx/one_element.inp deleted file mode 100755 index 46d725ed..00000000 --- a/examples/ccx-nasmat/ccx/one_element.inp +++ /dev/null @@ -1,51 +0,0 @@ -** -** Structure: One element test (Corner BC) -** Test objective: user beam element U1 -** -*NODE, NSET=Nall -1, 0.000, 1.000, 0.000 -2, 0.000, 1.000, 1.000 -3, 0.000, 0.000, 1.000 -4, 0.000, 0.000, 0.000 -5, 1.000, 1.000, 0.000 -6, 1.000, 1.000, 1.000 -7, 1.000, 0.000, 1.000 -8, 1.000, 0.000, 0.000 -*ELEMENT, TYPE=C3D8, ELSET=Eall - 1, 1, 2, 3, 4, 5, 6, 7, 8 -*MATERIAL, NAME=EL -*ELASTIC, TYPE=ANISOTROPIC -1.85e5, 40.75, 269.36e2, 5.6e1, 4.07e1, 1.84e2, 0.0, 0.0 -0.0, 1.36e2, 0.0, 0.0, 0.0, 0.0, 1.3e2, 0.0 -0.0, 0.0, 0.0,0.0, 135e0 -*SOLID SECTION,ELSET=Eall,MATERIAL=EL -*NSET, NSET=CX - 1, 2, 3, 4 -*NSET, NSET=CY - 3, 4, 7, 8 -*NSET, NSET=CZ - 2, 3, 6, 7 -*NSET, NSET=CXD - 5, 6, 7, 8 -*BOUNDARY -CX, 1 -*BOUNDARY -CY, 2 -*BOUNDARY -CZ, 3 -*STEP -*STATIC, SOLVER=PARDISO -*BOUNDARY -CXD, 1,1, 0.1 -*NODE PRINT,NSET=Nall -U -*EL PRINT,ELSET=Eall -S -*NODE FILE -U -*EL FILE -S, E -*END STEP - - - diff --git a/examples/ccx-nasmat/ccx/run.sh b/examples/ccx-nasmat/ccx/run.sh deleted file mode 100755 index 3b4bebad..00000000 --- a/examples/ccx-nasmat/ccx/run.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -set -e -u - -export OMP_NUM_THREADS=1 -export CCX_NPROC_EQUATION_SOLVER=1 -../../../bin/ccx_preCICE -i one_element -precice-participant macro_ccx diff --git a/examples/ccx-nasmat/nasmat/clean.sh b/examples/ccx-nasmat/nasmat/clean.sh deleted file mode 100755 index f406faba..00000000 --- a/examples/ccx-nasmat/nasmat/clean.sh +++ /dev/null @@ -1,7 +0,0 @@ -rm -rfv output/ -rm -fv *.log -rm -rfv __pycache__ -rm -rfv precice-profiling/ -rm -fv .nfs* - -clear diff --git a/examples/ccx-nasmat/nasmat/micro-manager-config.json b/examples/ccx-nasmat/nasmat/micro-manager-config.json deleted file mode 100644 index b441dc2c..00000000 --- a/examples/ccx-nasmat/nasmat/micro-manager-config.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "micro_file_name": "ruc_nasmat", - "coupling_params": { - "config_file_name": "../precice-config.xml", - "macro_mesh_name": "Eall", - "read_data_names": {"input_id":"scalar", - "strain1to3": "vector", - "strain4to6": "vector" - }, - "write_data_names": {"conv_flag": "scalar", - "stress1to3": "vector", - "stress4to6": "vector", - "cmat1":"vector", - "cmat2":"vector", - "cmat3":"vector", - "cmat4":"vector", - "cmat5":"vector", - "cmat6":"vector", - "cmat7":"vector" - } - }, - "simulation_params": { - "macro_domain_bounds": [0, 10000, 0, 10000, 0, 100000], - "decomposition": [1, 1, 1] - } -} diff --git a/examples/ccx-nasmat/nasmat/ruc_nasmat.py b/examples/ccx-nasmat/nasmat/ruc_nasmat.py deleted file mode 100644 index 71887bdd..00000000 --- a/examples/ccx-nasmat/nasmat/ruc_nasmat.py +++ /dev/null @@ -1,113 +0,0 @@ -""" -Solve RVE using NASMAT: https://software.nasa.gov/software/LEW-20244-1 -""" -import numpy as np -from ctypes import cdll, byref, c_double, POINTER -import time - -from pynasmat import Model, Constituent, Ruc -from pynasmat.constants import MAT_TRANSVERSE_ISOTROPIC, RUC_ARCHID_SQPACK_1FIBER, RUC_MODID_GMC_2D - -class MicroSimulation: - - def __init__(self, sim_id): - """ - Constructor of MicroSimulation class. - """ - self._dims = 3 - self._sim_id = sim_id - - print("MicroSimulation object created with ID: ", sim_id) - - def solve(self, macro_data, dt): - assert dt != 0 - - print(macro_data) - - # Processing input data - rve_id = int(macro_data["input_id"]) - mod_id = 102 - ruc_size = 16 - input_strain = np.zeros((6)) - for i in range(3): - input_strain[i] = float(macro_data["strain1to3"][i]) - input_strain[i + 3] = float(macro_data["strain4to6"][i]) - - # Building NASMAT Model - model = self.build_nasmat_model(rve_id, mod_id, ruc_size) - - # Solving RVE using NASMAT - cmat = model.homogenize(print_output=0) - print("Homogenization completed for RVE ID: ", self._sim_id) - - print(cmat) - - - # Stress calculation - stresses = np.zeros((6)) - stresses = np.dot(cmat, input_strain) - - - return {"stress1to3": stresses[0:3], "stress4to6": stresses[3:6], - "cmat1": cmat[0][0:3], "cmat2": cmat[0][3:6], - "cmat3": cmat[1][1:4], "cmat4": np.array(list(cmat[1][4:6])+list(cmat[2][2:3])), - "cmat5": cmat[2][3:6], "cmat6": cmat[3][3:6], - "cmat7": np.array(list(cmat[4][4:6])+list(cmat[5][5:6])), - "conv_flag": 1} - - def get_state(self): - # ID is returned as it is trivial. In real case, this method should return the state of the simulation. - return self._sim_id - - def set_state(self, state): - # ID is set as it is trivial. In real case, this method should set the state of the simulation. - self._sim_id = state - - def build_nasmat_model(self, rve_id, mod_id, ruc_size): - - # Building NASMAT Model - model = Model(name='example_01', id=rve_id) - - # Adding constituents - const1 = Constituent(name='Fiber', - model=MAT_TRANSVERSE_ISOTROPIC, - id=1, - data=[388.2E3, 7.6E3,0.41,0.45, 14.9E3,-0.68E-6,9.74E-6], # Units in MPa - comments='Fiber') - model.add_constituent(const1) - const2 = Constituent(name='Matrix', - model=MAT_TRANSVERSE_ISOTROPIC, - id=2, - data=[388.2E3, 7.6E3,0.41,0.45, 14.9E3,-0.68E-6,9.74E-6], # Units in MPa - comments='Matrix') - model.add_constituent(const2) - - # Adding RUC - if (mod_id%10 == 2): # 2D Model - ruc1 = Ruc( arch_id=RUC_ARCHID_SQPACK_1FIBER, - mod_id=mod_id, - nb=ruc_size, ng=ruc_size, - fiber_id=1, matrix_id=2, vf=0.6, - lh=1.0, ll=1.0) - elif (mod_id%10 == 3): # #D Model - ruc1 = Ruc(arch_id=RUC_ARCHID_SQPACK_1FIBER, - mod_id=mod_id, - na = ruc_size, nb=ruc_size, ng=ruc_size, - fiber_id=1, matrix_id=2, vf=0.6, - ld = 1.0, lh=1.0, ll=1.0) - model.add_ruc(ruc1) - return model - -def main(): - for i in range(1, 3): - sim = MicroSimulation(i) - strains = { "rve_id": i, - "mod_id": RUC_MODID_GMC_2D, - "ruc_size": 32, - "strains1to3": [0.1, 0.2, 0.3], - "strains4to6": [0.4, 0.5, 0.6]} - dt = 0.1 - print(sim.solve(strains, dt)) - -if __name__ == "__main__": - main() diff --git a/examples/ccx-nasmat/nasmat/run_micro_manager.py b/examples/ccx-nasmat/nasmat/run_micro_manager.py deleted file mode 100644 index 3cea5db3..00000000 --- a/examples/ccx-nasmat/nasmat/run_micro_manager.py +++ /dev/null @@ -1,21 +0,0 @@ -""" -Script to run the Micro Manager -""" - -from micro_manager import MicroManager -from argparse import ArgumentParser - -print("Entered the Python scrip to run the Micro Manager") - -parser = ArgumentParser() -parser.add_argument("--config", help="Path to the micro manager configuration file") -args = parser.parse_args() - -print("Accepted the config file") -print(args.config) - -manager = MicroManager(args.config) - -print("Micro Manager object created") - -manager.solve() diff --git a/examples/ccx-nasmat/nasmat/run_micromanager_nasmat.sh b/examples/ccx-nasmat/nasmat/run_micromanager_nasmat.sh deleted file mode 100755 index 8608545d..00000000 --- a/examples/ccx-nasmat/nasmat/run_micromanager_nasmat.sh +++ /dev/null @@ -1,5 +0,0 @@ -MKL_FOLDER=/opt/intel/oneapi/mkl/2023.1.0/lib/intel64 -PETSC_DIR=/usr/lib/petsc -export LD_PRELOAD=$MKL_FOLDER/libmkl_def.so.2:$MKL_FOLDER/libmkl_avx2.so.2:$MKL_FOLDER/libmkl_core.so:$MKL_FOLDER/libmkl_intel_lp64.so:$MKL_FOLDER/libmkl_intel_thread.so:/usr/lib/x86_64-linux-gnu/libomp5.so:$PETSC_DIR/lib/libpetsc_real.so:$LD_PRELOAD - -python3 run_micro_manager.py --config micro-manager-config.json diff --git a/examples/ccx-nasmat/precice-config.xml b/examples/ccx-nasmat/precice-config.xml deleted file mode 100755 index ed7eed07..00000000 --- a/examples/ccx-nasmat/precice-config.xml +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 33d08a6e566910d055eca464c7ade0bab4155702 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Thu, 11 Jul 2024 16:59:37 +0200 Subject: [PATCH 06/55] Revert to CalculiX 2.20, because the adapter only works with this version --- ccx_2.20.c | 2239 ++++++++++++++++++++++++++++++++++++++++++++++++++++ ccx_2.21.c | 1954 --------------------------------------------- 2 files changed, 2239 insertions(+), 1954 deletions(-) create mode 100644 ccx_2.20.c delete mode 100644 ccx_2.21.c diff --git a/ccx_2.20.c b/ccx_2.20.c new file mode 100644 index 00000000..84466232 --- /dev/null +++ b/ccx_2.20.c @@ -0,0 +1,2239 @@ +/* CalculiX - A 3-dimensional finite element program */ +/* Copyright (C) 1998-2022 Guido Dhondt */ + +/* This program is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License as */ +/* published by the Free Software Foundation(version 2); */ +/* */ + +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU General Public License for more details. */ + +/* You should have received a copy of the GNU General Public License */ +/* along with this program; if not, write to the Free Software */ +/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifdef __WIN32 +_set_output_format(_TWO_DIGIT_EXPONENT); +#endif + +#ifdef CALCULIX_MPI +#include +#endif + +#include +#include +#include +#include +#include "CalculiX.h" + +#ifdef CALCULIX_MPI +ITG myid = 0, nproc = 0; +#endif + +struct timespec totalCalculixTimeStart, totalCalculixTimeEnd; + +int main(int argc, char *argv[]) +{ + + FILE *f1; + + char *sideload = NULL, *set = NULL, *matname = NULL, *orname = NULL, *amname = NULL, + *filab = NULL, *lakon = NULL, *labmpc = NULL, *prlab = NULL, *prset = NULL, + jobnamec[792] = "", jobnamef[132] = "", output[5], *typeboun = NULL, + *inpc = NULL, *tieset = NULL, *cbody = NULL, fneig[132], *sideloadtemp = NULL, + kind1[2], kind2[2], *heading = NULL, *objectset = NULL; + + ITG *kon = NULL, *nodeboun = NULL, *ndirboun = NULL, *ipompc = NULL, + *nodempc = NULL, *nodeforc = NULL, *ndirforc = NULL, + *nelemload = NULL, im, *inodesd = NULL, nload1, *idefforc = NULL, + *nactdof = NULL, *icol = NULL, *ics = NULL, itempuser[3], + *jq = NULL, *mast1 = NULL, *irow = NULL, *rig = NULL, *idefbody = NULL, + *ikmpc = NULL, *ilmpc = NULL, *ikboun = NULL, *ilboun = NULL, + *nreorder = NULL, *ipointer = NULL, *idefload = NULL, + *istartset = NULL, *iendset = NULL, *ialset = NULL, *ielmat = NULL, + *ielorien = NULL, *nrhcon = NULL, *nodebounold = NULL, *ndirbounold = NULL, + *nelcon = NULL, *nalcon = NULL, *iamforc = NULL, *iamload = NULL, + *iamt1 = NULL, *namta = NULL, *ipkon = NULL, *iamboun = NULL, + *nplicon = NULL, *nplkcon = NULL, *inotr = NULL, *iponor = NULL, *knor = NULL, + *ikforc = NULL, *ilforc = NULL, *iponoel = NULL, *inoel = NULL, *nshcon = NULL, + *ncocon = NULL, *ibody = NULL, *ielprop = NULL, *islavsurf = NULL, + *ipoinpc = NULL, mt, nxstate, nload0, iload, *iuel = NULL, *ne2boun = NULL, + *irandomtype = NULL, irobustdesign[3], *iparentel = NULL, ifreebody, + *ipobody = NULL, inewton = 0, *iprfn = NULL, *konrfn = NULL; + + ITG nk, ne, nboun, nmpc, nforc, nload, nprint, nset, nalset, nentries = 18, + nmethod, neq[3], i, mpcfree, mei[4] = {0, 0, 0, 0}, j, nzl, nam, nbounold, + nforcold, nloadold, nbody, nbody_, nbodyold, network, nheading_, + k, nzs[3], nmpc_, nload_, nforc_, istep, istat, nboun_, nintpoint, + iperturb[2], nmat, ntmat_, norien, ithermal[2] = {0, 0}, nmpcold, + iprestr, kode, isolver, nslavs, nkon_, ne0, nkon0, mortar, + jout[2], nlabel, nkon, idrct, jmax[2], iexpl, nevtot, ifacecount, + iplas, npmat_, mi[3], ntrans, mpcend, namtot_, iumat, iheading, + icascade, maxlenmpc, mpcinfo[4], ne1d, ne2d, infree[4], + callfrommain, nflow, jin = 0, irstrt[2], nener, jrstrt, nenerold, + nline, *ipoinp = NULL, *inp = NULL, ntie, ntie_, mcs, nprop_, + nprop, itpamp, iviewfile, nkold, nevdamp_, npt_, cyclicsymmetry, + nmethodl, iaxial, inext, icontact, nobject, nobject_, iit, + nzsprevstep[3], memmpcref_, mpcfreeref, maxlenmpcref, *nodempcref = NULL, + *ikmpcref = NULL, isens, namtot, nstam, ndamp, nef, inp_size, + *ipoinp_sav = NULL, *inp_sav = NULL, irefineloop = 0, icoordinate = 0, + *nodedesi = NULL, ndesi = 0, nobjectstart = 0, nfc_, ndc_, nfc, ndc, *ikdc = NULL; + + ITG *meminset = NULL, *rmeminset = NULL; + + ITG nzs_, nk_, ne_, nset_ = 0, nalset_, nmat_, norien_, nam_, + ntrans_, ncs_, nstate_, ncmat_, memmpc_, nprint_, nuel_ = 0; + + double *co = NULL, *xboun = NULL, *coefmpc = NULL, *xforc = NULL, *clearini = NULL, + *xload = NULL, *xbounold = NULL, *xforcold = NULL, *randomval = NULL, + *vold = NULL, *sti = NULL, *xloadold = NULL, *xnor = NULL, + *reorder = NULL, *dcs = NULL, *thickn = NULL, *thicke = NULL, *offset = NULL, + *elcon = NULL, *rhcon = NULL, *alcon = NULL, *alzero = NULL, *t0 = NULL, *t1 = NULL, + *prestr = NULL, *orab = NULL, *amta = NULL, *veold = NULL, *accold = NULL, + *t1old = NULL, *eme = NULL, *plicon = NULL, *pslavsurf = NULL, *plkcon = NULL, + *xstate = NULL, *trab = NULL, *ener = NULL, *shcon = NULL, *cocon = NULL, + *cs = NULL, *tietol = NULL, *fmpc = NULL, *prop = NULL, *t0g = NULL, *t1g = NULL, + *xbody = NULL, *xbodyold = NULL, *coefmpcref = NULL, *dacon = NULL, *vel = NULL, + *velo = NULL, *veloo = NULL, energy[5], *ratiorfn = NULL, *dgdxglob = NULL, + *g0 = NULL, *xdesi = NULL, *coeffc = NULL, *edc = NULL; + + double ctrl[57]; + + double fei[3], *xmodal = NULL, timepar[5], alpha[2], ttime, qaold[2], physcon[14]; + + double totalCalculixTime; + + /* + * Additional variables for the coupling with preCICE + * preCICE is used only if a participant name is provided as a command line argument! + */ + char preciceParticipantName[256] = "", configFilename[256] = "config.yml"; + int preciceUsed = 0; + +#ifdef CALCULIX_MPI + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &myid); + MPI_Comm_size(MPI_COMM_WORLD, &nproc); +#endif + + clock_gettime(CLOCK_MONOTONIC, &totalCalculixTimeStart); + + if (argc == 1) { + printf("Usage: CalculiX.exe -i jobname\n"); + FORTRAN(stop, ()); + } else { + for (i = 1; i < argc; i++) { + if (strcmp1(argv[i], "-i") == 0) { + strcpy(jobnamec, argv[i + 1]); + strcpy1(jobnamef, argv[i + 1], 132); + jin++; + break; + } + if (strcmp1(argv[i], "-v") == 0) { + printf("\nThis is Version 2.20\n\n"); + FORTRAN(stop, ()); + } + } + if (jin == 0) { + strcpy(jobnamec, argv[1]); + strcpy1(jobnamef, argv[1], 132); + } + + /* next lines deactivated on March 18, 2020 */ + + /* for(i=1;i= 0) { + + fflush(stdout); + + /* in order to reduce the number of variables to be transferred to + the subroutines, the max. field sizes are (for most fields) copied + into the real sizes */ + + nzs[1] = nzs_; + + if ((istep == 0) || (irstrt[0] < 0)) { + ne = ne_; + nset = nset_; + nalset = nalset_; + nmat = nmat_; + norien = norien_; + ntrans = ntrans_; + ntie = ntie_; + + /* allocating space before the first step */ + + /* coordinates and topology */ + + NNEW(co, double, 3 * nk_); + NNEW(kon, ITG, nkon_); + NNEW(ipkon, ITG, ne_); + NNEW(lakon, char, 8 * ne_); + + /* property cards */ + + if (nprop_ > 0) { + NNEW(ielprop, ITG, ne_); + for (i = 0; i < ne_; i++) + ielprop[i] = -1; + NNEW(prop, double, nprop_); + } + + /* fields for 1-D and 2-D elements */ + + if ((ne1d != 0) || (ne2d != 0)) { + NNEW(iponor, ITG, 2 * nkon_); + for (i = 0; i < 2 * nkon_; i++) + iponor[i] = -1; + NNEW(xnor, double, 36 * ne1d + 24 * ne2d); + NNEW(knor, ITG, 24 * (ne1d + ne2d) * (mi[2] + 1)); + NNEW(thickn, double, 2 * nk_); + NNEW(thicke, double, mi[2] * nkon_); + NNEW(offset, double, 2 * ne_); + NNEW(iponoel, ITG, nk_); + NNEW(inoel, ITG, 9 * ne1d + 24 * ne2d); + NNEW(rig, ITG, nk_); + NNEW(ne2boun, ITG, 2 * nk_); + if (infree[2] == 0) + infree[2] = 1; + } + + /* SPC's */ + + NNEW(nodeboun, ITG, nboun_); + NNEW(ndirboun, ITG, nboun_); + NNEW(typeboun, char, nboun_ + 1); + if ((istep == 0) || ((irstrt[0] < 0) && (nam_ > 0))) + NNEW(iamboun, ITG, nboun_); + NNEW(xboun, double, nboun_); + NNEW(ikboun, ITG, nboun_); + NNEW(ilboun, ITG, nboun_); + + /* MPC's */ + + NNEW(ipompc, ITG, nmpc_); + NNEW(nodempc, ITG, 3 * memmpc_); + for (i = 0; i < 3 * memmpc_; i += 3) { + nodempc[i + 2] = i / 3 + 2; + } + nodempc[3 * memmpc_ - 1] = 0; + NNEW(coefmpc, double, memmpc_); + NNEW(labmpc, char, 20 * nmpc_ + 1); + NNEW(ikmpc, ITG, nmpc_); + NNEW(ilmpc, ITG, nmpc_); + NNEW(fmpc, double, nmpc_); + + /* coupling, distributed */ + + if (nfc_ > 0) { + NNEW(coeffc, double, 7 * nfc_); + NNEW(ikdc, ITG, ndc_); + NNEW(edc, double, 12 * ndc_); + } + + /* nodal loads */ + + NNEW(nodeforc, ITG, 2 * nforc_); + NNEW(ndirforc, ITG, nforc_); + if ((istep == 0) || ((irstrt[0] < 0) && (nam_ > 0))) + NNEW(iamforc, ITG, nforc_); + NNEW(idefforc, ITG, nforc_); + NNEW(xforc, double, nforc_); + NNEW(ikforc, ITG, nforc_); + NNEW(ilforc, ITG, nforc_); + + /* distributed facial loads */ + + NNEW(nelemload, ITG, 2 * nload_); + if ((istep == 0) || ((irstrt[0] < 0) && (nam_ > 0))) + NNEW(iamload, ITG, 2 * nload_); + NNEW(idefload, ITG, nload_); + NNEW(sideload, char, 20 * nload_); + NNEW(xload, double, 2 * nload_); + + /* distributed volumetric loads */ + + NNEW(cbody, char, 81 * nbody_); + NNEW(idefbody, ITG, nbody_); + NNEW(ibody, ITG, 3 * nbody_); + NNEW(xbody, double, 7 * nbody_); + NNEW(xbodyold, double, 7 * nbody_); + + /* printing output */ + + NNEW(prlab, char, 6 * nprint_); + NNEW(prset, char, 81 * nprint_); + + /* set definitions */ + + RENEW(set, char, 81 * nset); + NNEW(istartset, ITG, nset); + DMEMSET(istartset, 0, nset, 1); + NNEW(iendset, ITG, nset); + NNEW(ialset, ITG, nalset); + + /* (hyper)elastic constants */ + + NNEW(elcon, double, (ncmat_ + 1) * ntmat_ * nmat); + NNEW(nelcon, ITG, 2 * nmat); + + /* density */ + + NNEW(rhcon, double, 2 * ntmat_ * nmat); + NNEW(nrhcon, ITG, nmat); + + /* damping */ + + if (ndamp > 0) { + NNEW(dacon, double, nmat); + } + + /* specific heat */ + + NNEW(shcon, double, 4 * ntmat_ * nmat); + NNEW(nshcon, ITG, nmat); + + /* thermal expansion coefficients */ + + NNEW(alcon, double, 7 * ntmat_ * nmat); + NNEW(nalcon, ITG, 2 * nmat); + NNEW(alzero, double, nmat); + + /* conductivity */ + + NNEW(cocon, double, 7 * ntmat_ * nmat); + NNEW(ncocon, ITG, 2 * nmat); + + /* isotropic and kinematic hardening coefficients*/ + + if (npmat_ > 0) { + NNEW(plicon, double, (2 * npmat_ + 1) * ntmat_ * nmat); + NNEW(nplicon, ITG, (ntmat_ + 1) * nmat); + NNEW(plkcon, double, (2 * npmat_ + 1) * ntmat_ * nmat); + NNEW(nplkcon, ITG, (ntmat_ + 1) * nmat); + } + + /* linear dynamic properties */ + + NNEW(xmodal, double, 11 + nevdamp_); + xmodal[10] = nevdamp_ + 0.5; + + /* internal state variables (nslavs is needed for restart + calculations) */ + + if (mortar != 1) { + NNEW(xstate, double, nstate_ *mi[0] * (ne + nslavs)); + nxstate = nstate_ * mi[0] * (ne + nslavs); + } else if (mortar == 1) { + NNEW(xstate, double, nstate_ *mi[0] * (ne + nintpoint)); + nxstate = nstate_ * mi[0] * (ne + nintpoint); + } + + /* material orientation */ + + if ((istep == 0) || ((irstrt[0] < 0) && (norien > 0))) { + NNEW(orname, char, 80 * norien); + NNEW(orab, double, 7 * norien); + NNEW(ielorien, ITG, mi[2] * ne_); + } + + /* transformations */ + + if ((istep == 0) || ((irstrt[0] < 0) && (ntrans > 0))) { + NNEW(trab, double, 7 * ntrans); + NNEW(inotr, ITG, 2 * nk_); + } + + /* amplitude definitions */ + + if ((istep == 0) || ((irstrt[0] < 0) && (nam_ > 0))) { + NNEW(amname, char, 80 * nam_); + NNEW(amta, double, 2 * namtot_); + NNEW(namta, ITG, 3 * nam_); + } + + if ((istep == 0) || ((irstrt[0] < 0) && (ithermal[0] > 0))) { + NNEW(t0, double, nk_); + NNEW(t1, double, nk_); + if ((ne1d != 0) || (ne2d != 0) || (nuel_ != 0)) { + NNEW(t0g, double, 2 * nk_); + NNEW(t1g, double, 2 * nk_); + } + } + + /* the number in next line is NOT 1.2357111317 -> points + to user input; instead it is a generic nonzero + initialization */ + + if (istep == 0) { + DMEMSET(t0, 0, nk_, 1.2357111319); + DMEMSET(t1, 0, nk_, 1.2357111319); + } + + if ((istep == 0) || ((irstrt[0] < 0) && (ithermal[0] > 0) && (nam_ > 0))) + NNEW(iamt1, ITG, nk_); + + if ((istep == 0) || ((irstrt[0] < 0) && (iprestr > 0))) + NNEW(prestr, double, 6 * mi[0] * ne_); + + NNEW(vold, double, mt *nk_); + NNEW(veold, double, mt *nk_); + + /* CFD-results */ + + NNEW(vel, double, 8 * nef); + NNEW(velo, double, 8 * nef); + NNEW(veloo, double, 8 * nef); + + NNEW(ielmat, ITG, mi[2] * ne_); + + NNEW(matname, char, 80 * nmat); + + NNEW(filab, char, 87 * nlabel); + + /* tied constraints */ + + if (ntie_ > 0) { + NNEW(tieset, char, 243 * ntie_); + NNEW(tietol, double, 4 * ntie_); + NNEW(cs, double, 17 * ntie_); + } + + /* objectives for sensitivity analysis */ + + if (nobject_ > 0) { + NNEW(nodedesi, ITG, nk_); + NNEW(dgdxglob, double, nobject_ * 2 * nk_); + NNEW(g0, double, nobject_); + NNEW(xdesi, double, 3 * nk_); + NNEW(objectset, char, 405 * nobject_); + for (i = 0; i < 405 * nobject_; i++) { + objectset[i] = ' '; + } + } + + /* temporary fields for cyclic symmetry calculations */ + + if ((ncs_ > 0) || (npt_ > 0)) { + if (2 * npt_ > 24 * ncs_) { + NNEW(ics, ITG, 2 * npt_); + } else { + NNEW(ics, ITG, 24 * ncs_); + } + if (npt_ > 30 * ncs_) { + NNEW(dcs, double, npt_); + } else { + NNEW(dcs, double, 30 * ncs_); + } + } + + /* slave faces */ + + NNEW(islavsurf, ITG, 2 * ifacecount + 2); + + /* robustdesign analysis */ + + if (irobustdesign[0] > 0) { + NNEW(irandomtype, ITG, nk_); + NNEW(randomval, double, 2 * nk_); + } + + } else { + + /* allocating and reallocating space for subsequent steps */ + + if ((nmethod != 4) && (nmethod != 5) && (nmethod != 8) && (nmethod != 9) && + ((abs(nmethod) != 1) || (iperturb[0] < 2))) { + NNEW(veold, double, mt *nk_); + } else { + RENEW(veold, double, mt *nk_); + DMEMSET(veold, mt * nk, mt * nk_, 0.); + } + RENEW(vold, double, mt *nk_); + DMEMSET(vold, mt * nk, mt * nk_, 0.); + + RENEW(nodeboun, ITG, nboun_); + RENEW(ndirboun, ITG, nboun_); + RENEW(typeboun, char, nboun_ + 1); + RENEW(xboun, double, nboun_); + RENEW(ikboun, ITG, nboun_); + RENEW(ilboun, ITG, nboun_); + + RENEW(nodeforc, ITG, 2 * nforc_); + RENEW(ndirforc, ITG, nforc_); + NNEW(idefforc, ITG, nforc_); + RENEW(xforc, double, nforc_); + RENEW(ikforc, ITG, nforc_); + RENEW(ilforc, ITG, nforc_); + + RENEW(nelemload, ITG, 2 * nload_); + NNEW(idefload, ITG, nload_); + RENEW(sideload, char, 20 * nload_); + RENEW(xload, double, 2 * nload_); + + RENEW(cbody, char, 81 * nbody_); + NNEW(idefbody, ITG, nbody_); + RENEW(ibody, ITG, 3 * nbody_); + RENEW(xbody, double, 7 * nbody_); + RENEW(xbodyold, double, 7 * nbody_); + for (i = 7 * nbodyold; i < 7 * nbody_; i++) + xbodyold[i] = 0; + + if (nam > 0) { + RENEW(iamforc, ITG, nforc_); + RENEW(iamload, ITG, 2 * nload_); + RENEW(iamboun, ITG, nboun_); + RENEW(amname, char, 80 * nam_); + RENEW(amta, double, 2 * namtot_); + RENEW(namta, ITG, 3 * nam_); + } + + RENEW(ipompc, ITG, nmpc_); + + RENEW(labmpc, char, 20 * nmpc_ + 1); + RENEW(ikmpc, ITG, nmpc_); + RENEW(ilmpc, ITG, nmpc_); + RENEW(fmpc, double, nmpc_); + + if (ntrans > 0) { + RENEW(inotr, ITG, 2 * nk_); + DMEMSET(inotr, 2 * nk, 2 * nk_, 0); + } + + RENEW(co, double, 3 * nk_); + DMEMSET(co, 3 * nk, 3 * nk_, 0.); + + if (ithermal[0] != 0) { + RENEW(t0, double, nk_); + DMEMSET(t0, nk, nk_, 0.); + RENEW(t1, double, nk_); + DMEMSET(t1, nk, nk_, 0.); + if ((ne1d != 0) || (ne2d != 0) || (nuel_ != 0)) { + RENEW(t0g, double, 2 * nk_); + DMEMSET(t0g, 2 * nk, 2 * nk_, 0.); + RENEW(t1g, double, 2 * nk_); + DMEMSET(t1g, 2 * nk, 2 * nk_, 0.); + } + if (nam > 0) { + RENEW(iamt1, ITG, nk_); + } + } + } + + /* allocation of fields in the restart file */ + + if (irstrt[0] < 0) { + NNEW(nodebounold, ITG, nboun_); + NNEW(ndirbounold, ITG, nboun_); + NNEW(xbounold, double, nboun_); + NNEW(xforcold, double, nforc_); + NNEW(xloadold, double, 2 * nload_); + if (ithermal[0] != 0) + NNEW(t1old, double, nk_); + NNEW(sti, double, 6 * mi[0] * ne); + NNEW(eme, double, 6 * mi[0] * ne); + if (nener == 1) + NNEW(ener, double, mi[0] * ne * 2); + if (mcs > ntie_) + RENEW(cs, double, 17 * mcs); + if (mortar == 1) { + NNEW(pslavsurf, double, 3 * nintpoint); + NNEW(clearini, double, 3 * 9 * ifacecount); + } + } + + nenerold = nener; + nkold = nk; + + /* opening the eigenvalue file and checking for cyclic symmetry */ + + strcpy(fneig, jobnamec); + strcat(fneig, ".eig"); + cyclicsymmetry = 0; + if ((f1 = fopen(fneig, "rb")) != NULL) { + if (fread(&cyclicsymmetry, sizeof(ITG), 1, f1) != 1) { + printf(" *ERROR reading the information whether cyclic symmetry is involved in the eigenvalue file"); + exit(0); + } + fclose(f1); + } + + nmpcold = nmpc; + + /* reading the input file */ + + // if(istep==0)mortar=-2; + FORTRAN(calinput, (co, &nk, kon, ipkon, lakon, &nkon, &ne, nodeboun, ndirboun, xboun, + &nboun, ipompc, nodempc, coefmpc, &nmpc, &nmpc_, nodeforc, + ndirforc, xforc, &nforc, &nforc_, nelemload, sideload, xload, + &nload, &nload_, &nprint, prlab, prset, &mpcfree, &nboun_, mei, + set, istartset, iendset, ialset, &nset, &nalset, elcon, nelcon, + rhcon, nrhcon, alcon, nalcon, alzero, t0, t1, matname, ielmat, + orname, orab, ielorien, amname, amta, namta, &nam, &nmethod, + iamforc, iamload, iamt1, ithermal, iperturb, &istat, &istep, + &nmat, &ntmat_, &norien, prestr, &iprestr, &isolver, fei, veold, + timepar, xmodal, filab, jout, &nlabel, &idrct, jmax, &iexpl, + alpha, iamboun, plicon, nplicon, plkcon, nplkcon, &iplas, + &npmat_, mi, &nk_, trab, inotr, &ntrans, ikboun, ilboun, ikmpc, + ilmpc, ics, dcs, &ncs_, &namtot_, cs, &nstate_, &ncmat_, &iumat, + &mcs, labmpc, iponor, xnor, knor, thickn, thicke, ikforc, ilforc, + offset, iponoel, inoel, rig, infree, nshcon, shcon, cocon, + ncocon, physcon, &nflow, ctrl, &maxlenmpc, &ne1d, &ne2d, &nener, + vold, nodebounold, ndirbounold, xbounold, xforcold, xloadold, + t1old, eme, sti, ener, xstate, jobnamec, irstrt, &ttime, qaold, + output, typeboun, inpc, ipoinp, inp, tieset, tietol, &ntie, fmpc, + cbody, ibody, xbody, &nbody, &nbody_, xbodyold, &nam_, ielprop, + &nprop, &nprop_, prop, &itpamp, &iviewfile, ipoinpc, &nslavs, + t0g, t1g, &network, &cyclicsymmetry, idefforc, idefload, + idefbody, &mortar, &ifacecount, islavsurf, pslavsurf, + clearini, heading, &iaxial, &nobject, objectset, &nprint_, + iuel, &nuel_, nodempcref, coefmpcref, ikmpcref, &memmpcref_, + &mpcfreeref, &maxlenmpcref, &memmpc_, &isens, &namtot, &nstam, + dacon, vel, &nef, velo, veloo, ne2boun, itempuser, + irobustdesign, irandomtype, randomval, &nfc, &nfc_, coeffc, + ikdc, &ndc, &ndc_, edc)); + + SFREE(idefforc); + SFREE(idefload); + SFREE(idefbody); + + if (istat < 0) + break; + + /* assigning the body forces to the elements */ + + if (nbody > 0) { + ifreebody = ne + 1; + NNEW(ipobody, ITG, 2 * ifreebody * nbody); + for (k = 1; k <= nbody; k++) { + FORTRAN(bodyforce, (cbody, ibody, ipobody, &nbody, set, istartset, + iendset, ialset, &inewton, &nset, &ifreebody, &k)); + RENEW(ipobody, ITG, 2 * (ne + ifreebody)); + } + RENEW(ipobody, ITG, 2 * (ifreebody - 1)); + } + + if (irefineloop == 1) { + + /* in the last step refinement was requested and the mesh + was appropriately refined; this mesh has to be read */ + + readnewmesh(jobnamec, &nboun, nodeboun, iamboun, xboun, &nload, sideload, + iamload, &nforc, nodeforc, iamforc, xforc, ithermal, &nk, &t1, &iamt1, + &ne, &lakon, &ipkon, &kon, istartset, iendset, ialset, set, &nset, + filab, &co, &ipompc, &nodempc, &coefmpc, &nmpc, &nmpc_, &labmpc, + &mpcfree, &memmpc_, &ikmpc, &ilmpc, &nk_, &ne_, &nkon_, &istep, + &nprop_, &ielprop, &ne1d, &ne2d, &iponor, &thickn, &thicke, mi, + &offset, &iponoel, &rig, &ne2boun, &ielorien, &inotr, &t0, &t0g, &t1g, + &prestr, &vold, &veold, &ielmat, irobustdesign, &irandomtype, + &randomval, &nalset, &nalset_, &nkon, xnor, &iaxial, + &network, &nlabel, iuel, iperturb, &iprestr, &ntie, tieset, + &iparentel, ikboun, &ifreebody, &ipobody, &nbody, &iprfn, + &konrfn, &ratiorfn, nodempcref, coefmpcref, &memmpcref_, + &mpcfreeref, &maxlenmpcref, &maxlenmpc, &norien, tietol); + } + +#ifdef CALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT + for (i = 0; i != nmat; ++i) { + calculix_registerExternalBehaviour(matname + 80 * i); + } +#endif /* CALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT */ + + // if((istep==1)&&(mortar==-1)){mortar=0;}else{icontact=1;} + + nload0 = nload; + + if (iheading == 0) { + writeheading(jobnamec, heading, &nheading_); + iheading = 1; + } + + /* if(nheading_>=0){ + writeheading(jobnamec,heading,&nheading_); + SFREE(heading); + nheading_=-1; + }*/ + + if ((abs(nmethod) != 1) || (iperturb[0] < 2)) + icascade = 0; + + // FORTRAN(writeboun,(nodeboun,ndirboun,xboun,typeboun,&nboun)); + + if (istep == 1) { + + SFREE(iuel); + + /* tied contact constraints: generate appropriate MPC's */ + + tiedcontact(&ntie, tieset, &nset, set, istartset, iendset, ialset, + lakon, ipkon, kon, tietol, &nmpc, &mpcfree, &memmpc_, + &ipompc, &labmpc, &ikmpc, &ilmpc, &fmpc, &nodempc, &coefmpc, + ithermal, co, vold, &nef, &nmpc_, mi, &nk, &istep, ikboun, &nboun, + kind1, kind2, jobnamef); + + /* reallocating space in the first step */ + + /* allocating and initializing fields pointing to the previous step */ + + RENEW(vold, double, mt *nk); + NNEW(sti, double, 6 * mi[0] * ne); + + /* strains */ + + NNEW(eme, double, 6 * mi[0] * ne); + + /* residual stresses/strains */ + + if (iprestr == 1) { + RENEW(prestr, double, 6 * mi[0] * ne); + for (i = 0; i < ne; i++) { + for (j = 0; j < mi[0]; j++) { + for (k = 0; k < 6; k++) { + sti[6 * mi[0] * i + 6 * j + k] = prestr[6 * mi[0] * i + 6 * j + k]; + } + } + } + } else if (iprestr == 2) { + RENEW(prestr, double, 6 * mi[0] * ne); + for (i = 0; i < ne; i++) { + for (j = 0; j < mi[0]; j++) { + for (k = 0; k < 6; k++) { + eme[6 * mi[0] * i + 6 * j + k] = prestr[6 * mi[0] * i + 6 * j + k]; + } + } + } + } else { + SFREE(prestr); + } + + NNEW(nodebounold, ITG, nboun); + NNEW(ndirbounold, ITG, nboun); + NNEW(xbounold, double, nboun); + NNEW(xforcold, double, nforc); + NNEW(xloadold, double, 2 * nload); + + /* initial temperatures: store in the "old" boundary conditions */ + + if (ithermal[0] > 1) { + for (i = 0; i < nboun; i++) { + if (strcmp1(&typeboun[i], "F") == 0) + continue; + if (ndirboun[i] == 0) { + xbounold[i] = vold[mt * (nodeboun[i] - 1)]; + } + } + } + + /* initial temperatures: store in the "old" temperature field */ + + if (ithermal[0] != 0) { + NNEW(t1old, double, nk); + for (i = 0; i < nk; i++) + t1old[i] = t0[i]; + } + + /* element definition */ + + RENEW(kon, ITG, nkon); + RENEW(ipkon, ITG, ne); + RENEW(lakon, char, 8 * ne); + + /* property cards */ + + if (nprop_ > 0) { + RENEW(ielprop, ITG, ne); + RENEW(prop, double, nprop); + } else { + SFREE(ielprop); + SFREE(prop); + } + + /* coupling, distributed */ + + if (nfc > 0) { + RENEW(coeffc, double, 7 * nfc); + RENEW(ikdc, ITG, ndc); + RENEW(edc, double, 12 * ndc); + } else { + SFREE(coeffc); + SFREE(ikdc); + SFREE(edc); + } + + /* fields for 1-D and 2-D elements */ + + if ((ne1d != 0) || (ne2d != 0)) { + RENEW(iponor, ITG, 2 * nkon); + RENEW(xnor, double, infree[0]); + RENEW(knor, ITG, infree[1]); + SFREE(thickn); + RENEW(thicke, double, mi[2] * nkon); + RENEW(offset, double, 2 * ne); + RENEW(inoel, ITG, 3 * (infree[2] - 1)); + RENEW(iponoel, ITG, infree[3]); + RENEW(rig, ITG, infree[3]); + RENEW(ne2boun, ITG, 2 * infree[3]); + } + + /* set definitions */ + + RENEW(set, char, 81 * nset); + RENEW(istartset, ITG, nset); + RENEW(iendset, ITG, nset); + RENEW(ialset, ITG, nalset); + + /* material properties */ + + RENEW(elcon, double, (ncmat_ + 1) * ntmat_ * nmat); + RENEW(nelcon, ITG, 2 * nmat); + + RENEW(rhcon, double, 2 * ntmat_ * nmat); + RENEW(nrhcon, ITG, nmat); + + if (ndamp > 0) { + RENEW(dacon, double, nmat); + } + + RENEW(shcon, double, 4 * ntmat_ * nmat); + RENEW(nshcon, ITG, nmat); + + RENEW(cocon, double, 7 * ntmat_ * nmat); + RENEW(ncocon, ITG, 2 * nmat); + + RENEW(alcon, double, 7 * ntmat_ * nmat); + RENEW(nalcon, ITG, 2 * nmat); + RENEW(alzero, double, nmat); + + RENEW(matname, char, 80 * nmat); + RENEW(ielmat, ITG, mi[2] * ne); + + /* allocating space for the state variables */ + + if (mortar != 1) { + RENEW(xstate, double, nstate_ *mi[0] * (ne + nslavs)); + for (i = nxstate; i < nstate_ * mi[0] * (ne + nslavs); i++) { + xstate[i] = 0.; + } + } else if (mortar == 1) { + RENEW(xstate, double, nstate_ *mi[0] * (ne + nintpoint)); + for (i = nxstate; i < nstate_ * mi[0] * (ne + nintpoint); i++) { + xstate[i] = 0.; + } + } + + /* next statements for plastic materials and nonlinear springs */ + + if (npmat_ > 0) { + RENEW(plicon, double, (2 * npmat_ + 1) * ntmat_ * nmat); + RENEW(nplicon, ITG, (ntmat_ + 1) * nmat); + RENEW(plkcon, double, (2 * npmat_ + 1) * ntmat_ * nmat); + RENEW(nplkcon, ITG, (ntmat_ + 1) * nmat); + } + + /* material orientation */ + + if (norien > 0) { + RENEW(orname, char, 80 * norien); + RENEW(ielorien, ITG, mi[2] * ne); + RENEW(orab, double, 7 * norien); + } else { + SFREE(orname); + SFREE(ielorien); + SFREE(orab); + } + + /* amplitude definitions */ + + if (nam > 0) { + RENEW(amname, char, 80 * nam); + RENEW(namta, ITG, 3 * nam); + RENEW(amta, double, 2 * namta[3 * nam - 2]); + } else { + SFREE(amname); + SFREE(amta); + SFREE(namta); + SFREE(iamforc); + SFREE(iamload); + SFREE(iamboun); + } + + if (ntrans > 0) { + RENEW(trab, double, 7 * ntrans); + } else { + SFREE(trab); + SFREE(inotr); + } + + if (ithermal[0] == 0) { + SFREE(t0); + SFREE(t1); + if ((ne1d != 0) || (ne2d != 0) || (nuel_ != 0)) { + SFREE(t0g); + SFREE(t1g); + } + } + + if ((ithermal[0] == 0) || (nam <= 0)) { + SFREE(iamt1); + } + + if (ncs_ > 0) { + RENEW(ics, ITG, ncs_); + } else if (npt_ > 0) { + SFREE(ics); + } + if ((ncs_ > 0) || (npt_ > 0)) { + SFREE(dcs); + } + + if (mcs > 0) { + RENEW(cs, double, 17 * mcs); + } else { + SFREE(cs); + } + + /* check for design variables */ + + for (i = 0; i < ntie; i++) { + if (strcmp1(&tieset[i * 243 + 80], "D") == 0) { + if (strcmp1(&tieset[i * 243], "COORDINATE") == 0) { + icoordinate = 1; + } + } + } + + } else { + + /* reallocating space in all but the first step (>1) */ + + RENEW(vold, double, mt *nk); + + /* if the SPC boundary conditions were changed in the present step, + they have to be rematched with those in the last step. Removed SPC + boundary conditions do not appear any more (this is different from + forces and loads, where removed forces or loads are reset to zero; + a removed SPC constraint does not have a numerical value any more) */ + + NNEW(reorder, double, nboun); + NNEW(nreorder, ITG, nboun); + if (nbounold < nboun) { + RENEW(xbounold, double, nboun); + RENEW(nodebounold, ITG, nboun); + RENEW(ndirbounold, ITG, nboun); + } + FORTRAN(spcmatch, (xboun, nodeboun, ndirboun, &nboun, xbounold, nodebounold, + ndirbounold, &nbounold, ikboun, ilboun, vold, reorder, nreorder, + mi, typeboun)); + RENEW(xbounold, double, nboun); + RENEW(nodebounold, ITG, nboun); + RENEW(ndirbounold, ITG, nboun); + SFREE(reorder); + SFREE(nreorder); + + /* for additional forces or loads in the present step, the + corresponding slots in the force and load fields of the + previous steps are initialized */ + + RENEW(xforcold, double, nforc); + for (i = nforcold; i < nforc; i++) + xforcold[i] = 0; + + RENEW(xloadold, double, 2 * nload); + for (i = 2 * nloadold; i < 2 * nload; i++) + xloadold[i] = 0; + + if (ithermal[0] != 0) { + RENEW(t1old, double, nk); + } + + if (nam > 0) { + RENEW(amname, char, 80 * nam); + RENEW(namta, ITG, 3 * nam); + RENEW(amta, double, 2 * namta[3 * nam - 2]); + } + } + + /* reallocating fields for all steps (>=1) */ + + RENEW(co, double, 3 * nk); + + RENEW(nodeboun, ITG, nboun); + RENEW(ndirboun, ITG, nboun); + RENEW(typeboun, char, nboun + 1); + RENEW(xboun, double, nboun); + RENEW(ikboun, ITG, nboun); + RENEW(ilboun, ITG, nboun); + + RENEW(nodeforc, ITG, 2 * nforc); + RENEW(ndirforc, ITG, nforc); + RENEW(xforc, double, nforc); + RENEW(ikforc, ITG, nforc); + RENEW(ilforc, ITG, nforc); + + /* temperature loading */ + + if (ithermal[0] != 0) { + RENEW(t0, double, nk); + RENEW(t1, double, nk); + if ((ne1d != 0) || (ne2d != 0) || (nuel_ != 0)) { + RENEW(t0g, double, 2 * nk); + RENEW(t1g, double, 2 * nk); + } + if (nam > 0) { + RENEW(iamt1, ITG, nk); + } + } + + RENEW(nelemload, ITG, 2 * nload); + RENEW(sideload, char, 20 * nload); + RENEW(xload, double, 2 * nload); + + RENEW(cbody, char, 81 * nbody); + RENEW(ibody, ITG, 3 * nbody); + RENEW(xbody, double, 7 * nbody); + RENEW(xbodyold, double, 7 * nbody); + + RENEW(ipompc, ITG, nmpc); + RENEW(labmpc, char, 20 * nmpc + 1); + RENEW(ikmpc, ITG, nmpc); + RENEW(ilmpc, ITG, nmpc); + RENEW(fmpc, double, nmpc); + + /* energy */ + + if ((nener == 1) && (nenerold == 0)) { + NNEW(ener, double, mi[0] * ne * 2); + if ((istep > 1) && (iperturb[0] > 1)) { + printf(" *ERROR in CalculiX: in nonlinear calculations\n"); + printf(" energy output must be selected in the first step\n\n"); + FORTRAN(stop, ()); + } + } + + /* initial velocities and accelerations */ + + if ((nmethod == 4) || (nmethod == 5) || (nmethod == 8) || (nmethod == 9) || + ((abs(nmethod) == 1) && (iperturb[0] >= 2))) { + RENEW(veold, double, mt *nk); + } else { + SFREE(veold); + } + + if ((nmethod == 4) && (iperturb[0] > 1)) { + NNEW(accold, double, mt *nk); + } + + if (nam > 0) { + RENEW(iamforc, ITG, nforc); + RENEW(iamload, ITG, 2 * nload); + RENEW(iamboun, ITG, nboun); + } + + /* generate force convection elements */ + + if (network > 0) { + ne0 = ne; + nkon0 = nkon; + nload1 = nload; + RENEW(ipkon, ITG, ne + nload); + RENEW(ielmat, ITG, mi[2] * (ne + nload)); + for (i = mi[2] * ne; i < mi[2] * (ne + nload); i++) + ielmat[i] = 0; + if (norien > 0) { + RENEW(ielorien, ITG, mi[2] * (ne + nload)); + for (i = mi[2] * ne; i < mi[2] * (ne + nload); i++) + ielorien[i] = 0; + } + RENEW(lakon, char, 8 * (ne + nload)); + RENEW(kon, ITG, nkon + 9 * nload); + NNEW(inodesd, ITG, nk); + RENEW(nelemload, ITG, 4 * nload); + RENEW(sideload, char, 40 * nload); + + FORTRAN(genadvecelem, (inodesd, ipkon, &ne, lakon, kon, &nload, + sideload, nelemload, &nkon, &network)); + + SFREE(inodesd); + RENEW(ipkon, ITG, ne); + RENEW(lakon, char, 8 * ne); + RENEW(kon, ITG, nkon); + RENEW(sti, double, 6 * mi[0] * ne); + RENEW(eme, double, 6 * mi[0] * ne); + if (iprestr > 0) + RENEW(prestr, double, 6 * mi[0] * ne); + if (nprop > 0) + RENEW(ielprop, ITG, ne); + if ((ne1d != 0) || (ne2d != 0)) + RENEW(offset, double, 2 * ne); + RENEW(nelemload, ITG, 2 * nload); + RENEW(sideload, char, 20 * nload); + RENEW(xload, double, 2 * nload); + RENEW(xloadold, double, 2 * nload); + if (nam > 0) { + RENEW(iamload, ITG, 2 * nload); + for (i = 2 * nload1; i < 2 * nload; i++) + iamload[i] = 0; + } + if (nener == 1) + RENEW(ener, double, mi[0] * ne * 2); + if (norien > 0) + RENEW(ielorien, ITG, mi[2] * ne); + RENEW(ielmat, ITG, mi[2] * ne); + for (i = mi[2] * ne0; i < mi[2] * ne; i++) + ielmat[i] = 1; + } + + if (ntrans > 0) { + RENEW(inotr, ITG, 2 * nk); + } + + /* calling the user routine ufaceload (can be empty) */ + + if (ithermal[1] >= 2) { + NNEW(sideloadtemp, char, 20 * nload); + for (i = 0; i < nload; i++) { + strcpy1(&sideloadtemp[20 * i], &sideload[20 * i], 20); + if ((strcmp1(&sideload[20 * i], " ") == 0) && + (strcmp1(&sideload[20 * i + 1], " ") != 0)) { + strcpy1(&sideloadtemp[20 * i], "F", 1); + } + } + FORTRAN(ufaceload, (co, ipkon, kon, lakon, &nboun, nodeboun, + nelemload, sideloadtemp, &nload, &ne, &nk)); + SFREE(sideloadtemp); + } + + /* storing the undecascaded MPC's if needed (triggered by + mpcfreeref=-1); this is the case: + 1) in the first step always + 2) in any subsequent step in which the MPC's were changed by + the user in the input deck */ + + if (mpcfreeref == -1) { + if (istep > 1) { + SFREE(nodempcref); + SFREE(coefmpcref); + SFREE(ikmpcref); + } + memmpcref_ = memmpc_; + mpcfreeref = mpcfree; + maxlenmpcref = maxlenmpc; + NNEW(nodempcref, ITG, 3 * memmpc_); + memcpy(nodempcref, nodempc, sizeof(ITG) * 3 * memmpc_); + NNEW(coefmpcref, double, memmpc_); + memcpy(coefmpcref, coefmpc, sizeof(double) * memmpc_); + NNEW(ikmpcref, ITG, nmpc); + memcpy(ikmpcref, ikmpc, sizeof(ITG) * nmpc); + } + + /* decascading MPC's only necessary if MPC's changed */ + + if (((istep == 1) || (ntrans > 0) || (mpcend < 0) || (nk != nkold) || (nmpc != nmpcold)) && (icascade == 0)) { + + /* decascading the MPC's */ + + printf(" Decascading the MPC's\n\n"); + + callfrommain = 1; + cascade(ipompc, &coefmpc, &nodempc, &nmpc, + &mpcfree, nodeboun, ndirboun, &nboun, ikmpc, + ilmpc, ikboun, ilboun, &mpcend, + labmpc, &nk, &memmpc_, &icascade, &maxlenmpc, + &callfrommain, iperturb, ithermal); + } + + /* determining the matrix structure: changes if SPC's have changed */ + + if ((icascade == 0) && (nmethod < 8)) + printf(" Determining the structure of the matrix:\n"); + + NNEW(nactdof, ITG, mt * nk); + NNEW(mast1, ITG, nzs[1]); + NNEW(irow, ITG, 1); + + if ((mcs == 0) || (cs[1] < 0)) { + + NNEW(icol, ITG, mt * nk); + NNEW(jq, ITG, mt * nk + 1); + NNEW(ipointer, ITG, mt * nk); + + if ((icascade == 0) && ((nmethod < 8) || (nmethod > 10))) { + if ((nmethod == 11) || (nmethod == 13)) { + nmethodl = 2; + } else { + nmethodl = nmethod; + } + mastruct(&nk, kon, ipkon, lakon, &ne, nodeboun, ndirboun, &nboun, ipompc, + nodempc, &nmpc, nactdof, icol, jq, &mast1, &irow, &isolver, neq, + ikmpc, ilmpc, ipointer, nzs, &nmethodl, ithermal, + ikboun, ilboun, iperturb, mi, &mortar, typeboun, labmpc, + &iit, &icascade, &network, &iexpl); + } else { + neq[0] = 1; + neq[1] = 1; + neq[2] = 1; + } + } else { + + NNEW(icol, ITG, 8 * nk); + NNEW(jq, ITG, 8 * nk + 1); + NNEW(ipointer, ITG, 8 * nk); + + if (nmethod == 13) { + nmethodl = 2; + } else { + nmethodl = nmethod; + } + mastructcs(&nk, kon, ipkon, lakon, &ne, nodeboun, ndirboun, &nboun, + ipompc, nodempc, &nmpc, nactdof, icol, jq, &mast1, &irow, &isolver, + neq, ikmpc, ilmpc, ipointer, nzs, &nmethodl, + ics, cs, labmpc, &mcs, mi, &mortar); + } + + SFREE(ipointer); + SFREE(mast1); + if ((icascade == 0) && (nmethod < 8)) + RENEW(irow, ITG, nzs[2]); + + /* nmethod=1: static analysis */ + /* nmethod=2: frequency analysis */ + /* nmethod=3: buckling analysis */ + /* nmethod=4: (linear or nonlinear) dynamic analysis */ + /* nmethod=5: steady state dynamics analysis */ + /* nmethod=6: Coriolis frequency calculation */ + /* nmethod=7: flutter frequency calculation */ + /* nmethod=8: magnetostatics */ + /* nmethod=9: magnetodynamics */ + /* nmethod=10: electromagnetic eigenvalue problems */ + /* nmethod=11: superelement creation */ + /* nmethod=12: sensitivity analysis */ + /* nmethod=13: Green function calculation */ + /* nmethod=14: Robustness w.r.t. to geometric tolerances */ + /* nmethod=15: Crack propagation */ + /* nmethod=16: Feasible direction based on sensitivity information */ + if (preciceUsed) { + int isStaticOrDynamic = ((nmethod == 1) || (nmethod == 4)) && (iperturb[0] > 1); + int isDynamic = ((nmethod == 4) && (iperturb[0] > 1)); + int isThermalAnalysis = ithermal[0] >= 2; + int isModalDynamic = ((nmethod == 4) && (iperturb[0] < 2)); + int isStaticNLGEOM = ((nmethod == 1) && (iperturb[0] > 1)); + + if (isStaticOrDynamic && isThermalAnalysis) { + + printf("Starting CHT analysis via preCICE...\n"); + + mpcinfo[0] = memmpc_; + mpcinfo[1] = mpcfree; + mpcinfo[2] = icascade; + mpcinfo[3] = maxlenmpc; + + nonlingeo_precice(&co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, + &nboun, &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, + ndirforc, xforc, &nforc, &nelemload, &sideload, xload, &nload, + nactdof, &icol, jq, &irow, neq, &nzl, &nmethod, &ikmpc, &ilmpc, + ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, alcon, nalcon, + alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, t0, t1, t1old, + ithermal, prestr, &iprestr, &vold, iperturb, sti, nzs, &kode, + filab, &idrct, jmax, jout, timepar, eme, xbounold, xforcold, + xloadold, veold, accold, amname, amta, namta, &nam, iamforc, + &iamload, iamt1, alpha, &iexpl, iamboun, plicon, nplicon, plkcon, + nplkcon, &xstate, &npmat_, &istep, &ttime, matname, qaold, mi, + &isolver, &ncmat_, &nstate_, &iumat, cs, &mcs, &nkon, &ener, + mpcinfo, output, shcon, nshcon, cocon, ncocon, physcon, &nflow, + ctrl, set, &nset, istartset, iendset, ialset, &nprint, prlab, + prset, &nener, ikforc, ilforc, trab, inotr, &ntrans, &fmpc, cbody, + ibody, xbody, &nbody, xbodyold, ielprop, prop, &ntie, tieset, + &itpamp, &iviewfile, jobnamec, tietol, &nslavs, thicke, ics, + &nintpoint, &mortar, &ifacecount, typeboun, &islavsurf, + &pslavsurf, &clearini, &nmat, xmodal, &iaxial, &inext, &nprop, + &network, orname, vel, &nef, velo, veloo, energy, itempuser, + ipobody, &inewton, t0g, t1g, &ifreebody, + /* PreCICE args */ + preciceParticipantName, configFilename); + + memmpc_ = mpcinfo[0]; + mpcfree = mpcinfo[1]; + icascade = mpcinfo[2]; + maxlenmpc = mpcinfo[3]; + + } else if (isDynamic && !isThermalAnalysis) { + + printf("Starting FSI analysis via preCICE"); + + if (iperturb[1] == 0) { + printf(" using the geometrically linear CalculiX solver...\n"); + + mpcinfo[0] = memmpc_; + mpcinfo[1] = mpcfree; + mpcinfo[2] = icascade; + mpcinfo[3] = maxlenmpc; + + nonlingeo_precice(&co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, + &nboun, &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, + ndirforc, xforc, &nforc, &nelemload, &sideload, xload, &nload, + nactdof, &icol, jq, &irow, neq, &nzl, &nmethod, &ikmpc, &ilmpc, + ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, alcon, nalcon, + alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, t0, t1, t1old, + ithermal, prestr, &iprestr, &vold, iperturb, sti, nzs, &kode, + filab, &idrct, jmax, jout, timepar, eme, xbounold, xforcold, + xloadold, veold, accold, amname, amta, namta, &nam, iamforc, + &iamload, iamt1, alpha, &iexpl, iamboun, plicon, nplicon, plkcon, + nplkcon, &xstate, &npmat_, &istep, &ttime, matname, qaold, mi, + &isolver, &ncmat_, &nstate_, &iumat, cs, &mcs, &nkon, &ener, + mpcinfo, output, shcon, nshcon, cocon, ncocon, physcon, &nflow, + ctrl, set, &nset, istartset, iendset, ialset, &nprint, prlab, + prset, &nener, ikforc, ilforc, trab, inotr, &ntrans, &fmpc, cbody, + ibody, xbody, &nbody, xbodyold, ielprop, prop, &ntie, tieset, + &itpamp, &iviewfile, jobnamec, tietol, &nslavs, thicke, ics, + &nintpoint, &mortar, &ifacecount, typeboun, &islavsurf, + &pslavsurf, &clearini, &nmat, xmodal, &iaxial, &inext, &nprop, + &network, orname, vel, &nef, velo, veloo, energy, itempuser, + ipobody, &inewton, t0g, t1g, &ifreebody, + /* PreCICE args */ + preciceParticipantName, configFilename); + + memmpc_ = mpcinfo[0]; + mpcfree = mpcinfo[1]; + icascade = mpcinfo[2]; + maxlenmpc = mpcinfo[3]; + } else if (iperturb[1] == 1) { + printf(" using the geometrically non-linear CalculiX solver...\n"); + + mpcinfo[0] = memmpc_; + mpcinfo[1] = mpcfree; + mpcinfo[2] = icascade; + mpcinfo[3] = maxlenmpc; + + nonlingeo_precice(&co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, + &nboun, &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, + ndirforc, xforc, &nforc, &nelemload, &sideload, xload, &nload, + nactdof, &icol, jq, &irow, neq, &nzl, &nmethod, &ikmpc, &ilmpc, + ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, alcon, nalcon, + alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, t0, t1, t1old, + ithermal, prestr, &iprestr, &vold, iperturb, sti, nzs, &kode, + filab, &idrct, jmax, jout, timepar, eme, xbounold, xforcold, + xloadold, veold, accold, amname, amta, namta, &nam, iamforc, + &iamload, iamt1, alpha, &iexpl, iamboun, plicon, nplicon, plkcon, + nplkcon, &xstate, &npmat_, &istep, &ttime, matname, qaold, mi, + &isolver, &ncmat_, &nstate_, &iumat, cs, &mcs, &nkon, &ener, + mpcinfo, output, shcon, nshcon, cocon, ncocon, physcon, &nflow, + ctrl, set, &nset, istartset, iendset, ialset, &nprint, prlab, + prset, &nener, ikforc, ilforc, trab, inotr, &ntrans, &fmpc, cbody, + ibody, xbody, &nbody, xbodyold, ielprop, prop, &ntie, tieset, + &itpamp, &iviewfile, jobnamec, tietol, &nslavs, thicke, ics, + &nintpoint, &mortar, &ifacecount, typeboun, &islavsurf, + &pslavsurf, &clearini, &nmat, xmodal, &iaxial, &inext, &nprop, + &network, orname, vel, &nef, velo, veloo, energy, itempuser, + ipobody, &inewton, t0g, t1g, &ifreebody, + /* PreCICE args */ + preciceParticipantName, configFilename); + + memmpc_ = mpcinfo[0]; + mpcfree = mpcinfo[1]; + icascade = mpcinfo[2]; + maxlenmpc = mpcinfo[3]; + } else { + printf("ERROR: This simulation type is not available with preCICE"); + exit(0); + } + } else if (isStaticNLGEOM) { + + printf("Starting STATIC analysis via preCICE...\n"); + + mpcinfo[0] = memmpc_; + mpcinfo[1] = mpcfree; + mpcinfo[2] = icascade; + mpcinfo[3] = maxlenmpc; + + nonlingeo_precice(&co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, + &nboun, &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, + ndirforc, xforc, &nforc, &nelemload, &sideload, xload, &nload, + nactdof, &icol, jq, &irow, neq, &nzl, &nmethod, &ikmpc, &ilmpc, + ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, alcon, nalcon, + alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, t0, t1, t1old, + ithermal, prestr, &iprestr, &vold, iperturb, sti, nzs, &kode, + filab, &idrct, jmax, jout, timepar, eme, xbounold, xforcold, + xloadold, veold, accold, amname, amta, namta, &nam, iamforc, + &iamload, iamt1, alpha, &iexpl, iamboun, plicon, nplicon, plkcon, + nplkcon, &xstate, &npmat_, &istep, &ttime, matname, qaold, mi, + &isolver, &ncmat_, &nstate_, &iumat, cs, &mcs, &nkon, &ener, + mpcinfo, output, shcon, nshcon, cocon, ncocon, physcon, &nflow, + ctrl, set, &nset, istartset, iendset, ialset, &nprint, prlab, + prset, &nener, ikforc, ilforc, trab, inotr, &ntrans, &fmpc, cbody, + ibody, xbody, &nbody, xbodyold, ielprop, prop, &ntie, tieset, + &itpamp, &iviewfile, jobnamec, tietol, &nslavs, thicke, ics, + &nintpoint, &mortar, &ifacecount, typeboun, &islavsurf, + &pslavsurf, &clearini, &nmat, xmodal, &iaxial, &inext, &nprop, + &network, orname, vel, &nef, velo, veloo, energy, itempuser, + ipobody, &inewton, t0g, t1g, &ifreebody, + /* PreCICE args */ + preciceParticipantName, configFilename); + + memmpc_ = mpcinfo[0]; + mpcfree = mpcinfo[1]; + icascade = mpcinfo[2]; + maxlenmpc = mpcinfo[3]; + + } else if (isModalDynamic) { + + printf("Starting FSI analysis via preCICE\n"); + + if ((ne1d != 0) || (ne2d != 0)) { + printf(" *WARNING: 1-D or 2-D elements may cause problems in modal dynamic calculations\n"); + printf(" ensure that point loads defined in a *MODAL DYNAMIC step\n"); + printf(" and applied to nodes belonging to 1-D or 2-D elements have been\n"); + printf(" applied to the same nodes in the preceding FREQUENCY step with\n"); + printf(" magnitude zero; look at example shellf.inp for a guideline.\n\n"); + } + + printf(" Composing the dynamic response from the eigenmodes\n\n"); + + dyna_precice(&co, &nk, &kon, &ipkon, &lakon, &ne, &nodeboun, &ndirboun, &xboun, &nboun, + &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, ndirforc, xforc, + &nforc, + nelemload, sideload, xload, &nload, + &nactdof, neq, &nzl, icol, irow, &nmethod, &ikmpc, &ilmpc, &ikboun, &ilboun, + elcon, nelcon, rhcon, nrhcon, cocon, ncocon, + alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, &t0, + &t1, ithermal, prestr, &iprestr, &vold, iperturb, &sti, nzs, + timepar, xmodal, &veold, amname, amta, + namta, &nam, iamforc, iamload, &iamt1, + jout, &kode, filab, &eme, xforcold, xloadold, + &t1old, &iamboun, &xbounold, &iexpl, plicon, + nplicon, plkcon, nplkcon, &xstate, &npmat_, matname, + mi, &ncmat_, &nstate_, &ener, jobnamec, &ttime, set, &nset, + istartset, iendset, &ialset, &nprint, prlab, + prset, &nener, trab, &inotr, &ntrans, &fmpc, ipobody, ibody, xbody, &nbody, + xbodyold, &istep, &isolver, jq, output, &mcs, &nkon, &mpcend, ics, cs, + &ntie, tieset, &idrct, jmax, ctrl, &itpamp, tietol, &nalset, + ikforc, ilforc, thicke, &nslavs, &nmat, typeboun, ielprop, prop, orname, + t0g, t1g, + preciceParticipantName, configFilename); + } else { + printf("ERROR: Only thermal coupling or FSI is available with preCICE"); + exit(0); + } + } else if ((nmethod <= 1) || (nmethod == 11) || ((iperturb[0] > 1) && (nmethod < 8))) { + if (iperturb[0] < 2) { + + mpcinfo[0] = memmpc_; + mpcinfo[1] = mpcfree; + mpcinfo[2] = icascade; + mpcinfo[3] = maxlenmpc; + + if (icascade != 0) { + printf(" *ERROR in CalculiX: the matrix structure may"); + printf(" change due to nonlinear equations;"); + printf(" a purely linear calculation is not"); + printf(" feasible; use NLGEOM on the *STEP card."); + FORTRAN(stop, ()); + } + + linstatic(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, + &nboun, + ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, ndirforc, xforc, + &nforc, nelemload, sideload, xload, &nload, + nactdof, &icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, + ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, + alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, + t0, t1, t1old, ithermal, prestr, &iprestr, vold, iperturb, sti, nzs, + &kode, filab, eme, &iexpl, plicon, + nplicon, plkcon, nplkcon, &xstate, &npmat_, matname, + &isolver, mi, &ncmat_, &nstate_, cs, &mcs, &nkon, &ener, + xbounold, xforcold, xloadold, amname, amta, namta, + &nam, iamforc, iamload, iamt1, iamboun, &ttime, + output, set, &nset, istartset, iendset, ialset, &nprint, prlab, + prset, &nener, trab, inotr, &ntrans, fmpc, ipobody, ibody, xbody, + &nbody, + xbodyold, timepar, thicke, jobnamec, tieset, &ntie, &istep, &nmat, + ielprop, prop, typeboun, &mortar, mpcinfo, tietol, ics, + orname, itempuser, t0g, t1g); + + for (i = 0; i < 3; i++) { + nzsprevstep[i] = nzs[i]; + } + + memmpc_ = mpcinfo[0]; + mpcfree = mpcinfo[1]; + icascade = mpcinfo[2]; + maxlenmpc = mpcinfo[3]; + + } + + else { + + mpcinfo[0] = memmpc_; + mpcinfo[1] = mpcfree; + mpcinfo[2] = icascade; + mpcinfo[3] = maxlenmpc; + + nonlingeo(&co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, + &nboun, &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, + ndirforc, xforc, &nforc, &nelemload, &sideload, xload, &nload, + nactdof, &icol, jq, &irow, neq, &nzl, &nmethod, &ikmpc, &ilmpc, + ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, alcon, nalcon, + alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, t0, t1, t1old, + ithermal, prestr, &iprestr, &vold, iperturb, sti, nzs, &kode, + filab, &idrct, jmax, jout, timepar, eme, xbounold, xforcold, + xloadold, veold, accold, amname, amta, namta, &nam, iamforc, + &iamload, iamt1, alpha, &iexpl, iamboun, plicon, nplicon, plkcon, + nplkcon, &xstate, &npmat_, &istep, &ttime, matname, qaold, mi, + &isolver, &ncmat_, &nstate_, &iumat, cs, &mcs, &nkon, &ener, + mpcinfo, output, shcon, nshcon, cocon, ncocon, physcon, &nflow, + ctrl, set, &nset, istartset, iendset, ialset, &nprint, prlab, + prset, &nener, ikforc, ilforc, trab, inotr, &ntrans, &fmpc, cbody, + ibody, xbody, &nbody, xbodyold, ielprop, prop, &ntie, tieset, + &itpamp, &iviewfile, jobnamec, tietol, &nslavs, thicke, ics, + &nintpoint, &mortar, &ifacecount, typeboun, &islavsurf, + &pslavsurf, &clearini, &nmat, xmodal, &iaxial, &inext, &nprop, + &network, orname, vel, &nef, velo, veloo, energy, itempuser, + ipobody, &inewton, t0g, t1g, &ifreebody); + + memmpc_ = mpcinfo[0]; + mpcfree = mpcinfo[1]; + icascade = mpcinfo[2]; + maxlenmpc = mpcinfo[3]; + + for (i = 0; i < 3; i++) { + nzsprevstep[i] = nzs[i]; + } + } + } else if ((nmethod == 2) || (nmethod == 13)) { + + /* FREQUENCY ANALYSIS */ + + if ((mcs == 0) || (cs[1] < 0)) { +#ifdef ARPACK + + mpcinfo[0] = memmpc_; + mpcinfo[1] = mpcfree; + mpcinfo[2] = icascade; + mpcinfo[3] = maxlenmpc; + + arpack(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, &nboun, + ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, ndirforc, xforc, + &nforc, nelemload, sideload, xload, &nload, + nactdof, icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, + ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, + shcon, nshcon, cocon, ncocon, + alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, + t0, t1, t1old, ithermal, prestr, &iprestr, vold, iperturb, sti, nzs, + &kode, mei, fei, filab, + &iexpl, plicon, nplicon, plkcon, nplkcon, + &xstate, &npmat_, matname, mi, &ncmat_, &nstate_, &ener, jobnamec, + output, set, &nset, istartset, iendset, ialset, &nprint, prlab, + prset, &nener, &isolver, trab, inotr, &ntrans, &ttime, fmpc, ipobody, + ibody, xbody, &nbody, thicke, &nslavs, tietol, &nkon, mpcinfo, + &ntie, &istep, &mcs, ics, tieset, cs, &nintpoint, &mortar, &ifacecount, + &islavsurf, &pslavsurf, &clearini, &nmat, typeboun, ielprop, prop, + orname, &inewton, t0g, t1g); + + memmpc_ = mpcinfo[0]; + mpcfree = mpcinfo[1]; + icascade = mpcinfo[2]; + maxlenmpc = mpcinfo[3]; + + for (i = 0; i < 3; i++) { + nzsprevstep[i] = nzs[i]; + } + +#else + printf(" *ERROR in CalculiX: the ARPACK library is not linked\n\n"); + FORTRAN(stop, ()); +#endif + + } else { + +#ifdef ARPACK + + mpcinfo[0] = memmpc_; + mpcinfo[1] = mpcfree; + mpcinfo[2] = icascade; + mpcinfo[3] = maxlenmpc; + + arpackcs(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, + xboun, &nboun, + ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, ndirforc, xforc, + &nforc, nelemload, sideload, xload, &nload, + nactdof, icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, + ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, + alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, + t0, t1, t1old, ithermal, prestr, &iprestr, + vold, iperturb, sti, nzs, &kode, mei, fei, filab, + &iexpl, plicon, nplicon, plkcon, nplkcon, + &xstate, &npmat_, matname, mi, ics, cs, &mpcend, &ncmat_, + &nstate_, &mcs, &nkon, jobnamec, output, set, &nset, istartset, + iendset, ialset, &nprint, prlab, + prset, &nener, &isolver, trab, inotr, &ntrans, &ttime, fmpc, ipobody, + ibody, xbody, &nbody, &nevtot, thicke, &nslavs, tietol, mpcinfo, + &ntie, &istep, tieset, &nintpoint, &mortar, &ifacecount, &islavsurf, + &pslavsurf, &clearini, &nmat, typeboun, ielprop, prop, orname, + &inewton, t0g, t1g); + + memmpc_ = mpcinfo[0]; + mpcfree = mpcinfo[1]; + icascade = mpcinfo[2]; + maxlenmpc = mpcinfo[3]; + + for (i = 0; i < 3; i++) { + nzsprevstep[i] = nzs[i]; + } + +#else + printf(" *ERROR in CalculiX: the ARPACK library is not linked\n\n"); + FORTRAN(stop, ()); +#endif + } + } else if (nmethod == 3) { + +#ifdef ARPACK + arpackbu(co, &nk, kon, ipkon, lakon, &ne, nodeboun, ndirboun, xboun, &nboun, + ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, ndirforc, xforc, + &nforc, + nelemload, sideload, xload, &nload, + nactdof, icol, jq, irow, neq, &nzl, &nmethod, ikmpc, + ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, + alcon, nalcon, alzero, ielmat, ielorien, &norien, orab, &ntmat_, + t0, t1, t1old, ithermal, prestr, &iprestr, + vold, iperturb, sti, nzs, &kode, mei, fei, filab, + eme, &iexpl, plicon, nplicon, plkcon, nplkcon, + xstate, &npmat_, matname, mi, &ncmat_, &nstate_, ener, output, + set, &nset, istartset, iendset, ialset, &nprint, prlab, + prset, &nener, &isolver, trab, inotr, &ntrans, &ttime, fmpc, ipobody, + ibody, xbody, &nbody, thicke, jobnamec, &nmat, ielprop, prop, + orname, typeboun, t0g, t1g); +#else + printf(" *ERROR in CalculiX: the ARPACK library is not linked\n\n"); + FORTRAN(stop, ()); +#endif + } else if (nmethod == 4) { + if ((ne1d != 0) || (ne2d != 0)) { + printf(" *WARNING: 1-D or 2-D elements may cause problems in modal dynamic calculations\n"); + printf(" ensure that point loads defined in a *MODAL DYNAMIC step\n"); + printf(" and applied to nodes belonging to 1-D or 2-D elements have been\n"); + printf(" applied to the same nodes in the preceding FREQUENCY step with\n"); + printf(" magnitude zero; look at example shellf.inp for a guideline.\n\n"); + } + + printf(" Composing the dynamic response from the eigenmodes\n\n"); + + dyna(&co, &nk, &kon, &ipkon, &lakon, &ne, &nodeboun, &ndirboun, &xboun, &nboun, + &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, ndirforc, xforc, + &nforc, + nelemload, sideload, xload, &nload, + &nactdof, neq, &nzl, icol, irow, &nmethod, &ikmpc, &ilmpc, &ikboun, &ilboun, + elcon, nelcon, rhcon, nrhcon, cocon, ncocon, + alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, &t0, + &t1, ithermal, prestr, &iprestr, &vold, iperturb, &sti, nzs, + timepar, xmodal, &veold, amname, amta, + namta, &nam, iamforc, iamload, &iamt1, + jout, &kode, filab, &eme, xforcold, xloadold, + &t1old, &iamboun, &xbounold, &iexpl, plicon, + nplicon, plkcon, nplkcon, &xstate, &npmat_, matname, + mi, &ncmat_, &nstate_, &ener, jobnamec, &ttime, set, &nset, + istartset, iendset, &ialset, &nprint, prlab, + prset, &nener, trab, &inotr, &ntrans, &fmpc, ipobody, ibody, xbody, &nbody, + xbodyold, &istep, &isolver, jq, output, &mcs, &nkon, &mpcend, ics, cs, + &ntie, tieset, &idrct, jmax, ctrl, &itpamp, tietol, &nalset, + ikforc, ilforc, thicke, &nslavs, &nmat, typeboun, ielprop, prop, orname, + t0g, t1g); + } else if (nmethod == 5) { + if ((ne1d != 0) || (ne2d != 0)) { + printf(" *WARNING: 1-D or 2-D elements may cause problems in steady state calculations\n"); + printf(" ensure that point loads defined in a *STEADY STATE DYNAMICS step\n"); + printf(" and applied to nodes belonging to 1-D or 2-D elements have been\n"); + printf(" applied to the same nodes in the preceding FREQUENCY step with\n"); + printf(" magnitude zero; look at example shellf.inp for a guideline.\n\n"); + } + + printf(" Composing the steady state response from the eigenmodes\n\n"); + + steadystate(&co, &nk, &kon, &ipkon, &lakon, &ne, &nodeboun, &ndirboun, &xboun, + &nboun, + &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, ndirforc, + xforc, &nforc, + nelemload, sideload, xload, &nload, + &nactdof, neq, &nzl, icol, irow, &nmethod, &ikmpc, &ilmpc, &ikboun, + &ilboun, + elcon, nelcon, rhcon, nrhcon, cocon, ncocon, + alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, + &t0, + &t1, ithermal, prestr, &iprestr, &vold, iperturb, sti, nzs, + timepar, xmodal, &veold, amname, amta, + namta, &nam, iamforc, iamload, &iamt1, + jout, &kode, filab, &eme, xforcold, xloadold, + &t1old, &iamboun, &xbounold, &iexpl, plicon, + nplicon, plkcon, nplkcon, xstate, &npmat_, matname, + mi, &ncmat_, &nstate_, &ener, jobnamec, &ttime, set, &nset, + istartset, iendset, ialset, &nprint, prlab, + prset, &nener, trab, &inotr, &ntrans, &fmpc, ipobody, ibody, xbody, + &nbody, + xbodyold, &istep, &isolver, jq, output, &mcs, &nkon, ics, cs, + &mpcend, + ctrl, ikforc, ilforc, thicke, &nmat, typeboun, ielprop, prop, + orname, + &ndamp, dacon, t0g, t1g); + } else if ((nmethod == 6) || (nmethod == 7)) { + + printf(" Composing the complex eigenmodes from the real eigenmodes\n\n"); + + complexfreq(&co, &nk, &kon, &ipkon, &lakon, &ne, &nodeboun, &ndirboun, &xboun, + &nboun, &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, + ndirforc, xforc, &nforc, + nelemload, sideload, xload, &nload, + &nactdof, neq, &nzl, icol, irow, &nmethod, &ikmpc, &ilmpc, &ikboun, + &ilboun, + elcon, nelcon, rhcon, nrhcon, cocon, ncocon, + alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, + &t0, + &t1, ithermal, prestr, &iprestr, &vold, iperturb, &sti, nzs, + timepar, xmodal, &veold, amname, amta, + namta, &nam, iamforc, iamload, &iamt1, + jout, &kode, filab, &eme, xforcold, xloadold, + &t1old, &iamboun, &xbounold, &iexpl, plicon, + nplicon, plkcon, nplkcon, xstate, &npmat_, matname, + mi, &ncmat_, &nstate_, &ener, jobnamec, &ttime, set, &nset, + istartset, iendset, &ialset, &nprint, prlab, + prset, &nener, trab, &inotr, &ntrans, &fmpc, ipobody, ibody, xbody, + &nbody, + xbodyold, &istep, &isolver, jq, output, &mcs, &nkon, &mpcend, ics, + cs, + &ntie, tieset, &idrct, jmax, ctrl, &itpamp, tietol, &nalset, + ikforc, ilforc, thicke, jobnamef, mei, &nmat, ielprop, prop, orname, + typeboun, t0g, t1g); + } else if ((nmethod > 7) && (nmethod < 12)) { + + mpcinfo[0] = memmpc_; + mpcinfo[1] = mpcfree; + mpcinfo[2] = icascade; + mpcinfo[3] = maxlenmpc; + + electromagnetics(&co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, + ndirboun, xboun, &nboun, + &ipompc, &nodempc, &coefmpc, &labmpc, &nmpc, nodeforc, + ndirforc, xforc, + &nforc, &nelemload, &sideload, xload, &nload, + nactdof, &icol, &jq, &irow, neq, &nzl, &nmethod, &ikmpc, + &ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, + alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, + &ntmat_, + t0, t1, t1old, ithermal, prestr, &iprestr, + &vold, iperturb, sti, nzs, &kode, filab, &idrct, jmax, + jout, timepar, eme, xbounold, xforcold, xloadold, + veold, accold, amname, amta, namta, + &nam, iamforc, &iamload, iamt1, alpha, + &iexpl, iamboun, plicon, nplicon, plkcon, nplkcon, + &xstate, &npmat_, &istep, &ttime, matname, qaold, mi, + &isolver, &ncmat_, &nstate_, &iumat, cs, &mcs, &nkon, &ener, + mpcinfo, output, + shcon, nshcon, cocon, ncocon, physcon, &nflow, ctrl, + &set, &nset, &istartset, &iendset, &ialset, &nprint, prlab, + prset, &nener, ikforc, ilforc, trab, inotr, &ntrans, &fmpc, + ipobody, ibody, xbody, &nbody, xbodyold, ielprop, prop, + &ntie, &tieset, &itpamp, &iviewfile, jobnamec, &tietol, + &nslavs, thicke, + ics, &nalset, &nmpc_, &nmat, typeboun, &iaxial, &nload_, &nprop, + &network, orname, t0g, t1g); + + memmpc_ = mpcinfo[0]; + mpcfree = mpcinfo[1]; + icascade = mpcinfo[2]; + maxlenmpc = mpcinfo[3]; + } + + else if (nmethod == 12) { + + if (icoordinate == 1) { + sensi_coor(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, + xboun, &nboun, ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, + ndirforc, xforc, &nforc, nelemload, sideload, xload, &nload, + nactdof, icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, + ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, + alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, + t0, t1, t1old, ithermal, prestr, &iprestr, vold, iperturb, sti, nzs, + &kode, filab, eme, &iexpl, plicon, + nplicon, plkcon, nplkcon, &xstate, &npmat_, matname, + &isolver, mi, &ncmat_, &nstate_, cs, &mcs, &nkon, &ener, + xbounold, xforcold, xloadold, amname, amta, namta, + &nam, iamforc, iamload, iamt1, iamboun, &ttime, + output, set, &nset, istartset, iendset, ialset, &nprint, prlab, + prset, &nener, trab, inotr, &ntrans, fmpc, ipobody, ibody, xbody, + &nbody, + xbodyold, timepar, thicke, jobnamec, tieset, &ntie, &istep, &nmat, + ielprop, prop, typeboun, &mortar, mpcinfo, tietol, ics, + &nobject, &objectset, &istat, orname, nzsprevstep, &nlabel, + physcon, + jobnamef, iponor, knor, &ne2d, iponoel, inoel, &mpcend, dgdxglob, + g0, &nodedesi, &ndesi, &nobjectstart, &xdesi); + + } else { + sensi_orien(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, + xboun, &nboun, ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, + ndirforc, xforc, &nforc, nelemload, sideload, xload, &nload, + nactdof, icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, + ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, + alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, + t0, t1, t1old, ithermal, prestr, &iprestr, vold, iperturb, sti, nzs, + &kode, filab, eme, &iexpl, plicon, + nplicon, plkcon, nplkcon, &xstate, &npmat_, matname, + &isolver, mi, &ncmat_, &nstate_, cs, &mcs, &nkon, &ener, + xbounold, xforcold, xloadold, amname, amta, namta, + &nam, iamforc, iamload, iamt1, iamboun, &ttime, + output, set, &nset, istartset, iendset, ialset, &nprint, prlab, + prset, &nener, trab, inotr, &ntrans, fmpc, ipobody, ibody, xbody, + &nbody, + xbodyold, timepar, thicke, jobnamec, tieset, &ntie, &istep, &nmat, + ielprop, prop, typeboun, &mortar, mpcinfo, tietol, ics, + &nobject, &objectset, &istat, orname, nzsprevstep, &nlabel, + physcon, + jobnamef, iponor, knor, &ne2d, iponoel, inoel, &mpcend); + } + + } + + else if (nmethod == 14) { + + robustdesign(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, + &nboun, ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, + ndirforc, xforc, &nforc, nelemload, sideload, xload, &nload, + nactdof, icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, ilmpc, ikboun, + ilboun, elcon, nelcon, rhcon, nrhcon, alcon, nalcon, alzero, + &ielmat, &ielorien, &norien, orab, &ntmat_, t0, t1, t1old, ithermal, + prestr, &iprestr, vold, iperturb, sti, nzs, &kode, filab, eme, + &iexpl, plicon, nplicon, plkcon, nplkcon, &xstate, &npmat_, + matname, &isolver, mi, &ncmat_, &nstate_, cs, &mcs, &nkon, &ener, + xbounold, xforcold, xloadold, amname, amta, namta, &nam, iamforc, + iamload, iamt1, iamboun, &ttime, output, set, &nset, istartset, + iendset, ialset, &nprint, prlab, prset, &nener, trab, inotr, + &ntrans, fmpc, ipobody, ibody, xbody, &nbody, xbodyold, timepar, + thicke, jobnamec, tieset, &ntie, &istep, &nmat, ielprop, prop, + typeboun, &mortar, mpcinfo, tietol, ics, &nobject, + &objectset, &istat, orname, nzsprevstep, &nlabel, physcon, + jobnamef, iponor, knor, &ne2d, iponoel, inoel, &mpcend, + irobustdesign, irandomtype, randomval); + } + + else if (nmethod == 15) { + + crackpropagation(&ipkon, &kon, &lakon, &ne, &nk, jobnamec, &nboun, iamboun, xboun, + &nload, sideload, iamload, &nforc, iamforc, xforc, ithermal, + &t1, &iamt1, &co, &nkon, mi, &ielmat, matname, output, &nmat, set, + &nset, istartset, iendset, ialset, jmax, timepar, nelcon, + elcon, &ncmat_, &ntmat_, &istep, filab, &nmethod, mei, &ntrans, + &inotr, &t0, &ne1d, &ne2d, &t0g, &t1g, &nam, &t1old, &vold, + iperturb, &iprestr, &prestr, &norien, &ielorien, &nprop, + &ielprop, &offset, &sti, &eme, &nener, &ener, &nstate_, + &mortar, &nslavs, &nintpoint, &xstate, &iponor, &thicke); + } + + else if (nmethod == 16) { + + feasibledirection(&nobject, &objectset, &dgdxglob, g0, &ndesi, nodedesi, &nk, + &isolver, &ipkon, &kon, &lakon, &ne, nelemload, &nload, + nodeboun, &nboun, ndirboun, ithermal, co, vold, mi, &ielmat, + ielprop, prop, &kode, &nmethod, filab, &nstate_, &istep, cs, + set, &nset, istartset, iendset, ialset, jobnamec, output, + &ntrans, inotr, trab, orname, xdesi); + } + + SFREE(nactdof); + SFREE(icol); + SFREE(jq); + SFREE(irow); + SFREE(ipobody); + + /* check whether refinement was active */ + + // if(irefineloop==20){ + if (strcmp1(&filab[4089], "RM") == 0) { + irefineloop++; + + if (irefineloop == 1) { + + /* refinement was requested in the step which was just + finished and a refined mesh was created and stored. + The calculation has to restart from the beginning with + this new mesh */ + + memcpy(ipoinp, ipoinp_sav, sizeof(ITG) * 2 * nentries); + memcpy(inp, inp_sav, sizeof(ITG) * inp_size); + + /* deallocating fields */ + + dealloc_cal(&ncs_, &ics, &mcs, &cs, &tieset, &tietol, &co, + &kon, &ipkon, &lakon, &nodeboun, &ndirboun, &typeboun, &xboun, + &ikboun, &ilboun, &nodebounold, &ndirbounold, &xbounold, &ipompc, + &labmpc, &ikmpc, &ilmpc, &fmpc, &nodempc, &coefmpc, &nodempcref, + &coefmpcref, &ikmpcref, &nodeforc, &ndirforc, &xforc, + &ikforc, &ilforc, &xforcold, &nelemload, &sideload, &xload, + &xloadold, &cbody, &ibody, &xbody, &xbodyold, &nam, + &iamboun, &iamforc, &iamload, &amname, &amta, &namta, &set, + &istartset, &iendset, &ialset, &elcon, &nelcon, &rhcon, + &nrhcon, &shcon, &nshcon, &cocon, &ncocon, &alcon, + &nalcon, &alzero, &nprop, &ielprop, &prop, &npmat_, + &plicon, &nplicon, &plkcon, &nplkcon, &ndamp, &dacon, &norien, + &orname, &orab, &ielorien, &ntrans, &trab, &inotr, &iprestr, + &prestr, ithermal, &t0, &t1, &t1old, &iamt1, &ne1d, + &ne2d, &t0g, &t1g, irobustdesign, &irandomtype, + &randomval, &prlab, &prset, &filab, &xmodal, &ielmat, + &matname, &sti, &eme, &ener, &xstate, &vold, + &veold, &vel, &velo, &veloo, &iponor, &xnor, + &knor, &thicke, &offset, &iponoel, &inoel, &rig, + &ne2boun, &islavsurf, &mortar, &pslavsurf, &clearini, + &nobject_, &objectset, &nmethod, iperturb, &irefineloop, + &iparentel, &iprfn, &konrfn, &ratiorfn, &heading, + &nodedesi, &dgdxglob, &g0, &nuel_, &xdesi, &nfc, &coeffc, + &ikdc, &edc); + + /* closing and reopening the output files */ + + FORTRAN(openfile, (jobnamef)); + + /* initialization of the variables */ + + ini_cal(jobnamec, output, fneig, kind1, kind2, itempuser, irobustdesign, + &nprint, neq, &mpcfree, &nbounold, &nforcold, &nloadold, &nbody_, + &nbodyold, &network, &nheading_, &nmpc_, &nload_, &nforc_, &nboun_, + &nintpoint, iperturb, &ntmat_, ithermal, &isolver, &nslavs, &nkon_, + &mortar, jout, &nkon, &nevtot, &ifacecount, &iplas, &npmat_, mi, + &mpcend, &namtot_, &iumat, &icascade, &ne1d, &ne2d, infree, &nflow, + irstrt, &nener, &jrstrt, &ntie_, &mcs, &nprop_, &nprop, &itpamp, + &nevdamp_, &npt_, &iaxial, &inext, &icontact, &nobject, &nobject_, + &iit, &mpcfreeref, &isens, &namtot, &nstam, &ndamp, &nef, + &nk_, &ne_, &nalset_, &nmat_, &norien_, &nam_, &ntrans_, + &ncs_, &nstate_, &ncmat_, &memmpc_, &nprint_, energy, ctrl, alpha, + qaold, physcon, &istep, &istat, &iprestr, &kode, &nload, &nbody, &nforc, + &nboun, &nk, &nmpc, &nam, &nzs_, &nlabel, &ttime, &iheading, &nfc, + &nfc_, &ndc, &ndc_); + + NNEW(set, char, 81 * nset_); + NNEW(meminset, ITG, nset_); + NNEW(rmeminset, ITG, nset_); + NNEW(iuel, ITG, 4 * nuel_); + + FORTRAN(allocation, (&nload_, &nforc_, &nboun_, &nk_, &ne_, &nmpc_, &nset_, + &nalset_, &nmat_, &ntmat_, &npmat_, &norien_, &nam_, + &nprint_, mi, &ntrans_, set, meminset, rmeminset, &ncs_, + &namtot_, &ncmat_, &memmpc_, &ne1d, &ne2d, &nflow, + jobnamec, irstrt, ithermal, &nener, &nstate_, &istep, + inpc, ipoinp, inp, &ntie_, &nbody_, + &nprop_, ipoinpc, &nevdamp_, &npt_, &nslavs, &nkon_, &mcs, + &mortar, &ifacecount, &nintpoint, infree, &nheading_, + &nobject_, iuel, &iprestr, &nstam, &ndamp, &nef, + &nbounold, &nforcold, &nloadold, &nbodyold, &mpcend, + irobustdesign, &nfc_, &ndc_)); + + // SFREE(set); + SFREE(meminset); + SFREE(rmeminset); + mt = mi[1] + 1; + NNEW(heading, char, 66 * nheading_); + + continue; + } + } + + /* reset tempuserflag */ + + itempuser[0] = 0; + + /* deleting the perturbation loads and temperatures */ + + if ((iperturb[0] == 1) && (nmethod == 3)) { + nforc = 0; + nload = 0; + nbody = 0; + if (ithermal[0] == 1) { + for (k = 0; k < nk; ++k) { + t1[k] = t0[k]; + } + } + } else { + nbounold = nboun; + for (i = 0; i < nboun; i++) { + nodebounold[i] = nodeboun[i]; + ndirbounold[i] = ndirboun[i]; + } + nforcold = nforc; + nloadold = nload; + nbodyold = nbody; + + /* resetting the amplitude to none except for time=total time amplitudes */ + + if (nam > 0) { + for (i = 0; i < nboun; i++) { + if (iamboun[i] > 0) { + if (namta[3 * iamboun[i] - 1] > 0) { + iamboun[i] = 0; + xboun[i] = xbounold[i]; + } + } + } + for (i = 0; i < nforc; i++) { + if (iamforc[i] > 0) { + if (namta[3 * iamforc[i] - 1] > 0) { + iamforc[i] = 0; + xforc[i] = xforcold[i]; + } + } + } + for (i = 0; i < 2 * nload; i++) { + if (iamload[i] > 0) { + if (namta[3 * iamload[i] - 1] > 0) { + iamload[i] = 0; + xload[i] = xloadold[i]; + } + } + } + for (i = 1; i < 3 * nbody; i = i + 3) { + if (ibody[i] > 0) { + if (namta[3 * ibody[i] - 1] > 0) { + ibody[i] = 0; + xbody[7 * (i - 1) / 3] = xbodyold[7 * (i - 1) / 3]; + } + } + } + if (ithermal[0] == 1) { + if (iamt1[i] > 0) { + if (namta[3 * iamt1[i] - 1] > 0) { + iamt1[i] = 0; + t1[i] = t1old[i]; + } + } + } + } + } + + /* removing the advective elements, if any */ + + if (network > 0) { + ne = ne0; + nkon = nkon0; + RENEW(ipkon, ITG, ne); + RENEW(lakon, char, 8 * ne); + RENEW(kon, ITG, nkon); + RENEW(sti, double, 6 * mi[0] * ne); + RENEW(eme, double, 6 * mi[0] * ne); + if (iprestr > 0) + RENEW(prestr, double, 6 * mi[0] * ne); + if (nprop > 0) + RENEW(ielprop, ITG, ne); + if ((ne1d != 0) || (ne2d != 0)) + RENEW(offset, double, 2 * ne); + if (nener == 1) + RENEW(ener, double, mi[0] * ne * 2); + if (norien > 0) + RENEW(ielorien, ITG, mi[2] * ne); + RENEW(ielmat, ITG, mi[2] * ne); + + /* reactivating the original load labels */ + + for (i = nload - 1; i >= nload0; i--) { + if (strcmp2(&sideload[20 * i], " ", 20) == 0) { + iload = nelemload[2 * i + 1]; + strcpy1(&sideload[20 * (iload - 1)], "F", 1); + } + } + } + + nload = nload0; + + if ((nmethod == 4) && (iperturb[0] > 1)) + SFREE(accold); + + if (irstrt[0] > 0) { + jrstrt++; + if (jrstrt >= irstrt[0]) { + jrstrt = 0; + FORTRAN(restartwrite, (&istep, &nset, &nload, &nforc, &nboun, &nk, &ne, &nmpc, + &nalset, &nmat, &ntmat_, &npmat_, &norien, &nam, + &nprint, mi, &ntrans, &ncs_, &namtot, &ncmat_, &mpcend, + &maxlenmpc, &ne1d, &ne2d, &nflow, &nlabel, &iplas, + &nkon, ithermal, &nmethod, iperturb, &nstate_, &nener, + set, istartset, iendset, ialset, co, kon, ipkon, lakon, + nodeboun, ndirboun, iamboun, xboun, ikboun, ilboun, + ipompc, nodempc, coefmpc, labmpc, ikmpc, ilmpc, + nodeforc, ndirforc, iamforc, xforc, ikforc, ilforc, + nelemload, iamload, sideload, xload, elcon, nelcon, + rhcon, nrhcon, alcon, nalcon, alzero, plicon, nplicon, + plkcon, nplkcon, orname, orab, ielorien, trab, inotr, + amname, amta, namta, t0, t1, iamt1, veold, ielmat, + matname, prlab, prset, filab, vold, nodebounold, + ndirbounold, xbounold, xforcold, xloadold, t1old, eme, + iponor, xnor, knor, thicke, offset, iponoel, inoel, rig, + shcon, nshcon, cocon, ncocon, ics, sti, ener, xstate, + jobnamec, infree, prestr, &iprestr, cbody, ibody, + xbody, &nbody, xbodyold, &ttime, qaold, cs, &mcs, + output, physcon, ctrl, typeboun, fmpc, tieset, &ntie, + tietol, &nslavs, t0g, t1g, &nprop, ielprop, prop, + &mortar, &nintpoint, &ifacecount, islavsurf, + pslavsurf, clearini, irstrt, vel, &nef, velo, veloo, + ne2boun, &memmpc_, heading, &nheading_, &network, + &nfc, &ndc, coeffc, ikdc, edc)); + } + } + } + + FORTRAN(closefile, ()); + + strcpy(fneig, jobnamec); + strcat(fneig, ".frd"); + if ((f1 = fopen(fneig, "ab")) == NULL) { + printf(" *ERROR in frd: cannot open frd file for writing..."); + exit(0); + } + fprintf(f1, " 9999\n"); + fclose(f1); + + /* deallocating the fields + this section is addressed immediately after leaving calinput */ + + SFREE(ipoinpc); + SFREE(inpc); + SFREE(inp); + SFREE(ipoinp); + SFREE(inp_sav); + SFREE(ipoinp_sav); + + dealloc_cal(&ncs_, &ics, &mcs, &cs, &tieset, &tietol, &co, + &kon, &ipkon, &lakon, &nodeboun, &ndirboun, &typeboun, &xboun, + &ikboun, &ilboun, &nodebounold, &ndirbounold, &xbounold, &ipompc, + &labmpc, &ikmpc, &ilmpc, &fmpc, &nodempc, &coefmpc, + &nodempcref, &coefmpcref, &ikmpcref, &nodeforc, &ndirforc, &xforc, + &ikforc, &ilforc, &xforcold, &nelemload, &sideload, &xload, + &xloadold, &cbody, &ibody, &xbody, &xbodyold, &nam, + &iamboun, &iamforc, &iamload, &amname, &amta, &namta, &set, + &istartset, &iendset, &ialset, &elcon, &nelcon, &rhcon, + &nrhcon, &shcon, &nshcon, &cocon, &ncocon, &alcon, + &nalcon, &alzero, &nprop, &ielprop, &prop, &npmat_, + &plicon, &nplicon, &plkcon, &nplkcon, &ndamp, &dacon, &norien, + &orname, &orab, &ielorien, &ntrans, &trab, &inotr, &iprestr, + &prestr, ithermal, &t0, &t1, &t1old, &iamt1, &ne1d, + &ne2d, &t0g, &t1g, irobustdesign, &irandomtype, + &randomval, &prlab, &prset, &filab, &xmodal, &ielmat, + &matname, &sti, &eme, &ener, &xstate, &vold, + &veold, &vel, &velo, &veloo, &iponor, &xnor, + &knor, &thicke, &offset, &iponoel, &inoel, &rig, + &ne2boun, &islavsurf, &mortar, &pslavsurf, &clearini, + &nobject_, &objectset, &nmethod, iperturb, &irefineloop, + &iparentel, &iprfn, &konrfn, &ratiorfn, &heading, + &nodedesi, &dgdxglob, &g0, &nuel_, &xdesi, &nfc, &coeffc, + &ikdc, &edc); + +#ifdef CALCULIX_MPI + MPI_Finalize(); +#endif + +#ifdef CALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT + calculix_freeExternalBehaviours(); +#endif /* CALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT */ + + clock_gettime(CLOCK_MONOTONIC, &totalCalculixTimeEnd); + + totalCalculixTime = (totalCalculixTimeEnd.tv_sec - totalCalculixTimeStart.tv_sec) * 1e9; + totalCalculixTime = (totalCalculixTime + (totalCalculixTimeEnd.tv_nsec - totalCalculixTimeStart.tv_nsec)) * 1e-9; + + printf("________________________________________\n\n"); + + printf("Total CalculiX Time: %lf\n", totalCalculixTime); + + printf("________________________________________\n"); + + return 0; +} diff --git a/ccx_2.21.c b/ccx_2.21.c deleted file mode 100644 index 85653b2b..00000000 --- a/ccx_2.21.c +++ /dev/null @@ -1,1954 +0,0 @@ -/* CalculiX - A 3-dimensional finite element program */ -/* Copyright (C) 1998-2023 Guido Dhondt */ - -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU General Public License as */ -/* published by the Free Software Foundation(version 2); */ -/* */ - -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU General Public License for more details. */ - -/* You should have received a copy of the GNU General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifdef __WIN32 -_set_output_format(_TWO_DIGIT_EXPONENT); -#endif - -#ifdef CALCULIX_MPI -#include -#endif - -#include -#include -#include -#include -#include "CalculiX.h" -#include "CalculiX_precice.h" - -#ifdef CALCULIX_MPI -ITG myid = 0,nproc = 0; -#endif - -struct timespec totalCalculixTimeStart,totalCalculixTimeEnd; - -int main(int argc,char *argv[]) -{ - - FILE *f1; - - char *sideload=NULL,*set=NULL,*matname=NULL,*orname=NULL,*amname=NULL, - *filab=NULL,*lakon=NULL,*labmpc=NULL,*prlab=NULL,*prset=NULL, - jobnamec[792]="",jobnamef[132]="",output[5],*typeboun=NULL, - *inpc=NULL,*tieset=NULL,*cbody=NULL,fneig[132],*sideloadtemp=NULL, - kind1[2],kind2[2],*heading=NULL,*objectset=NULL; - - ITG *kon=NULL,*nodeboun=NULL,*ndirboun=NULL,*ipompc=NULL, - *nodempc=NULL,*nodeforc=NULL,*ndirforc=NULL, - *nelemload=NULL,im,*inodesd=NULL,nload1,*idefforc=NULL, - *nactdof=NULL,*icol=NULL,*ics=NULL,itempuser[3], - *jq=NULL,*mast1=NULL,*irow=NULL,*rig=NULL,*idefbody=NULL, - *ikmpc=NULL,*ilmpc=NULL,*ikboun=NULL,*ilboun=NULL, - *nreorder=NULL,*ipointer=NULL,*idefload=NULL, - *istartset=NULL,*iendset=NULL,*ialset=NULL,*ielmat=NULL, - *ielorien=NULL,*nrhcon=NULL,*nodebounold=NULL,*ndirbounold=NULL, - *nelcon=NULL,*nalcon=NULL,*iamforc=NULL,*iamload=NULL, - *iamt1=NULL,*namta=NULL,*ipkon=NULL,*iamboun=NULL, - *nplicon=NULL,*nplkcon=NULL,*inotr=NULL,*iponor=NULL,*knor=NULL, - *ikforc=NULL,*ilforc=NULL,*iponoel=NULL,*inoel=NULL,*nshcon=NULL, - *ncocon=NULL,*ibody=NULL,*ielprop=NULL,*islavsurf=NULL, - *ipoinpc=NULL,mt,nxstate,nload0,iload,*iuel=NULL,*ne2boun=NULL, - *irandomtype=NULL,irobustdesign[3],*iparentel=NULL,ifreebody, - *ipobody=NULL,inewton=0,*iprfn=NULL,*konrfn=NULL; - - ITG nk,ne,nboun,nmpc,nforc,nload,nprint,nset,nalset,nentries=19, - nmethod,neq[3],i,mpcfree,mei[4]={0,0,0,0},j,nzl,nam,nbounold, - nforcold,nloadold,nbody,nbody_,nbodyold,network,nheading_, - k,nzs[3],nmpc_,nload_,nforc_,istep,istat,nboun_,nintpoint, - iperturb[2],nmat,ntmat_,norien,ithermal[2]={0,0},nmpcold, - iprestr,kode,isolver,nslavs,nkon_,ne1,nkon0,mortar, - jout[2],nlabel,nkon,idrct,jmax[2],iexpl,nevtot,ifacecount, - iplas,npmat_,mi[3],ntrans,mpcend,namtot_,iheading, - icascade,maxlenmpc,mpcinfo[4],ne1d,ne2d,infree[4], - callfrommain,nflow,jin=0,irstrt[2],nener,jrstrt,nenerold, - nline,*ipoinp=NULL,*inp=NULL,ntie,ntie_,mcs,nprop_, - nprop,itpamp,iviewfile,nkold,nevdamp_,npt_,cyclicsymmetry, - nmethodl,iaxial,inext,icontact,nobject,nobject_,iit, - nzsprevstep[3],memmpcref_,mpcfreeref,maxlenmpcref,*nodempcref=NULL, - *ikmpcref=NULL,isens,namtot,nstam,ndamp,nef,inp_size, - *ipoinp_sav=NULL,*inp_sav=NULL,irefineloop=0,icoordinate=0, - *nodedesi=NULL,ndesi=0,nobjectstart=0,nfc_,ndc_,nfc,ndc,*ikdc=NULL; - - ITG *meminset=NULL,*rmeminset=NULL; - - ITG nzs_,nk_,ne_,nset_=0,nalset_,nmat_,norien_,nam_, - ntrans_,ncs_,nstate_,ncmat_,memmpc_,nprint_,nuel_=0; - - double *co=NULL,*xboun=NULL,*coefmpc=NULL,*xforc=NULL,*clearini=NULL, - *xload=NULL,*xbounold=NULL,*xforcold=NULL,*randomval=NULL, - *vold=NULL,*sti=NULL,*xloadold=NULL,*xnor=NULL, - *reorder=NULL,*dcs=NULL,*thickn=NULL,*thicke=NULL,*offset=NULL, - *elcon=NULL,*rhcon=NULL,*alcon=NULL,*alzero=NULL,*t0=NULL,*t1=NULL, - *prestr=NULL,*orab=NULL,*amta=NULL,*veold=NULL,*accold=NULL, - *t1old=NULL,*eme=NULL,*plicon=NULL,*pslavsurf=NULL,*plkcon=NULL, - *xstate=NULL,*trab=NULL,*ener=NULL,*shcon=NULL,*cocon=NULL, - *cs=NULL,*tietol=NULL,*fmpc=NULL,*prop=NULL,*t0g=NULL,*t1g=NULL, - *xbody=NULL,*xbodyold=NULL,*coefmpcref=NULL,*dacon=NULL,*vel=NULL, - *velo=NULL,*veloo=NULL,energy[5],*ratiorfn=NULL,*dgdxglob=NULL, - *g0=NULL,*xdesi=NULL,*coeffc=NULL,*edc=NULL,*coini=NULL; - - double ctrl[57]; - - double fei[3],*xmodal=NULL,timepar[5],alpha[2],ttime,qaold[2],physcon[14]; - - double totalCalculixTime; - -/* - * Additional variables for the coupling with preCICE - * preCICE is used only if a participant name is provided as a command line argument! - */ - char preciceParticipantName[256] = "", configFilename[256] = "config.yml"; - int preciceUsed = 0; - -#ifdef CALCULIX_MPI - MPI_Init(&argc, &argv) ; - MPI_Comm_rank(MPI_COMM_WORLD, &myid) ; - MPI_Comm_size(MPI_COMM_WORLD, &nproc) ; -#endif - - clock_gettime(CLOCK_MONOTONIC, &totalCalculixTimeStart); - - if(argc==1){printf("Usage: CalculiX.exe -i jobname\n");FORTRAN(stop,());} - else{ - for(i=1;i127){ - printf(" *ERROR in CalculiX: the number of characters in the name of the input deck (without .inp) exceeds 127 characters\n"); - FORTRAN(stop,()); - } - strcpy2(jobnamec,argv[i+1],132); - strcpy1(jobnamef,argv[i+1],132);jin++;break;} - if(strcmp1(argv[i],"-v")==0){ - printf("\nThis is Version 2.21\n\n"); - FORTRAN(stop,()); - } - } - if(jin==0){ - if(strlen(argv[1])>127){ - printf(" *ERROR in CalculiX: the number of characters in the name of the input deck (without .inp) exceeds 127 characters\n"); - FORTRAN(stop,()); - } - strcpy2(jobnamec,argv[1],132); - strcpy1(jobnamef,argv[1],132);} - - /* preCICE information*/ - for (i = 1; i < argc; i++) { - - // Get preCICE participantName - if (strcmp1(argv[i], "-precice-participant") == 0) { - strcpy(preciceParticipantName, argv[i + 1]); - preciceUsed = 1; - } - // Overwrite YAML config file name in case a specific file name is given on the command line - if (strcmp1(argv[i], "-precice-config") == 0) { - strcpy(configFilename, argv[i + 1]); - } - } - } - - if (preciceUsed) { - } else { - printf(" *ERROR reading the preCICE participant name. \n"); - exit(0); - } - - putenv("CCX_JOBNAME_GETJOBNAME=jobnamec"); - -#ifdef BAM - ITG lop=0,lrestart=0,kstep=1,kinc=1; - double time[2],dtime; - FORTRAN(uexternaldb,(&lop,&lrestart,time,&dtime,&kstep,&kinc)); -#endif - - FORTRAN(openfile,(jobnamef)); - - printf("\n************************************************************\n\n"); -#ifdef INTSIZE64 - printf("CalculiX Version 2.21 i8, Copyright(C) 1998-2023 Guido Dhondt\n"); -#else - printf("CalculiX Version 2.21, Copyright(C) 1998-2023 Guido Dhondt\n"); -#endif - printf("CalculiX comes with ABSOLUTELY NO WARRANTY. This is free\n"); - printf("software, and you are welcome to redistribute it under\n"); - printf("certain conditions, see gpl.htm\n\n"); - printf("************************************************************\n\n"); - printf("You are using an executable made on Thu Apr 11 03:24:54 PM EDT 2024\n\n"); - printf("CalculiX is used with preCICE participant: %s\n\n", preciceParticipantName); - fflush(stdout); - - NNEW(ipoinp,ITG,2*nentries); - - /* conservative estimate of the fields to be allocated */ - - readinput(jobnamec,&inpc,&nline,&nset_,ipoinp,&inp,&ipoinpc,ithermal,&nuel_, - &inp_size); - - /* saving the original input deck reading pointers */ - - NNEW(ipoinp_sav,ITG,2*nentries); - memcpy(ipoinp_sav,ipoinp,sizeof(ITG)*2*nentries); - NNEW(inp_sav,ITG,inp_size); - memcpy(inp_sav,inp,sizeof(ITG)*inp_size); - - /* initialization of the variables */ - - ini_cal(jobnamec,output,fneig,kind1,kind2,itempuser,irobustdesign,&nprint, - neq,&mpcfree,&nbounold,&nforcold,&nloadold,&nbody_, - &nbodyold,&network,&nheading_,&nmpc_,&nload_,&nforc_,&nboun_, - &nintpoint,iperturb,&ntmat_,ithermal,&isolver,&nslavs,&nkon_,&mortar, - jout,&nkon,&nevtot,&ifacecount,&iplas,&npmat_,mi,&mpcend,&namtot_, - &icascade,&ne1d,&ne2d,infree,&nflow,irstrt,&nener,&jrstrt, - &ntie_,&mcs,&nprop_,&nprop,&itpamp,&nevdamp_,&npt_,&iaxial,&inext, - &icontact,&nobject,&nobject_,&iit,&mpcfreeref,&isens,&namtot,&nstam, - &ndamp,&nef,&nk_,&ne_,&nalset_,&nmat_,&norien_,&nam_, - &ntrans_,&ncs_,&nstate_,&ncmat_,&memmpc_,&nprint_,energy,ctrl,alpha, - qaold,physcon,&istep,&istat,&iprestr,&kode,&nload,&nbody,&nforc, - &nboun,&nk,&nmpc,&nam,&nzs_,&nlabel,&ttime,&iheading,&nfc,&nfc_,&ndc, - &ndc_); - - NNEW(set,char,81*nset_); - NNEW(meminset,ITG,nset_); - NNEW(rmeminset,ITG,nset_); - NNEW(iuel,ITG,4*nuel_); - - FORTRAN(allocation,(&nload_,&nforc_,&nboun_,&nk_,&ne_,&nmpc_,&nset_,&nalset_, - &nmat_,&ntmat_,&npmat_,&norien_,&nam_,&nprint_,mi, - &ntrans_,set,meminset,rmeminset,&ncs_,&namtot_,&ncmat_, - &memmpc_,&ne1d,&ne2d,&nflow,jobnamec,irstrt,ithermal, - &nener,&nstate_,&istep,inpc,ipoinp,inp,&ntie_,&nbody_, - &nprop_,ipoinpc,&nevdamp_,&npt_,&nslavs,&nkon_,&mcs, - &mortar,&ifacecount,&nintpoint,infree,&nheading_, - &nobject_,iuel,&iprestr,&nstam,&ndamp,&nef,&nbounold, - &nforcold,&nloadold,&nbodyold,&mpcend,irobustdesign, - &nfc_,&ndc_)); - - SFREE(meminset);SFREE(rmeminset);mt=mi[1]+1; - NNEW(heading,char,66*nheading_); - - while(istat>=0){ - - fflush(stdout); - - /* in order to reduce the number of variables to be transferred to - the subroutines, the max. field sizes are (for most fields) copied - into the real sizes */ - - nzs[1]=nzs_; - - if((istep==0)||(irstrt[0]<0)){ - ne=ne_; - nset=nset_; - nalset=nalset_; - nmat=nmat_; - norien=norien_; - ntrans=ntrans_; - ntie=ntie_; - - /* allocating space before the first step */ - - /* coordinates and topology */ - - NNEW(co,double,3*nk_); - NNEW(kon,ITG,nkon_); - NNEW(ipkon,ITG,ne_); - NNEW(lakon,char,8*ne_); - - /* property cards */ - - if(nprop_>0){ - NNEW(ielprop,ITG,ne_); - for(i=0;i0)))NNEW(iamboun,ITG,nboun_); - NNEW(xboun,double,nboun_); - NNEW(ikboun,ITG,nboun_); - NNEW(ilboun,ITG,nboun_); - - /* MPC's */ - - NNEW(ipompc,ITG,nmpc_); - NNEW(nodempc,ITG,3*memmpc_); - for(i=0;i<3*memmpc_;i+=3){nodempc[i+2]=i/3+2;} - nodempc[3*memmpc_-1]=0; - NNEW(coefmpc,double,memmpc_); - NNEW(labmpc,char,20*nmpc_+1); - NNEW(ikmpc,ITG,nmpc_); - NNEW(ilmpc,ITG,nmpc_); - NNEW(fmpc,double,nmpc_); - - /* coupling, distributed */ - - if(nfc_>0){ - NNEW(coeffc,double,7*nfc_); - NNEW(ikdc,ITG,ndc_); - NNEW(edc,double,12*ndc_); - } - - /* nodal loads */ - - NNEW(nodeforc,ITG,2*nforc_); - NNEW(ndirforc,ITG,nforc_); - if((istep==0)||((irstrt[0]<0)&&(nam_>0)))NNEW(iamforc,ITG,nforc_); - NNEW(idefforc,ITG,nforc_); - NNEW(xforc,double,nforc_); - NNEW(ikforc,ITG,nforc_); - NNEW(ilforc,ITG,nforc_); - - /* distributed facial loads */ - - NNEW(nelemload,ITG,2*nload_); - if((istep==0)||((irstrt[0]<0)&&(nam_>0)))NNEW(iamload,ITG,2*nload_); - NNEW(idefload,ITG,nload_); - NNEW(sideload,char,20*nload_); - NNEW(xload,double,2*nload_); - - /* distributed volumetric loads */ - - NNEW(cbody,char,81*nbody_); - NNEW(idefbody,ITG,nbody_); - NNEW(ibody,ITG,3*nbody_); - NNEW(xbody,double,7*nbody_); - NNEW(xbodyold,double,7*nbody_); - - /* printing output */ - - NNEW(prlab,char,6*nprint_); - NNEW(prset,char,81*nprint_); - - /* set definitions */ - - RENEW(set,char,81*nset); - NNEW(istartset,ITG,nset);DMEMSET(istartset,0,nset,1); - NNEW(iendset,ITG,nset); - NNEW(ialset,ITG,nalset); - - /* (hyper)elastic constants */ - - NNEW(elcon,double,(ncmat_+1)*ntmat_*nmat); - NNEW(nelcon,ITG,2*nmat); - - /* density */ - - NNEW(rhcon,double,2*ntmat_*nmat); - NNEW(nrhcon,ITG,nmat); - - /* damping */ - - if(ndamp>0){NNEW(dacon,double,nmat);} - - /* specific heat */ - - NNEW(shcon,double,4*ntmat_*nmat); - NNEW(nshcon,ITG,nmat); - - /* thermal expansion coefficients */ - - NNEW(alcon,double,7*ntmat_*nmat); - NNEW(nalcon,ITG,2*nmat); - NNEW(alzero,double,nmat); - - /* conductivity */ - - NNEW(cocon,double,7*ntmat_*nmat); - NNEW(ncocon,ITG,2*nmat); - - /* isotropic and kinematic hardening coefficients*/ - - if(npmat_>0){ - NNEW(plicon,double,(2*npmat_+1)*ntmat_*nmat); - NNEW(nplicon,ITG,(ntmat_+1)*nmat); - NNEW(plkcon,double,(2*npmat_+1)*ntmat_*nmat); - NNEW(nplkcon,ITG,(ntmat_+1)*nmat); - } - - /* linear dynamic properties */ - - NNEW(xmodal,double,11+nevdamp_); - xmodal[10]=nevdamp_+0.5; - - /* internal state variables (nslavs is needed for restart - calculations) */ - - if(mortar!=1){ - NNEW(xstate,double,nstate_*mi[0]*(ne+nslavs)); - nxstate=nstate_*mi[0]*(ne+nslavs); - }else if(mortar==1){ - NNEW(xstate,double,nstate_*mi[0]*(ne+nintpoint)); - nxstate=nstate_*mi[0]*(ne+nintpoint); - } - - /* material orientation */ - - if((istep==0)||((irstrt[0]<0)&&(norien>0))){ - NNEW(orname,char,80*norien); - NNEW(orab,double,7*norien); - NNEW(ielorien,ITG,mi[2]*ne_); - } - - /* transformations */ - - if((istep==0)||((irstrt[0]<0)&&(ntrans>0))){ - NNEW(trab,double,7*ntrans); - NNEW(inotr,ITG,2*nk_); - } - - /* amplitude definitions */ - - if((istep==0)||((irstrt[0]<0)&&(nam_>0))){ - NNEW(amname,char,80*nam_); - NNEW(amta,double,2*namtot_); - NNEW(namta,ITG,3*nam_); - } - - if((istep==0)||((irstrt[0]<0)&&(ithermal[0]>0))){ - NNEW(t0,double,nk_); - NNEW(t1,double,nk_); - if((ne1d!=0)||(ne2d!=0)||(nuel_!=0)){ - NNEW(t0g,double,2*nk_); - NNEW(t1g,double,2*nk_); - } - } - - /* the number in next line is NOT 1.2357111317 -> points - to user input; instead it is a generic nonzero - initialization */ - - if(istep==0){ - DMEMSET(t0,0,nk_,1.2357111319); - DMEMSET(t1,0,nk_,1.2357111319); - } - - if((istep==0)||((irstrt[0]<0)&&(ithermal[0]>0)&&(nam_>0)))NNEW(iamt1,ITG,nk_); - - if((istep==0)||((irstrt[0]<0)&&(iprestr>0)))NNEW(prestr,double,6*mi[0]*ne_); - - NNEW(vold,double,mt*nk_); - NNEW(veold,double,mt*nk_); - - /* CFD-results */ - - NNEW(vel,double,8*nef); - NNEW(velo,double,8*nef); - NNEW(veloo,double,8*nef); - - NNEW(ielmat,ITG,mi[2]*ne_); - - NNEW(matname,char,80*nmat); - - NNEW(filab,char,87*nlabel); - - /* tied constraints */ - - if(ntie_>0){ - NNEW(tieset,char,243*ntie_); - NNEW(tietol,double,4*ntie_); - NNEW(cs,double,17*ntie_); - } - - /* objectives for sensitivity analysis */ - - if(nobject_>0){ - NNEW(nodedesi,ITG,nk_); - NNEW(dgdxglob,double,nobject_*2*nk_); - NNEW(g0,double,nobject_); - NNEW(xdesi,double,3*nk_); - NNEW(objectset,char,405*nobject_); - for(i=0;i<405*nobject_;i++){objectset[i]=' ';} - NNEW(coini,double,3*nk_); - } - - /* temporary fields for cyclic symmetry calculations */ - - if((ncs_>0)||(npt_>0)){ - if(2*npt_>24*ncs_){ - NNEW(ics,ITG,2*npt_); - }else{ - NNEW(ics,ITG,24*ncs_); - } - if(npt_>30*ncs_){ - NNEW(dcs,double,npt_); - }else{ - NNEW(dcs,double,30*ncs_); - } - } - - /* slave faces */ - - NNEW(islavsurf,ITG,2*ifacecount+2); - - /* robustdesign analysis */ - - if(irobustdesign[0]>0){ - NNEW(irandomtype,ITG,nk_); - NNEW(randomval,double,2*nk_); - } - - } - else { - - /* allocating and reallocating space for subsequent steps */ - - if((nmethod!=4)&&(nmethod!=5)&&(nmethod!=8)&&(nmethod!=9)&& - ((abs(nmethod)!=1)||(iperturb[0]<2))){ - NNEW(veold,double,mt*nk_); - } - else{ - RENEW(veold,double,mt*nk_); - DMEMSET(veold,mt*nk,mt*nk_,0.); - } - RENEW(vold,double,mt*nk_); - DMEMSET(vold,mt*nk,mt*nk_,0.); - - RENEW(nodeboun,ITG,nboun_); - RENEW(ndirboun,ITG,nboun_); - RENEW(typeboun,char,nboun_+1); - RENEW(xboun,double,nboun_); - RENEW(ikboun,ITG,nboun_); - RENEW(ilboun,ITG,nboun_); - - RENEW(nodeforc,ITG,2*nforc_); - RENEW(ndirforc,ITG,nforc_); - NNEW(idefforc,ITG,nforc_); - RENEW(xforc,double,nforc_); - RENEW(ikforc,ITG,nforc_); - RENEW(ilforc,ITG,nforc_); - - RENEW(nelemload,ITG,2*nload_); - NNEW(idefload,ITG,nload_); - RENEW(sideload,char,20*nload_); - RENEW(xload,double,2*nload_); - - RENEW(cbody,char,81*nbody_); - NNEW(idefbody,ITG,nbody_); - RENEW(ibody,ITG,3*nbody_); - RENEW(xbody,double,7*nbody_); - RENEW(xbodyold,double,7*nbody_); - for(i=7*nbodyold;i<7*nbody_;i++) xbodyold[i]=0; - - if(nam>0){ - RENEW(iamforc,ITG,nforc_); - RENEW(iamload,ITG,2*nload_); - RENEW(iamboun,ITG,nboun_); - RENEW(amname,char,80*nam_); - RENEW(amta,double,2*namtot_); - RENEW(namta,ITG,3*nam_); - } - - RENEW(ipompc,ITG,nmpc_); - - RENEW(labmpc,char,20*nmpc_+1); - RENEW(ikmpc,ITG,nmpc_); - RENEW(ilmpc,ITG,nmpc_); - RENEW(fmpc,double,nmpc_); - - if(ntrans>0){ - RENEW(inotr,ITG,2*nk_);DMEMSET(inotr,2*nk,2*nk_,0); - } - - RENEW(co,double,3*nk_);DMEMSET(co,3*nk,3*nk_,0.); - - if(ithermal[0] != 0){ - RENEW(t0,double,nk_);DMEMSET(t0,nk,nk_,0.); - RENEW(t1,double,nk_);DMEMSET(t1,nk,nk_,0.); - if((ne1d!=0)||(ne2d!=0)||(nuel_!=0)){ - RENEW(t0g,double,2*nk_);DMEMSET(t0g,2*nk,2*nk_,0.); - RENEW(t1g,double,2*nk_);DMEMSET(t1g,2*nk,2*nk_,0.); - } - if(nam>0){RENEW(iamt1,ITG,nk_);} - } - - } - - /* allocation of fields in the restart file */ - - if(irstrt[0]<0){ - NNEW(nodebounold,ITG,nboun_); - NNEW(ndirbounold,ITG,nboun_); - NNEW(xbounold,double,nboun_); - NNEW(xforcold,double,nforc_); - NNEW(xloadold,double,2*nload_); - if(ithermal[0]!=0) NNEW(t1old,double,nk_); - NNEW(sti,double,6*mi[0]*ne); - NNEW(eme,double,6*mi[0]*ne); - if(nener==1)NNEW(ener,double,2*mi[0]*ne); - if(mcs>ntie_) RENEW(cs,double,17*mcs); - if(mortar==1){ - NNEW(pslavsurf,double,3*nintpoint); - NNEW(clearini,double,3*9*ifacecount); - } - - } - - nenerold=nener; - nkold=nk; - - /* opening the eigenvalue file and checking for cyclic symmetry */ - - strcpy2(fneig,jobnamec,132); - strcat(fneig,".eig"); - cyclicsymmetry=0; - if((f1=fopen(fneig,"rb"))!=NULL){ - if(fread(&cyclicsymmetry,sizeof(ITG),1,f1)!=1){ - printf(" *ERROR reading the information whether cyclic symmetry is involved in the eigenvalue file"); - exit(0); - } - fclose(f1); - } - - nmpcold=nmpc; - - /* reading the input file */ - - FORTRAN(calinput,(co,&nk,kon,ipkon,lakon,&nkon,&ne,nodeboun,ndirboun,xboun, - &nboun,ipompc,nodempc,coefmpc,&nmpc,&nmpc_,nodeforc, - ndirforc,xforc,&nforc,&nforc_,nelemload,sideload,xload, - &nload,&nload_,&nprint,prlab,prset,&mpcfree,&nboun_,mei, - set,istartset,iendset,ialset,&nset,&nalset,elcon,nelcon, - rhcon,nrhcon,alcon,nalcon,alzero,t0,t1,matname,ielmat, - orname,orab,ielorien,amname,amta,namta,&nam,&nmethod, - iamforc,iamload,iamt1,ithermal,iperturb,&istat,&istep, - &nmat,&ntmat_,&norien,prestr,&iprestr,&isolver,fei,veold, - timepar,xmodal,filab,jout,&nlabel,&idrct,jmax,&iexpl, - alpha,iamboun,plicon,nplicon,plkcon,nplkcon,&iplas, - &npmat_,mi,&nk_,trab,inotr,&ntrans,ikboun,ilboun,ikmpc, - ilmpc,ics,dcs,&ncs_,&namtot_,cs,&nstate_,&ncmat_, - &mcs,labmpc,iponor,xnor,knor,thickn,thicke,ikforc,ilforc, - offset,iponoel,inoel,rig,infree,nshcon,shcon,cocon, - ncocon,physcon,&nflow,ctrl,&maxlenmpc,&ne1d,&ne2d,&nener, - vold,nodebounold,ndirbounold,xbounold,xforcold,xloadold, - t1old,eme,sti,ener,xstate,jobnamec,irstrt,&ttime,qaold, - output,typeboun,inpc,ipoinp,inp,tieset,tietol,&ntie,fmpc, - cbody,ibody,xbody,&nbody,&nbody_,xbodyold,&nam_,ielprop, - &nprop,&nprop_,prop,&itpamp,&iviewfile,ipoinpc,&nslavs, - t0g,t1g,&network,&cyclicsymmetry,idefforc,idefload, - idefbody,&mortar,&ifacecount,islavsurf,pslavsurf, - clearini,heading,&iaxial,&nobject,objectset,&nprint_, - iuel,&nuel_,nodempcref,coefmpcref,ikmpcref,&memmpcref_, - &mpcfreeref,&maxlenmpcref,&memmpc_,&isens,&namtot,&nstam, - dacon,vel,&nef,velo,veloo,ne2boun,itempuser, - irobustdesign,irandomtype,randomval,&nfc,&nfc_,coeffc, - ikdc,&ndc,&ndc_,edc,coini)); - - SFREE(idefforc);SFREE(idefload);SFREE(idefbody); - - if(istat<0) break; - - /* assigning the body forces to the elements */ - - if(nbody>0){ - ifreebody=ne+1; - NNEW(ipobody,ITG,2*ifreebody*nbody); - for(k=1;k<=nbody;k++){ - FORTRAN(bodyforce,(cbody,ibody,ipobody,&nbody,set,istartset, - iendset,ialset,&inewton,&nset,&ifreebody,&k)); - RENEW(ipobody,ITG,2*(ne+ifreebody)); - } - RENEW(ipobody,ITG,2*(ifreebody-1)); - } - - if(irefineloop==1){ - - /* in the last step refinement was requested and the mesh - was appropriately refined; this mesh has to be read */ - - readnewmesh(jobnamec,&nboun,nodeboun,iamboun,xboun,&nload,sideload, - iamload,&nforc,nodeforc,iamforc,xforc,ithermal,&nk,&t1,&iamt1, - &ne,&lakon,&ipkon,&kon,istartset,iendset,ialset,set,&nset, - filab,&co,&ipompc,&nodempc,&coefmpc,&nmpc,&nmpc_,&labmpc, - &mpcfree,&memmpc_,&ikmpc,&ilmpc,&nk_,&ne_,&nkon_,&istep, - &nprop_,&ielprop,&ne1d,&ne2d,&iponor,&thickn,&thicke,mi, - &offset,&iponoel,&rig,&ne2boun,&ielorien,&inotr,&t0,&t0g,&t1g, - &prestr,&vold,&veold,&ielmat,irobustdesign,&irandomtype, - &randomval,&nalset,&nalset_,&nkon,xnor,&iaxial, - &network,&nlabel,iuel,iperturb,&iprestr,&ntie,tieset, - &iparentel,ikboun,&ifreebody,&ipobody,&nbody,&iprfn, - &konrfn,&ratiorfn,nodempcref,coefmpcref,&memmpcref_, - &mpcfreeref,&maxlenmpcref,&maxlenmpc,&norien,tietol); - } - -#ifdef CALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT - for(i=0;i!=nmat;++i){ - calculix_registerExternalBehaviour(matname+80*i); - } -#endif /* CALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT */ - - nload0=nload; - - if(iheading==0){ - writeheading(jobnamec,heading,&nheading_); - iheading=1; - } - - if((abs(nmethod)!=1)||(iperturb[0]<2))icascade=0; - - // FORTRAN(writeboun,(nodeboun,ndirboun,xboun,typeboun,&nboun)); - - if(istep==1){ - - SFREE(iuel); - - /* tied contact constraints: generate appropriate MPC's */ - - tiedcontact(&ntie,tieset,&nset,set,istartset,iendset,ialset, - lakon,ipkon,kon,tietol,&nmpc,&mpcfree,&memmpc_, - &ipompc,&labmpc,&ikmpc,&ilmpc,&fmpc,&nodempc,&coefmpc, - ithermal,co,vold,&nef,&nmpc_,mi,&nk,&istep,ikboun,&nboun, - kind1,kind2,jobnamef); - - /* reallocating space in the first step */ - - /* allocating and initializing fields pointing to the previous step */ - - RENEW(vold,double,mt*nk); - NNEW(sti,double,6*mi[0]*ne); - - /* strains */ - - NNEW(eme,double,6*mi[0]*ne); - - /* residual stresses/strains */ - - if(iprestr==1){ - RENEW(prestr,double,6*mi[0]*ne); - for(i=0;i1){ - for(i=0;i0){ - RENEW(ielprop,ITG,ne); - RENEW(prop,double,nprop); - }else{ - SFREE(ielprop);SFREE(prop); - } - - /* coupling, distributed */ - - if(nfc>0){ - RENEW(coeffc,double,7*nfc); - RENEW(ikdc,ITG,ndc); - RENEW(edc,double,12*ndc); - }else{ - SFREE(coeffc);SFREE(ikdc);SFREE(edc); - } - - /* fields for 1-D and 2-D elements */ - - if((ne1d!=0)||(ne2d!=0)){ - RENEW(iponor,ITG,2*nkon); - RENEW(xnor,double,infree[0]); - RENEW(knor,ITG,infree[1]); - SFREE(thickn); - RENEW(thicke,double,mi[2]*nkon); - RENEW(offset,double,2*ne); - RENEW(inoel,ITG,3*(infree[2]-1)); - RENEW(iponoel,ITG,infree[3]); - RENEW(rig,ITG,infree[3]); - RENEW(ne2boun,ITG,2*infree[3]); - } - - /* set definitions */ - - RENEW(set,char,81*nset); - RENEW(istartset,ITG,nset); - RENEW(iendset,ITG,nset); - RENEW(ialset,ITG,nalset); - - /* material properties */ - - RENEW(elcon,double,(ncmat_+1)*ntmat_*nmat); - RENEW(nelcon,ITG,2*nmat); - - RENEW(rhcon,double,2*ntmat_*nmat); - RENEW(nrhcon,ITG,nmat); - - if(ndamp>0){RENEW(dacon,double,nmat);} - - RENEW(shcon,double,4*ntmat_*nmat); - RENEW(nshcon,ITG,nmat); - - RENEW(cocon,double,7*ntmat_*nmat); - RENEW(ncocon,ITG,2*nmat); - - RENEW(alcon,double,7*ntmat_*nmat); - RENEW(nalcon,ITG,2*nmat); - RENEW(alzero,double,nmat); - - RENEW(matname,char,80*nmat); - RENEW(ielmat,ITG,mi[2]*ne); - - /* allocating space for the state variables */ - - if(mortar!=1){ - RENEW(xstate,double,nstate_*mi[0]*(ne+nslavs)); - for(i=nxstate;i0){ - RENEW(plicon,double,(2*npmat_+1)*ntmat_*nmat); - RENEW(nplicon,ITG,(ntmat_+1)*nmat); - RENEW(plkcon,double,(2*npmat_+1)*ntmat_*nmat); - RENEW(nplkcon,ITG,(ntmat_+1)*nmat); - } - - /* material orientation */ - - if(norien>0){ - RENEW(orname,char,80*norien); - RENEW(ielorien,ITG,mi[2]*ne); - RENEW(orab,double,7*norien); - } - else { - SFREE(orname); - SFREE(ielorien); - SFREE(orab); - } - - /* amplitude definitions */ - - if(nam>0){ - RENEW(amname,char,80*nam); - RENEW(namta,ITG,3*nam); - RENEW(amta,double,2*namta[3*nam-2]); - } - else { - SFREE(amname); - SFREE(amta); - SFREE(namta); - SFREE(iamforc); - SFREE(iamload); - SFREE(iamboun); - } - - if(ntrans>0){ - RENEW(trab,double,7*ntrans); - } - else{SFREE(trab);SFREE(inotr);} - - if(ithermal[0]==0){ - SFREE(t0);SFREE(t1); - if((ne1d!=0)||(ne2d!=0)||(nuel_!=0)){ - SFREE(t0g);SFREE(t1g); - } - } - - if((ithermal[0]==0)||(nam<=0)){SFREE(iamt1);} - - if(ncs_>0){ - RENEW(ics,ITG,ncs_); - }else if(npt_>0){ - SFREE(ics); - } - if((ncs_>0)||(npt_>0)){ - SFREE(dcs); - } - - if(mcs>0){ - RENEW(cs,double,17*mcs); - }else{ - SFREE(cs); - } - - /* check for design variables */ - - for(i=0;i1) */ - - RENEW(vold,double,mt*nk); - - /* if the SPC boundary conditions were changed in the present step, - they have to be rematched with those in the last step. Removed SPC - boundary conditions do not appear any more (this is different from - forces and loads, where removed forces or loads are reset to zero; - a removed SPC constraint does not have a numerical value any more) */ - - NNEW(reorder,double,nboun); - NNEW(nreorder,ITG,nboun); - if(nbounold0){ - RENEW(amname,char,80*nam); - RENEW(namta,ITG,3*nam); - RENEW(amta,double,2*namta[3*nam-2]); - } - - } - - /* reallocating fields for all steps (>=1) */ - - RENEW(co,double,3*nk); - - RENEW(nodeboun,ITG,nboun); - RENEW(ndirboun,ITG,nboun); - RENEW(typeboun,char,nboun+1); - RENEW(xboun,double,nboun); - RENEW(ikboun,ITG,nboun); - RENEW(ilboun,ITG,nboun); - - RENEW(nodeforc,ITG,2*nforc); - RENEW(ndirforc,ITG,nforc); - RENEW(xforc,double,nforc); - RENEW(ikforc,ITG,nforc); - RENEW(ilforc,ITG,nforc); - - /* temperature loading */ - - if(ithermal[0] != 0){ - RENEW(t0,double,nk); - RENEW(t1,double,nk); - if((ne1d!=0)||(ne2d!=0)||(nuel_!=0)){ - RENEW(t0g,double,2*nk); - RENEW(t1g,double,2*nk); - } - if(nam>0){RENEW(iamt1,ITG,nk);} - } - - RENEW(nelemload,ITG,2*nload); - RENEW(sideload,char,20*nload); - RENEW(xload,double,2*nload); - - RENEW(cbody,char,81*nbody); - RENEW(ibody,ITG,3*nbody); - RENEW(xbody,double,7*nbody); - RENEW(xbodyold,double,7*nbody); - - RENEW(ipompc,ITG,nmpc); - RENEW(labmpc,char,20*nmpc+1); - RENEW(ikmpc,ITG,nmpc); - RENEW(ilmpc,ITG,nmpc); - RENEW(fmpc,double,nmpc); - - /* energy */ - - if((nener==1)&&(nenerold==0)){ - NNEW(ener,double,2*mi[0]*ne); - if((istep>1)&&(iperturb[0]>1)){ - printf(" *ERROR in CalculiX: in nonlinear calculations\n"); - printf(" energy output requests, if any,\n"); - printf(" must be specified in the first step\n\n"); - FORTRAN(stop,()); - } - } - - /* initial velocities and accelerations */ - - if((nmethod==4)||(nmethod==5)||(nmethod==8)||(nmethod==9)|| - ((abs(nmethod)==1)&&(iperturb[0]>=2))){ - RENEW(veold,double,mt*nk); - } - else{ - SFREE(veold); - } - - if((nmethod==4)&&(iperturb[0]>1)){ - NNEW(accold,double,mt*nk); - } - - if(nam>0){ - RENEW(iamforc,ITG,nforc); - RENEW(iamload,ITG,2*nload); - RENEW(iamboun,ITG,nboun); - } - - /* generate force convection elements */ - - if(network>0){ - ne1=ne;nkon0=nkon;nload1=nload; - RENEW(ipkon,ITG,ne+nload); - RENEW(ielmat,ITG,mi[2]*(ne+nload)); - for(i=mi[2]*ne;i0){ - RENEW(ielorien,ITG,mi[2]*(ne+nload)); - for(i=mi[2]*ne;i0) RENEW(prestr,double,6*mi[0]*ne); - if(nprop>0) RENEW(ielprop,ITG,ne); - if((ne1d!=0)||(ne2d!=0)) RENEW(offset,double,2*ne); - RENEW(nelemload,ITG,2*nload); - RENEW(sideload,char,20*nload); - RENEW(xload,double,2*nload); - RENEW(xloadold,double,2*nload); - if(nam>0){ - RENEW(iamload,ITG,2*nload); - for(i=2*nload1;i<2*nload;i++)iamload[i]=0; - } - if(nener==1)RENEW(ener,double,2*mi[0]*ne); - - /* moving the contact state variables forward by (ne-ne1) - element blocks (because of the advective elements) */ - - if(mortar!=1){ - RENEW(xstate,double,nstate_*mi[0]*(ne+nslavs)); - for(i=nstate_*mi[0]*(ne+nslavs)-1;i>=nstate_*mi[0]*ne;i--){ - xstate[i]=xstate[i-nstate_*mi[0]*(ne-ne1)]; - } - }else if(mortar==1){ - RENEW(xstate,double,nstate_*mi[0]*(ne+nintpoint)); - for(i=nstate_*mi[0]*(ne+nintpoint)-1;i>=nstate_*mi[0]*ne;i--){ - xstate[i]=xstate[i-nstate_*mi[0]*(ne-ne1)]; - } - } - - if(norien>0)RENEW(ielorien,ITG,mi[2]*ne); - RENEW(ielmat,ITG,mi[2]*ne); - for(i=mi[2]*ne1;i0){ - RENEW(inotr,ITG,2*nk); - } - - /* calling the user routine ufaceload (can be empty) */ - - if(ithermal[1]>=2){ - NNEW(sideloadtemp,char,20*nload); - for(i=0;i1){SFREE(nodempcref);SFREE(coefmpcref);SFREE(ikmpcref);} - memmpcref_=memmpc_;mpcfreeref=mpcfree;maxlenmpcref=maxlenmpc; - NNEW(nodempcref,ITG,3*memmpc_); - memcpy(nodempcref,nodempc,sizeof(ITG)*3*memmpc_); - NNEW(coefmpcref,double,memmpc_); - memcpy(coefmpcref,coefmpc,sizeof(double)*memmpc_); - NNEW(ikmpcref,ITG,nmpc);memcpy(ikmpcref,ikmpc,sizeof(ITG)*nmpc); - } - - /* decascading MPC's only necessary if MPC's changed */ - - if(((istep==1)||(ntrans>0)||(mpcend<0)||(nk!=nkold)||(nmpc!=nmpcold))&&(icascade==0)){ - - /* decascading the MPC's */ - - printf(" Decascading the MPC's\n\n"); - - callfrommain=1; - cascade(ipompc,&coefmpc,&nodempc,&nmpc, - &mpcfree,nodeboun,ndirboun,&nboun,ikmpc, - ilmpc,ikboun,ilboun,&mpcend, - labmpc,&nk,&memmpc_,&icascade,&maxlenmpc, - &callfrommain,iperturb,ithermal); - } - - /* determining the matrix structure: changes if SPC's have changed */ - - if((icascade==0)&&(nmethod<8)) printf(" Determining the structure of the matrix:\n"); - - NNEW(nactdof,ITG,mt*nk); - NNEW(mast1,ITG,nzs[1]); - NNEW(irow,ITG,1); - - if((mcs==0)||(cs[1]<0)){ - - NNEW(icol,ITG,mt*nk); - NNEW(jq,ITG,mt*nk+1); - NNEW(ipointer,ITG,mt*nk); - - if((icascade==0)&&((nmethod<8)||(nmethod>10))){ - if((nmethod==11)||(nmethod==13)){nmethodl=2;}else{nmethodl=nmethod;} - mastruct(&nk,kon,ipkon,lakon,&ne,nodeboun,ndirboun,&nboun,ipompc, - nodempc,&nmpc,nactdof,icol,jq,&mast1,&irow,&isolver,neq, - ikmpc,ilmpc,ipointer,nzs,&nmethodl,ithermal, - ikboun,ilboun,iperturb,mi,&mortar,typeboun,labmpc, - &iit,&icascade,&network,&iexpl,ielmat,matname); - } - else{neq[0]=1;neq[1]=1;neq[2]=1;} - } - else{ - - NNEW(icol,ITG,8*nk); - NNEW(jq,ITG,8*nk+1); - NNEW(ipointer,ITG,8*nk); - - if(nmethod==13){nmethodl=2;}else{nmethodl=nmethod;} - mastructcs(&nk,kon,ipkon,lakon,&ne,nodeboun,ndirboun,&nboun, - ipompc,nodempc,&nmpc,nactdof,icol,jq,&mast1,&irow,&isolver, - neq,ikmpc,ilmpc,ipointer,nzs,&nmethodl, - ics,cs,labmpc,&mcs,mi,&mortar,ielmat,matname); - } - - SFREE(ipointer);SFREE(mast1); - if((icascade==0)&&(nmethod<8))RENEW(irow,ITG,nzs[2]); - - /* nmethod=1: static analysis */ - /* nmethod=2: frequency analysis */ - /* nmethod=3: buckling analysis */ - /* nmethod=4: (linear or nonlinear) dynamic analysis */ - /* nmethod=5: steady state dynamics analysis */ - /* nmethod=6: Coriolis frequency calculation */ - /* nmethod=7: flutter frequency calculation */ - /* nmethod=8: magnetostatics */ - /* nmethod=9: magnetodynamics */ - /* nmethod=10: electromagnetic eigenvalue problems */ - /* nmethod=11: superelement creation */ - /* nmethod=12: sensitivity analysis */ - /* nmethod=13: Green function calculation */ - /* nmethod=14: Robustness w.r.t. to geometric tolerances */ - /* nmethod=15: Crack propagation */ - /* nmethod=16: Feasible direction based on sensitivity information */ - - if((nmethod<=1)||(nmethod==11)||((iperturb[0]>1)&&(nmethod<8))){ - if(iperturb[0]<2){ - - mpcinfo[0]=memmpc_;mpcinfo[1]=mpcfree;mpcinfo[2]=icascade; - mpcinfo[3]=maxlenmpc; - - if(icascade!=0){ - printf(" *ERROR in CalculiX: the matrix structure may"); - printf(" change due to nonlinear equations;"); - printf(" a purely linear calculation is not"); - printf(" feasible; use NLGEOM on the *STEP card."); - FORTRAN(stop,()); - } - - linstatic_precice(co,&nk,&kon,&ipkon,&lakon,&ne,nodeboun,ndirboun,xboun, - &nboun, - ipompc,nodempc,coefmpc,labmpc,&nmpc,nodeforc,ndirforc,xforc, - &nforc,nelemload,sideload,xload,&nload, - nactdof,&icol,jq,&irow,neq,&nzl,&nmethod,ikmpc, - ilmpc,ikboun,ilboun,elcon,nelcon,rhcon,nrhcon, - alcon,nalcon,alzero,&ielmat,&ielorien,&norien,orab,&ntmat_, - t0,t1,t1old,ithermal,prestr,&iprestr,vold,iperturb,sti,nzs, - &kode,filab,eme,&iexpl,plicon, - nplicon,plkcon,nplkcon,&xstate,&npmat_,matname, - &isolver,mi,&ncmat_,&nstate_,cs,&mcs,&nkon,&ener, - xbounold,xforcold,xloadold,amname,amta,namta, - &nam,iamforc,iamload,iamt1,iamboun,&ttime, - output,set,&nset,istartset,iendset,ialset,&nprint,prlab, - prset,&nener,trab,inotr,&ntrans,fmpc,ipobody,ibody,xbody, - &nbody, - xbodyold,timepar,thicke,jobnamec,tieset,&ntie,&istep,&nmat, - ielprop,prop,typeboun,&mortar,mpcinfo,tietol,ics, - orname,itempuser,t0g,t1g,jmax, - /* PreCICE args */ - preciceParticipantName, configFilename); - - for(i=0;i<3;i++){nzsprevstep[i]=nzs[i];} - - memmpc_=mpcinfo[0];mpcfree=mpcinfo[1];icascade=mpcinfo[2]; - maxlenmpc=mpcinfo[3]; - - } - - // else{ - - // mpcinfo[0]=memmpc_;mpcinfo[1]=mpcfree;mpcinfo[2]=icascade; - // mpcinfo[3]=maxlenmpc; - - // nonlingeo(&co,&nk,&kon,&ipkon,&lakon,&ne,nodeboun,ndirboun,xboun, - // &nboun,&ipompc,&nodempc,&coefmpc,&labmpc,&nmpc,nodeforc, - // ndirforc,xforc,&nforc,&nelemload,&sideload,xload,&nload, - // nactdof,&icol,jq,&irow,neq,&nzl,&nmethod,&ikmpc,&ilmpc, - // ikboun,ilboun,elcon,nelcon,rhcon,nrhcon,alcon,nalcon, - // alzero,&ielmat,&ielorien,&norien,orab,&ntmat_,t0,t1,t1old, - // ithermal,prestr,&iprestr,&vold,iperturb,sti,nzs,&kode, - // filab,&idrct,jmax,jout,timepar,eme,xbounold,xforcold, - // xloadold,veold,accold,amname,amta,namta,&nam,iamforc, - // &iamload,iamt1,alpha,&iexpl,iamboun,plicon,nplicon,plkcon, - // nplkcon,&xstate,&npmat_,&istep,&ttime,matname,qaold,mi, - // &isolver,&ncmat_,&nstate_,cs,&mcs,&nkon,&ener, - // mpcinfo,output,shcon,nshcon,cocon,ncocon,physcon,&nflow, - // ctrl,set,&nset,istartset,iendset,ialset,&nprint,prlab, - // prset,&nener,ikforc,ilforc,trab,inotr,&ntrans,&fmpc,cbody, - // ibody,xbody,&nbody,xbodyold,ielprop,prop,&ntie,tieset, - // &itpamp,&iviewfile,jobnamec,tietol,&nslavs,thicke,ics, - // &nintpoint,&mortar,&ifacecount,typeboun,&islavsurf, - // &pslavsurf,&clearini,&nmat,xmodal,&iaxial,&inext,&nprop, - // &network,orname,vel,&nef,velo,veloo,energy,itempuser, - // ipobody,&inewton,t0g,t1g,&ifreebody); - - // memmpc_=mpcinfo[0];mpcfree=mpcinfo[1];icascade=mpcinfo[2]; - // maxlenmpc=mpcinfo[3]; - - // for(i=0;i<3;i++){nzsprevstep[i]=nzs[i];} - - // } - } -// else if((nmethod==2)||(nmethod==13)){ - -// /* FREQUENCY ANALYSIS */ - -// if((mcs==0)||(cs[1]<0)){ -// #ifdef ARPACK - -// mpcinfo[0]=memmpc_;mpcinfo[1]=mpcfree;mpcinfo[2]=icascade; -// mpcinfo[3]=maxlenmpc; - -// arpack(co,&nk,&kon,&ipkon,&lakon,&ne,nodeboun,ndirboun,xboun,&nboun, -// ipompc,nodempc,coefmpc,labmpc,&nmpc,nodeforc,ndirforc,xforc, -// &nforc,nelemload,sideload,xload,&nload, -// nactdof,icol,jq,&irow,neq,&nzl,&nmethod,ikmpc, -// ilmpc,ikboun,ilboun,elcon,nelcon,rhcon,nrhcon, -// shcon,nshcon,cocon,ncocon, -// alcon,nalcon,alzero,&ielmat,&ielorien,&norien,orab,&ntmat_, -// t0,t1,t1old,ithermal,prestr,&iprestr,vold,iperturb,sti,nzs, -// &kode,mei,fei,filab, -// &iexpl,plicon,nplicon,plkcon,nplkcon, -// &xstate,&npmat_,matname,mi,&ncmat_,&nstate_,&ener,jobnamec, -// output,set,&nset,istartset,iendset,ialset,&nprint,prlab, -// prset,&nener,&isolver,trab,inotr,&ntrans,&ttime,fmpc,ipobody, -// ibody,xbody,&nbody,thicke,&nslavs,tietol,&nkon,mpcinfo, -// &ntie,&istep,&mcs,ics,tieset,cs,&nintpoint,&mortar,&ifacecount, -// &islavsurf,&pslavsurf,&clearini,&nmat,typeboun,ielprop,prop, -// orname,&inewton,t0g,t1g); - -// memmpc_=mpcinfo[0];mpcfree=mpcinfo[1];icascade=mpcinfo[2]; -// maxlenmpc=mpcinfo[3]; - -// for(i=0;i<3;i++){nzsprevstep[i]=nzs[i];} - -// #else -// printf(" *ERROR in CalculiX: the ARPACK library is not linked\n\n"); -// FORTRAN(stop,()); -// #endif - -// }else{ - -// #ifdef ARPACK - -// mpcinfo[0]=memmpc_;mpcinfo[1]=mpcfree;mpcinfo[2]=icascade; -// mpcinfo[3]=maxlenmpc; - -// arpackcs(co,&nk,&kon,&ipkon,&lakon,&ne,nodeboun,ndirboun, -// xboun,&nboun, -// ipompc,nodempc,coefmpc,labmpc,&nmpc,nodeforc,ndirforc,xforc, -// &nforc,nelemload,sideload,xload,&nload, -// nactdof,icol,jq,&irow,neq,&nzl,&nmethod,ikmpc, -// ilmpc,ikboun,ilboun,elcon,nelcon,rhcon,nrhcon, -// alcon,nalcon,alzero,&ielmat,&ielorien,&norien,orab,&ntmat_, -// t0,t1,t1old,ithermal,prestr,&iprestr, -// vold,iperturb,sti,nzs,&kode,mei,fei,filab, -// &iexpl,plicon,nplicon,plkcon,nplkcon, -// &xstate,&npmat_,matname,mi,ics,cs,&mpcend,&ncmat_, -// &nstate_,&mcs,&nkon,jobnamec,output,set,&nset,istartset, -// iendset,ialset,&nprint,prlab, -// prset,&nener,&isolver,trab,inotr,&ntrans,&ttime,fmpc,ipobody, -// ibody,xbody,&nbody,&nevtot,thicke,&nslavs,tietol,mpcinfo, -// &ntie,&istep,tieset,&nintpoint,&mortar,&ifacecount,&islavsurf, -// &pslavsurf,&clearini,&nmat,typeboun,ielprop,prop,orname, -// &inewton,t0g,t1g); - -// memmpc_=mpcinfo[0];mpcfree=mpcinfo[1];icascade=mpcinfo[2]; -// maxlenmpc=mpcinfo[3]; - -// for(i=0;i<3;i++){nzsprevstep[i]=nzs[i];} - -// #else -// printf(" *ERROR in CalculiX: the ARPACK library is not linked\n\n"); -// FORTRAN(stop,()); -// #endif - -// } -// }else if(nmethod==3){ - -// #ifdef ARPACK -// arpackbu(co,&nk,kon,ipkon,lakon,&ne,nodeboun,ndirboun,xboun,&nboun, -// ipompc,nodempc,coefmpc,labmpc,&nmpc,nodeforc,ndirforc,xforc, -// &nforc, -// nelemload,sideload,xload,&nload, -// nactdof,icol,jq,irow,neq,&nzl,&nmethod,ikmpc, -// ilmpc,ikboun,ilboun,elcon,nelcon,rhcon,nrhcon, -// alcon,nalcon,alzero,ielmat,ielorien,&norien,orab,&ntmat_, -// t0,t1,t1old,ithermal,prestr,&iprestr, -// vold,iperturb,sti,nzs,&kode,mei,fei,filab, -// eme,&iexpl,plicon,nplicon,plkcon,nplkcon, -// xstate,&npmat_,matname,mi,&ncmat_,&nstate_,ener,output, -// set,&nset,istartset,iendset,ialset,&nprint,prlab, -// prset,&nener,&isolver,trab,inotr,&ntrans,&ttime,fmpc,ipobody, -// ibody,xbody,&nbody,thicke,jobnamec,&nmat,ielprop,prop, -// orname,typeboun,t0g,t1g,&mcs,&istep); -// #else -// printf(" *ERROR in CalculiX: the ARPACK library is not linked\n\n"); -// FORTRAN(stop,()); -// #endif -// } -// else if(nmethod==4) -// { -// if((ne1d!=0)||(ne2d!=0)){ -// printf(" *WARNING: 1-D or 2-D elements may cause problems in modal dynamic calculations\n"); -// printf(" ensure that point loads defined in a *MODAL DYNAMIC step\n"); -// printf(" and applied to nodes belonging to 1-D or 2-D elements have been\n"); -// printf(" applied to the same nodes in the preceding FREQUENCY step with\n"); -// printf(" magnitude zero; look at example shellf.inp for a guideline.\n\n");} - -// printf(" Composing the dynamic response from the eigenmodes\n\n"); - -// dyna(&co,&nk,&kon,&ipkon,&lakon,&ne,&nodeboun,&ndirboun,&xboun,&nboun, -// &ipompc,&nodempc,&coefmpc,&labmpc,&nmpc,nodeforc,ndirforc,xforc, -// &nforc, -// nelemload,sideload,xload,&nload, -// &nactdof,neq,&nzl,icol,irow,&nmethod,&ikmpc,&ilmpc,&ikboun,&ilboun, -// elcon,nelcon,rhcon,nrhcon,cocon,ncocon, -// alcon,nalcon,alzero,&ielmat,&ielorien,&norien,orab,&ntmat_,&t0, -// &t1,ithermal,prestr,&iprestr,&vold,iperturb,&sti,nzs, -// timepar,xmodal,&veold,amname,amta, -// namta,&nam,iamforc,iamload,&iamt1, -// jout,&kode,filab,&eme,xforcold,xloadold, -// &t1old,&iamboun,&xbounold,&iexpl,plicon, -// nplicon,plkcon,nplkcon,&xstate,&npmat_,matname, -// mi,&ncmat_,&nstate_,&ener,jobnamec,&ttime,set,&nset, -// istartset,iendset,&ialset,&nprint,prlab, -// prset,&nener,trab,&inotr,&ntrans,&fmpc,ipobody,ibody,xbody,&nbody, -// xbodyold,&istep,&isolver,jq,output,&mcs,&nkon,&mpcend,ics,cs, -// &ntie,tieset,&idrct,jmax,ctrl,&itpamp,tietol,&nalset, -// ikforc,ilforc,thicke,&nslavs,&nmat,typeboun,ielprop,prop,orname, -// t0g,t1g); -// } -// else if(nmethod==5) -// { -// if((ne1d!=0)||(ne2d!=0)){ -// printf(" *WARNING: 1-D or 2-D elements may cause problems in steady state calculations\n"); -// printf(" ensure that point loads defined in a *STEADY STATE DYNAMICS step\n"); -// printf(" and applied to nodes belonging to 1-D or 2-D elements have been\n"); -// printf(" applied to the same nodes in the preceding FREQUENCY step with\n"); -// printf(" magnitude zero; look at example shellf.inp for a guideline.\n\n");} - -// printf(" Composing the steady state response from the eigenmodes\n\n"); - -// steadystate(&co,&nk,&kon,&ipkon,&lakon,&ne,&nodeboun,&ndirboun,&xboun, -// &nboun, -// &ipompc,&nodempc,&coefmpc,&labmpc,&nmpc,nodeforc,ndirforc, -// xforc,&nforc, -// nelemload,sideload,xload,&nload, -// &nactdof,neq,&nzl,icol,irow,&nmethod,&ikmpc,&ilmpc,&ikboun, -// &ilboun, -// elcon,nelcon,rhcon,nrhcon,cocon,ncocon, -// alcon,nalcon,alzero,&ielmat,&ielorien,&norien,orab,&ntmat_, -// &t0, -// &t1,ithermal,prestr,&iprestr,&vold,iperturb,sti,nzs, -// timepar,xmodal,&veold,amname,amta, -// namta,&nam,iamforc,iamload,&iamt1, -// jout,&kode,filab,&eme,xforcold,xloadold, -// &t1old,&iamboun,&xbounold,&iexpl,plicon, -// nplicon,plkcon,nplkcon,xstate,&npmat_,matname, -// mi,&ncmat_,&nstate_,&ener,jobnamec,&ttime,set,&nset, -// istartset,iendset,ialset,&nprint,prlab, -// prset,&nener,trab,&inotr,&ntrans,&fmpc,ipobody,ibody,xbody, -// &nbody, -// xbodyold,&istep,&isolver,jq,output,&mcs,&nkon,ics,cs, -// &mpcend, -// ctrl,ikforc,ilforc,thicke,&nmat,typeboun,ielprop,prop, -// orname, -// &ndamp,dacon,t0g,t1g); -// } -// else if((nmethod==6)||(nmethod==7)) -// { - -// printf(" Composing the complex eigenmodes from the real eigenmodes\n\n"); - -// complexfreq(&co,&nk,&kon,&ipkon,&lakon,&ne,&nodeboun,&ndirboun,&xboun, -// &nboun,&ipompc,&nodempc,&coefmpc,&labmpc,&nmpc,nodeforc, -// ndirforc,xforc,&nforc, -// nelemload,sideload,xload,&nload, -// &nactdof,neq,&nzl,icol,irow,&nmethod,&ikmpc,&ilmpc,&ikboun, -// &ilboun, -// elcon,nelcon,rhcon,nrhcon,cocon,ncocon, -// alcon,nalcon,alzero,&ielmat,&ielorien,&norien,orab,&ntmat_, -// &t0, -// &t1,ithermal,prestr,&iprestr,&vold,iperturb,&sti,nzs, -// timepar,xmodal,&veold,amname,amta, -// namta,&nam,iamforc,iamload,&iamt1, -// jout,&kode,filab,&eme,xforcold,xloadold, -// &t1old,&iamboun,&xbounold,&iexpl,plicon, -// nplicon,plkcon,nplkcon,xstate,&npmat_,matname, -// mi,&ncmat_,&nstate_,&ener,jobnamec,&ttime,set,&nset, -// istartset,iendset,&ialset,&nprint,prlab, -// prset,&nener,trab,&inotr,&ntrans,&fmpc,ipobody,ibody,xbody, -// &nbody, -// xbodyold,&istep,&isolver,jq,output,&mcs,&nkon,&mpcend,ics, -// cs, -// &ntie,tieset,&idrct,jmax,ctrl,&itpamp,tietol,&nalset, -// ikforc,ilforc,thicke,jobnamef,mei,&nmat,ielprop,prop,orname, -// typeboun,t0g,t1g); -// } -// else if((nmethod>7)&&(nmethod<12)){ - -// mpcinfo[0]=memmpc_;mpcinfo[1]=mpcfree;mpcinfo[2]=icascade; -// mpcinfo[3]=maxlenmpc; - -// electromagnetics(&co,&nk,&kon,&ipkon,&lakon,&ne,nodeboun, -// ndirboun,xboun,&nboun, -// &ipompc,&nodempc,&coefmpc,&labmpc,&nmpc,nodeforc, -// ndirforc,xforc, -// &nforc,&nelemload,&sideload,xload,&nload, -// nactdof,&icol,&jq,&irow,neq,&nzl,&nmethod,&ikmpc, -// &ilmpc,ikboun,ilboun,elcon,nelcon,rhcon,nrhcon, -// alcon,nalcon,alzero,&ielmat,&ielorien,&norien,orab, -// &ntmat_, -// t0,t1,t1old,ithermal,prestr,&iprestr, -// &vold,iperturb,sti,nzs,&kode,filab,&idrct,jmax, -// jout,timepar,eme,xbounold,xforcold,xloadold, -// veold,accold,amname,amta,namta, -// &nam,iamforc,&iamload,iamt1,alpha, -// &iexpl,iamboun,plicon,nplicon,plkcon,nplkcon, -// &xstate,&npmat_,&istep,&ttime,matname,qaold,mi, -// &isolver,&ncmat_,&nstate_,cs,&mcs,&nkon,&ener, -// mpcinfo,output, -// shcon,nshcon,cocon,ncocon,physcon,&nflow,ctrl, -// &set,&nset,&istartset,&iendset,&ialset,&nprint,prlab, -// prset,&nener,ikforc,ilforc,trab,inotr,&ntrans,&fmpc, -// ipobody,ibody,xbody,&nbody,xbodyold,ielprop,prop, -// &ntie,&tieset,&itpamp,&iviewfile,jobnamec,&tietol, -// &nslavs,thicke, -// ics,&nalset,&nmpc_,&nmat,typeboun,&iaxial,&nload_,&nprop, -// &network,orname,t0g,t1g); - -// memmpc_=mpcinfo[0];mpcfree=mpcinfo[1];icascade=mpcinfo[2]; -// maxlenmpc=mpcinfo[3]; -// } - -// else if(nmethod==12){ - -// if(icoordinate==1){ -// sensi_coor(co,&nk,&kon,&ipkon,&lakon,&ne,nodeboun,ndirboun, -// xboun,&nboun,ipompc,nodempc,coefmpc,labmpc,&nmpc,nodeforc, -// ndirforc,xforc,&nforc,nelemload,sideload,xload,&nload, -// nactdof,icol,jq,&irow,neq,&nzl,&nmethod,ikmpc, -// ilmpc,ikboun,ilboun,elcon,nelcon,rhcon,nrhcon, -// alcon,nalcon,alzero,&ielmat,&ielorien,&norien,orab,&ntmat_, -// t0,t1,t1old,ithermal,prestr,&iprestr,vold,iperturb,sti,nzs, -// &kode,filab,eme,&iexpl,plicon, -// nplicon,plkcon,nplkcon,&xstate,&npmat_,matname, -// &isolver,mi,&ncmat_,&nstate_,cs,&mcs,&nkon,&ener, -// xbounold,xforcold,xloadold,amname,amta,namta, -// &nam,iamforc,iamload,iamt1,iamboun,&ttime, -// output,set,&nset,istartset,iendset,ialset,&nprint,prlab, -// prset,&nener,trab,inotr,&ntrans,fmpc,ipobody,ibody,xbody, -// &nbody, -// xbodyold,timepar,thicke,jobnamec,tieset,&ntie,&istep,&nmat, -// ielprop,prop,typeboun,&mortar,mpcinfo,tietol,ics, -// &nobject,&objectset,&istat,orname,nzsprevstep,&nlabel, -// physcon, -// jobnamef,iponor,knor,&ne2d,iponoel,inoel,&mpcend,dgdxglob, -// g0,&nodedesi,&ndesi,&nobjectstart,&xdesi,rig); - -// }else{ -// sensi_orien(co,&nk,&kon,&ipkon,&lakon,&ne,nodeboun,ndirboun, -// xboun,&nboun,ipompc,nodempc,coefmpc,labmpc,&nmpc,nodeforc, -// ndirforc,xforc,&nforc,nelemload,sideload,xload,&nload, -// nactdof,icol,jq,&irow,neq,&nzl,&nmethod,ikmpc, -// ilmpc,ikboun,ilboun,elcon,nelcon,rhcon,nrhcon, -// alcon,nalcon,alzero,&ielmat,&ielorien,&norien,orab,&ntmat_, -// t0,t1,t1old,ithermal,prestr,&iprestr,vold,iperturb,sti,nzs, -// &kode,filab,eme,&iexpl,plicon, -// nplicon,plkcon,nplkcon,&xstate,&npmat_,matname, -// &isolver,mi,&ncmat_,&nstate_,cs,&mcs,&nkon,&ener, -// xbounold,xforcold,xloadold,amname,amta,namta, -// &nam,iamforc,iamload,iamt1,iamboun,&ttime, -// output,set,&nset,istartset,iendset,ialset,&nprint,prlab, -// prset,&nener,trab,inotr,&ntrans,fmpc,ipobody,ibody,xbody, -// &nbody, -// xbodyold,timepar,thicke,jobnamec,tieset,&ntie,&istep,&nmat, -// ielprop,prop,typeboun,&mortar,mpcinfo,tietol,ics, -// &nobject,&objectset,&istat,orname,nzsprevstep,&nlabel, -// physcon, -// jobnamef,iponor,knor,&ne2d,iponoel,inoel,&mpcend); -// } - -// } - -// else if(nmethod==14){ - -// robustdesign(co,&nk,&kon,&ipkon,&lakon,&ne,nodeboun,ndirboun,xboun, -// &nboun,ipompc,nodempc,coefmpc,labmpc,&nmpc,nodeforc, -// ndirforc,xforc,&nforc,nelemload,sideload,xload,&nload, -// nactdof,icol,jq,&irow,neq,&nzl,&nmethod,ikmpc,ilmpc,ikboun, -// ilboun,elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero, -// &ielmat,&ielorien,&norien,orab,&ntmat_,t0,t1,t1old,ithermal, -// prestr,&iprestr,vold,iperturb,sti,nzs,&kode,filab,eme, -// &iexpl,plicon,nplicon,plkcon,nplkcon,&xstate,&npmat_, -// matname,&isolver,mi,&ncmat_,&nstate_,cs,&mcs,&nkon,&ener, -// xbounold,xforcold,xloadold,amname,amta,namta,&nam,iamforc, -// iamload,iamt1,iamboun,&ttime,output,set,&nset,istartset, -// iendset,ialset,&nprint,prlab,prset,&nener,trab,inotr, -// &ntrans,fmpc,ipobody,ibody,xbody,&nbody,xbodyold,timepar, -// thicke,jobnamec,tieset,&ntie,&istep,&nmat,ielprop,prop, -// typeboun,&mortar,mpcinfo,tietol,ics,&nobject, -// &objectset,&istat,orname,nzsprevstep,&nlabel,physcon, -// jobnamef,iponor,knor,&ne2d,iponoel,inoel,&mpcend, -// irobustdesign,irandomtype,randomval,rig); -// } - -// else if(nmethod==15){ - -// crackpropagation(&ipkon,&kon,&lakon,&ne,&nk,jobnamec,&nboun,iamboun,xboun, -// &nload,sideload,iamload,&nforc,iamforc,xforc,ithermal, -// &t1,&iamt1,&co,&nkon,mi,&ielmat,matname,output,&nmat,set, -// &nset,istartset,iendset,ialset,jmax,timepar,nelcon, -// elcon,&ncmat_,&ntmat_,&istep,filab,&nmethod,mei,&ntrans, -// &inotr,&t0,&ne1d,&ne2d,&t0g,&t1g,&nam,&t1old,&vold, -// iperturb,&iprestr,&prestr,&norien,&ielorien,&nprop, -// &ielprop,&offset,&sti,&eme,&nener,&ener,&nstate_, -// &mortar,&nslavs,&nintpoint,&xstate,&iponor,&thicke); -// } - -// else if(nmethod==16){ - -// feasibledirection(&nobject,&objectset,&dgdxglob,g0,&ndesi,nodedesi,&nk, -// &isolver,&ipkon,&kon,&lakon,&ne,nelemload,&nload, -// nodeboun,&nboun,ndirboun,ithermal,co,vold,mi,&ielmat, -// ielprop,prop,&kode,&nmethod,filab,&nstate_,&istep,cs, -// set,&nset,istartset,iendset,ialset,jobnamec,output, -// &ntrans,inotr,trab,orname,xdesi,timepar,coini,ikboun, -// nactdof,&ne2d,&nkon); - -// } - - SFREE(nactdof);SFREE(icol);SFREE(jq);SFREE(irow);SFREE(ipobody); - - /* check whether refinement was active */ - - // if(irefineloop==20){ - if(strcmp1(&filab[4089],"RM")==0){ - irefineloop++; - - if(irefineloop==1){ - - /* refinement was requested in the step which was just - finished and a refined mesh was created and stored. - The calculation has to restart from the beginning with - this new mesh */ - - memcpy(ipoinp,ipoinp_sav,sizeof(ITG)*2*nentries); - memcpy(inp,inp_sav,sizeof(ITG)*inp_size); - - /* deallocating fields */ - - dealloc_cal(&ncs_,&ics,&mcs,&cs,&tieset,&tietol,&co, - &kon,&ipkon,&lakon,&nodeboun,&ndirboun,&typeboun,&xboun, - &ikboun,&ilboun,&nodebounold,&ndirbounold,&xbounold,&ipompc, - &labmpc,&ikmpc,&ilmpc,&fmpc,&nodempc,&coefmpc,&nodempcref, - &coefmpcref,&ikmpcref,&nodeforc,&ndirforc,&xforc, - &ikforc,&ilforc,&xforcold,&nelemload,&sideload,&xload, - &xloadold,&cbody,&ibody,&xbody,&xbodyold,&nam, - &iamboun,&iamforc,&iamload,&amname,&amta,&namta,&set, - &istartset,&iendset,&ialset,&elcon,&nelcon,&rhcon, - &nrhcon,&shcon,&nshcon,&cocon,&ncocon,&alcon, - &nalcon,&alzero,&nprop,&ielprop,&prop,&npmat_, - &plicon,&nplicon,&plkcon,&nplkcon,&ndamp,&dacon,&norien, - &orname,&orab,&ielorien,&ntrans,&trab,&inotr,&iprestr, - &prestr,ithermal,&t0,&t1,&t1old,&iamt1,&ne1d, - &ne2d,&t0g,&t1g,irobustdesign,&irandomtype, - &randomval,&prlab,&prset,&filab,&xmodal,&ielmat, - &matname,&sti,&eme,&ener,&xstate,&vold, - &veold,&vel,&velo,&veloo,&iponor,&xnor, - &knor,&thicke,&offset,&iponoel,&inoel,&rig, - &ne2boun,&islavsurf,&mortar,&pslavsurf,&clearini, - &nobject_,&objectset,&nmethod,iperturb,&irefineloop, - &iparentel,&iprfn,&konrfn,&ratiorfn,&heading, - &nodedesi,&dgdxglob,&g0,&nuel_,&xdesi,&nfc,&coeffc, - &ikdc,&edc,&coini); - - /* closing and reopening the output files */ - - FORTRAN(openfile,(jobnamef)); - - /* initialization of the variables */ - - ini_cal(jobnamec,output,fneig,kind1,kind2,itempuser,irobustdesign, - &nprint,neq,&mpcfree,&nbounold,&nforcold,&nloadold,&nbody_, - &nbodyold,&network,&nheading_,&nmpc_,&nload_,&nforc_,&nboun_, - &nintpoint,iperturb,&ntmat_,ithermal,&isolver,&nslavs,&nkon_, - &mortar,jout,&nkon,&nevtot,&ifacecount,&iplas,&npmat_,mi, - &mpcend,&namtot_,&icascade,&ne1d,&ne2d,infree,&nflow, - irstrt,&nener,&jrstrt,&ntie_,&mcs,&nprop_,&nprop,&itpamp, - &nevdamp_,&npt_,&iaxial,&inext,&icontact,&nobject,&nobject_, - &iit,&mpcfreeref,&isens,&namtot,&nstam,&ndamp,&nef, - &nk_,&ne_,&nalset_,&nmat_,&norien_,&nam_,&ntrans_, - &ncs_,&nstate_,&ncmat_,&memmpc_,&nprint_,energy,ctrl,alpha, - qaold,physcon,&istep,&istat,&iprestr,&kode,&nload,&nbody,&nforc, - &nboun,&nk,&nmpc,&nam,&nzs_,&nlabel,&ttime,&iheading,&nfc, - &nfc_,&ndc,&ndc_); - - NNEW(set,char,81*nset_); - NNEW(meminset,ITG,nset_); - NNEW(rmeminset,ITG,nset_); - NNEW(iuel,ITG,4*nuel_); - - FORTRAN(allocation,(&nload_,&nforc_,&nboun_,&nk_,&ne_,&nmpc_,&nset_, - &nalset_,&nmat_,&ntmat_,&npmat_,&norien_,&nam_, - &nprint_,mi,&ntrans_,set,meminset,rmeminset,&ncs_, - &namtot_,&ncmat_,&memmpc_,&ne1d,&ne2d,&nflow, - jobnamec,irstrt,ithermal,&nener,&nstate_,&istep, - inpc,ipoinp,inp,&ntie_,&nbody_, - &nprop_,ipoinpc,&nevdamp_,&npt_,&nslavs,&nkon_,&mcs, - &mortar,&ifacecount,&nintpoint,infree,&nheading_, - &nobject_,iuel,&iprestr,&nstam,&ndamp,&nef, - &nbounold,&nforcold,&nloadold,&nbodyold,&mpcend, - irobustdesign,&nfc_,&ndc_)); - - SFREE(meminset);SFREE(rmeminset);mt=mi[1]+1; - NNEW(heading,char,66*nheading_); - - continue; - } - } - - /* reset tempuserflag */ - - itempuser[0]=0; - - /* deleting the perturbation loads and temperatures */ - - if((iperturb[0]==1)&&(nmethod==3)){ - nforc=0; - nload=0; - nbody=0; - if(ithermal[0]==1){ - for(k=0;k0){ - for(i=0;i0){ - if(namta[3*iamboun[i]-1]>0){ - iamboun[i]=0; - xboun[i]=xbounold[i];} - } - } - for(i=0;i0){ - if(namta[3*iamforc[i]-1]>0){ - iamforc[i]=0; - xforc[i]=xforcold[i];} - } - } - for(i=0;i<2*nload;i++){ - if(iamload[i]>0){ - if(namta[3*iamload[i]-1]>0){ - iamload[i]=0; - xload[i]=xloadold[i];} - } - } - for(i=1;i<3*nbody;i=i+3){ - if(ibody[i]>0){ - if(namta[3*ibody[i]-1]>0){ - ibody[i]=0; - xbody[7*(i-1)/3]=xbodyold[7*(i-1)/3];} - } - } - if(ithermal[0]==1){ - if(iamt1[i]>0){ - if(namta[3*iamt1[i]-1]>0){ - iamt1[i]=0; - t1[i]=t1old[i];} - } - } - } - } - - /* removing the advective elements, if any */ - - if(network>0){ - RENEW(ipkon,ITG,ne1); - RENEW(lakon,char,8*ne1); - RENEW(kon,ITG,nkon0); - RENEW(sti,double,6*mi[0]*ne1); - RENEW(eme,double,6*mi[0]*ne1); - if(iprestr>0) RENEW(prestr,double,6*mi[0]*ne1); - if(nprop>0) RENEW(ielprop,ITG,ne1); - if((ne1d!=0)||(ne2d!=0)) RENEW(offset,double,2*ne1); - if(nener==1)RENEW(ener,double,2*mi[0]*ne1); - - /* moving the contact state variables back by (ne-ne1) - element blocks */ - - if(mortar!=1){ - for(i=nstate_*mi[0]*ne1;i0)RENEW(ielorien,ITG,mi[2]*ne1); - RENEW(ielmat,ITG,mi[2]*ne1); - - /* reactivating the original load labels */ - - for(i=nload-1;i>=nload0;i--){ - if(strcmp2(&sideload[20*i]," ",20)==0){ - iload=nelemload[2*i+1]; - strcpy1(&sideload[20*(iload-1)],"F",1); - } - } - ne=ne1;nkon=nkon0; - - } - - nload=nload0; - - if((nmethod==4)&&(iperturb[0]>1)) SFREE(accold); - - if(irstrt[0]>0){ - jrstrt++; - if(jrstrt>=irstrt[0]){ - jrstrt=0; - FORTRAN(restartwrite,(&istep,&nset,&nload,&nforc,&nboun,&nk,&ne,&nmpc, - &nalset,&nmat,&ntmat_,&npmat_,&norien,&nam, - &nprint,mi,&ntrans,&ncs_,&namtot,&ncmat_,&mpcend, - &maxlenmpc,&ne1d,&ne2d,&nflow,&nlabel,&iplas, - &nkon,ithermal,&nmethod,iperturb,&nstate_,&nener, - set,istartset,iendset,ialset,co,kon,ipkon,lakon, - nodeboun,ndirboun,iamboun,xboun,ikboun,ilboun, - ipompc,nodempc,coefmpc,labmpc,ikmpc,ilmpc, - nodeforc,ndirforc,iamforc,xforc,ikforc,ilforc, - nelemload,iamload,sideload,xload,elcon,nelcon, - rhcon,nrhcon,alcon,nalcon,alzero,plicon,nplicon, - plkcon,nplkcon,orname,orab,ielorien,trab,inotr, - amname,amta,namta,t0,t1,iamt1,veold,ielmat, - matname,prlab,prset,filab,vold,nodebounold, - ndirbounold,xbounold,xforcold,xloadold,t1old,eme, - iponor,xnor,knor,thicke,offset,iponoel,inoel,rig, - shcon,nshcon,cocon,ncocon,ics,sti,ener,xstate, - jobnamec,infree,prestr,&iprestr,cbody,ibody, - xbody,&nbody,xbodyold,&ttime,qaold,cs,&mcs, - output,physcon,ctrl,typeboun,fmpc,tieset,&ntie, - tietol,&nslavs,t0g,t1g,&nprop,ielprop,prop, - &mortar,&nintpoint,&ifacecount,islavsurf, - pslavsurf,clearini,irstrt,vel,&nef,velo,veloo, - ne2boun,&memmpc_,heading,&nheading_,&network, - &nfc,&ndc,coeffc,ikdc,edc)); - } - } - - } - - FORTRAN(closefile,()); - - strcpy2(fneig,jobnamec,132); - strcat(fneig,".frd"); - if((f1=fopen(fneig,"ab"))==NULL){ - printf(" *ERROR in frd: cannot open frd file for writing..."); - exit(0); - } - fprintf(f1," 9999\n"); - fclose(f1); - - /* deallocating the fields - this section is addressed immediately after leaving calinput */ - - SFREE(ipoinpc);SFREE(inpc);SFREE(inp);SFREE(ipoinp);SFREE(inp_sav); - SFREE(ipoinp_sav); - - dealloc_cal(&ncs_,&ics,&mcs,&cs,&tieset,&tietol,&co, - &kon,&ipkon,&lakon,&nodeboun,&ndirboun,&typeboun,&xboun, - &ikboun,&ilboun,&nodebounold,&ndirbounold,&xbounold,&ipompc, - &labmpc,&ikmpc,&ilmpc,&fmpc,&nodempc,&coefmpc, - &nodempcref,&coefmpcref,&ikmpcref,&nodeforc,&ndirforc,&xforc, - &ikforc,&ilforc,&xforcold,&nelemload,&sideload,&xload, - &xloadold,&cbody,&ibody,&xbody,&xbodyold,&nam, - &iamboun,&iamforc,&iamload,&amname,&amta,&namta,&set, - &istartset,&iendset,&ialset,&elcon,&nelcon,&rhcon, - &nrhcon,&shcon,&nshcon,&cocon,&ncocon,&alcon, - &nalcon,&alzero,&nprop,&ielprop,&prop,&npmat_, - &plicon,&nplicon,&plkcon,&nplkcon,&ndamp,&dacon,&norien, - &orname,&orab,&ielorien,&ntrans,&trab,&inotr,&iprestr, - &prestr,ithermal,&t0,&t1,&t1old,&iamt1,&ne1d, - &ne2d,&t0g,&t1g,irobustdesign,&irandomtype, - &randomval,&prlab,&prset,&filab,&xmodal,&ielmat, - &matname,&sti,&eme,&ener,&xstate,&vold, - &veold,&vel,&velo,&veloo,&iponor,&xnor, - &knor,&thicke,&offset,&iponoel,&inoel,&rig, - &ne2boun,&islavsurf,&mortar,&pslavsurf,&clearini, - &nobject_,&objectset,&nmethod,iperturb,&irefineloop, - &iparentel,&iprfn,&konrfn,&ratiorfn,&heading, - &nodedesi,&dgdxglob,&g0,&nuel_,&xdesi,&nfc,&coeffc, - &ikdc,&edc,&coini); - -#ifdef CALCULIX_MPI - MPI_Finalize(); -#endif - -#ifdef CALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT - calculix_freeExternalBehaviours(); -#endif /* CALCULIX_EXTERNAL_BEHAVIOURS_SUPPORT */ - - clock_gettime(CLOCK_MONOTONIC, &totalCalculixTimeEnd); - - totalCalculixTime = (totalCalculixTimeEnd.tv_sec - totalCalculixTimeStart.tv_sec) * 1e9; - totalCalculixTime = (totalCalculixTime + (totalCalculixTimeEnd.tv_nsec - totalCalculixTimeStart.tv_nsec)) * 1e-9; - - printf("________________________________________\n\n"); - - printf("Total CalculiX Time: %lf\n", totalCalculixTime); - - printf("________________________________________\n"); - - return 0; - -} From 355cdd40681c216f29a8180369457b9860446f96 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Thu, 11 Jul 2024 17:18:31 +0200 Subject: [PATCH 07/55] Revert CalculiX header file to 2.20 --- CalculiX.h | 9692 ++++++++++++++++++++++++++-------------------------- Makefile | 2 +- 2 files changed, 4806 insertions(+), 4888 deletions(-) mode change 100755 => 100644 CalculiX.h diff --git a/CalculiX.h b/CalculiX.h old mode 100755 new mode 100644 index 10bbac29..e069de0c --- a/CalculiX.h +++ b/CalculiX.h @@ -1,5 +1,5 @@ /* CALCULIX - A 3-dimensional finite element program */ -/* Copyright (C) 1998-2023 Guido Dhondt */ +/* Copyright (C) 1998-2022 Guido Dhondt */ /* This program is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU General Public License as */ @@ -7,7 +7,7 @@ /* the License, or (at your option) any later version. */ /* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /* GNU General Public License for more details. */ @@ -23,47 +23,55 @@ #define HP 4 #if ARCH == Linux -#define FORTRAN(A,B) A##_ B +#define FORTRAN(A, B) A##_ B #elif ARCH == IRIX || ARCH == IRIX64 -#define FORTRAN(A,B) A##_##B +#define FORTRAN(A, B) A##_##B #elif ARCH == HP -#define FORTRAN(A,B) A##B +#define FORTRAN(A, B) A##B #endif #if ARCH == Linux -#define CEE(A,B) A##_ B +#define CEE(A, B) A##_ B #elif ARCH == IRIX || ARCH == IRIX64 -#define CEE(A,B) A##_##B +#define CEE(A, B) A##_##B #elif ARCH == HP -#define CEE(A,B) A##B +#define CEE(A, B) A##B #endif /* setting arrays to constant values */ /* serial */ -#define DMEMSET(a,b,c,d) for(im=b;im Date: Thu, 11 Jul 2024 17:23:13 +0200 Subject: [PATCH 08/55] Remove unnecessary files which resulted from duplication --- CalculiX_precice.h | 106 ---- linstatic_precice_.c | 1372 ------------------------------------------ 2 files changed, 1478 deletions(-) delete mode 100644 CalculiX_precice.h delete mode 100755 linstatic_precice_.c diff --git a/CalculiX_precice.h b/CalculiX_precice.h deleted file mode 100644 index f6f42f48..00000000 --- a/CalculiX_precice.h +++ /dev/null @@ -1,106 +0,0 @@ -/* CALCULIX - A 3-dimensional finite element program */ -/* Copyright (C) 1998-2022 Guido Dhondt */ - -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU General Public License as */ -/* published by the Free Software Foundation; either version 2 of */ -/* the License, or (at your option) any later version. */ - -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU General Public License for more details. */ - -/* You should have received a copy of the GNU General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* preCICE header files*/ - -void nonlingeo_precice(double **co, ITG *nk, ITG **konp, ITG **ipkonp, char **lakonp, - ITG *ne, - ITG *nodeboun, ITG *ndirboun, double *xboun, ITG *nboun, - ITG **ipompcp, ITG **nodempcp, double **coefmpcp, char **labmpcp, - ITG *nmpc, - ITG *nodeforc, ITG *ndirforc, double *xforc, ITG *nforc, - ITG **nelemloadp, char **sideloadp, double *xload, - ITG *nload, ITG *nactdof, - ITG **icolp, ITG *jq, ITG **irowp, ITG *neq, ITG *nzl, - ITG *nmethod, ITG **ikmpcp, ITG **ilmpcp, ITG *ikboun, - ITG * ilboun, - double *elcon, ITG *nelcon, double *rhcon, ITG *nrhcon, - double *alcon, ITG *nalcon, double *alzero, ITG **ielmatp, - ITG **ielorienp, ITG *norien, double *orab, ITG *ntmat_, - double *t0, double *t1, double *t1old, - ITG *ithermal, double *prestr, ITG *iprestr, - double **vold, ITG *iperturb, double *sti, ITG *nzs, - ITG *kode, char *filab, ITG *idrct, - ITG *jmax, ITG *jout, double *timepar, - double *eme, double *xbounold, - double *xforcold, double *xloadold, - double *veold, double *accold, - char *amname, double *amta, ITG *namta, ITG *nam, - ITG *iamforc, ITG **iamloadp, - ITG *iamt1, double *alpha, ITG *iexpl, - ITG *iamboun, double *plicon, ITG *nplicon, double *plkcon, - ITG * nplkcon, - double **xstatep, ITG *npmat_, ITG *istep, double *ttime, - char *matname, double *qaold, ITG *mi, - ITG *isolver, ITG *ncmat_, ITG *nstate_, ITG *iumat, - double *cs, ITG *mcs, ITG *nkon, double **ener, ITG *mpcinfo, - char * output, - double *shcon, ITG *nshcon, double *cocon, ITG *ncocon, - double *physcon, ITG *nflow, double *ctrl, - char *set, ITG *nset, ITG *istartset, - ITG *iendset, ITG *ialset, ITG *nprint, char *prlab, - char *prset, ITG *nener, ITG *ikforc, ITG *ilforc, double *trab, - ITG *inotr, ITG *ntrans, double **fmpcp, char *cbody, - ITG *ibody, double *xbody, ITG *nbody, double *xbodyold, - ITG *ielprop, double *prop, ITG *ntie, char *tieset, - ITG *itpamp, ITG *iviewfile, char *jobnamec, double *tietol, - ITG *nslavs, double *thicke, ITG *ics, - ITG *nintpoint, ITG *mortar, ITG *ifacecount, char *typeboun, - ITG **islavsurfp, double **pslavsurfp, double **clearinip, - ITG *nmat, double *xmodal, ITG *iaxial, ITG *inext, ITG *nprop, - ITG *network, char *orname, double *vel, ITG *nef, - double *velo, double *veloo, double *energy, ITG *itempuser, - ITG *ipobody, ITG *inewton, double *t0g, double *t1g, - ITG *ifreebody, char *preciceParticipantName, char *configFilename); - -void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, - ITG *ne, - ITG *nodeboun,ITG *ndirboun,double *xboun,ITG *nboun, - ITG *ipompc,ITG *nodempc,double *coefmpc,char *labmpc, - ITG *nmpc, - ITG *nodeforc,ITG *ndirforc,double *xforc,ITG *nforc, - ITG *nelemload,char *sideload,double *xload, - ITG *nload,ITG *nactdof, - ITG **icolp,ITG *jq,ITG **irowp,ITG *neq,ITG *nzl, - ITG *nmethod,ITG *ikmpc,ITG *ilmpc,ITG *ikboun, - ITG *ilboun, - double *elcon,ITG *nelcon,double *rhcon,ITG *nrhcon, - double *alcon,ITG *nalcon,double *alzero,ITG **ielmatp, - ITG **ielorienp,ITG *norien,double *orab,ITG *ntmat_, - double *t0,double *t1,double *t1old, - ITG *ithermal,double *prestr,ITG *iprestr, - double *vold,ITG *iperturb,double *sti,ITG *nzs, - ITG *kode,char *filab,double *eme, - ITG *iexpl,double *plicon,ITG *nplicon,double *plkcon, - ITG *nplkcon, - double **xstatep,ITG *npmat_,char *matname,ITG *isolver, - ITG *mi,ITG *ncmat_,ITG *nstate_,double *cs,ITG *mcs, - ITG *nkon,double **enerp,double *xbounold, - double *xforcold,double *xloadold, - char *amname,double *amta,ITG *namta, - ITG *nam,ITG *iamforc,ITG *iamload, - ITG *iamt1,ITG *iamboun,double *ttime,char *output, - char *set,ITG *nset,ITG *istartset, - ITG *iendset,ITG *ialset,ITG *nprint,char *prlab, - char *prset,ITG *nener,double *trab, - ITG *inotr,ITG *ntrans,double *fmpc,ITG *ipobody,ITG *ibody, - double *xbody,ITG *nbody,double *xbodyold,double *timepar, - double *thicke,char *jobnamec,char *tieset,ITG *ntie, - ITG *istep,ITG *nmat,ITG *ielprop,double *prop,char *typeboun, - ITG *mortar,ITG *mpcinfo,double *tietol,ITG *ics, - char *orname,ITG *itempuser,double *t0g,double *t1g, - ITG *jmax, char *preciceParticipantName, char *configFilename); diff --git a/linstatic_precice_.c b/linstatic_precice_.c deleted file mode 100755 index d18e27b1..00000000 --- a/linstatic_precice_.c +++ /dev/null @@ -1,1372 +0,0 @@ -/* CalculiX - A 3-dimensional finite element program */ -/* Copyright (C) 1998-2021 Guido Dhondt */ - -/* This program is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU General Public License as */ -/* published by the Free Software Foundation(version 2); */ -/* */ - -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU General Public License for more details. */ - -/* You should have received a copy of the GNU General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include -#include "CalculiX.h" -#ifdef SPOOLES -#include "spooles.h" -#endif -#ifdef SGI -#include "sgi.h" -#endif -#ifdef TAUCS -#include "tau.h" -#endif -#ifdef PARDISO -#include "pardiso.h" -#endif -#ifdef PASTIX -#include "pastix.h" -#endif - -/* Adapter: Add header */ -#include "adapter/PreciceInterface.h" - - -void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, - ITG *ne, - ITG *nodeboun,ITG *ndirboun,double *xboun,ITG *nboun, - ITG *ipompc,ITG *nodempc,double *coefmpc,char *labmpc, - ITG *nmpc, - ITG *nodeforc,ITG *ndirforc,double *xforc,ITG *nforc, - ITG *nelemload,char *sideload,double *xload, - ITG *nload,ITG *nactdof, - ITG **icolp,ITG *jq,ITG **irowp,ITG *neq,ITG *nzl, - ITG *nmethod,ITG *ikmpc,ITG *ilmpc,ITG *ikboun, - ITG *ilboun, - double *elcon,ITG *nelcon,double *rhcon,ITG *nrhcon, - double *alcon,ITG *nalcon,double *alzero,ITG **ielmatp, - ITG **ielorienp,ITG *norien,double *orab,ITG *ntmat_, - double *t0,double *t1,double *t1old, - ITG *ithermal,double *prestr,ITG *iprestr, - double *vold,ITG *iperturb,double *sti,ITG *nzs, - ITG *kode,char *filab,double *eme, - ITG *iexpl,double *plicon,ITG *nplicon,double *plkcon, - ITG *nplkcon, - double **xstatep,ITG *npmat_,char *matname,ITG *isolver, - ITG *mi,ITG *ncmat_,ITG *nstate_,double *cs,ITG *mcs, - ITG *nkon,double **enerp,double *xbounold, - double *xforcold,double *xloadold, - char *amname,double *amta,ITG *namta, - ITG *nam,ITG *iamforc,ITG *iamload, - ITG *iamt1,ITG *iamboun,double *ttime,char *output, - char *set,ITG *nset,ITG *istartset, - ITG *iendset,ITG *ialset,ITG *nprint,char *prlab, - char *prset,ITG *nener,double *trab, - ITG *inotr,ITG *ntrans,double *fmpc,ITG *ipobody,ITG *ibody, - double *xbody,ITG *nbody,double *xbodyold,double *timepar, - double *thicke,char *jobnamec,char *tieset,ITG *ntie, - ITG *istep,ITG *nmat,ITG *ielprop,double *prop,char *typeboun, - ITG *mortar,ITG *mpcinfo,double *tietol,ITG *ics, - char *orname,ITG *itempuser,double *t0g,double *t1g, - /* Adapter: Add variables for the participant name and the config file */ - char *preciceParticipantName, char *configFilename){ - - char description[13]=" ",*lakon=NULL,stiffmatrix[132]="", - fneig[132]="",jobnamef[396]="",*labmpc2=NULL; - - ITG *inum=NULL,k,*icol=NULL,*irow=NULL,ielas=0,icmd=0,iinc=1,nasym=0,i,j,ic,ir, - mass[2]={0,0},stiffness=1,buckling=0,rhsi=1,intscheme=0,*ncocon=NULL, - *nshcon=NULL,mode=-1,noddiam=-1,coriolis=0,iout, - *itg=NULL,ntg=0,symmetryflag=0,inputformat=0,ngraph=1,im, - mt=mi[1]+1,ne0,*integerglob=NULL,iglob=0,*ipneigh=NULL,*neigh=NULL, - icfd=0,*inomat=NULL,*islavact=NULL,*islavnode=NULL,*nslavnode=NULL, - *islavsurf=NULL,nretain,*iretain=NULL,*noderetain=NULL,*ndirretain=NULL, - nmethodl,nintpoint,ifacecount,memmpc_,mpcfree,icascade,maxlenmpc, - ncont=0,*itietri=NULL,*koncont=NULL,nslavs=0,ismallsliding=0, - *itiefac=NULL,*imastnode=NULL,*nmastnode=NULL,*imastop=NULL,iitsta, - *iponoels=NULL,*inoels=NULL,*ipe=NULL,*ime=NULL,iit=-1,iflagact=0, - icutb=0,*kon=NULL,*ipkon=NULL,*ielmat=NULL,ialeatoric=0,kscale=1, - *iponoel=NULL,*inoel=NULL,zero=0,nherm=1,nev=*nforc,node,idir, - *ielorien=NULL,network=0,nrhs=1,iperturbsav,mscalmethod=0,*jqw=NULL, - *iroww=NULL,nzsw,*islavelinv=NULL,*irowtloc=NULL,*jqtloc=NULL,nboun2, - *ndirboun2=NULL,*nodeboun2=NULL,nmpc2,*ipompc2=NULL,*nodempc2=NULL, - *ikboun2=NULL,*ilboun2=NULL,*ikmpc2=NULL,*ilmpc2=NULL,mortartrafoflag=0, - *ikforc=NULL, *ilforc=NULL; - - double *stn=NULL,*v=NULL,*een=NULL,cam[5],*xstiff=NULL,*stiini=NULL,*tper, - *f=NULL,*fn=NULL,qa[4],*fext=NULL,*epn=NULL,*xstateini=NULL,dtheta, - *vini=NULL,*stx=NULL,*enern=NULL,*xbounact=NULL,*xforcact=NULL, - *xloadact=NULL,*t1act=NULL,*ampli=NULL,*xstaten=NULL,*eei=NULL, - *enerini=NULL,*cocon=NULL,*shcon=NULL,*physcon=NULL,*qfx=NULL, - *qfn=NULL,sigma=0.,*cgr=NULL,*xbodyact=NULL,*vr=NULL,*vi=NULL, - *stnr=NULL,*stni=NULL,*vmax=NULL,*stnmax=NULL,*springarea=NULL, - *eenmax=NULL,*fnr=NULL,*fni=NULL,*emn=NULL,*clearini=NULL,ptime, - *emeini=NULL,*doubleglob=NULL,*au=NULL,*ad=NULL,*b=NULL,*aub=NULL, - *adb=NULL,*pslavsurf=NULL,*pmastsurf=NULL,*cdn=NULL,*cdnr=NULL, - *cdni=NULL,*submatrix=NULL,*xnoels=NULL,*cg=NULL,*straight=NULL, - *areaslav=NULL,*xmastnor=NULL,theta=0.,*ener=NULL,*xstate=NULL, - *fnext=NULL,*energyini=NULL,*energy=NULL,*d=NULL,alea=0.1,*smscale=NULL, - *auw=NULL,*autloc=NULL,*xboun2=NULL,*coefmpc2=NULL; - - FILE *f1,*f2; - -#ifdef SGI - ITG token; -#endif - - /* dummy arguments for the results call */ - - double *veold=NULL,*accold=NULL,bet,gam,dtime,time,reltime=1.; - - irow=*irowp;ener=*enerp;xstate=*xstatep;ipkon=*ipkonp;lakon=*lakonp; - kon=*konp;ielmat=*ielmatp;ielorien=*ielorienp;icol=*icolp; - - for(k=0;k<3;k++){ - strcpy1(&jobnamef[k*132],&jobnamec[k*132],132); - } - - tper=&timepar[1]; - - time=*tper; - dtime=*tper; - - ne0=*ne; - - - /* Adapter: Put all the CalculiX data that is needed for the coupling into an array */ - struct SimulationData simulationData = { - .ialset = ialset, - .ielmat = ielmat, - .istartset = istartset, - .iendset = iendset, - .kon = kon, - .ipkon = ipkon, - .lakon = &lakon, - .co = co, - .set = set, - .nset = *nset, - .ikboun = ikboun, - .ikforc = ikforc, - .ilboun = ilboun, - .ilforc = ilforc, - .nboun = *nboun, - .nforc = *nforc, - .nelemload = nelemload, - .nload = *nload, - .sideload = sideload, - .mt = mt, - .nk = *nk, - .theta = &theta, - .dtheta = &dtheta, - .tper = tper, - .nmethod = nmethod, - .xload = xload, - .xforc = xforc, - .xboun = xboun, - .ntmat_ = ntmat_, - .vold = vold, - .veold = veold, - .fn = fn, - .cocon = cocon, - .ncocon = ncocon, - .mi = mi, - // .eei = &eei, - // .xstiff = &xstiff - }; - - /* determining the global values to be used as boundary conditions - for a submodel */ - - /* iglob=-1 if global results are from a *FREQUENCY calculation - iglob=0 if no global results are used by boundary conditions - iglob=1 if global results are from a *STATIC calculation */ - - ITG irefine=0; - getglobalresults(&jobnamec[396],&integerglob,&doubleglob,nboun,iamboun,xboun, - nload,sideload,iamload,&iglob,nforc,iamforc,xforc, - ithermal,nk,t1,iamt1,&sigma,&irefine); - - /* reading temperatures from frd-file */ - - if((itempuser[0]==2)&&(itempuser[1]!=itempuser[2])) { - utempread(t1,&itempuser[2],jobnamec); - } - - /* allocating fields for the actual external loading */ - - NNEW(xbounact,double,*nboun); - for(k=0;k<*nboun;++k){xbounact[k]=xbounold[k];} - NNEW(xforcact,double,*nforc); - NNEW(xloadact,double,2**nload); - NNEW(xbodyact,double,7**nbody); - /* copying the rotation axis and/or acceleration vector */ - for(k=0;k<7**nbody;k++){xbodyact[k]=xbody[k];} - if(*ithermal==1){ - NNEW(t1act,double,*nk); - for(k=0;k<*nk;++k){t1act[k]=t1old[k];} - } - - /* assigning the body forces to the elements */ - - /* if(*nbody>0){ - ifreebody=*ne+1; - NNEW(ipobody,ITG,2*ifreebody**nbody); - for(k=1;k<=*nbody;k++){ - FORTRAN(bodyforce,(cbody,ibody,ipobody,nbody,set,istartset, - iendset,ialset,&inewton,nset,&ifreebody,&k)); - RENEW(ipobody,ITG,2*(*ne+ifreebody)); - } - RENEW(ipobody,ITG,2*(ifreebody-1)); - }*/ - - /* contact conditions */ - - // if(*icontact==1){ - if(*mortar>-2){ - - memmpc_=mpcinfo[0];mpcfree=mpcinfo[1];icascade=mpcinfo[2]; - maxlenmpc=mpcinfo[3]; - - inicont(nk,&ncont,ntie,tieset,nset,set,istartset,iendset,ialset,&itietri, - lakon,ipkon,kon,&koncont,&nslavs,tietol,&ismallsliding,&itiefac, - &islavsurf,&islavnode,&imastnode,&nslavnode,&nmastnode, - mortar,&imastop,nkon,&iponoels,&inoels,&ipe,&ime,ne,&ifacecount, - iperturb,ikboun,nboun,co,istep,&xnoels); - - if(ncont!=0){ - - NNEW(cg,double,3*ncont); - NNEW(straight,double,16*ncont); - - /* 11 instead of 10: last position is reserved for the - local contact spring element number; needed as - pointer into springarea */ - - if(*mortar==0){ - RENEW(kon,ITG,*nkon+11*nslavs); - NNEW(springarea,double,2*nslavs); - if(*nener==1){ - RENEW(ener,double,mi[0]*(*ne+nslavs)*2); - } - RENEW(ipkon,ITG,*ne+nslavs); - RENEW(lakon,char,8*(*ne+nslavs)); - - if(*norien>0){ - RENEW(ielorien,ITG,mi[2]*(*ne+nslavs)); - for(k=mi[2]**ne;k0){ - RENEW(ielorien,ITG,mi[2]*(*ne+nintpoint)); - for(k=mi[2]**ne;k0)){ - iperturbsav=iperturb[0]; - iperturb[0]=0; - } - - iout=-1; - NNEW(v,double,mt**nk); - NNEW(fn,double,mt**nk); - NNEW(stx,double,6*mi[0]**ne); - NNEW(inum,ITG,*nk); - results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, - elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, - ielorien,norien,orab,ntmat_,t0,t1act,ithermal, - prestr,iprestr,filab,eme,emn,een,iperturb, - f,fn,nactdof,&iout,qa,vold,b,nodeboun, - ndirboun,xbounact,nboun,ipompc, - nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold,accold, - &bet,&gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, - xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas, - &icmd,ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern, - emeini,xstaten,eei,enerini,cocon,ncocon,set,nset,istartset, - iendset,ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans, - fmpc,nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea, - &reltime,&ne0,thicke,shcon,nshcon, - sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, - mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, - islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, - inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, - itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, - islavelinv,autloc,irowtloc,jqtloc,&nboun2, - ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, - labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, - &intscheme); - SFREE(v);SFREE(fn);SFREE(stx);SFREE(inum); - iout=1; - - // RECIEVING MATERIAL TANGENT FROM NASMAT - simulationData.xstiff = xstiff; - Precice_ReadCouplingData(&simulationData); - - } - - precicec_finalize(); - - if((*nmethod==1)&&(iglob<0)&&(iperturb[0]>0)){ - iperturb[0]=iperturbsav; - } - - /* determining the system matrix and the external forces */ - - NNEW(ad,double,*neq); - NNEW(fext,double,*neq); - - if(*nmethod==11){ - - /* determining the nodes and the degrees of freedom in those nodes - belonging to the substructure */ - - NNEW(iretain,ITG,*nk); - NNEW(noderetain,ITG,*nk); - NNEW(ndirretain,ITG,*nk); - nretain=0; - - for(i=0;i<*nboun;i++){ - if(strcmp1(&typeboun[i],"C")==0){ - iretain[nretain]=i+1; - noderetain[nretain]=nodeboun[i]; - ndirretain[nretain]=ndirboun[i]; - nretain++; - } - } - - /* nretain!=0: submatrix application - nretain==0: Green function application */ - - if(nretain>0){ - RENEW(iretain,ITG,nretain); - RENEW(noderetain,ITG,nretain); - RENEW(ndirretain,ITG,nretain); - }else{ - SFREE(iretain);SFREE(noderetain);SFREE(ndirretain); - } - - /* creating the right size au */ - - NNEW(au,double,nzs[2]); - rhsi=0; - // nmethodl=2; - nmethodl=*nmethod; - - /* providing for the mass matrix in case of Green functions */ - - if(nretain==0){ - mass[0]=1.; - NNEW(adb,double,*neq); - NNEW(aub,double,nzs[1]); - } - - }else{ - - /* linear static calculation */ - - NNEW(au,double,*nzs); - nmethodl=*nmethod; - - /* if submodel calculation with a global model obtained by - a *FREQUENCY calculation: replace stiffness matrix K by - K-sigma*M */ - - if(iglob<0){ - mass[0]=1; - NNEW(adb,double,*neq); - NNEW(aub,double,nzs[1]); - } - - } - - - mafillsmmain(co,nk,kon,ipkon,lakon,ne,nodeboun,ndirboun,xbounact,nboun, - ipompc,nodempc,coefmpc,nmpc,nodeforc,ndirforc,xforcact, - nforc,nelemload,sideload,xloadact,nload,xbodyact,ipobody, - nbody,cgr,ad,au,fext,nactdof,icol,jq,irow,neq,nzl,&nmethodl, - ikmpc,ilmpc,ikboun,ilboun, - elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, - ielorien,norien,orab,ntmat_, - t0,t1act,ithermal,prestr,iprestr,vold,iperturb,sti, - nzs,stx,adb,aub,iexpl,plicon,nplicon,plkcon,nplkcon, - xstiff,npmat_,&dtime,matname,mi, - ncmat_,mass,&stiffness,&buckling,&rhsi,&intscheme,physcon, - shcon,nshcon,cocon,ncocon,ttime,&time,istep,&iinc,&coriolis, - ibody,xloadold,&reltime,veold,springarea,nstate_, - xstateini,xstate,thicke,integerglob,doubleglob, - tieset,istartset,iendset,ialset,ntie,&nasym,pslavsurf, - pmastsurf,mortar,clearini,ielprop,prop,&ne0,fnext,&kscale, - iponoel,inoel,&network,ntrans,inotr,trab,smscale,&mscalmethod, - set,nset,islavelinv,autloc,irowtloc,jqtloc,&mortartrafoflag); - - /* check for negative Jacobians */ - - if(nmethodl==0) *nmethod=0; - - if(nasym==1){ - RENEW(au,double,2*nzs[1]); - symmetryflag=2; - inputformat=1; - - mafillsmasmain(co,nk,kon,ipkon,lakon,ne,nodeboun, - ndirboun,xbounact,nboun, - ipompc,nodempc,coefmpc,nmpc,nodeforc,ndirforc,xforcact, - nforc,nelemload,sideload,xloadact,nload,xbodyact,ipobody, - nbody,cgr,ad,au,fext,nactdof,icol,jq,irow,neq,nzl, - nmethod,ikmpc,ilmpc,ikboun,ilboun, - elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero, - ielmat,ielorien,norien,orab,ntmat_, - t0,t1act,ithermal,prestr,iprestr,vold,iperturb,sti, - nzs,stx,adb,aub,iexpl,plicon,nplicon,plkcon,nplkcon, - xstiff,npmat_,&dtime,matname,mi, - ncmat_,mass,&stiffness,&buckling,&rhsi,&intscheme, - physcon,shcon,nshcon,cocon,ncocon,ttime,&time,istep,&iinc, - &coriolis,ibody,xloadold,&reltime,veold,springarea,nstate_, - xstateini,xstate,thicke, - integerglob,doubleglob,tieset,istartset,iendset, - ialset,ntie,&nasym,pslavsurf,pmastsurf,mortar,clearini, - ielprop,prop,&ne0,&kscale,iponoel,inoel,&network,set,nset); - - /* FORTRAN(mafillsmas,(co,nk,kon,ipkon,lakon,ne,nodeboun, - ndirboun,xbounact,nboun, - ipompc,nodempc,coefmpc,nmpc,nodeforc,ndirforc,xforcact, - nforc,nelemload,sideload,xloadact,nload,xbodyact,ipobody, - nbody,cgr,ad,au,fext,nactdof,icol,jq,irow,neq,nzl, - nmethod,ikmpc,ilmpc,ikboun,ilboun, - elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero, - ielmat,ielorien,norien,orab,ntmat_, - t0,t1act,ithermal,prestr,iprestr,vold,iperturb,sti, - nzs,stx,adb,aub,iexpl,plicon,nplicon,plkcon,nplkcon, - xstiff,npmat_,&dtime,matname,mi, - ncmat_,mass,&stiffness,&buckling,&rhsi,&intscheme, - physcon,shcon,nshcon,cocon,ncocon,ttime,&time,istep,&iinc, - &coriolis,ibody,xloadold,&reltime,veold,springarea,nstate_, - xstateini,xstate,thicke, - integerglob,doubleglob,tieset,istartset,iendset, - ialset,ntie,&nasym,pslavsurf,pmastsurf,mortar,clearini, - ielprop,prop,&ne0,&kscale,iponoel,inoel,&network));*/ - } - - /* determining the right hand side */ - - NNEW(b,double,*neq); - for(k=0;k<*neq;++k){ - b[k]=fext[k]-f[k]; - } - SFREE(fext);SFREE(f); - - - /* generation of a substructure stiffness matrix (nretain>0) or treating - Green functions (nretain=0) */ - - if(*nmethod==11){ - - /* recovering omega_0^2 for Green applications */ - - if(nretain==0){ - if(*nforc>0){sigma=xforc[0];} - } - - /* factorizing the matrix */ - - if(*neq>0){ - if(*isolver==0){ - #ifdef SPOOLES - spooles_factor(ad,au,adb,aub,&sigma,icol,irow,neq,nzs,&symmetryflag, - &inputformat,&nzs[2]); - #else - printf("*ERROR in linstatic: the SPOOLES library is not linked\n\n"); - FORTRAN(stop,()); - #endif - } - else if(*isolver==7){ - #ifdef PARDISO - pardiso_factor(ad,au,adb,aub,&sigma,icol,irow,neq,nzs, - &symmetryflag,&inputformat,jq,&nzs[2]); - #else - printf("*ERROR in linstatic: the PARDISO library is not linked\n\n"); - FORTRAN(stop,()); - #endif - } - else if(*isolver==8){ - #ifdef PASTIX - pastix_factor_main(ad,au,adb,aub,&sigma,icol,irow,neq,nzs, - &symmetryflag,&inputformat,jq,&nzs[2]); - #else - printf("*ERROR in linstatic: the PASTIX library is not linked\n\n"); - FORTRAN(stop,()); - #endif - } - } - - - /* solving the system of equations with appropriate rhs */ - - if(nretain>0){ - - /* substructure calculations */ - - NNEW(submatrix,double,nretain*nretain); - - for(i=0;i0){ - if(*isolver==0){ - #ifdef SPOOLES - spooles_solve(b,neq); - #endif - } - else if(*isolver==7){ - #ifdef PARDISO - pardiso_solve(b,neq,&symmetryflag,&inputformat,&nrhs); - #endif - - } - else if(*isolver==8){ - #ifdef PASTIX - pastix_solve(b,neq,&symmetryflag,&nrhs); - #endif - - } - } - - /* calculating the internal forces */ - - - - NNEW(v,double,mt**nk); - NNEW(fn,double,mt**nk); - NNEW(stn,double,6**nk); - NNEW(inum,ITG,*nk); - NNEW(stx,double,6*mi[0]**ne); - - if(strcmp1(&filab[261],"E ")==0) NNEW(een,double,6**nk); - if(strcmp1(&filab[2697],"ME ")==0) NNEW(emn,double,6**nk); - if(strcmp1(&filab[522],"ENER")==0) NNEW(enern,double,*nk); - - NNEW(eei,double,6*mi[0]**ne); - if(*nener==1){ - NNEW(stiini,double,6*mi[0]**ne); - NNEW(emeini,double,6*mi[0]**ne); - NNEW(enerini,double,mi[0]**ne);} - - /* replacing the appropriate boundary value by unity */ - - xbounact[iretain[i]-1]=1.; - - - - results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, - elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, - ielorien,norien,orab,ntmat_,t0,t1act,ithermal, - prestr,iprestr,filab,eme,emn,een,iperturb, - f,fn,nactdof,&iout,qa,vold,b,nodeboun,ndirboun, - xbounact,nboun,ipompc, - nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold, - accold,&bet, - &gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, - xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas,&icmd, - ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern,emeini, - xstaten,eei,enerini,cocon,ncocon,set,nset,istartset,iendset, - ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans,fmpc, - nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea,&reltime, - &ne0,thicke,shcon,nshcon, - sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, - mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, - islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, - inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, - itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, - islavelinv,autloc,irowtloc,jqtloc,&nboun2, - ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, - labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, - &intscheme); - - xbounact[iretain[i]-1]=0.; - - SFREE(v);SFREE(stn);SFREE(inum);SFREE(stx); - - if(strcmp1(&filab[261],"E ")==0) SFREE(een); - if(strcmp1(&filab[2697],"ME ")==0) SFREE(emn); - if(strcmp1(&filab[522],"ENER")==0) SFREE(enern); - - SFREE(eei);if(*nener==1){SFREE(stiini);SFREE(emeini);SFREE(enerini);} - - /* storing the internal forces in the substructure - stiffness matrix */ - - for(j=0;j0){ - if(*isolver==0){ - #ifdef SPOOLES - spooles_solve(b,neq); - #endif - } - else if(*isolver==7){ - #ifdef PARDISO - pardiso_solve(b,neq,&symmetryflag,&inputformat,&nrhs); - #endif - - } - else if(*isolver==8){ - #ifdef PASTIX - pastix_solve(b,neq,&symmetryflag,&nrhs); - #endif - - } - } - - /* storing the Green function */ - - if(fwrite(b,sizeof(double),*neq,f2)!=*neq){ - printf("*ERROR saving data to the eigenvalue file..."); - exit(0); - } - - /* calculating the displacements and the stresses and storing */ - /* the results in frd format for each valid eigenmode */ - - NNEW(v,double,mt**nk); - NNEW(fn,double,mt**nk); - NNEW(stn,double,6**nk); - NNEW(inum,ITG,*nk); - NNEW(stx,double,6*mi[0]**ne); - - if(strcmp1(&filab[261],"E ")==0) NNEW(een,double,6**nk); - if(strcmp1(&filab[2697],"ME ")==0) NNEW(emn,double,6**nk); - if(strcmp1(&filab[522],"ENER")==0) NNEW(enern,double,*nk); - if(strcmp1(&filab[2175],"CONT")==0) NNEW(cdn,double,6**nk); - - NNEW(eei,double,6*mi[0]**ne); - if(*nener==1){ - NNEW(stiini,double,6*mi[0]**ne); - NNEW(emeini,double,6*mi[0]**ne); - NNEW(enerini,double,mi[0]**ne);} - - - results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, - elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, - ielorien,norien,orab,ntmat_,t0,t1act,ithermal, - prestr,iprestr,filab,eme,emn,een,iperturb, - f,fn,nactdof,&iout,qa,vold,b,nodeboun,ndirboun, - xbounact,nboun,ipompc, - nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold, - accold,&bet, - &gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, - xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas,&icmd, - ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern,emeini, - xstaten,eei,enerini,cocon,ncocon,set,nset,istartset,iendset, - ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans,fmpc, - nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea,&reltime, - &ne0,thicke,shcon,nshcon, - sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, - mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, - islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, - inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, - itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, - islavelinv,autloc,irowtloc,jqtloc,&nboun2, - ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, - labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, - &intscheme); - - SFREE(eei); - if(*nener==1){ - SFREE(stiini);SFREE(emeini);SFREE(enerini);} - - /* memcpy(&vold[0],&v[0],sizeof(double)*mt**nk); - memcpy(&sti[0],&stx[0],sizeof(double)*6*mi[0]*ne0);*/ - - ++*kode; - time=1.*i; - - /* for cyclic symmetric sectors: duplicating the results */ - - if(*mcs>0){ - ptime=*ttime+time; - frdcyc(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod,kode,filab,een,t1act, - fn,&ptime,epn,ielmat,matname,cs,mcs,nkon,enern,xstaten, - nstate_,istep,&iinc,iperturb,ener,mi,output,ithermal, - qfn,ialset,istartset,iendset,trab,inotr,ntrans,orab, - ielorien,norien,sti,veold,&noddiam,set,nset,emn,thicke, - jobnamec,&ne0,cdn,mortar,nmat,qfx,ielprop,prop); - } - else{ - if(strcmp1(&filab[1044],"ZZS")==0){ - NNEW(neigh,ITG,40**ne); - NNEW(ipneigh,ITG,*nk); - } - ptime=*ttime+time; - frd(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod, - kode,filab,een,t1act,fn,&ptime,epn,ielmat,matname,enern,xstaten, - nstate_,istep,&iinc,ithermal,qfn,&mode,&noddiam,trab,inotr, - ntrans,orab,ielorien,norien,description,ipneigh,neigh, - mi,stx,vr,vi,stnr,stni,vmax,stnmax,&ngraph,veold,ener,ne, - cs,set,nset,istartset,iendset,ialset,eenmax,fnr,fni,emn, - thicke,jobnamec,output,qfx,cdn,mortar,cdnr,cdni,nmat, - ielprop,prop,sti); - if(strcmp1(&filab[1044],"ZZS")==0){SFREE(ipneigh);SFREE(neigh);} - } - - SFREE(v);SFREE(stn);SFREE(inum); - SFREE(stx);SFREE(fn); - - if(strcmp1(&filab[261],"E ")==0) SFREE(een); - if(strcmp1(&filab[2697],"ME ")==0) SFREE(emn); - if(strcmp1(&filab[522],"ENER")==0) SFREE(enern); - if(strcmp1(&filab[2175],"CONT")==0) SFREE(cdn); - - } - - - fclose(f2); - - } - - SFREE(au);SFREE(ad);SFREE(b); - - SFREE(xbounact);SFREE(xforcact);SFREE(xloadact);SFREE(t1act);SFREE(ampli); - SFREE(xbodyact); - - // if(*nbody>0) SFREE(ipobody); - - SFREE(xstiff); - - if(iglob!=0){SFREE(integerglob);SFREE(doubleglob);} - - return; - - - }else if(*nmethod!=0){ - - /* linear static applications */ - - if(*isolver==0){ - #ifdef SPOOLES - spooles(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs,&symmetryflag, - &inputformat,&nzs[2]); - #else - printf("*ERROR in linstatic: the SPOOLES library is not linked\n\n"); - FORTRAN(stop,()); - #endif - } - else if((*isolver==2)||(*isolver==3)){ - if(nasym>0){ - printf(" *ERROR in nonlingeo: the iterative solver cannot be used for asymmetric matrices\n\n"); - FORTRAN(stop,()); - } - preiter(ad,&au,b,&icol,&irow,neq,nzs,isolver,iperturb); - } - else if(*isolver==4){ - #ifdef SGI - if(nasym>0){ - printf(" *ERROR in nonlingeo: the SGI solver cannot be used for asymmetric matrices\n\n"); - FORTRAN(stop,()); - } - token=1; - sgi_main(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs,token); - #else - printf("*ERROR in linstatic: the SGI library is not linked\n\n"); - FORTRAN(stop,()); - #endif - } - else if(*isolver==5){ - #ifdef TAUCS - if(nasym>0){ - printf(" *ERROR in nonlingeo: the TAUCS solver cannot be used for asymmetric matrices\n\n"); - FORTRAN(stop,()); - } - tau(ad,&au,adb,aub,&sigma,b,icol,&irow,neq,nzs); - #else - printf("*ERROR in linstatic: the TAUCS library is not linked\n\n"); - FORTRAN(stop,()); - #endif - } - else if(*isolver==7){ - #ifdef PARDISO - pardiso_main(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs, - &symmetryflag,&inputformat,jq,&nzs[2],&nrhs); - #else - printf("*ERROR in linstatic: the PARDISO library is not linked\n\n"); - FORTRAN(stop,()); - #endif - } - else if(*isolver==8){ - #ifdef PASTIX - pastix_main(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs, - &symmetryflag,&inputformat,jq,&nzs[2],&nrhs); - #else - printf("*ERROR in linstatic: the PASTIX library is not linked\n\n"); - FORTRAN(stop,()); - #endif - } - - /* saving of ad and au for sensitivity analysis */ - - for(i=0;i<*ntie;i++){ - if(strcmp1(&tieset[i*243+80],"D")==0){ - - strcpy(stiffmatrix,jobnamec); - strcat(stiffmatrix,".stm"); - - if((f1=fopen(stiffmatrix,"wb"))==NULL){ - printf("*ERROR in linstatic: cannot open stiffness matrix file for writing..."); - exit(0); - } - - /* storing the stiffness matrix */ - - /* nzs,irow,jq and icol have to be stored too, since the static analysis - can involve contact, whereas in the sensitivity analysis contact is not - taken into account while determining the structure of the stiffness - matrix (in mastruct.c) - */ - - if(fwrite(&nasym,sizeof(ITG),1,f1)!=1){ - printf("*ERROR saving the symmetry flag to the stiffness matrix file..."); - exit(0); - } - if(fwrite(nzs,sizeof(ITG),3,f1)!=3){ - printf("*ERROR saving the number of subdiagonal nonzeros to the stiffness matrix file..."); - exit(0); - } - if(fwrite(irow,sizeof(ITG),nzs[2],f1)!=nzs[2]){ - printf("*ERROR saving irow to the stiffness matrix file..."); - exit(0); - } - if(fwrite(jq,sizeof(ITG),neq[1]+1,f1)!=neq[1]+1){ - printf("*ERROR saving jq to the stiffness matrix file..."); - exit(0); - } - if(fwrite(icol,sizeof(ITG),neq[1],f1)!=neq[1]){ - printf("*ERROR saving icol to the stiffness matrix file..."); - exit(0); - } - if(fwrite(ad,sizeof(double),neq[1],f1)!=neq[1]){ - printf("*ERROR saving the diagonal of the stiffness matrix to the stiffness matrix file..."); - exit(0); - } - if(fwrite(au,sizeof(double),nzs[2],f1)!=nzs[2]){ - printf("*ERROR saving the off-diagonal terms of the stiffness matrix to the tiffness matrix file..."); - exit(0); - } - fclose(f1); - - break; - } - } - - SFREE(ad);SFREE(au); - if(iglob<0){SFREE(adb);SFREE(aub);} - - /* calculating the displacements and the stresses and storing */ - /* the results in frd format for each valid eigenmode */ - - NNEW(v,double,mt**nk); - NNEW(fn,double,mt**nk); - NNEW(stn,double,6**nk); - NNEW(inum,ITG,*nk); - NNEW(stx,double,6*mi[0]**ne); - - if(strcmp1(&filab[261],"E ")==0) NNEW(een,double,6**nk); - if(strcmp1(&filab[2697],"ME ")==0) NNEW(emn,double,6**nk); - if(strcmp1(&filab[522],"ENER")==0) NNEW(enern,double,*nk); - if(strcmp1(&filab[2175],"CONT")==0) NNEW(cdn,double,6**nk); - - NNEW(eei,double,6*mi[0]**ne); - if(*nener==1){ - NNEW(stiini,double,6*mi[0]**ne); - NNEW(emeini,double,6*mi[0]**ne); - NNEW(enerini,double,mi[0]**ne);} - - - results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, - elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, - ielorien,norien,orab,ntmat_,t0,t1act,ithermal, - prestr,iprestr,filab,eme,emn,een,iperturb, - f,fn,nactdof,&iout,qa,vold,b,nodeboun,ndirboun,xbounact,nboun,ipompc, - nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold,accold,&bet, - &gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, - xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas,&icmd, - ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern,emeini, - xstaten,eei,enerini,cocon,ncocon,set,nset,istartset,iendset, - ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans,fmpc, - nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea,&reltime, - &ne0,thicke,shcon,nshcon, - sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, - mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, - islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, - inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, - itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, - islavelinv,autloc,irowtloc,jqtloc,&nboun2, - ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, - labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, - &intscheme); - - SFREE(eei); - if(*nener==1){ - SFREE(stiini);SFREE(emeini);SFREE(enerini);} - - memcpy(&vold[0],&v[0],sizeof(double)*mt**nk); - memcpy(&sti[0],&stx[0],sizeof(double)*6*mi[0]*ne0); - - ++*kode; - - /* for cyclic symmetric sectors: duplicating the results */ - - if(*mcs>0){ - ptime=*ttime+time; - frdcyc(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod,kode,filab,een,t1act, - fn,&ptime,epn,ielmat,matname,cs,mcs,nkon,enern,xstaten, - nstate_,istep,&iinc,iperturb,ener,mi,output,ithermal, - qfn,ialset,istartset,iendset,trab,inotr,ntrans,orab, - ielorien,norien,sti,veold,&noddiam,set,nset,emn,thicke, - jobnamec,&ne0,cdn,mortar,nmat,qfx,ielprop,prop); - } - else{ - if(strcmp1(&filab[1044],"ZZS")==0){ - NNEW(neigh,ITG,40**ne); - NNEW(ipneigh,ITG,*nk); - } - ptime=*ttime+time; - frd(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod, - kode,filab,een,t1act,fn,&ptime,epn,ielmat,matname,enern,xstaten, - nstate_,istep,&iinc,ithermal,qfn,&mode,&noddiam,trab,inotr, - ntrans,orab,ielorien,norien,description,ipneigh,neigh, - mi,stx,vr,vi,stnr,stni,vmax,stnmax,&ngraph,veold,ener,ne, - cs,set,nset,istartset,iendset,ialset,eenmax,fnr,fni,emn, - thicke,jobnamec,output,qfx,cdn,mortar,cdnr,cdni,nmat,ielprop, - prop,sti); - if(strcmp1(&filab[1044],"ZZS")==0){SFREE(ipneigh);SFREE(neigh);} - } - - /* updating the .sta file */ - - iitsta=1; - FORTRAN(writesta,(istep,&iinc,&icutb,&iitsta,ttime,&time,&dtime)); - - SFREE(v);SFREE(stn);SFREE(inum); - SFREE(b);SFREE(stx);SFREE(fn); - - if(strcmp1(&filab[261],"E ")==0) SFREE(een); - if(strcmp1(&filab[2697],"ME ")==0) SFREE(emn); - if(strcmp1(&filab[522],"ENER")==0) SFREE(enern); - if(strcmp1(&filab[2175],"CONT")==0) SFREE(cdn); - - } - else { - - /* error occurred in mafill: storing the geometry in frd format */ - - ++*kode; - NNEW(inum,ITG,*nk);for(k=0;k<*nk;k++) inum[k]=1; - if(strcmp1(&filab[1044],"ZZS")==0){ - NNEW(neigh,ITG,40**ne); - NNEW(ipneigh,ITG,*nk); - } - ptime=*ttime+time; - frd(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod, - kode,filab,een,t1,fn,&ptime,epn,ielmat,matname,enern,xstaten, - nstate_,istep,&iinc,ithermal,qfn,&mode,&noddiam,trab,inotr, - ntrans,orab,ielorien,norien,description,ipneigh,neigh, - mi,sti,vr,vi,stnr,stni,vmax,stnmax,&ngraph,veold,ener,ne, - cs,set,nset,istartset,iendset,ialset,eenmax,fnr,fni,emn, - thicke,jobnamec,output,qfx,cdn,mortar,cdnr,cdni,nmat,ielprop, - prop,sti); - if(strcmp1(&filab[1044],"ZZS")==0){SFREE(ipneigh);SFREE(neigh);} - SFREE(inum);FORTRAN(stop,()); - - } - - if(*mortar>-2){ - if(ncont!=0){ - *ne=ne0; - if(*nener==1){ - RENEW(ener,double,mi[0]**ne*2); - } - RENEW(ipkon,ITG,*ne); - RENEW(lakon,char,8**ne); - RENEW(kon,ITG,*nkon); - if(*norien>0){ - RENEW(ielorien,ITG,mi[2]**ne); - } - RENEW(ielmat,ITG,mi[2]**ne); - SFREE(cg);SFREE(straight); - SFREE(imastop);SFREE(itiefac);SFREE(islavnode);SFREE(islavsurf); - SFREE(nslavnode);SFREE(iponoels);SFREE(inoels);SFREE(imastnode); - SFREE(nmastnode);SFREE(itietri);SFREE(koncont);SFREE(xnoels); - SFREE(springarea);SFREE(xmastnor); - - if(*mortar==0){ - SFREE(areaslav); - }else if(*mortar==1){ - SFREE(pmastsurf);SFREE(ipe);SFREE(ime);SFREE(pslavsurf); - SFREE(islavact);SFREE(clearini); - } - } - mpcinfo[0]=memmpc_;mpcinfo[1]=mpcfree;mpcinfo[2]=icascade; - mpcinfo[3]=maxlenmpc; - } - - /* updating the loading at the end of the step; - important in case the amplitude at the end of the step - is not equal to one */ - - for(k=0;k<*nboun;++k){xbounold[k]=xbounact[k];} - for(k=0;k<*nforc;++k){xforcold[k]=xforcact[k];} - for(k=0;k<2**nload;++k){xloadold[k]=xloadact[k];} - for(k=0;k<7**nbody;k=k+7){xbodyold[k]=xbodyact[k];} - if(*ithermal==1){ - for(k=0;k<*nk;++k){t1old[k]=t1act[k];} - for(k=0;k<*nk;++k){vold[mt*k]=t1act[k];} - } - - SFREE(xbounact);SFREE(xforcact);SFREE(xloadact);SFREE(t1act);SFREE(ampli); - SFREE(xbodyact); - - // if(*nbody>0) SFREE(ipobody); - - SFREE(xstiff); - - if(iglob!=0){SFREE(integerglob);SFREE(doubleglob);} - - *irowp=irow;*enerp=ener;*xstatep=xstate;*ipkonp=ipkon;*lakonp=lakon; - *konp=kon;*ielmatp=ielmat;*ielorienp=ielorien;*icolp=icol; - - (*ttime)+=(*tper); - - return; - - -} From 6329a473a5c38fd6a598aa213907dc1be7916d90 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Thu, 11 Jul 2024 17:30:12 +0200 Subject: [PATCH 09/55] Revert files which only had size change --- adapter/ConfigReader.hpp | 0 getflux.f | 0 getkdeltatemp.f | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 adapter/ConfigReader.hpp mode change 100755 => 100644 getflux.f mode change 100755 => 100644 getkdeltatemp.f diff --git a/adapter/ConfigReader.hpp b/adapter/ConfigReader.hpp old mode 100755 new mode 100644 diff --git a/getflux.f b/getflux.f old mode 100755 new mode 100644 diff --git a/getkdeltatemp.f b/getkdeltatemp.f old mode 100755 new mode 100644 From a9a0127dd73358e4352000ff77d9328a421b4f17 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Fri, 12 Jul 2024 10:54:30 +0200 Subject: [PATCH 10/55] Adding necessary definitions in Fortran part, and code formatting --- adapter/CCXHelpers.c | 59 ++++++++++---------- adapter/CCXHelpers.h | 2 +- adapter/PreciceInterface.c | 81 ++++++++++++++------------- adapter/PreciceInterface.h | 110 ++++++++++++++++++------------------- multiscale_routines.f | 15 ++--- 5 files changed, 132 insertions(+), 135 deletions(-) diff --git a/adapter/CCXHelpers.c b/adapter/CCXHelpers.c index 7c2e2b3b..bc58fe42 100644 --- a/adapter/CCXHelpers.c +++ b/adapter/CCXHelpers.c @@ -125,19 +125,18 @@ void getNodeForces(ITG *nodes, ITG numNodes, int dim, double *fn, ITG mt, double void getElementStrain(int strainIdx, int *mi, int nelem, double *eei, double *strainData) { - + int i, count, idx; // Loop through all element and respective gauss points - count=0; - for (i = 0; i < mi[0]*nelem; i++) { - idx = i*6+strainIdx; - strainData[count] = eei[idx]; - strainData[count+1] = eei[idx+1]; - strainData[count+2] = eei[idx+2]; - count = count + 3; + count = 0; + for (i = 0; i < mi[0] * nelem; i++) { + idx = i * 6 + strainIdx; + strainData[count] = eei[idx]; + strainData[count + 1] = eei[idx + 1]; + strainData[count + 2] = eei[idx + 2]; + count = count + 3; } - } void getNodeDisplacements(ITG *nodes, ITG numNodes, int dim, double *v, ITG mt, double *displacements) @@ -475,29 +474,29 @@ void setNodeDisplacements(double *displacements, ITG numNodes, int dim, int *xbo void setElementXstiff(int nelem, ITG *mi, double *cmatData, double *xstiff) { - printf("bbbefore setting xstiff\n"); + printf("bbbefore setting xstiff\n"); - // int i, count, j,xstiffSize, nSize; - // xstiffSize = 27; - // nSize = mi[0]*nelem; - // cidx = 15; + // int i, count, j,xstiffSize, nSize; + // xstiffSize = 27; + // nSize = mi[0]*nelem; + // cidx = 15; - printf("before setting xstiff\n"); - for (int i = 0; i < mi[0]*nelem*27; i++) { - xstiff[i] = 1.0; - } - printf("after setting xstiff\n"); + printf("before setting xstiff\n"); + for (int i = 0; i < mi[0] * nelem * 27; i++) { + xstiff[i] = 1.0; + } + printf("after setting xstiff\n"); - // // Loop through all element and respective gauss points - // count=0; - // for (i = 0; i < nSize; i++) { - // j = i*xstiffSize+cidx; - // printf("idx: %ld\n",j); - // xstiff[j] = 1.0; //cmatData[count]; - // xstiff[j+1] = 1.0; //cmatData[count+1]; - // xstiff[j+2] = 1.0; //cmatData[count+2]; - // count = count + 3; - // } + // // Loop through all element and respective gauss points + // count=0; + // for (i = 0; i < nSize; i++) { + // j = i*xstiffSize+cidx; + // printf("idx: %ld\n",j); + // xstiff[j] = 1.0; //cmatData[count]; + // xstiff[j+1] = 1.0; //cmatData[count+1]; + // xstiff[j+2] = 1.0; //cmatData[count+2]; + // count = count + 3; + // } } bool isSteadyStateSimulation(ITG *nmethod) @@ -660,5 +659,3 @@ void unreachableError() printf("ERROR: The preCICE adapter just entered an unreachable state. Something is very wrong!\n"); exit(EXIT_FAILURE); } - - diff --git a/adapter/CCXHelpers.h b/adapter/CCXHelpers.h index 36879327..ade1ec81 100644 --- a/adapter/CCXHelpers.h +++ b/adapter/CCXHelpers.h @@ -52,7 +52,7 @@ enum CouplingDataType { TEMPERATURE, POSITIONS, PRESSURE, MACRO_IP_ID, - INPUT_ID, + INPUT_ID, CONV_FLAG, STRAIN1TO3, STRAIN4TO6, diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index b4330247..a636af64 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -241,23 +241,23 @@ void Precice_ReadCouplingData(SimulationData *sim) // VOLUMETRIC COUPLING - MULTISCALE case CONV_FLAG: - // READ CONVERGENCE FLAG + // READ CONVERGENCE FLAG // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->macroInputData, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPScalarData); printf("Reading CONVERGENCE FLAG coupling data.\n"); break; case CMAT1: - // READ MATERIAL MATRIX COMPONENTS - C11, C12, C13 - idx=1; + // READ MATERIAL MATRIX COMPONENTS - C11, C12, C13 + idx = 1; precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent1Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); // for (int k = 0; k < interfaces[i]->numIPTotal; k++) { // printf( " %i, %e, %e, %e \n", k, interfaces[i]->elementIPVectorData[k*3], interfaces[i]->elementIPVectorData[k*3+1], interfaces[i]->elementIPVectorData[k*3+2]); // } FORTRAN(precice_multiscale_set_xstiff, (sim->mi, - idx, - interfaces[i]->numElements, - interfaces[i]->elementIPVectorData, - sim->xstiff)); + idx, + interfaces[i]->numElements, + interfaces[i]->elementIPVectorData, + sim->xstiff)); printf("Reading MATERIAL TANGENT 1 coupling data.\n"); break; @@ -266,7 +266,7 @@ void Precice_ReadCouplingData(SimulationData *sim) // idx=4; // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent2Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); // FORTRAN(precice_multiscale_set_xstiff, (sim->mi, - // &idx, + // &idx, // &interfaces[i]->numElements, // interfaces[i]->elementIPVectorData, // sim->xstiff)); @@ -278,7 +278,7 @@ void Precice_ReadCouplingData(SimulationData *sim) // idx=7; // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent3Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); // FORTRAN(precice_multiscale_set_xstiff, (sim->mi, - // &idx, + // &idx, // &interfaces[i]->numElements, // interfaces[i]->elementIPVectorData, // sim->xstiff)); @@ -290,7 +290,7 @@ void Precice_ReadCouplingData(SimulationData *sim) // idx=10; // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent4Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); // FORTRAN(precice_multiscale_set_xstiff, (sim->mi, - // &idx, + // &idx, // &interfaces[i]->numElements, // interfaces[i]->elementIPVectorData, // sim->xstiff)); @@ -302,7 +302,7 @@ void Precice_ReadCouplingData(SimulationData *sim) // idx=13; // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent5Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); // FORTRAN(precice_multiscale_set_xstiff, (sim->mi, - // &idx, + // &idx, // &interfaces[i]->numElements, // interfaces[i]->elementIPVectorData, // sim->xstiff)); @@ -314,7 +314,7 @@ void Precice_ReadCouplingData(SimulationData *sim) // idx=16; // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent6Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); // FORTRAN(precice_multiscale_set_xstiff, (sim->mi, - // &idx, + // &idx, // &interfaces[i]->numElements, // interfaces[i]->elementIPVectorData, // sim->xstiff)); @@ -326,7 +326,7 @@ void Precice_ReadCouplingData(SimulationData *sim) // idx=19; // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent7Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); // FORTRAN(precice_multiscale_set_xstiff, (sim->mi, - // &idx, + // &idx, // &interfaces[i]->numElements, // interfaces[i]->elementIPVectorData, // sim->xstiff)); @@ -334,8 +334,8 @@ void Precice_ReadCouplingData(SimulationData *sim) break; case STRESS1TO3: - // READ STRESS COMPONENTS - S11, S22, S33 - idx=1; + // READ STRESS COMPONENTS - S11, S22, S33 + idx = 1; // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->stress1to3Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); // FORTRAN(precice_multiscale_set_stx, (sim->mi, // &idx, @@ -408,7 +408,6 @@ void Precice_WriteCouplingData(SimulationData *sim) int i, j, idx; int iset; - for (i = 0; i < numInterfaces; i++) { // Prepare data double *KDelta = NULL; @@ -530,13 +529,13 @@ void Precice_WriteCouplingData(SimulationData *sim) printf("Writing INPUT ID coupling data.\n"); break; case STRAIN1TO3: - idx=0; + idx = 0; getElementStrain(idx, sim->mi, interfaces[i]->numElements, sim->eei, interfaces[i]->elementIPVectorData); precicec_writeData(interfaces[i]->couplingMeshName, interfaces[i]->strain1to3Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, interfaces[i]->elementIPVectorData); printf("Writing STRAIN1TO3 coupling data.\n"); break; case STRAIN4TO6: - idx=3; + idx = 3; getElementStrain(idx, sim->mi, interfaces[i]->numElements, sim->eei, interfaces[i]->elementIPVectorData); precicec_writeData(interfaces[i]->couplingMeshName, interfaces[i]->strain4to6Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, interfaces[i]->elementIPVectorData); printf("Writing STRAIN4TO6 coupling data.\n"); @@ -710,7 +709,7 @@ void PreciceInterface_ConfigureElementsMesh(PreciceInterface *interface, Simulat interface->elemIPID = malloc(interface->numIPTotal * sizeof(int)); for (int j = 0; j < interface->numIPTotal; j++) { - interface->elemIPID[j] = j; + interface->elemIPID[j] = j; interface->elemIPCoordinates[j * 3] = j; interface->elemIPCoordinates[j * 3 + 1] = 0.0; interface->elemIPCoordinates[j * 3 + 2] = 0.0; @@ -773,7 +772,7 @@ void PreciceInterface_ConfigureNodesMesh(PreciceInterface *interface, Simulation // If 2D-3Q coupling is used (for a node mesh) delegate this to the specialized data structure. if (interface->nodesMeshName != NULL) { - int count = 0; + int count = 0; int dimCCX = interface->dimCCX; for (int i = 0; i < interface->numNodes; i++) { for (int ii = 0; ii < interface->numNodes; ii++) { @@ -868,7 +867,7 @@ void PreciceInterface_ConfigureCouplingData(PreciceInterface *interface, Simulat interface->elementIPScalarData = malloc(interface->numIPTotal * sizeof(double)); interface->elementIPVectorData = malloc(interface->numIPTotal * 3 * sizeof(double)); for (int i = 0; i < interface->numIPTotal; i++) { - interface->elementIPScalarData[i] = 0.0; + interface->elementIPScalarData[i] = 0.0; interface->elementIPVectorData[i * 3] = 0.0; interface->elementIPVectorData[i * 3 + 1] = 0.0; interface->elementIPVectorData[i * 3 + 2] = 0.0; @@ -934,32 +933,32 @@ void PreciceInterface_ConfigureCouplingData(PreciceInterface *interface, Simulat printf("Read data '%s' found.\n", config->readDataNames[i]); } else if (startsWith(config->readDataNames[i], "cmat2")) { PreciceInterface_EnsureValidRead(interface, CMAT2); - interface->readData[i] = CMAT2; + interface->readData[i] = CMAT2; interface->materialTangent2Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); } else if (startsWith(config->readDataNames[i], "cmat3")) { PreciceInterface_EnsureValidRead(interface, CMAT3); - interface->readData[i] = CMAT3; + interface->readData[i] = CMAT3; interface->materialTangent3Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); } else if (startsWith(config->readDataNames[i], "cmat4")) { PreciceInterface_EnsureValidRead(interface, CMAT4); - interface->readData[i] = CMAT4; + interface->readData[i] = CMAT4; interface->materialTangent4Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); } else if (startsWith(config->readDataNames[i], "cmat5")) { PreciceInterface_EnsureValidRead(interface, CMAT5); - interface->readData[i] = CMAT5; + interface->readData[i] = CMAT5; interface->materialTangent5Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); } else if (startsWith(config->readDataNames[i], "cmat6")) { PreciceInterface_EnsureValidRead(interface, CMAT6); - interface->readData[i] = CMAT6; + interface->readData[i] = CMAT6; interface->materialTangent6Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); } else if (startsWith(config->readDataNames[i], "cmat7")) { PreciceInterface_EnsureValidRead(interface, CMAT7); - interface->readData[i] = CMAT7; + interface->readData[i] = CMAT7; interface->materialTangent7Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); } else if (startsWith(config->readDataNames[i], "conv_flag")) { @@ -968,12 +967,12 @@ void PreciceInterface_ConfigureCouplingData(PreciceInterface *interface, Simulat printf("Read data '%s' found.\n", config->readDataNames[i]); } else if (startsWith(config->readDataNames[i], "stress1to3")) { PreciceInterface_EnsureValidRead(interface, STRESS1TO3); - interface->readData[i] = STRESS1TO3; + interface->readData[i] = STRESS1TO3; interface->stress1to3Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); } else if (startsWith(config->readDataNames[i], "stress4to6")) { PreciceInterface_EnsureValidRead(interface, STRESS4TO6); - interface->readData[i] = STRESS4TO6; + interface->readData[i] = STRESS4TO6; interface->stress4to6Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); } else { @@ -1026,15 +1025,15 @@ void PreciceInterface_ConfigureCouplingData(PreciceInterface *interface, Simulat interface->forces = strdup(config->writeDataNames[i]); printf("Write data '%s' found.\n", interface->forces); } else if (isEqual(config->writeDataNames[i], "input_id")) { - interface->writeData[i] = INPUT_ID; - interface->macroInputData = strdup(config->writeDataNames[i]); + interface->writeData[i] = INPUT_ID; + interface->macroInputData = strdup(config->writeDataNames[i]); printf("Write data '%s' found.\n", config->writeDataNames[i]); } else if (isEqual(config->writeDataNames[i], "strain1to3")) { interface->writeData[i] = STRAIN1TO3; interface->strain1to3Data = strdup(config->writeDataNames[i]); printf("Write data '%s' found.\n", config->writeDataNames[i]); } else if (isEqual(config->writeDataNames[i], "strain4to6")) { - interface->writeData[i] = STRAIN4TO6; + interface->writeData[i] = STRAIN4TO6; interface->strain4to6Data = strdup(config->writeDataNames[i]); printf("Write data '%s' found.\n", config->writeDataNames[i]); } else { @@ -1095,18 +1094,18 @@ void PreciceInterface_FreeData(PreciceInterface *preciceInterface) free(preciceInterface->materialTangent7Data); } -void PreciceInterface_MultiscaleCheckpoint(SimulationData *sim){ - - if( Precice_IsCouplingOngoing()){ +void PreciceInterface_MultiscaleCheckpoint(SimulationData *sim) +{ - // Write strain data - Precice_WriteCouplingData(sim); + if (Precice_IsCouplingOngoing()) { - // Advance time - Precice_Advance(sim); + // Write strain data + Precice_WriteCouplingData(sim); - // Read stress, material tangent data - Precice_ReadCouplingData(sim); + // Advance time + Precice_Advance(sim); + // Read stress, material tangent data + Precice_ReadCouplingData(sim); } } diff --git a/adapter/PreciceInterface.h b/adapter/PreciceInterface.h index 5351b086..fbd6bb25 100644 --- a/adapter/PreciceInterface.h +++ b/adapter/PreciceInterface.h @@ -21,9 +21,9 @@ */ typedef struct PreciceInterface { - char * name; - int dim; // Dimension received from preCICE configuration - int dimCCX; // Dimension as seen by CalculiX + char *name; + int dim; // Dimension received from preCICE configuration + int dimCCX; // Dimension as seen by CalculiX // Interface nodes int numNodes; @@ -39,71 +39,71 @@ typedef struct PreciceInterface { char * nodesMeshName; // Interface face elements - int numElements; - int * elementIDs; - int * faceIDs; - double * faceCenterCoordinates; - int faceSetID; - char * faceCentersMeshName; - int * preciceFaceCenterIDs; + int numElements; + int * elementIDs; + int * faceIDs; + double *faceCenterCoordinates; + int faceSetID; + char * faceCentersMeshName; + int * preciceFaceCenterIDs; // Interface volumetric elements - int elementMeshID; - char * elementMeshName; - int elementSetID; - int numIPTotal; - double * elemIPCoordinates; - int * elemIPID; + int elementMeshID; + char * elementMeshName; + int elementSetID; + int numIPTotal; + double *elemIPCoordinates; + int * elemIPID; // Arrays to store the coupling data - double * nodeScalarData; - double * node2DScalarData; // Scalar quantities in 2D in case quasi 2D-3D coupling is done - double * nodeVectorData; // Forces, displacements, velocities, positions and displacementDeltas are vector quantities - double * node2DVectorData; // Vector quantities in 2D in case quasi 2D-3D coupling is done - double * faceCenterData; - double * elementIPScalarData; - double * elementIPVectorData; + double *nodeScalarData; + double *node2DScalarData; // Scalar quantities in 2D in case quasi 2D-3D coupling is done + double *nodeVectorData; // Forces, displacements, velocities, positions and displacementDeltas are vector quantities + double *node2DVectorData; // Vector quantities in 2D in case quasi 2D-3D coupling is done + double *faceCenterData; + double *elementIPScalarData; + double *elementIPVectorData; // preCICE mesh name - char * couplingMeshName; + char *couplingMeshName; // preCICE data names - char * temperature; - char * flux; - char * kDeltaWrite; - char * kDeltaTemperatureWrite; - char * kDeltaRead; - char * kDeltaTemperatureRead; - char * displacements; - char * displacementsData; - char * displacementDeltas; - char * positions; - char * velocities; - char * forces; - char * pressure; - char * macroInputData; - char * strain1to3Data; - char * strain4to6Data; - char * stress1to3Data; - char * stress4to6Data; - char * materialTangent1Data; - char * materialTangent2Data; - char * materialTangent3Data; - char * materialTangent4Data; - char * materialTangent5Data; - char * materialTangent6Data; - char * materialTangent7Data; + char *temperature; + char *flux; + char *kDeltaWrite; + char *kDeltaTemperatureWrite; + char *kDeltaRead; + char *kDeltaTemperatureRead; + char *displacements; + char *displacementsData; + char *displacementDeltas; + char *positions; + char *velocities; + char *forces; + char *pressure; + char *macroInputData; + char *strain1to3Data; + char *strain4to6Data; + char *stress1to3Data; + char *stress4to6Data; + char *materialTangent1Data; + char *materialTangent2Data; + char *materialTangent3Data; + char *materialTangent4Data; + char *materialTangent5Data; + char *materialTangent6Data; + char *materialTangent7Data; // Indices that indicate where to apply the boundary conditions / forces - int * xloadIndices; - int * xbounIndices; - int * xforcIndices; + int *xloadIndices; + int *xbounIndices; + int *xforcIndices; // Mapping type if nearest-projection mapping - int mapNPType; + int mapNPType; // Indicates if pseudo 2D-3D coupling is implemented - int quasi2D3D; + int quasi2D3D; int numReadData; int numWriteData; @@ -159,7 +159,7 @@ typedef struct SimulationData { ITG * nea; // element bounds in each thread - start ITG * neb; // element bounds in each thread - end double *eei; // Strain values for multiscale - double *stx; // Stress values for multiscale + double *stx; // Stress values for multiscale double *xstiff; // Strain values for multiscale // Interfaces diff --git a/multiscale_routines.f b/multiscale_routines.f index 28d6b485..095c3e79 100644 --- a/multiscale_routines.f +++ b/multiscale_routines.f @@ -41,13 +41,14 @@ END SUBROUTINE PRECICE_MULTISCALE_SET_STX - SUBROUTINE PRECICE_MULTISCALE_SET_XSTIFF(MAX_NGP, + SUBROUTINE PRECICE_MULTISCALE_SET_XSTIFF(MI, & INTPT, NUM_ELEM, pdata, XSTIFF) IMPLICIT NONE ! IO VARIABLES - INTEGER :: MAX_NGP ! MAXIMUM VALUE OF INTEGRATION POINT PER ELEMENT (MI[0]) + INTEGER :: MI(*) ! MAXIMUM VALUE OF INTEGRATION POINT PER ELEMENT (MI[0]) + INTEGER :: MAX_NGP ! MAXIMUM VALUE OF INTEGRATION POINT PER ELEMENT (MI[0]) INTEGER :: NUM_ELEM ! NUMBER OF ELEMENTS INTEGER :: INTPT ! INTERCEPT ADDED TO XSTIFF REAL(8) :: PDATA(:) ! DATA RECEIVED FROM PRECICE @@ -71,11 +72,11 @@ SUBROUTINE PRECICE_MULTISCALE_SET_XSTIFF(MAX_NGP, ENDDO ! IF(INTPT == 19) THEN - DO I = 1, NUM_ELEM - DO J = 1, NGP_MAX - write(*,*) XSTIFF(1:3, J, I) - ENDDO - ENDDO + ! DO I = 1, NUM_ELEM + ! DO J = 1, NGP_MAX + ! write(*,*) XSTIFF(1:3, J, I) + ! ENDDO + ! ENDDO ! ENDIF From 54bf8cb73c1fa14fd167d8b2c09071e346f0bb3a Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Fri, 12 Jul 2024 11:40:49 +0200 Subject: [PATCH 11/55] Formatting .c files --- linstatic_precice.c | 1558 +++++++++++++++++++++++-------------------- nonlingeo_precice.c | 201 +++--- 2 files changed, 931 insertions(+), 828 deletions(-) mode change 100755 => 100644 nonlingeo_precice.c diff --git a/linstatic_precice.c b/linstatic_precice.c index b2a59217..27520f45 100644 --- a/linstatic_precice.c +++ b/linstatic_precice.c @@ -7,7 +7,7 @@ /* */ /* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /* GNU General Public License for more details. */ @@ -15,8 +15,8 @@ /* along with this program; if not, write to the Free Software */ /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include #include +#include #include #include "CalculiX.h" #ifdef SPOOLES @@ -38,105 +38,113 @@ /* Adapter: Add header */ #include "adapter/PreciceInterface.h" -void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, - ITG *ne, - ITG *nodeboun,ITG *ndirboun,double *xboun,ITG *nboun, - ITG *ipompc,ITG *nodempc,double *coefmpc,char *labmpc, - ITG *nmpc, - ITG *nodeforc,ITG *ndirforc,double *xforc,ITG *nforc, - ITG *nelemload,char *sideload,double *xload, - ITG *nload,ITG *nactdof, - ITG **icolp,ITG *jq,ITG **irowp,ITG *neq,ITG *nzl, - ITG *nmethod,ITG *ikmpc,ITG *ilmpc,ITG *ikboun, - ITG *ilboun, - double *elcon,ITG *nelcon,double *rhcon,ITG *nrhcon, - double *alcon,ITG *nalcon,double *alzero,ITG **ielmatp, - ITG **ielorienp,ITG *norien,double *orab,ITG *ntmat_, - double *t0,double *t1,double *t1old, - ITG *ithermal,double *prestr,ITG *iprestr, - double *vold,ITG *iperturb,double *sti,ITG *nzs, - ITG *kode,char *filab,double *eme, - ITG *iexpl,double *plicon,ITG *nplicon,double *plkcon, - ITG *nplkcon, - double **xstatep,ITG *npmat_,char *matname,ITG *isolver, - ITG *mi,ITG *ncmat_,ITG *nstate_,double *cs,ITG *mcs, - ITG *nkon,double **enerp,double *xbounold, - double *xforcold,double *xloadold, - char *amname,double *amta,ITG *namta, - ITG *nam,ITG *iamforc,ITG *iamload, - ITG *iamt1,ITG *iamboun,double *ttime,char *output, - char *set,ITG *nset,ITG *istartset, - ITG *iendset,ITG *ialset,ITG *nprint,char *prlab, - char *prset,ITG *nener,double *trab, - ITG *inotr,ITG *ntrans,double *fmpc,ITG *ipobody,ITG *ibody, - double *xbody,ITG *nbody,double *xbodyold,double *timepar, - double *thicke,char *jobnamec,char *tieset,ITG *ntie, - ITG *istep,ITG *nmat,ITG *ielprop,double *prop,char *typeboun, - ITG *mortar,ITG *mpcinfo,double *tietol,ITG *ics, - char *orname,ITG *itempuser,double *t0g,double *t1g, - ITG *jmax, - /* Adapter: Add variables for the participant name and the config file */ - char *preciceParticipantName, char *configFilename){ - - char description[13]=" ",*lakon=NULL,stiffmatrix[132]="", - fneig[132]="",jobnamef[396]="",*labmpc2=NULL; - - ITG *inum=NULL,k,*icol=NULL,*irow=NULL,ielas=0,icmd=0,iinc=1,nasym=0,i,j,ic,ir, - mass[2]={0,0},stiffness=1,buckling=0,rhsi=1,intscheme=0,*ncocon=NULL, - *nshcon=NULL,mode=-1,noddiam=-1,coriolis=0,iout, - *itg=NULL,ntg=0,symmetryflag=0,inputformat=0,ngraph=1,im, - mt=mi[1]+1,ne0,*integerglob=NULL,iglob=0,*ipneigh=NULL,*neigh=NULL, - icfd=0,*inomat=NULL,*islavact=NULL,*islavnode=NULL,*nslavnode=NULL, - *islavsurf=NULL,nretain,*iretain=NULL,*noderetain=NULL,*ndirretain=NULL, - nmethodl,nintpoint,ifacecount,memmpc_,mpcfree,icascade,maxlenmpc, - ncont=0,*itietri=NULL,*koncont=NULL,nslavs=0,ismallsliding=0, - *itiefac=NULL,*imastnode=NULL,*nmastnode=NULL,*imastop=NULL,iitsta, - *iponoels=NULL,*inoels=NULL,*ipe=NULL,*ime=NULL,iit=-1,iflagact=0, - icutb=0,*kon=NULL,*ipkon=NULL,*ielmat=NULL,ialeatoric=0,kscale=1, - *iponoel=NULL,*inoel=NULL,zero=0,nherm=1,nev=*nforc,node,idir, - *ielorien=NULL,network=0,nrhs=1,iperturbsav,mscalmethod=0,*jqw=NULL, - *iroww=NULL,nzsw,*islavelinv=NULL,*irowtloc=NULL,*jqtloc=NULL,nboun2, - *ndirboun2=NULL,*nodeboun2=NULL,nmpc2,*ipompc2=NULL,*nodempc2=NULL, - *ikboun2=NULL,*ilboun2=NULL,*ikmpc2=NULL,*ilmpc2=NULL,mortartrafoflag=0; - - double *stn=NULL,*v=NULL,*een=NULL,cam[5],*xstiff=NULL,*stiini=NULL,*tper, - *f=NULL,*fn=NULL,qa[4],*fext=NULL,*epn=NULL,*xstateini=NULL, - *vini=NULL,*stx=NULL,*enern=NULL,*xbounact=NULL,*xforcact=NULL, - *xloadact=NULL,*t1act=NULL,*ampli=NULL,*xstaten=NULL,*eei=NULL, - *enerini=NULL,*cocon=NULL,*shcon=NULL,*physcon=NULL,*qfx=NULL, - *qfn=NULL,sigma=0.,*cgr=NULL,*xbodyact=NULL,*vr=NULL,*vi=NULL, - *stnr=NULL,*stni=NULL,*vmax=NULL,*stnmax=NULL,*springarea=NULL, - *eenmax=NULL,*fnr=NULL,*fni=NULL,*emn=NULL,*clearini=NULL,ptime, - *emeini=NULL,*doubleglob=NULL,*au=NULL,*ad=NULL,*b=NULL,*aub=NULL, - *adb=NULL,*pslavsurf=NULL,*pmastsurf=NULL,*cdn=NULL,*cdnr=NULL, - *cdni=NULL,*submatrix=NULL,*xnoels=NULL,*cg=NULL,*straight=NULL, - *areaslav=NULL,*xmastnor=NULL,theta=0.,*ener=NULL,*xstate=NULL, - *fnext=NULL,*energyini=NULL,*energy=NULL,*d=NULL,alea=0.1,*smscale=NULL, - *auw=NULL,*autloc=NULL,*xboun2=NULL,*coefmpc2=NULL; - - FILE *f1,*f2; - +void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lakonp, + ITG *ne, + ITG *nodeboun, ITG *ndirboun, double *xboun, ITG *nboun, + ITG *ipompc, ITG *nodempc, double *coefmpc, char *labmpc, + ITG *nmpc, + ITG *nodeforc, ITG *ndirforc, double *xforc, ITG *nforc, + ITG *nelemload, char *sideload, double *xload, + ITG *nload, ITG *nactdof, + ITG **icolp, ITG *jq, ITG **irowp, ITG *neq, ITG *nzl, + ITG *nmethod, ITG *ikmpc, ITG *ilmpc, ITG *ikboun, + ITG *ilboun, + double *elcon, ITG *nelcon, double *rhcon, ITG *nrhcon, + double *alcon, ITG *nalcon, double *alzero, ITG **ielmatp, + ITG **ielorienp, ITG *norien, double *orab, ITG *ntmat_, + double *t0, double *t1, double *t1old, + ITG *ithermal, double *prestr, ITG *iprestr, + double *vold, ITG *iperturb, double *sti, ITG *nzs, + ITG *kode, char *filab, double *eme, + ITG *iexpl, double *plicon, ITG *nplicon, double *plkcon, + ITG *nplkcon, + double **xstatep, ITG *npmat_, char *matname, ITG *isolver, + ITG *mi, ITG *ncmat_, ITG *nstate_, double *cs, ITG *mcs, + ITG *nkon, double **enerp, double *xbounold, + double *xforcold, double *xloadold, + char *amname, double *amta, ITG *namta, + ITG *nam, ITG *iamforc, ITG *iamload, + ITG *iamt1, ITG *iamboun, double *ttime, char *output, + char *set, ITG *nset, ITG *istartset, + ITG *iendset, ITG *ialset, ITG *nprint, char *prlab, + char *prset, ITG *nener, double *trab, + ITG *inotr, ITG *ntrans, double *fmpc, ITG *ipobody, ITG *ibody, + double *xbody, ITG *nbody, double *xbodyold, double *timepar, + double *thicke, char *jobnamec, char *tieset, ITG *ntie, + ITG *istep, ITG *nmat, ITG *ielprop, double *prop, char *typeboun, + ITG *mortar, ITG *mpcinfo, double *tietol, ITG *ics, + char *orname, ITG *itempuser, double *t0g, double *t1g, + ITG *jmax, + /* Adapter: Add variables for the participant name and the config file */ + char *preciceParticipantName, char *configFilename) +{ + + char description[13] = " ", *lakon = NULL, stiffmatrix[132] = "", + fneig[132] = "", jobnamef[396] = "", *labmpc2 = NULL; + + ITG *inum = NULL, k, *icol = NULL, *irow = NULL, ielas = 0, icmd = 0, iinc = 1, nasym = 0, i, j, ic, ir, + mass[2] = {0, 0}, stiffness = 1, buckling = 0, rhsi = 1, intscheme = 0, *ncocon = NULL, + *nshcon = NULL, mode = -1, noddiam = -1, coriolis = 0, iout, + *itg = NULL, ntg = 0, symmetryflag = 0, inputformat = 0, ngraph = 1, im, + mt = mi[1] + 1, ne0, *integerglob = NULL, iglob = 0, *ipneigh = NULL, *neigh = NULL, + icfd = 0, *inomat = NULL, *islavact = NULL, *islavnode = NULL, *nslavnode = NULL, + *islavsurf = NULL, nretain, *iretain = NULL, *noderetain = NULL, *ndirretain = NULL, + nmethodl, nintpoint, ifacecount, memmpc_, mpcfree, icascade, maxlenmpc, + ncont = 0, *itietri = NULL, *koncont = NULL, nslavs = 0, ismallsliding = 0, + *itiefac = NULL, *imastnode = NULL, *nmastnode = NULL, *imastop = NULL, iitsta, + *iponoels = NULL, *inoels = NULL, *ipe = NULL, *ime = NULL, iit = -1, iflagact = 0, + icutb = 0, *kon = NULL, *ipkon = NULL, *ielmat = NULL, ialeatoric = 0, kscale = 1, + *iponoel = NULL, *inoel = NULL, zero = 0, nherm = 1, nev = *nforc, node, idir, + *ielorien = NULL, network = 0, nrhs = 1, iperturbsav, mscalmethod = 0, *jqw = NULL, + *iroww = NULL, nzsw, *islavelinv = NULL, *irowtloc = NULL, *jqtloc = NULL, nboun2, + *ndirboun2 = NULL, *nodeboun2 = NULL, nmpc2, *ipompc2 = NULL, *nodempc2 = NULL, + *ikboun2 = NULL, *ilboun2 = NULL, *ikmpc2 = NULL, *ilmpc2 = NULL, mortartrafoflag = 0; + + double *stn = NULL, *v = NULL, *een = NULL, cam[5], *xstiff = NULL, *stiini = NULL, *tper, + *f = NULL, *fn = NULL, qa[4], *fext = NULL, *epn = NULL, *xstateini = NULL, + *vini = NULL, *stx = NULL, *enern = NULL, *xbounact = NULL, *xforcact = NULL, + *xloadact = NULL, *t1act = NULL, *ampli = NULL, *xstaten = NULL, *eei = NULL, + *enerini = NULL, *cocon = NULL, *shcon = NULL, *physcon = NULL, *qfx = NULL, + *qfn = NULL, sigma = 0., *cgr = NULL, *xbodyact = NULL, *vr = NULL, *vi = NULL, + *stnr = NULL, *stni = NULL, *vmax = NULL, *stnmax = NULL, *springarea = NULL, + *eenmax = NULL, *fnr = NULL, *fni = NULL, *emn = NULL, *clearini = NULL, ptime, + *emeini = NULL, *doubleglob = NULL, *au = NULL, *ad = NULL, *b = NULL, *aub = NULL, + *adb = NULL, *pslavsurf = NULL, *pmastsurf = NULL, *cdn = NULL, *cdnr = NULL, + *cdni = NULL, *submatrix = NULL, *xnoels = NULL, *cg = NULL, *straight = NULL, + *areaslav = NULL, *xmastnor = NULL, theta = 0., *ener = NULL, *xstate = NULL, + *fnext = NULL, *energyini = NULL, *energy = NULL, *d = NULL, alea = 0.1, *smscale = NULL, + *auw = NULL, *autloc = NULL, *xboun2 = NULL, *coefmpc2 = NULL; + + FILE *f1, *f2; + #ifdef SGI ITG token; #endif /* dummy arguments for the results call */ - double *veold=NULL,*accold=NULL,bet,gam,dtime,time,reltime=1.; + double *veold = NULL, *accold = NULL, bet, gam, dtime, time, reltime = 1.; - irow=*irowp;ener=*enerp;xstate=*xstatep;ipkon=*ipkonp;lakon=*lakonp; - kon=*konp;ielmat=*ielmatp;ielorien=*ielorienp;icol=*icolp; - - for(k=0;k<3;k++){ - strcpy1(&jobnamef[k*132],&jobnamec[k*132],132); + irow = *irowp; + ener = *enerp; + xstate = *xstatep; + ipkon = *ipkonp; + lakon = *lakonp; + kon = *konp; + ielmat = *ielmatp; + ielorien = *ielorienp; + icol = *icolp; + + for (k = 0; k < 3; k++) { + strcpy1(&jobnamef[k * 132], &jobnamec[k * 132], 132); } - tper=&timepar[1]; + tper = &timepar[1]; - time=*tper; - dtime=*tper; + time = *tper; + dtime = *tper; - ne0=*ne; + ne0 = *ne; /* preCICE Adapter: Initialize the Calculix data structure */ struct SimulationData simulationData = { @@ -152,7 +160,7 @@ void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, .nset = *nset, .ikboun = ikboun, // .ikforc = ikforc, - .ilboun = ilboun, + .ilboun = ilboun, // .ilforc = ilforc, .nboun = *nboun, .nforc = *nforc, @@ -163,24 +171,24 @@ void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, .nk = *nk, .theta = &theta, // .dtheta = &dtheta, - .tper = tper, - .nmethod = nmethod, - .xload = xload, - .xforc = xforc, - .xboun = xboun, - .ntmat_ = ntmat_, - .vold = vold, - .veold = veold, - .fn = fn, - .cocon = cocon, - .ncocon = ncocon, - .mi = mi, + .tper = tper, + .nmethod = nmethod, + .xload = xload, + .xforc = xforc, + .xboun = xboun, + .ntmat_ = ntmat_, + .vold = vold, + .veold = veold, + .fn = fn, + .cocon = cocon, + .ncocon = ncocon, + .mi = mi, // .eei = &eei, // .stx = &stx, // .xstiff = xstiff - }; + }; - /* preCICE Adapter: Initialize */ + /* preCICE Adapter: Initialize */ Precice_Setup(configFilename, preciceParticipantName, &simulationData); Precice_AdjustSolverTimestep(&simulationData); @@ -191,32 +199,38 @@ void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, iglob=0 if no global results are used by boundary conditions iglob=1 if global results are from a *STATIC calculation */ - ITG irefine=0; - getglobalresults(&jobnamec[396],&integerglob,&doubleglob,nboun,iamboun,xboun, - nload,sideload,iamload,&iglob,nforc,iamforc,xforc, - ithermal,nk,t1,iamt1,&sigma,&irefine); + ITG irefine = 0; + getglobalresults(&jobnamec[396], &integerglob, &doubleglob, nboun, iamboun, xboun, + nload, sideload, iamload, &iglob, nforc, iamforc, xforc, + ithermal, nk, t1, iamt1, &sigma, &irefine); /* reading temperatures from frd-file */ - - if((itempuser[0]==2)&&(itempuser[1]!=itempuser[2])) { - utempread(t1,&itempuser[2],jobnamec); - } + + if ((itempuser[0] == 2) && (itempuser[1] != itempuser[2])) { + utempread(t1, &itempuser[2], jobnamec); + } /* allocating fields for the actual external loading */ - NNEW(xbounact,double,*nboun); - for(k=0;k<*nboun;++k){xbounact[k]=xbounold[k];} - NNEW(xforcact,double,*nforc); - NNEW(xloadact,double,2**nload); - NNEW(xbodyact,double,7**nbody); + NNEW(xbounact, double, *nboun); + for (k = 0; k < *nboun; ++k) { + xbounact[k] = xbounold[k]; + } + NNEW(xforcact, double, *nforc); + NNEW(xloadact, double, 2 * *nload); + NNEW(xbodyact, double, 7 * *nbody); /* copying the rotation axis and/or acceleration vector */ - for(k=0;k<7**nbody;k++){xbodyact[k]=xbody[k];} - if(*ithermal==1){ - NNEW(t1act,double,*nk); - for(k=0;k<*nk;++k){t1act[k]=t1old[k];} + for (k = 0; k < 7 * *nbody; k++) { + xbodyact[k] = xbody[k]; } - - /* assigning the body forces to the elements */ + if (*ithermal == 1) { + NNEW(t1act, double, *nk); + for (k = 0; k < *nk; ++k) { + t1act[k] = t1old[k]; + } + } + + /* assigning the body forces to the elements */ /* if(*nbody>0){ ifreebody=*ne+1; @@ -230,365 +244,372 @@ void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, }*/ /* contact conditions */ - + // if(*icontact==1){ - if(*mortar>-2){ + if (*mortar > -2) { + + memmpc_ = mpcinfo[0]; + mpcfree = mpcinfo[1]; + icascade = mpcinfo[2]; + maxlenmpc = mpcinfo[3]; - memmpc_=mpcinfo[0];mpcfree=mpcinfo[1];icascade=mpcinfo[2]; - maxlenmpc=mpcinfo[3]; + inicont(nk, &ncont, ntie, tieset, nset, set, istartset, iendset, ialset, &itietri, + lakon, ipkon, kon, &koncont, &nslavs, tietol, &ismallsliding, &itiefac, + &islavsurf, &islavnode, &imastnode, &nslavnode, &nmastnode, + mortar, &imastop, nkon, &iponoels, &inoels, &ipe, &ime, ne, &ifacecount, + iperturb, ikboun, nboun, co, istep, &xnoels); - inicont(nk,&ncont,ntie,tieset,nset,set,istartset,iendset,ialset,&itietri, - lakon,ipkon,kon,&koncont,&nslavs,tietol,&ismallsliding,&itiefac, - &islavsurf,&islavnode,&imastnode,&nslavnode,&nmastnode, - mortar,&imastop,nkon,&iponoels,&inoels,&ipe,&ime,ne,&ifacecount, - iperturb,ikboun,nboun,co,istep,&xnoels); + if (ncont != 0) { - if(ncont!=0){ + NNEW(cg, double, 3 * ncont); + NNEW(straight, double, 16 * ncont); - NNEW(cg,double,3*ncont); - NNEW(straight,double,16*ncont); - /* 11 instead of 10: last position is reserved for the - local contact spring element number; needed as - pointer into springarea */ - - if(*mortar==0){ - RENEW(kon,ITG,*nkon+11*nslavs); - NNEW(springarea,double,2*nslavs); - if(*nener==1){ - RENEW(ener,double,2*mi[0]*(*ne+nslavs)); - DMEMSET(ener,2*mi[0]**ne,2*mi[0]*(*ne+nslavs),0.); - } - RENEW(ipkon,ITG,*ne+nslavs); - RENEW(lakon,char,8*(*ne+nslavs)); - - if(*norien>0){ - RENEW(ielorien,ITG,mi[2]*(*ne+nslavs)); - for(k=mi[2]**ne;k0){ - RENEW(ielorien,ITG,mi[2]*(*ne+nintpoint)); - for(k=mi[2]**ne;k 0) { + RENEW(ielorien, ITG, mi[2] * (*ne + nslavs)); + for (k = mi[2] * *ne; k < mi[2] * (*ne + nslavs); k++) + ielorien[k] = 0; + } + + RENEW(ielmat, ITG, mi[2] * (*ne + nslavs)); + for (k = mi[2] * *ne; k < mi[2] * (*ne + nslavs); k++) + ielmat[k] = 1; + + if (nslavs != 0) { + RENEW(xstate, double, *nstate_ *mi[0] * (*ne + nslavs)); + for (k = *nstate_ * mi[0] * *ne; k < *nstate_ * mi[0] * (*ne + nslavs); k++) { + xstate[k] = 0.; + } + } + + NNEW(areaslav, double, ifacecount); + NNEW(xmastnor, double, 3 * nmastnode[*ntie]); + } else if (*mortar == 1) { + NNEW(islavact, ITG, nslavnode[*ntie]); + DMEMSET(islavact, 0, nslavnode[*ntie], 1); + NNEW(clearini, double, 3 * 9 * ifacecount); + NNEW(xmastnor, double, 3 * nmastnode[*ntie]); + + nintpoint = 0; + + precontact(&ncont, ntie, tieset, nset, set, istartset, + iendset, ialset, itietri, lakon, ipkon, kon, koncont, ne, + cg, straight, co, vold, istep, &iinc, &iit, itiefac, + islavsurf, islavnode, imastnode, nslavnode, nmastnode, + imastop, mi, ipe, ime, tietol, &iflagact, + &nintpoint, &pslavsurf, xmastnor, cs, mcs, ics, clearini, + &nslavs); + + /* changing the dimension of element-related fields */ + + RENEW(kon, ITG, *nkon + 22 * nintpoint); + RENEW(springarea, double, 2 * nintpoint); + RENEW(pmastsurf, double, 6 * nintpoint); + + if (*nener == 1) { + RENEW(ener, double, 2 * mi[0] * (*ne + nintpoint)); + DMEMSET(ener, 2 * mi[0] * *ne, 2 * mi[0] * (*ne + nintpoint), 0.); + } + RENEW(ipkon, ITG, *ne + nintpoint); + RENEW(lakon, char, 8 * (*ne + nintpoint)); + + if (*norien > 0) { + RENEW(ielorien, ITG, mi[2] * (*ne + nintpoint)); + for (k = mi[2] * *ne; k < mi[2] * (*ne + nintpoint); k++) + ielorien[k] = 0; + } + RENEW(ielmat, ITG, mi[2] * (*ne + nintpoint)); + for (k = mi[2] * *ne; k < mi[2] * (*ne + nintpoint); k++) + ielmat[k] = 1; + + /* interpolating the state variables */ + + if (*nstate_ != 0) { + + RENEW(xstate, double, *nstate_ *mi[0] * (ne0 + nintpoint)); + for (k = *nstate_ * mi[0] * ne0; k < *nstate_ * mi[0] * (ne0 + nintpoint); k++) { + xstate[k] = 0.; + } + + RENEW(xstateini, double, *nstate_ *mi[0] * (ne0 + nintpoint)); + for (k = 0; k < *nstate_ * mi[0] * (ne0 + nintpoint); ++k) { + xstateini[k] = xstate[k]; + } + } } - + /* generating contact spring elements */ - contact(&ncont,ntie,tieset,nset,set,istartset,iendset, - ialset,itietri,lakon,ipkon,kon,koncont,ne,cg,straight,nkon, - co,vold,ielmat,cs,elcon,istep,&iinc,&iit,ncmat_,ntmat_, - &ne0,nmethod, - iperturb,ikboun,nboun,mi,imastop,nslavnode,islavnode,islavsurf, - itiefac,areaslav,iponoels,inoels,springarea,tietol,&reltime, - imastnode,nmastnode,xmastnor,filab,mcs,ics,&nasym, - xnoels,mortar,pslavsurf,pmastsurf,clearini,&theta, - xstateini,xstate,nstate_,&icutb,&ialeatoric,jobnamef, - &alea,auw,jqw,iroww,&nzsw); - - printf("number of contact spring elements=%" ITGFORMAT "\n\n",*ne-ne0); - + contact(&ncont, ntie, tieset, nset, set, istartset, iendset, + ialset, itietri, lakon, ipkon, kon, koncont, ne, cg, straight, nkon, + co, vold, ielmat, cs, elcon, istep, &iinc, &iit, ncmat_, ntmat_, + &ne0, nmethod, + iperturb, ikboun, nboun, mi, imastop, nslavnode, islavnode, islavsurf, + itiefac, areaslav, iponoels, inoels, springarea, tietol, &reltime, + imastnode, nmastnode, xmastnor, filab, mcs, ics, &nasym, + xnoels, mortar, pslavsurf, pmastsurf, clearini, &theta, + xstateini, xstate, nstate_, &icutb, &ialeatoric, jobnamef, + &alea, auw, jqw, iroww, &nzsw); + + printf("number of contact spring elements=%" ITGFORMAT "\n\n", *ne - ne0); + /* determining the structure of the stiffness/mass matrix */ - - remastructar(ipompc,&coefmpc,&nodempc,nmpc, - &mpcfree,nodeboun,ndirboun,nboun,ikmpc,ilmpc,ikboun,ilboun, - labmpc,nk,&memmpc_,&icascade,&maxlenmpc, - kon,ipkon,lakon,ne,nactdof,icol,jq,&irow,isolver, - neq,nzs,nmethod,ithermal,iperturb,mass,mi,ics,cs, - mcs,mortar,typeboun,&iit,&network,iexpl,ielmat,matname); + + remastructar(ipompc, &coefmpc, &nodempc, nmpc, + &mpcfree, nodeboun, ndirboun, nboun, ikmpc, ilmpc, ikboun, ilboun, + labmpc, nk, &memmpc_, &icascade, &maxlenmpc, + kon, ipkon, lakon, ne, nactdof, icol, jq, &irow, isolver, + neq, nzs, nmethod, ithermal, iperturb, mass, mi, ics, cs, + mcs, mortar, typeboun, &iit, &network, iexpl, ielmat, matname); } /* field for initial values of state variables (needed for contact */ - if((*nstate_!=0)&&((*mortar==0)||(ncont==0))){ - NNEW(xstateini,double,*nstate_*mi[0]*(ne0+nslavs)); - for(k=0;k<*nstate_*mi[0]*(ne0+nslavs);++k){ - xstateini[k]=xstate[k]; + if ((*nstate_ != 0) && ((*mortar == 0) || (ncont == 0))) { + NNEW(xstateini, double, *nstate_ *mi[0] * (ne0 + nslavs)); + for (k = 0; k < *nstate_ * mi[0] * (ne0 + nslavs); ++k) { + xstateini[k] = xstate[k]; } } } /* allocating a field for the instantaneous amplitude */ - NNEW(ampli,double,*nam); - - FORTRAN(tempload,(xforcold,xforc,xforcact,iamforc,nforc,xloadold,xload, - xloadact,iamload,nload,ibody,xbody,nbody,xbodyold,xbodyact, - t1old,t1,t1act,iamt1,nk,amta, - namta,nam,ampli,&time,&reltime,ttime,&dtime,ithermal,nmethod, - xbounold,xboun,xbounact,iamboun,nboun, - nodeboun,ndirboun,nodeforc,ndirforc,istep,&iinc, - co,vold,itg,&ntg,amname,ikboun,ilboun,nelemload,sideload,mi, - ntrans,trab,inotr,veold,integerglob,doubleglob,tieset,istartset, - iendset,ialset,ntie,nmpc,ipompc,ikmpc,ilmpc,nodempc,coefmpc, - ipobody,iponoel,inoel,ipkon,kon,ielprop,prop,ielmat, - shcon,nshcon,rhcon,nrhcon,cocon,ncocon,ntmat_,lakon, - set,nset)); + NNEW(ampli, double, *nam); + + FORTRAN(tempload, (xforcold, xforc, xforcact, iamforc, nforc, xloadold, xload, + xloadact, iamload, nload, ibody, xbody, nbody, xbodyold, xbodyact, + t1old, t1, t1act, iamt1, nk, amta, + namta, nam, ampli, &time, &reltime, ttime, &dtime, ithermal, nmethod, + xbounold, xboun, xbounact, iamboun, nboun, + nodeboun, ndirboun, nodeforc, ndirforc, istep, &iinc, + co, vold, itg, &ntg, amname, ikboun, ilboun, nelemload, sideload, mi, + ntrans, trab, inotr, veold, integerglob, doubleglob, tieset, istartset, + iendset, ialset, ntie, nmpc, ipompc, ikmpc, ilmpc, nodempc, coefmpc, + ipobody, iponoel, inoel, ipkon, kon, ielprop, prop, ielmat, + shcon, nshcon, rhcon, nrhcon, cocon, ncocon, ntmat_, lakon, + set, nset)); /* determining the internal forces and the stiffness coefficients */ - NNEW(f,double,*neq); + NNEW(f, double, *neq); /* allocating a field for the stiffness matrix */ - NNEW(xstiff,double,(long long)27*mi[0]**ne); + NNEW(xstiff, double, (long long) 27 * mi[0] * *ne); /* for a *STATIC,PERTURBATION analysis with submodel boundary conditions from a *FREQUENCY analysis iperturb[0]=1 has to be temporarily set to iperturb[0]=0 in order for f to be calculated in resultsini and subsequent results* routines */ - if((*nmethod==1)&&(iglob<0)&&(iperturb[0]>0)){ - iperturbsav=iperturb[0]; - iperturb[0]=0; + if ((*nmethod == 1) && (iglob < 0) && (iperturb[0] > 0)) { + iperturbsav = iperturb[0]; + iperturb[0] = 0; } - iout=-1; - NNEW(v,double,mt**nk); - NNEW(fn,double,mt**nk); - NNEW(stx,double,6*mi[0]**ne); - NNEW(inum,ITG,*nk); - NNEW(eei,double,6*mi[0]**ne); - results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, - elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, - ielorien,norien,orab,ntmat_,t0,t1act,ithermal, - prestr,iprestr,filab,eme,emn,een,iperturb, - f,fn,nactdof,&iout,qa,vold,b,nodeboun, - ndirboun,xbounact,nboun,ipompc, - nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold,accold, - &bet,&gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, - xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas, - &icmd,ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern, - emeini,xstaten,eei,enerini,cocon,ncocon,set,nset,istartset, - iendset,ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans, - fmpc,nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea, - &reltime,&ne0,thicke,shcon,nshcon, - sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, - mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, - islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, - inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, - itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, - islavelinv,autloc,irowtloc,jqtloc,&nboun2, - ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, - labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, - &intscheme,physcon); - + iout = -1; + NNEW(v, double, mt **nk); + NNEW(fn, double, mt **nk); + NNEW(stx, double, 6 * mi[0] * *ne); + NNEW(inum, ITG, *nk); + NNEW(eei, double, 6 * mi[0] * *ne); + results(co, nk, kon, ipkon, lakon, ne, v, stn, inum, stx, + elcon, nelcon, rhcon, nrhcon, alcon, nalcon, alzero, ielmat, + ielorien, norien, orab, ntmat_, t0, t1act, ithermal, + prestr, iprestr, filab, eme, emn, een, iperturb, + f, fn, nactdof, &iout, qa, vold, b, nodeboun, + ndirboun, xbounact, nboun, ipompc, + nodempc, coefmpc, labmpc, nmpc, nmethod, cam, neq, veold, accold, + &bet, &gam, &dtime, &time, ttime, plicon, nplicon, plkcon, nplkcon, + xstateini, xstiff, xstate, npmat_, epn, matname, mi, &ielas, + &icmd, ncmat_, nstate_, stiini, vini, ikboun, ilboun, ener, enern, + emeini, xstaten, eei, enerini, cocon, ncocon, set, nset, istartset, + iendset, ialset, nprint, prlab, prset, qfx, qfn, trab, inotr, ntrans, + fmpc, nelemload, nload, ikmpc, ilmpc, istep, &iinc, springarea, + &reltime, &ne0, thicke, shcon, nshcon, + sideload, xloadact, xloadold, &icfd, inomat, pslavsurf, pmastsurf, + mortar, islavact, cdn, islavnode, nslavnode, ntie, clearini, + islavsurf, ielprop, prop, energyini, energy, &kscale, iponoel, + inoel, nener, orname, &network, ipobody, xbodyact, ibody, typeboun, + itiefac, tieset, smscale, &mscalmethod, nbody, t0g, t1g, + islavelinv, autloc, irowtloc, jqtloc, &nboun2, + ndirboun2, nodeboun2, xboun2, &nmpc2, ipompc2, nodempc2, coefmpc2, + labmpc2, ikboun2, ilboun2, ikmpc2, ilmpc2, &mortartrafoflag, + &intscheme, physcon); /* preCICE Adapter: Multiscale checkpoint*/ simulationData.xstiff = &xstiff; - simulationData.eei = &eei; - simulationData.stx = &stx; + simulationData.eei = &eei; + simulationData.stx = &stx; PreciceInterface_MultiscaleCheckpoint(&simulationData); - - SFREE(v);SFREE(fn);SFREE(stx);SFREE(inum); SFREE(eei); - iout=1; - if((*nmethod==1)&&(iglob<0)&&(iperturb[0]>0)){ - iperturb[0]=iperturbsav; + SFREE(v); + SFREE(fn); + SFREE(stx); + SFREE(inum); + SFREE(eei); + iout = 1; + + if ((*nmethod == 1) && (iglob < 0) && (iperturb[0] > 0)) { + iperturb[0] = iperturbsav; } - + /* determining the system matrix and the external forces */ - NNEW(ad,double,*neq); - NNEW(fext,double,*neq); + NNEW(ad, double, *neq); + NNEW(fext, double, *neq); + + if (*nmethod == 11) { - if(*nmethod==11){ - /* determining the nodes and the degrees of freedom in those nodes belonging to the substructure */ - - NNEW(iretain,ITG,*nk); - NNEW(noderetain,ITG,*nk); - NNEW(ndirretain,ITG,*nk); - nretain=0; - - for(i=0;i<*nboun;i++){ - if(strcmp1(&typeboun[i],"C")==0){ - iretain[nretain]=i+1; - noderetain[nretain]=nodeboun[i]; - ndirretain[nretain]=ndirboun[i]; - nretain++; + + NNEW(iretain, ITG, *nk); + NNEW(noderetain, ITG, *nk); + NNEW(ndirretain, ITG, *nk); + nretain = 0; + + for (i = 0; i < *nboun; i++) { + if (strcmp1(&typeboun[i], "C") == 0) { + iretain[nretain] = i + 1; + noderetain[nretain] = nodeboun[i]; + ndirretain[nretain] = ndirboun[i]; + nretain++; } } - + /* nretain!=0: substructure application */ - - RENEW(iretain,ITG,nretain); - RENEW(noderetain,ITG,nretain); - RENEW(ndirretain,ITG,nretain); - + + RENEW(iretain, ITG, nretain); + RENEW(noderetain, ITG, nretain); + RENEW(ndirretain, ITG, nretain); + /* creating the right size au */ - NNEW(au,double,nzs[2]); - rhsi=0; - nmethodl=2; + NNEW(au, double, nzs[2]); + rhsi = 0; + nmethodl = 2; - }else{ + } else { /* linear static calculation */ - NNEW(au,double,*nzs); - nmethodl=*nmethod; + NNEW(au, double, *nzs); + nmethodl = *nmethod; /* if submodel calculation with a global model obtained by a *FREQUENCY calculation: replace stiffness matrix K by K-sigma*M */ - if(iglob<0){ - mass[0]=1; - NNEW(adb,double,*neq); - NNEW(aub,double,nzs[1]); + if (iglob < 0) { + mass[0] = 1; + NNEW(adb, double, *neq); + NNEW(aub, double, nzs[1]); } - } - mafillsmmain(co,nk,kon,ipkon,lakon,ne,nodeboun,ndirboun,xbounact,nboun, - ipompc,nodempc,coefmpc,nmpc,nodeforc,ndirforc,xforcact, - nforc,nelemload,sideload,xloadact,nload,xbodyact,ipobody, - nbody,cgr,ad,au,fext,nactdof,icol,jq,irow,neq,nzl,&nmethodl, - ikmpc,ilmpc,ikboun,ilboun, - elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, - ielorien,norien,orab,ntmat_, - t0,t1act,ithermal,prestr,iprestr,vold,iperturb,sti, - nzs,stx,adb,aub,iexpl,plicon,nplicon,plkcon,nplkcon, - xstiff,npmat_,&dtime,matname,mi, - ncmat_,mass,&stiffness,&buckling,&rhsi,&intscheme,physcon, - shcon,nshcon,cocon,ncocon,ttime,&time,istep,&iinc,&coriolis, - ibody,xloadold,&reltime,veold,springarea,nstate_, - xstateini,xstate,thicke,integerglob,doubleglob, - tieset,istartset,iendset,ialset,ntie,&nasym,pslavsurf, - pmastsurf,mortar,clearini,ielprop,prop,&ne0,fnext,&kscale, - iponoel,inoel,&network,ntrans,inotr,trab,smscale,&mscalmethod, - set,nset,islavelinv,autloc,irowtloc,jqtloc,&mortartrafoflag); + mafillsmmain(co, nk, kon, ipkon, lakon, ne, nodeboun, ndirboun, xbounact, nboun, + ipompc, nodempc, coefmpc, nmpc, nodeforc, ndirforc, xforcact, + nforc, nelemload, sideload, xloadact, nload, xbodyact, ipobody, + nbody, cgr, ad, au, fext, nactdof, icol, jq, irow, neq, nzl, &nmethodl, + ikmpc, ilmpc, ikboun, ilboun, + elcon, nelcon, rhcon, nrhcon, alcon, nalcon, alzero, ielmat, + ielorien, norien, orab, ntmat_, + t0, t1act, ithermal, prestr, iprestr, vold, iperturb, sti, + nzs, stx, adb, aub, iexpl, plicon, nplicon, plkcon, nplkcon, + xstiff, npmat_, &dtime, matname, mi, + ncmat_, mass, &stiffness, &buckling, &rhsi, &intscheme, physcon, + shcon, nshcon, cocon, ncocon, ttime, &time, istep, &iinc, &coriolis, + ibody, xloadold, &reltime, veold, springarea, nstate_, + xstateini, xstate, thicke, integerglob, doubleglob, + tieset, istartset, iendset, ialset, ntie, &nasym, pslavsurf, + pmastsurf, mortar, clearini, ielprop, prop, &ne0, fnext, &kscale, + iponoel, inoel, &network, ntrans, inotr, trab, smscale, &mscalmethod, + set, nset, islavelinv, autloc, irowtloc, jqtloc, &mortartrafoflag); /* check for negative Jacobians */ - if(nmethodl==0) *nmethod=0; - - if(nasym==1){ - RENEW(au,double,2*nzs[1]); - symmetryflag=2; - inputformat=1; - - mafillsmasmain(co,nk,kon,ipkon,lakon,ne,nodeboun, - ndirboun,xbounact,nboun, - ipompc,nodempc,coefmpc,nmpc,nodeforc,ndirforc,xforcact, - nforc,nelemload,sideload,xloadact,nload,xbodyact,ipobody, - nbody,cgr,ad,au,fext,nactdof,icol,jq,irow,neq,nzl, - nmethod,ikmpc,ilmpc,ikboun,ilboun, - elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero, - ielmat,ielorien,norien,orab,ntmat_, - t0,t1act,ithermal,prestr,iprestr,vold,iperturb,sti, - nzs,stx,adb,aub,iexpl,plicon,nplicon,plkcon,nplkcon, - xstiff,npmat_,&dtime,matname,mi, - ncmat_,mass,&stiffness,&buckling,&rhsi,&intscheme, - physcon,shcon,nshcon,cocon,ncocon,ttime,&time,istep,&iinc, - &coriolis,ibody,xloadold,&reltime,veold,springarea,nstate_, - xstateini,xstate,thicke, - integerglob,doubleglob,tieset,istartset,iendset, - ialset,ntie,&nasym,pslavsurf,pmastsurf,mortar,clearini, - ielprop,prop,&ne0,&kscale,iponoel,inoel,&network,set,nset); + if (nmethodl == 0) + *nmethod = 0; + + if (nasym == 1) { + RENEW(au, double, 2 * nzs[1]); + symmetryflag = 2; + inputformat = 1; + + mafillsmasmain(co, nk, kon, ipkon, lakon, ne, nodeboun, + ndirboun, xbounact, nboun, + ipompc, nodempc, coefmpc, nmpc, nodeforc, ndirforc, xforcact, + nforc, nelemload, sideload, xloadact, nload, xbodyact, ipobody, + nbody, cgr, ad, au, fext, nactdof, icol, jq, irow, neq, nzl, + nmethod, ikmpc, ilmpc, ikboun, ilboun, + elcon, nelcon, rhcon, nrhcon, alcon, nalcon, alzero, + ielmat, ielorien, norien, orab, ntmat_, + t0, t1act, ithermal, prestr, iprestr, vold, iperturb, sti, + nzs, stx, adb, aub, iexpl, plicon, nplicon, plkcon, nplkcon, + xstiff, npmat_, &dtime, matname, mi, + ncmat_, mass, &stiffness, &buckling, &rhsi, &intscheme, + physcon, shcon, nshcon, cocon, ncocon, ttime, &time, istep, &iinc, + &coriolis, ibody, xloadold, &reltime, veold, springarea, nstate_, + xstateini, xstate, thicke, + integerglob, doubleglob, tieset, istartset, iendset, + ialset, ntie, &nasym, pslavsurf, pmastsurf, mortar, clearini, + ielprop, prop, &ne0, &kscale, iponoel, inoel, &network, set, nset); } /* determining the right hand side */ - NNEW(b,double,*neq); - for(k=0;k<*neq;++k){ - b[k]=fext[k]-f[k]; + NNEW(b, double, *neq); + for (k = 0; k < *neq; ++k) { + b[k] = fext[k] - f[k]; } - SFREE(fext);SFREE(f); + SFREE(fext); + SFREE(f); /* generation of a substructure stiffness matrix */ - if(*nmethod==11){ + if (*nmethod == 11) { /* factorizing the matrix */ - if(*neq>0){ - if(*isolver==0){ + if (*neq > 0) { + if (*isolver == 0) { #ifdef SPOOLES - spooles_factor(ad,au,adb,aub,&sigma,icol,irow,neq,nzs,&symmetryflag, - &inputformat,&nzs[2]); + spooles_factor(ad, au, adb, aub, &sigma, icol, irow, neq, nzs, &symmetryflag, + &inputformat, &nzs[2]); #else - printf(" *ERROR in linstatic: the SPOOLES library is not linked\n\n"); - FORTRAN(stop,()); + printf(" *ERROR in linstatic: the SPOOLES library is not linked\n\n"); + FORTRAN(stop, ()); #endif - } - else if(*isolver==7){ + } else if (*isolver == 7) { #ifdef PARDISO - pardiso_factor(ad,au,adb,aub,&sigma,icol,irow,neq,nzs, - &symmetryflag,&inputformat,jq,&nzs[2]); + pardiso_factor(ad, au, adb, aub, &sigma, icol, irow, neq, nzs, + &symmetryflag, &inputformat, jq, &nzs[2]); #else - printf(" *ERROR in linstatic: the PARDISO library is not linked\n\n"); - FORTRAN(stop,()); + printf(" *ERROR in linstatic: the PARDISO library is not linked\n\n"); + FORTRAN(stop, ()); #endif - } - else if(*isolver==8){ + } else if (*isolver == 8) { #ifdef PASTIX - pastix_factor_main(ad,au,adb,aub,&sigma,icol,irow,neq,nzs, - &symmetryflag,&inputformat,jq,&nzs[2]); + pastix_factor_main(ad, au, adb, aub, &sigma, icol, irow, neq, nzs, + &symmetryflag, &inputformat, jq, &nzs[2]); #else - printf(" *ERROR in linstatic: the PASTIX library is not linked\n\n"); - FORTRAN(stop,()); + printf(" *ERROR in linstatic: the PASTIX library is not linked\n\n"); + FORTRAN(stop, ()); #endif } } @@ -597,445 +618,528 @@ void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, /* substructure calculations */ - NNEW(submatrix,double,nretain*nretain); - - for(i=0;i0){ - if(*isolver==0){ + + if (*neq > 0) { + if (*isolver == 0) { #ifdef SPOOLES - spooles_solve(b,neq); + spooles_solve(b, neq); #endif - } - else if(*isolver==7){ + } else if (*isolver == 7) { #ifdef PARDISO - pardiso_solve(b,neq,&symmetryflag,&inputformat,&nrhs); + pardiso_solve(b, neq, &symmetryflag, &inputformat, &nrhs); #endif - - } - else if(*isolver==8){ + + } else if (*isolver == 8) { #ifdef PASTIX - pastix_solve(b,neq,&symmetryflag,&nrhs); + pastix_solve(b, neq, &symmetryflag, &nrhs); #endif - - } + } } - + /* calculating the internal forces */ - - NNEW(v,double,mt**nk); - NNEW(fn,double,mt**nk); - NNEW(stn,double,6**nk); - NNEW(inum,ITG,*nk); - NNEW(stx,double,6*mi[0]**ne); - - if(strcmp1(&filab[261],"E ")==0) NNEW(een,double,6**nk); - if(strcmp1(&filab[2697],"ME ")==0) NNEW(emn,double,6**nk); - if(strcmp1(&filab[522],"ENER")==0) NNEW(enern,double,*nk); - - NNEW(eei,double,6*mi[0]**ne); - if(*nener==1){ - NNEW(stiini,double,6*mi[0]**ne); - NNEW(emeini,double,6*mi[0]**ne); - NNEW(enerini,double,2*mi[0]**ne);} - + + NNEW(v, double, mt **nk); + NNEW(fn, double, mt **nk); + NNEW(stn, double, 6 * *nk); + NNEW(inum, ITG, *nk); + NNEW(stx, double, 6 * mi[0] * *ne); + + if (strcmp1(&filab[261], "E ") == 0) + NNEW(een, double, 6 * *nk); + if (strcmp1(&filab[2697], "ME ") == 0) + NNEW(emn, double, 6 * *nk); + if (strcmp1(&filab[522], "ENER") == 0) + NNEW(enern, double, *nk); + + NNEW(eei, double, 6 * mi[0] * *ne); + if (*nener == 1) { + NNEW(stiini, double, 6 * mi[0] * *ne); + NNEW(emeini, double, 6 * mi[0] * *ne); + NNEW(enerini, double, 2 * mi[0] * *ne); + } + /* replacing the appropriate boundary value by unity */ - - xbounact[iretain[i]-1]=1.; - - results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, - elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, - ielorien,norien,orab,ntmat_,t0,t1act,ithermal, - prestr,iprestr,filab,eme,emn,een,iperturb, - f,fn,nactdof,&iout,qa,vold,b,nodeboun,ndirboun, - xbounact,nboun,ipompc, - nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold, - accold,&bet, - &gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, - xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas,&icmd, - ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern,emeini, - xstaten,eei,enerini,cocon,ncocon,set,nset,istartset,iendset, - ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans,fmpc, - nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea,&reltime, - &ne0,thicke,shcon,nshcon, - sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, - mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, - islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, - inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, - itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, - islavelinv,autloc,irowtloc,jqtloc,&nboun2, - ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, - labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, - &intscheme,physcon); - - xbounact[iretain[i]-1]=0.; - - SFREE(v);SFREE(stn);SFREE(inum);SFREE(stx); - - if(strcmp1(&filab[261],"E ")==0) SFREE(een); - if(strcmp1(&filab[2697],"ME ")==0) SFREE(emn); - if(strcmp1(&filab[522],"ENER")==0) SFREE(enern); - - SFREE(eei);if(*nener==1){SFREE(stiini);SFREE(emeini);SFREE(enerini);} - + + xbounact[iretain[i] - 1] = 1.; + + results(co, nk, kon, ipkon, lakon, ne, v, stn, inum, stx, + elcon, nelcon, rhcon, nrhcon, alcon, nalcon, alzero, ielmat, + ielorien, norien, orab, ntmat_, t0, t1act, ithermal, + prestr, iprestr, filab, eme, emn, een, iperturb, + f, fn, nactdof, &iout, qa, vold, b, nodeboun, ndirboun, + xbounact, nboun, ipompc, + nodempc, coefmpc, labmpc, nmpc, nmethod, cam, neq, veold, + accold, &bet, + &gam, &dtime, &time, ttime, plicon, nplicon, plkcon, nplkcon, + xstateini, xstiff, xstate, npmat_, epn, matname, mi, &ielas, &icmd, + ncmat_, nstate_, stiini, vini, ikboun, ilboun, ener, enern, emeini, + xstaten, eei, enerini, cocon, ncocon, set, nset, istartset, iendset, + ialset, nprint, prlab, prset, qfx, qfn, trab, inotr, ntrans, fmpc, + nelemload, nload, ikmpc, ilmpc, istep, &iinc, springarea, &reltime, + &ne0, thicke, shcon, nshcon, + sideload, xloadact, xloadold, &icfd, inomat, pslavsurf, pmastsurf, + mortar, islavact, cdn, islavnode, nslavnode, ntie, clearini, + islavsurf, ielprop, prop, energyini, energy, &kscale, iponoel, + inoel, nener, orname, &network, ipobody, xbodyact, ibody, typeboun, + itiefac, tieset, smscale, &mscalmethod, nbody, t0g, t1g, + islavelinv, autloc, irowtloc, jqtloc, &nboun2, + ndirboun2, nodeboun2, xboun2, &nmpc2, ipompc2, nodempc2, coefmpc2, + labmpc2, ikboun2, ilboun2, ikmpc2, ilmpc2, &mortartrafoflag, + &intscheme, physcon); + + xbounact[iretain[i] - 1] = 0.; + + SFREE(v); + SFREE(stn); + SFREE(inum); + SFREE(stx); + + if (strcmp1(&filab[261], "E ") == 0) + SFREE(een); + if (strcmp1(&filab[2697], "ME ") == 0) + SFREE(emn); + if (strcmp1(&filab[522], "ENER") == 0) + SFREE(enern); + + SFREE(eei); + if (*nener == 1) { + SFREE(stiini); + SFREE(emeini); + SFREE(enerini); + } + /* storing the internal forces in the substructure - stiffness matrix */ - - for(j=0;j0){ - if(*isolver==0){ + + if (*neq > 0) { + if (*isolver == 0) { #ifdef SPOOLES - spooles_cleanup(); + spooles_cleanup(); #endif - } - else if(*isolver==7){ + } else if (*isolver == 7) { #ifdef PARDISO - pardiso_cleanup(&neq[0],&symmetryflag,&inputformat); + pardiso_cleanup(&neq[0], &symmetryflag, &inputformat); #endif - } - else if(*isolver==8){ + } else if (*isolver == 8) { #ifdef PASTIX #endif } } - + SFREE(iretain); - - FORTRAN(writesubmatrix,(submatrix,noderetain,ndirretain,&nretain,jobnamec, - jmax)); - - SFREE(submatrix);SFREE(noderetain);SFREE(ndirretain); - - SFREE(au);SFREE(ad);SFREE(b); - - SFREE(xbounact);SFREE(xforcact);SFREE(xloadact);SFREE(t1act);SFREE(ampli); + + FORTRAN(writesubmatrix, (submatrix, noderetain, ndirretain, &nretain, jobnamec, + jmax)); + + SFREE(submatrix); + SFREE(noderetain); + SFREE(ndirretain); + + SFREE(au); + SFREE(ad); + SFREE(b); + + SFREE(xbounact); + SFREE(xforcact); + SFREE(xloadact); + SFREE(t1act); + SFREE(ampli); SFREE(xbodyact); // if(*nbody>0) SFREE(ipobody); SFREE(xstiff); - - if(iglob!=0){SFREE(integerglob);SFREE(doubleglob);} - - return; + if (iglob != 0) { + SFREE(integerglob); + SFREE(doubleglob); + } - }else if(*nmethod!=0){ + return; + + } else if (*nmethod != 0) { /* linear static applications */ - if(*isolver==0){ + if (*isolver == 0) { #ifdef SPOOLES - spooles(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs,&symmetryflag, - &inputformat,&nzs[2]); + spooles(ad, au, adb, aub, &sigma, b, icol, irow, neq, nzs, &symmetryflag, + &inputformat, &nzs[2]); #else printf(" *ERROR in linstatic: the SPOOLES library is not linked\n\n"); - FORTRAN(stop,()); + FORTRAN(stop, ()); #endif - } - else if((*isolver==2)||(*isolver==3)){ - if(nasym>0){ - printf(" *ERROR in nonlingeo: the iterative solver cannot be used for asymmetric matrices\n\n"); - FORTRAN(stop,()); + } else if ((*isolver == 2) || (*isolver == 3)) { + if (nasym > 0) { + printf(" *ERROR in nonlingeo: the iterative solver cannot be used for asymmetric matrices\n\n"); + FORTRAN(stop, ()); } - preiter(ad,&au,b,&icol,&irow,neq,nzs,isolver,iperturb); - } - else if(*isolver==4){ + preiter(ad, &au, b, &icol, &irow, neq, nzs, isolver, iperturb); + } else if (*isolver == 4) { #ifdef SGI - if(nasym>0){ - printf(" *ERROR in nonlingeo: the SGI solver cannot be used for asymmetric matrices\n\n"); - FORTRAN(stop,()); + if (nasym > 0) { + printf(" *ERROR in nonlingeo: the SGI solver cannot be used for asymmetric matrices\n\n"); + FORTRAN(stop, ()); } - token=1; - sgi_main(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs,token); + token = 1; + sgi_main(ad, au, adb, aub, &sigma, b, icol, irow, neq, nzs, token); #else printf(" *ERROR in linstatic: the SGI library is not linked\n\n"); - FORTRAN(stop,()); + FORTRAN(stop, ()); #endif - } - else if(*isolver==5){ + } else if (*isolver == 5) { #ifdef TAUCS - if(nasym>0){ - printf(" *ERROR in nonlingeo: the TAUCS solver cannot be used for asymmetric matrices\n\n"); - FORTRAN(stop,()); + if (nasym > 0) { + printf(" *ERROR in nonlingeo: the TAUCS solver cannot be used for asymmetric matrices\n\n"); + FORTRAN(stop, ()); } - tau(ad,&au,adb,aub,&sigma,b,icol,&irow,neq,nzs); + tau(ad, &au, adb, aub, &sigma, b, icol, &irow, neq, nzs); #else printf(" *ERROR in linstatic: the TAUCS library is not linked\n\n"); - FORTRAN(stop,()); + FORTRAN(stop, ()); #endif - } - else if(*isolver==7){ + } else if (*isolver == 7) { #ifdef PARDISO - pardiso_main(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs, - &symmetryflag,&inputformat,jq,&nzs[2],&nrhs); + pardiso_main(ad, au, adb, aub, &sigma, b, icol, irow, neq, nzs, + &symmetryflag, &inputformat, jq, &nzs[2], &nrhs); #else printf(" *ERROR in linstatic: the PARDISO library is not linked\n\n"); - FORTRAN(stop,()); + FORTRAN(stop, ()); #endif - } - else if(*isolver==8){ + } else if (*isolver == 8) { #ifdef PASTIX - pastix_main(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs, - &symmetryflag,&inputformat,jq,&nzs[2],&nrhs); + pastix_main(ad, au, adb, aub, &sigma, b, icol, irow, neq, nzs, + &symmetryflag, &inputformat, jq, &nzs[2], &nrhs); #else printf(" *ERROR in linstatic: the PASTIX library is not linked\n\n"); - FORTRAN(stop,()); + FORTRAN(stop, ()); #endif } /* saving of ad and au for sensitivity analysis */ - for(i=0;i<*ntie;i++){ - if(strcmp1(&tieset[i*243+80],"D")==0){ - - strcpy2(stiffmatrix,jobnamec,132); - strcat(stiffmatrix,".stm"); - - if((f1=fopen(stiffmatrix,"wb"))==NULL){ - printf(" *ERROR in linstatic: cannot open stiffness matrix file for writing..."); - exit(0); - } - - /* storing the stiffness matrix */ - - /* nzs,irow,jq and icol have to be stored too, since the static analysis - can involve contact, whereas in the sensitivity analysis contact is not - taken into account while determining the structure of the stiffness - matrix (in mastruct.c) - */ - - if(fwrite(&nasym,sizeof(ITG),1,f1)!=1){ - printf(" *ERROR saving the symmetry flag to the stiffness matrix file..."); - exit(0); - } - if(fwrite(nzs,sizeof(ITG),3,f1)!=3){ - printf(" *ERROR saving the number of subdiagonal nonzeros to the stiffness matrix file..."); - exit(0); - } - if(fwrite(irow,sizeof(ITG),nzs[2],f1)!=nzs[2]){ - printf(" *ERROR saving irow to the stiffness matrix file..."); - exit(0); - } - if(fwrite(jq,sizeof(ITG),neq[1]+1,f1)!=neq[1]+1){ - printf(" *ERROR saving jq to the stiffness matrix file..."); - exit(0); - } - if(fwrite(icol,sizeof(ITG),neq[1],f1)!=neq[1]){ - printf(" *ERROR saving icol to the stiffness matrix file..."); - exit(0); - } - if(fwrite(ad,sizeof(double),neq[1],f1)!=neq[1]){ - printf(" *ERROR saving the diagonal of the stiffness matrix to the stiffness matrix file..."); - exit(0); - } - if(fwrite(au,sizeof(double),nzs[2],f1)!=nzs[2]){ - printf(" *ERROR saving the off-diagonal terms of the stiffness matrix to the tiffness matrix file..."); - exit(0); - } - fclose(f1); - - break; + for (i = 0; i < *ntie; i++) { + if (strcmp1(&tieset[i * 243 + 80], "D") == 0) { + + strcpy2(stiffmatrix, jobnamec, 132); + strcat(stiffmatrix, ".stm"); + + if ((f1 = fopen(stiffmatrix, "wb")) == NULL) { + printf(" *ERROR in linstatic: cannot open stiffness matrix file for writing..."); + exit(0); + } + + /* storing the stiffness matrix */ + + /* nzs,irow,jq and icol have to be stored too, since the static analysis + can involve contact, whereas in the sensitivity analysis contact is not + taken into account while determining the structure of the stiffness + matrix (in mastruct.c) + */ + + if (fwrite(&nasym, sizeof(ITG), 1, f1) != 1) { + printf(" *ERROR saving the symmetry flag to the stiffness matrix file..."); + exit(0); + } + if (fwrite(nzs, sizeof(ITG), 3, f1) != 3) { + printf(" *ERROR saving the number of subdiagonal nonzeros to the stiffness matrix file..."); + exit(0); + } + if (fwrite(irow, sizeof(ITG), nzs[2], f1) != nzs[2]) { + printf(" *ERROR saving irow to the stiffness matrix file..."); + exit(0); + } + if (fwrite(jq, sizeof(ITG), neq[1] + 1, f1) != neq[1] + 1) { + printf(" *ERROR saving jq to the stiffness matrix file..."); + exit(0); + } + if (fwrite(icol, sizeof(ITG), neq[1], f1) != neq[1]) { + printf(" *ERROR saving icol to the stiffness matrix file..."); + exit(0); + } + if (fwrite(ad, sizeof(double), neq[1], f1) != neq[1]) { + printf(" *ERROR saving the diagonal of the stiffness matrix to the stiffness matrix file..."); + exit(0); + } + if (fwrite(au, sizeof(double), nzs[2], f1) != nzs[2]) { + printf(" *ERROR saving the off-diagonal terms of the stiffness matrix to the tiffness matrix file..."); + exit(0); + } + fclose(f1); + + break; } } - - SFREE(ad);SFREE(au); - if(iglob<0){SFREE(adb);SFREE(aub);} + + SFREE(ad); + SFREE(au); + if (iglob < 0) { + SFREE(adb); + SFREE(aub); + } /* calculating the displacements and the stresses and storing */ /* the results in frd format for each valid eigenmode */ - NNEW(v,double,mt**nk); - NNEW(fn,double,mt**nk); - NNEW(stn,double,6**nk); - NNEW(inum,ITG,*nk); - NNEW(stx,double,6*mi[0]**ne); - - if(strcmp1(&filab[261],"E ")==0) NNEW(een,double,6**nk); - if(strcmp1(&filab[2697],"ME ")==0) NNEW(emn,double,6**nk); - if(strcmp1(&filab[522],"ENER")==0) NNEW(enern,double,*nk); - if(strcmp1(&filab[2175],"CONT")==0) NNEW(cdn,double,6**nk); - - NNEW(eei,double,6*mi[0]**ne); - if(*nener==1){ - NNEW(stiini,double,6*mi[0]**ne); - NNEW(emeini,double,6*mi[0]**ne); - NNEW(enerini,double,2*mi[0]**ne);} - - results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, - elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, - ielorien,norien,orab,ntmat_,t0,t1act,ithermal, - prestr,iprestr,filab,eme,emn,een,iperturb, - f,fn,nactdof,&iout,qa,vold,b,nodeboun,ndirboun,xbounact,nboun, - ipompc, - nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold,accold,&bet, - &gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, - xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas,&icmd, - ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern,emeini, - xstaten,eei,enerini,cocon,ncocon,set,nset,istartset,iendset, - ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans,fmpc, - nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea,&reltime, - &ne0,thicke,shcon,nshcon, - sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, - mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, - islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, - inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, - itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, - islavelinv,autloc,irowtloc,jqtloc,&nboun2, - ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, - labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, - &intscheme,physcon); + NNEW(v, double, mt **nk); + NNEW(fn, double, mt **nk); + NNEW(stn, double, 6 * *nk); + NNEW(inum, ITG, *nk); + NNEW(stx, double, 6 * mi[0] * *ne); + + if (strcmp1(&filab[261], "E ") == 0) + NNEW(een, double, 6 * *nk); + if (strcmp1(&filab[2697], "ME ") == 0) + NNEW(emn, double, 6 * *nk); + if (strcmp1(&filab[522], "ENER") == 0) + NNEW(enern, double, *nk); + if (strcmp1(&filab[2175], "CONT") == 0) + NNEW(cdn, double, 6 * *nk); + + NNEW(eei, double, 6 * mi[0] * *ne); + if (*nener == 1) { + NNEW(stiini, double, 6 * mi[0] * *ne); + NNEW(emeini, double, 6 * mi[0] * *ne); + NNEW(enerini, double, 2 * mi[0] * *ne); + } + + results(co, nk, kon, ipkon, lakon, ne, v, stn, inum, stx, + elcon, nelcon, rhcon, nrhcon, alcon, nalcon, alzero, ielmat, + ielorien, norien, orab, ntmat_, t0, t1act, ithermal, + prestr, iprestr, filab, eme, emn, een, iperturb, + f, fn, nactdof, &iout, qa, vold, b, nodeboun, ndirboun, xbounact, nboun, + ipompc, + nodempc, coefmpc, labmpc, nmpc, nmethod, cam, neq, veold, accold, &bet, + &gam, &dtime, &time, ttime, plicon, nplicon, plkcon, nplkcon, + xstateini, xstiff, xstate, npmat_, epn, matname, mi, &ielas, &icmd, + ncmat_, nstate_, stiini, vini, ikboun, ilboun, ener, enern, emeini, + xstaten, eei, enerini, cocon, ncocon, set, nset, istartset, iendset, + ialset, nprint, prlab, prset, qfx, qfn, trab, inotr, ntrans, fmpc, + nelemload, nload, ikmpc, ilmpc, istep, &iinc, springarea, &reltime, + &ne0, thicke, shcon, nshcon, + sideload, xloadact, xloadold, &icfd, inomat, pslavsurf, pmastsurf, + mortar, islavact, cdn, islavnode, nslavnode, ntie, clearini, + islavsurf, ielprop, prop, energyini, energy, &kscale, iponoel, + inoel, nener, orname, &network, ipobody, xbodyact, ibody, typeboun, + itiefac, tieset, smscale, &mscalmethod, nbody, t0g, t1g, + islavelinv, autloc, irowtloc, jqtloc, &nboun2, + ndirboun2, nodeboun2, xboun2, &nmpc2, ipompc2, nodempc2, coefmpc2, + labmpc2, ikboun2, ilboun2, ikmpc2, ilmpc2, &mortartrafoflag, + &intscheme, physcon); SFREE(eei); - if(*nener==1){ - SFREE(stiini);SFREE(emeini);SFREE(enerini);} + if (*nener == 1) { + SFREE(stiini); + SFREE(emeini); + SFREE(enerini); + } - memcpy(&vold[0],&v[0],sizeof(double)*mt**nk); - memcpy(&sti[0],&stx[0],sizeof(double)*6*mi[0]*ne0); + memcpy(&vold[0], &v[0], sizeof(double) * mt * *nk); + memcpy(&sti[0], &stx[0], sizeof(double) * 6 * mi[0] * ne0); ++*kode; /* for cyclic symmetric sectors: duplicating the results */ - if(*mcs>0){ - ptime=*ttime+time; - frdcyc(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod,kode,filab,een,t1act, - fn,&ptime,epn,ielmat,matname,cs,mcs,nkon,enern,xstaten, - nstate_,istep,&iinc,iperturb,ener,mi,output,ithermal, - qfn,ialset,istartset,iendset,trab,inotr,ntrans,orab, - ielorien,norien,sti,veold,&noddiam,set,nset,emn,thicke, - jobnamec,&ne0,cdn,mortar,nmat,qfx,ielprop,prop); - } - else{ - if(strcmp1(&filab[1044],"ZZS")==0){ - NNEW(neigh,ITG,40**ne); - NNEW(ipneigh,ITG,*nk); + if (*mcs > 0) { + ptime = *ttime + time; + frdcyc(co, nk, kon, ipkon, lakon, ne, v, stn, inum, nmethod, kode, filab, een, t1act, + fn, &ptime, epn, ielmat, matname, cs, mcs, nkon, enern, xstaten, + nstate_, istep, &iinc, iperturb, ener, mi, output, ithermal, + qfn, ialset, istartset, iendset, trab, inotr, ntrans, orab, + ielorien, norien, sti, veold, &noddiam, set, nset, emn, thicke, + jobnamec, &ne0, cdn, mortar, nmat, qfx, ielprop, prop); + } else { + if (strcmp1(&filab[1044], "ZZS") == 0) { + NNEW(neigh, ITG, 40 * *ne); + NNEW(ipneigh, ITG, *nk); + } + ptime = *ttime + time; + frd(co, nk, kon, ipkon, lakon, ne, v, stn, inum, nmethod, + kode, filab, een, t1act, fn, &ptime, epn, ielmat, matname, enern, xstaten, + nstate_, istep, &iinc, ithermal, qfn, &mode, &noddiam, trab, inotr, + ntrans, orab, ielorien, norien, description, ipneigh, neigh, + mi, stx, vr, vi, stnr, stni, vmax, stnmax, &ngraph, veold, ener, ne, + cs, set, nset, istartset, iendset, ialset, eenmax, fnr, fni, emn, + thicke, jobnamec, output, qfx, cdn, mortar, cdnr, cdni, nmat, ielprop, + prop, sti); + if (strcmp1(&filab[1044], "ZZS") == 0) { + SFREE(ipneigh); + SFREE(neigh); } - ptime=*ttime+time; - frd(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod, - kode,filab,een,t1act,fn,&ptime,epn,ielmat,matname,enern,xstaten, - nstate_,istep,&iinc,ithermal,qfn,&mode,&noddiam,trab,inotr, - ntrans,orab,ielorien,norien,description,ipneigh,neigh, - mi,stx,vr,vi,stnr,stni,vmax,stnmax,&ngraph,veold,ener,ne, - cs,set,nset,istartset,iendset,ialset,eenmax,fnr,fni,emn, - thicke,jobnamec,output,qfx,cdn,mortar,cdnr,cdni,nmat,ielprop, - prop,sti); - if(strcmp1(&filab[1044],"ZZS")==0){SFREE(ipneigh);SFREE(neigh);} } /* updating the .sta file */ - iitsta=1; - FORTRAN(writesta,(istep,&iinc,&icutb,&iitsta,ttime,&time,&dtime)); + iitsta = 1; + FORTRAN(writesta, (istep, &iinc, &icutb, &iitsta, ttime, &time, &dtime)); - SFREE(v);SFREE(stn);SFREE(inum); - SFREE(b);SFREE(stx);SFREE(fn); + SFREE(v); + SFREE(stn); + SFREE(inum); + SFREE(b); + SFREE(stx); + SFREE(fn); - if(strcmp1(&filab[261],"E ")==0) SFREE(een); - if(strcmp1(&filab[2697],"ME ")==0) SFREE(emn); - if(strcmp1(&filab[522],"ENER")==0) SFREE(enern); - if(strcmp1(&filab[2175],"CONT")==0) SFREE(cdn); + if (strcmp1(&filab[261], "E ") == 0) + SFREE(een); + if (strcmp1(&filab[2697], "ME ") == 0) + SFREE(emn); + if (strcmp1(&filab[522], "ENER") == 0) + SFREE(enern); + if (strcmp1(&filab[2175], "CONT") == 0) + SFREE(cdn); - } - else { + } else { /* error occurred in mafill: storing the geometry in frd format */ ++*kode; - NNEW(inum,ITG,*nk);for(k=0;k<*nk;k++) inum[k]=1; - if(strcmp1(&filab[1044],"ZZS")==0){ - NNEW(neigh,ITG,40**ne); - NNEW(ipneigh,ITG,*nk); + NNEW(inum, ITG, *nk); + for (k = 0; k < *nk; k++) + inum[k] = 1; + if (strcmp1(&filab[1044], "ZZS") == 0) { + NNEW(neigh, ITG, 40 * *ne); + NNEW(ipneigh, ITG, *nk); } - ptime=*ttime+time; - frd(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod, - kode,filab,een,t1,fn,&ptime,epn,ielmat,matname,enern,xstaten, - nstate_,istep,&iinc,ithermal,qfn,&mode,&noddiam,trab,inotr, - ntrans,orab,ielorien,norien,description,ipneigh,neigh, - mi,sti,vr,vi,stnr,stni,vmax,stnmax,&ngraph,veold,ener,ne, - cs,set,nset,istartset,iendset,ialset,eenmax,fnr,fni,emn, - thicke,jobnamec,output,qfx,cdn,mortar,cdnr,cdni,nmat,ielprop, - prop,sti); - if(strcmp1(&filab[1044],"ZZS")==0){SFREE(ipneigh);SFREE(neigh);} - SFREE(inum);FORTRAN(stop,()); - + ptime = *ttime + time; + frd(co, nk, kon, ipkon, lakon, ne, v, stn, inum, nmethod, + kode, filab, een, t1, fn, &ptime, epn, ielmat, matname, enern, xstaten, + nstate_, istep, &iinc, ithermal, qfn, &mode, &noddiam, trab, inotr, + ntrans, orab, ielorien, norien, description, ipneigh, neigh, + mi, sti, vr, vi, stnr, stni, vmax, stnmax, &ngraph, veold, ener, ne, + cs, set, nset, istartset, iendset, ialset, eenmax, fnr, fni, emn, + thicke, jobnamec, output, qfx, cdn, mortar, cdnr, cdni, nmat, ielprop, + prop, sti); + if (strcmp1(&filab[1044], "ZZS") == 0) { + SFREE(ipneigh); + SFREE(neigh); + } + SFREE(inum); + FORTRAN(stop, ()); } - if(*mortar>-2){ - if(ncont!=0){ - *ne=ne0; - if(*nener==1) RENEW(ener,double,2*mi[0]**ne); - RENEW(ipkon,ITG,*ne); - RENEW(lakon,char,8**ne); - RENEW(kon,ITG,*nkon); - if(*norien>0){ - RENEW(ielorien,ITG,mi[2]**ne); + if (*mortar > -2) { + if (ncont != 0) { + *ne = ne0; + if (*nener == 1) + RENEW(ener, double, 2 * mi[0] * *ne); + RENEW(ipkon, ITG, *ne); + RENEW(lakon, char, 8 * *ne); + RENEW(kon, ITG, *nkon); + if (*norien > 0) { + RENEW(ielorien, ITG, mi[2] * *ne); } - RENEW(ielmat,ITG,mi[2]**ne); - SFREE(cg);SFREE(straight); - SFREE(imastop);SFREE(itiefac);SFREE(islavnode);SFREE(islavsurf); - SFREE(nslavnode);SFREE(iponoels);SFREE(inoels);SFREE(imastnode); - SFREE(nmastnode);SFREE(itietri);SFREE(koncont);SFREE(xnoels); - SFREE(springarea);SFREE(xmastnor); - - if(*mortar==0){ - SFREE(areaslav); - }else if(*mortar==1){ - SFREE(pmastsurf);SFREE(ipe);SFREE(ime);SFREE(pslavsurf); - SFREE(islavact);SFREE(clearini); + RENEW(ielmat, ITG, mi[2] * *ne); + SFREE(cg); + SFREE(straight); + SFREE(imastop); + SFREE(itiefac); + SFREE(islavnode); + SFREE(islavsurf); + SFREE(nslavnode); + SFREE(iponoels); + SFREE(inoels); + SFREE(imastnode); + SFREE(nmastnode); + SFREE(itietri); + SFREE(koncont); + SFREE(xnoels); + SFREE(springarea); + SFREE(xmastnor); + + if (*mortar == 0) { + SFREE(areaslav); + } else if (*mortar == 1) { + SFREE(pmastsurf); + SFREE(ipe); + SFREE(ime); + SFREE(pslavsurf); + SFREE(islavact); + SFREE(clearini); } } - mpcinfo[0]=memmpc_;mpcinfo[1]=mpcfree;mpcinfo[2]=icascade; - mpcinfo[3]=maxlenmpc; + mpcinfo[0] = memmpc_; + mpcinfo[1] = mpcfree; + mpcinfo[2] = icascade; + mpcinfo[3] = maxlenmpc; } - /* updating the loading at the end of the step; + /* updating the loading at the end of the step; important in case the amplitude at the end of the step is not equal to one */ - for(k=0;k<*nboun;++k){xbounold[k]=xbounact[k];} - for(k=0;k<*nforc;++k){xforcold[k]=xforcact[k];} - for(k=0;k<2**nload;++k){xloadold[k]=xloadact[k];} - for(k=0;k<7**nbody;k=k+7){xbodyold[k]=xbodyact[k];} - if(*ithermal==1){ - for(k=0;k<*nk;++k){t1old[k]=t1act[k];} - for(k=0;k<*nk;++k){vold[mt*k]=t1act[k];} + for (k = 0; k < *nboun; ++k) { + xbounold[k] = xbounact[k]; + } + for (k = 0; k < *nforc; ++k) { + xforcold[k] = xforcact[k]; + } + for (k = 0; k < 2 * *nload; ++k) { + xloadold[k] = xloadact[k]; + } + for (k = 0; k < 7 * *nbody; k = k + 7) { + xbodyold[k] = xbodyact[k]; + } + if (*ithermal == 1) { + for (k = 0; k < *nk; ++k) { + t1old[k] = t1act[k]; + } + for (k = 0; k < *nk; ++k) { + vold[mt * k] = t1act[k]; + } } - SFREE(xbounact);SFREE(xforcact);SFREE(xloadact);SFREE(t1act);SFREE(ampli); + SFREE(xbounact); + SFREE(xforcact); + SFREE(xloadact); + SFREE(t1act); + SFREE(ampli); SFREE(xbodyact); // if(*nbody>0) SFREE(ipobody); SFREE(xstiff); - if(iglob!=0){SFREE(integerglob);SFREE(doubleglob);} + if (iglob != 0) { + SFREE(integerglob); + SFREE(doubleglob); + } + + *irowp = irow; + *enerp = ener; + *xstatep = xstate; + *ipkonp = ipkon; + *lakonp = lakon; + *konp = kon; + *ielmatp = ielmat; + *ielorienp = ielorien; + *icolp = icol; - *irowp=irow;*enerp=ener;*xstatep=xstate;*ipkonp=ipkon;*lakonp=lakon; - *konp=kon;*ielmatp=ielmat;*ielorienp=ielorien;*icolp=icol; + (*ttime) += (*tper); - (*ttime)+=(*tper); - return; } diff --git a/nonlingeo_precice.c b/nonlingeo_precice.c old mode 100755 new mode 100644 index ddc17471..cfb60fcd --- a/nonlingeo_precice.c +++ b/nonlingeo_precice.c @@ -48,10 +48,10 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l ITG *nmpc, ITG *nodeforc, ITG *ndirforc, double *xforc, ITG *nforc, ITG **nelemloadp, char **sideloadp, double *xload, ITG *nload, - ITG * nactdof, + ITG *nactdof, ITG **icolp, ITG *jq, ITG **irowp, ITG *neq, ITG *nzl, ITG *nmethod, ITG **ikmpcp, ITG **ilmpcp, ITG *ikboun, - ITG * ilboun, + ITG *ilboun, double *elcon, ITG *nelcon, double *rhcon, ITG *nrhcon, double *alcon, ITG *nalcon, double *alzero, ITG **ielmatp, ITG **ielorienp, ITG *norien, double *orab, ITG *ntmat_, @@ -67,12 +67,12 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l ITG *iamforc, ITG **iamloadp, ITG *iamt1, double *alpha, ITG *iexpl, ITG *iamboun, double *plicon, ITG *nplicon, double *plkcon, - ITG * nplkcon, + ITG *nplkcon, double **xstatep, ITG *npmat_, ITG *istep, double *ttime, char *matname, double *qaold, ITG *mi, ITG *isolver, ITG *ncmat_, ITG *nstate_, ITG *iumat, double *cs, ITG *mcs, ITG *nkon, double **enerp, ITG *mpcinfo, - char * output, + char *output, double *shcon, ITG *nshcon, double *cocon, ITG *ncocon, double *physcon, ITG *nflow, double *ctrl, char *set, ITG *nset, ITG *istartset, @@ -343,8 +343,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l .cocon = cocon, .ncocon = ncocon, .mi = mi, - .eei = &eei - }; + .eei = &eei}; if (*ithermal == 4) { uncoupled = 1; @@ -370,7 +369,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l } nslavs_prev_step = *nslavs; - /* turbulence model + /* turbulence model iturbulent==0: laminar iturbulent==1: k-epsilon iturbulent==2: q-omega @@ -669,7 +668,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l SFREE(nactdohinv); /* rearranging the fluid nodes and elements such that - no gaps occur */ + no gaps occur */ NNEW(ipkonf, ITG, *nef); NNEW(lakonf, char, 8 * *nef); @@ -848,7 +847,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l NNEW(clearini, double, 3 * 9 * *ifacecount); /* check whether at least one contact definition involves true contact - and not just tied contact */ + and not just tied contact */ FORTRAN(checktruecontact, (ntie, tieset, tietol, elcon, &itruecontact, ncmat_, ntmat_)); @@ -987,7 +986,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l } } - /* storing the element and topology information before introducing + /* storing the element and topology information before introducing contact elements */ ne0 = *ne; @@ -1034,8 +1033,8 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l dtime = 1.; /* updating the nonlinear mpc's (also affects the boundary - conditions through the nonhomogeneous part of the mpc's) - if contact arises the number of MPC's can also change */ + conditions through the nonhomogeneous part of the mpc's) + if contact arises the number of MPC's can also change */ cam[0] = 0.; cam[1] = 0.; @@ -1143,15 +1142,15 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l mscalmethod = 0; /* Explicit: Calculation of stable time increment according to - Courant's Law Carlo Monjaraz Tec (CMT) and Selctive Mass Scaling CC*/ + Courant's Law Carlo Monjaraz Tec (CMT) and Selctive Mass Scaling CC*/ /*Mass Scaling - mscalmethod < 0: no explicit dynamics - mscalmethod = 0: no mass scaling - mscalmethod = 1: selective mass scaling for nonlinearity after - Olovsson et. al 2005 + mscalmethod < 0: no explicit dynamics + mscalmethod = 0: no mass scaling + mscalmethod = 1: selective mass scaling for nonlinearity after + Olovsson et. al 2005 - mscalmethod=2 and mscalmethod=3 correspond to 0 and 1, + mscalmethod=2 and mscalmethod=3 correspond to 0 and 1, respectively with in addition contact scaling active; contact scaling is activated if the user time increment cannot be satisfied */ @@ -1165,9 +1164,9 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l lakon, wavespeed, nmat, ipkon, co, kon, &dtvol, alpha, smscale, &dtset, &mscalmethod)); - //printf("\033[1;33m"); // yellow + // printf("\033[1;33m"); // yellow printf("Explicit time integration: Volumetric COURANT initial stable time increment:%e\n\n", dtvol); - //printf("\033[0m"); // reset color + // printf("\033[0m"); // reset color if (dtvol > (*tmax * (*tper))) { *tinc = *tmax * (*tper); @@ -1179,19 +1178,19 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l dtheta = (*tinc) / (*tper); dthetaref = dtheta; - //printf("\033[1;33m"); // yellow + // printf("\033[1;33m"); // yellow printf("SELECTED time increment:%e\n\n", *tinc); - //printf("\033[0m"); // reset color + // printf("\033[0m"); // reset color } /* in mafillsm the stiffness and mass matrix are computed; - The primary aim is to calculate the mass matrix (not + The primary aim is to calculate the mass matrix (not lumped for an implicit dynamic calculation, lumped for an explicit dynamic calculation). However: - for an implicit calculation the mass matrix is "doped" with a small amount of stiffness matrix, therefore the calculation of the stiffness matrix is needed. - - for an explicit calculation the stiffness matrix is not + - for an explicit calculation the stiffness matrix is not needed at all. Since the calculation of the mass matrix alone is not possible in mafillsm, the determination of the stiffness matrix is taken as unavoidable "ballast". */ @@ -1344,9 +1343,9 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l #endif } - } //endif massless + } // endif massless - /* mass x acceleration = f(external)-f(internal) + /* mass x acceleration = f(external)-f(internal) only for the mechanical loading*/ /* not needed for massless contact */ @@ -1360,8 +1359,8 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l if (*iexpl <= 1) { /* a small amount of stiffness is added to the mass matrix - otherwise the system leads to huge accelerations in - case of discontinuous load changes at the start of the step */ + otherwise the system leads to huge accelerations in + case of discontinuous load changes at the start of the step */ dtime = *tinc / 10.; scal1 = bet * dtime * dtime * (1. + alpha[0]); @@ -1502,8 +1501,8 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l MNEW(fn, double, mt **nk); /* setting a "special" time consisting of the first primes; - used to recognize the initial acceleration procedure - in file resultsini.f */ + used to recognize the initial acceleration procedure + in file resultsini.f */ if (ne1d2d == 1) NNEW(inum, ITG, *nk); @@ -1561,8 +1560,8 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l // # # # # # # # # # # # # # # # # # # # # # # # # # # # # # // MPADD start - /* lumping of the mass matrix for implicit calculations to - modify the increment time when contact is involved + /* lumping of the mass matrix for implicit calculations to + modify the increment time when contact is involved */ NNEW(tmp, double, neq[1]); @@ -1589,9 +1588,9 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l /* starting the loop over the increments */ /**************************************************************/ - //printf("\033[0;34m"); // blue - //printf("Starting the loop over the increments\n"); - //printf("\033[0m"); // reset color + // printf("\033[0;34m"); // blue + // printf("Starting the loop over the increments\n"); + // printf("\033[0m"); // reset color newstep = 1; @@ -1646,7 +1645,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l jprint++; /* store number of elements (important for implicit dynamic - contact */ + contact */ neini = *ne; @@ -1826,8 +1825,8 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l &dampwkini, energystartstep); /* the divergence is flagged by icntrl!=0 - icutb is reset to zero in order to generate - regular contact elements etc.. */ + icutb is reset to zero in order to generate + regular contact elements etc.. */ icutb--; } @@ -1877,17 +1876,17 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l if ((ncont != 0) && (*mortar <= 1) && /* for purely thermal calculations: determine contact integration - points only at the start of a step */ + points only at the start of a step */ ((*ithermal != 2) || (iit == -1))) { *ne = ne0; *nkon = nkon0; - /* at start of new increment: - - copy state variables (node-to-face) - - determine slave integration points (face-to-face) - - interpolate state variables (face-to-face) */ + /* at start of new increment: + - copy state variables (node-to-face) + - determine slave integration points (face-to-face) + - interpolate state variables (face-to-face) */ if (icutb == 0) { if (*mortar == 1) { @@ -1908,7 +1907,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l *nintpoint = 0; /* determine the location of the slave integration - points */ + points */ precontact(&ncont, ntie, tieset, nset, set, istartset, iendset, ialset, itietri, lakon, ipkon, kon, koncont, ne, @@ -2004,8 +2003,8 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l xstateini, xstate, nstate_, &icutb, &ialeatoric, jobnamef, &alea, auw, jqw, iroww, &nzsw); - /* check whether, for a dynamic calculation, contact damping - is involved */ + /* check whether, for a dynamic calculation, contact damping + is involved */ if (*nmethod == 4) { if (*iexpl <= 1) { @@ -2034,8 +2033,8 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l /* carlo start */ - /* dynamic time step estimation for explicit dynamics under penalty - contact(CMT) start */ + /* dynamic time step estimation for explicit dynamics under penalty + contact(CMT) start */ if ((*iexpl > 1)) { @@ -2091,7 +2090,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l } /* updating the nonlinear mpc's (also affects the boundary - conditions through the nonhomogeneous part of the mpc's) */ + conditions through the nonhomogeneous part of the mpc's) */ FORTRAN(nonlinmpc, (co, vold, ipompc, nodempc, coefmpc, labmpc, nmpc, ikboun, ilboun, nboun, xbounact, aux, iaux, @@ -2169,29 +2168,29 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l NNEW(stx, double, 6 * mi[0] * *ne); /* determining the internal forces at the start of the increment - + for a static calculation with increased forced displacements the linear strains are calculated corresponding to - + the displacements at the end of the previous increment, extrapolated if appropriate (for nondispersive media) + the forced displacements at the end of the present increment + the temperatures at the end of the present increment (this sum is v) - the displacements at the end of the previous increment (this is vold) - + these linear strains are converted in stresses by multiplication with the tangent element stiffness matrix and converted into nodal - forces. - + forces. + this boils down to the fact that the effect of forced displacements should be handled in a purely linear way at the start of a new increment, in order to speed up the convergence and (for dissipative media) guarantee smooth loading within the increment. - + for all other cases the nodal force calculation is based on the true stresses derived from the appropriate strain tensor taking - into account the extrapolated displacements at the end of the + into account the extrapolated displacements at the end of the previous increment + the forced displacements and the temperatures at the end of the present increment */ @@ -2242,7 +2241,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l SFREE(inum); /* check whether any displacements or temperatures are changed - in the new increment */ + in the new increment */ for (k = 0; k < neq[1]; ++k) { f[k] = f[k] + b[k]; @@ -2332,14 +2331,14 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l #endif /* updating the nonlinear mpc's (also affects the boundary - conditions through the nonhomogeneous part of the mpc's) */ + conditions through the nonhomogeneous part of the mpc's) */ if ((iit != 1) || ((uncoupled) && (*ithermal == 1))) { printf(" iteration %" ITGFORMAT "\n\n", iit); /* restoring the distributed loading before adding the - friction heating */ + friction heating */ if ((*ithermal == 3) && (ncont != 0) && (*mortar == 1) && (*ncmat_ >= 11)) { *nload = nloadref; @@ -2423,10 +2422,10 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l if ((ncont != 0) && (*mortar <= 1) && (ismallsliding == 0) && /* for node-to-face contact: freeze contact elements for - iterations 8 and higher */ + iterations 8 and higher */ ((iit <= 8) || (*mortar == 1)) && /* for purely thermal calculations: freeze contact elements - during complete step */ + during complete step */ ((*ithermal != 2) || (iit == -1))) { neold = *ne; @@ -2444,8 +2443,8 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l clearini, &theta, xstateini, xstate, nstate_, &icutb, &ialeatoric, jobnamef, &alea, auw, jqw, iroww, &nzsw); - /* check whether, for a dynamic calculation, contact damping is - involved */ + /* check whether, for a dynamic calculation, contact damping is + involved */ if (*nmethod == 4) { if (*iexpl <= 1) { @@ -2506,7 +2505,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l /* recalculating the matrix structure */ /* for face-to-face contact (mortar=1) this is only done if - the dependent term in nonlinear MPC's changed */ + the dependent term in nonlinear MPC's changed */ if ((icascade > 0) || (ncont != 0)) { if ((*mortar != 1) || (kchdep == 1)) { @@ -2676,9 +2675,9 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l } else { - /* calculating the external loading + /* calculating the external loading - This is only done once per increment. In reality, the + This is only done once per increment. In reality, the external loading is a function of vold (specifically, the body forces and surface loading). This effect is neglected, since the increment size in dynamic explicit @@ -2700,9 +2699,9 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l } /* for(k=0;k 1) { /* restoring the structure of the original stiffness - matrix */ + matrix */ for (i = 0; i < 3; i++) { nzs[i] = nzstemp[i]; @@ -3539,7 +3538,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l } /* next line is inserted to cope with stress-less - temperature calculations */ + temperature calculations */ if (*ithermal != 2) { if (ram[0] < 1.e-6) { @@ -3547,11 +3546,11 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l } printf(" average force= %f\n", qa[0]); printf(" time avg. forc= %f\n", qam[0]); - if ((ITG)((double) nactdofinv[(ITG) ram[2]] / mt) + 1 == 0) { + if ((ITG) ((double) nactdofinv[(ITG) ram[2]] / mt) + 1 == 0) { printf(" largest residual force= %f\n", ram[0]); } else { - inode = (ITG)((double) nactdofinv[(ITG) ram[2]] / mt) + 1; + inode = (ITG) ((double) nactdofinv[(ITG) ram[2]] / mt) + 1; idir = nactdofinv[(ITG) ram[2]] - mt * (inode - 1); printf(" largest residual force= %f in node %" ITGFORMAT " and dof %" ITGFORMAT "\n", @@ -3562,7 +3561,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l printf(" largest correction to disp= %e\n\n", cam[0]); } else { - inode = (ITG)((double) nactdofinv[(ITG) cam[3]] / mt) + 1; + inode = (ITG) ((double) nactdofinv[(ITG) cam[3]] / mt) + 1; idir = nactdofinv[(ITG) cam[3]] - mt * (inode - 1); printf(" largest correction to disp= %e in node %" ITGFORMAT " and dof %" ITGFORMAT "\n\n", @@ -3575,11 +3574,11 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l } printf(" average flux= %f\n", qa[1]); printf(" time avg. flux= %f\n", qam[1]); - if ((ITG)((double) nactdofinv[(ITG) ram[3]] / mt) + 1 == 0) { + if ((ITG) ((double) nactdofinv[(ITG) ram[3]] / mt) + 1 == 0) { printf(" largest residual flux= %f\n", ram[1]); } else { - inode = (ITG)((double) nactdofinv[(ITG) ram[3]] / mt) + 1; + inode = (ITG) ((double) nactdofinv[(ITG) ram[3]] / mt) + 1; idir = nactdofinv[(ITG) ram[3]] - mt * (inode - 1); printf(" largest residual flux= %f in node %" ITGFORMAT " and dof %" ITGFORMAT "\n", @@ -3590,7 +3589,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l printf(" largest correction to temp= %e\n\n", cam[1]); } else { - inode = (ITG)((double) nactdofinv[(ITG) cam[4]] / mt) + 1; + inode = (ITG) ((double) nactdofinv[(ITG) cam[4]] / mt) + 1; idir = nactdofinv[(ITG) cam[4]] - mt * (inode - 1); printf(" largest correction to temp= %e in node %" ITGFORMAT " and dof %" ITGFORMAT "\n\n", @@ -4053,7 +4052,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l if (jprint != 0) { - /* calculating the displacements and the stresses and storing + /* calculating the displacements and the stresses and storing the results in frd format */ MNEW(v, double, mt **nk); @@ -4277,7 +4276,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l } } - /* updating the loading at the end of the step; + /* updating the loading at the end of the step; important in case the amplitude at the end of the step is not equal to one */ @@ -4291,8 +4290,8 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l continue; /* mechanical boundary conditions are updated only - if the step was not thermal or the node is a - network node */ + if the step was not thermal or the node is a + network node */ } else if ((ndirboun[k] > 0) && (ndirboun[k] < 4)) { node = nodeboun[k]; From fcf72c94e2f26bc1f40ee8b1ef776703eeea5986 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Wed, 7 Aug 2024 13:05:49 +0200 Subject: [PATCH 12/55] Put old things back into CCXHelpers.c --- adapter/CCXHelpers.c | 48 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/adapter/CCXHelpers.c b/adapter/CCXHelpers.c index bc58fe42..99f3d874 100644 --- a/adapter/CCXHelpers.c +++ b/adapter/CCXHelpers.c @@ -86,7 +86,7 @@ void getNodeCoordinates(ITG *nodes, ITG numNodes, int dim, double *co, double *v for (i = 0; i < numNodes; i++) { int nodeIdx = nodes[i] - 1; - //The displacements are added to the coordinates such that in case of a simulation restart the displaced coordinates are used for initializing the coupling interface instead of the initial coordinates + // The displacements are added to the coordinates such that in case of a simulation restart the displaced coordinates are used for initializing the coupling interface instead of the initial coordinates for (j = 0; j < dim; j++) { coordinates[i * dim + j] = co[nodeIdx * 3 + j] + v[nodeIdx * mt + j + 1]; } @@ -147,7 +147,7 @@ void getNodeDisplacements(ITG *nodes, ITG numNodes, int dim, double *v, ITG mt, ITG i, j; for (i = 0; i < numNodes; i++) { - int nodeIdx = nodes[i] - 1; //The node Id starts with 1, not with 0, therefore, decrement is necessary + int nodeIdx = nodes[i] - 1; // The node Id starts with 1, not with 0, therefore, decrement is necessary for (j = 0; j < dim; j++) { displacements[dim * i + j] = v[nodeIdx * mt + j + 1]; } @@ -162,7 +162,7 @@ void getNodeDisplacementDeltas(ITG *nodes, ITG numNodes, int dim, double *v, dou ITG i, j; for (i = 0; i < numNodes; i++) { - int nodeIdx = nodes[i] - 1; //The node Id starts with 1, not with 0, therefore, decrement is necessary + int nodeIdx = nodes[i] - 1; // The node Id starts with 1, not with 0, therefore, decrement is necessary for (j = 0; j < dim; j++) { displacementDeltas[dim * i + j] = v[nodeIdx * mt + j + 1] - v_init[nodeIdx * mt + j + 1]; } @@ -177,7 +177,7 @@ void getNodeVelocities(ITG *nodes, ITG numNodes, int dim, double *ve, ITG mt, do ITG i, j; for (i = 0; i < numNodes; i++) { - int nodeIdx = nodes[i] - 1; //The node Id starts with 1, not with 0, therefore, decrement is necessary + int nodeIdx = nodes[i] - 1; // The node Id starts with 1, not with 0, therefore, decrement is necessary for (j = 0; j < dim; j++) { velocities[dim * i + j] = ve[nodeIdx * mt + j + 1]; } @@ -185,16 +185,14 @@ void getNodeVelocities(ITG *nodes, ITG numNodes, int dim, double *ve, ITG mt, do } /* - int getNodesPerFace(char * lakon, int elementIdx) { - - int nodesPerFace; + int getNodesPerFace(char * lakon, int elementIdx) { + int nodesPerFace; if(strcmp1(&lakon[elementIdx * 8], "C3D4") == 0) { nodesPerFace = 3; } else if(strcmp1(&lakon[elementIdx * 8], "C3D10") == 0) { nodesPerFace = 6; } return nodesPerFace; - } */ @@ -232,6 +230,40 @@ void getTetraFaceCenters(ITG *elements, ITG *faces, ITG numElements, ITG *kon, I } } +void getHexaFaceCenters(ITG *elements, ITG *faces, ITG numElements, ITG *kon, ITG *ipkon, double *co, double *faceCenters) +{ + + // Assume all hexa elements -- maybe implement checking later... + + // Node numbering for faces of hexahedral elements (in the documentation the number is + 1) + // Numbering is the same for first and second order elements + int faceNodes[6][4] = {{0, 1, 2, 3}, {4, 7, 6, 5}, {0, 4, 5, 1}, {1, 5, 6, 2}, {2, 6, 7, 3}, {3, 7, 4, 0}}; + + ITG i, j; + + for (i = 0; i < numElements; i++) { + + ITG faceIdx = faces[i] - 1; + ITG elementIdx = elements[i] - 1; + double x = 0, y = 0, z = 0; + + for (j = 0; j < 4; j++) { + + ITG nodeNum = faceNodes[faceIdx][j]; + ITG nodeID = kon[ipkon[elementIdx] + nodeNum]; + ITG nodeIdx = (nodeID - 1) * 3; + // The nodeIdx is already multiplied by 3, therefore it must be divided by 3 ONLY when checking if coordinates match getNodeCoordinates + + x += co[nodeIdx + 0]; + y += co[nodeIdx + 1]; + z += co[nodeIdx + 2]; + } + faceCenters[i * 3 + 0] = x / 4; + faceCenters[i * 3 + 1] = y / 4; + faceCenters[i * 3 + 2] = z / 4; + } +} + /* void getSurfaceGaussPoints(int setID, ITG * co, ITG istartset, ITG iendset, ITG * ipkon, ITG * lakon, ITG * kon, ITG * ialset, double * coords) { From b93231307c1d842b7efe788be2aee2a8072256ad Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Wed, 7 Aug 2024 16:24:05 +0200 Subject: [PATCH 13/55] Compile with nonlingeo_precice.c and formatting --- Makefile | 8 +- linstatic_precice.c | 1557 ++++++++++++++++++++----------------------- 2 files changed, 729 insertions(+), 836 deletions(-) diff --git a/Makefile b/Makefile index 5cefa32c..cc124848 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # Set the following variables before building: # Path to original CalculiX source (e.g. $(HOME)/ccx_2.xx/src ) CCX_VERSION = 2.20 -CCX = $(CCX_ROOT)/ccx_$(CCX_VERSION) +CCX = $(HOME)/CalculiX/ccx_$(CCX_VERSION)/src CCX_FLAGS = -DPARDISO -DMATRIXSTORAGE -DUSE_MT ### Change these if you built SPOOLES, ARPACK, or yaml-cpp from source ### @@ -85,12 +85,10 @@ include $(CCX)/Makefile.inc SCCXMAIN = ccx_$(CCX_VERSION).c # Append additional sources -# SCCXC += nonlingeo_precice.c linstatic_precice.c dyna_precice.c CCXHelpers.c PreciceInterface.c -SCCXC += linstatic_precice.c CCXHelpers.c PreciceInterface.c +SCCXC += nonlingeo_precice.c linstatic_precice.c dyna_precice.c CCXHelpers.c PreciceInterface.c +# SCCXC += linstatic_precice.c CCXHelpers.c PreciceInterface.c SCCXF += getflux.f getkdeltatemp.f multiscale_routines.f - - # Source files in this folder and in the adapter directory $(OBJDIR)/%.o : %.c $(CC) $(CFLAGS) -c $< -o $@ diff --git a/linstatic_precice.c b/linstatic_precice.c index 27520f45..301134ce 100644 --- a/linstatic_precice.c +++ b/linstatic_precice.c @@ -7,7 +7,7 @@ /* */ /* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /* GNU General Public License for more details. */ @@ -15,8 +15,8 @@ /* along with this program; if not, write to the Free Software */ /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include #include +#include #include #include "CalculiX.h" #ifdef SPOOLES @@ -38,113 +38,105 @@ /* Adapter: Add header */ #include "adapter/PreciceInterface.h" -void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lakonp, - ITG *ne, - ITG *nodeboun, ITG *ndirboun, double *xboun, ITG *nboun, - ITG *ipompc, ITG *nodempc, double *coefmpc, char *labmpc, - ITG *nmpc, - ITG *nodeforc, ITG *ndirforc, double *xforc, ITG *nforc, - ITG *nelemload, char *sideload, double *xload, - ITG *nload, ITG *nactdof, - ITG **icolp, ITG *jq, ITG **irowp, ITG *neq, ITG *nzl, - ITG *nmethod, ITG *ikmpc, ITG *ilmpc, ITG *ikboun, - ITG *ilboun, - double *elcon, ITG *nelcon, double *rhcon, ITG *nrhcon, - double *alcon, ITG *nalcon, double *alzero, ITG **ielmatp, - ITG **ielorienp, ITG *norien, double *orab, ITG *ntmat_, - double *t0, double *t1, double *t1old, - ITG *ithermal, double *prestr, ITG *iprestr, - double *vold, ITG *iperturb, double *sti, ITG *nzs, - ITG *kode, char *filab, double *eme, - ITG *iexpl, double *plicon, ITG *nplicon, double *plkcon, - ITG *nplkcon, - double **xstatep, ITG *npmat_, char *matname, ITG *isolver, - ITG *mi, ITG *ncmat_, ITG *nstate_, double *cs, ITG *mcs, - ITG *nkon, double **enerp, double *xbounold, - double *xforcold, double *xloadold, - char *amname, double *amta, ITG *namta, - ITG *nam, ITG *iamforc, ITG *iamload, - ITG *iamt1, ITG *iamboun, double *ttime, char *output, - char *set, ITG *nset, ITG *istartset, - ITG *iendset, ITG *ialset, ITG *nprint, char *prlab, - char *prset, ITG *nener, double *trab, - ITG *inotr, ITG *ntrans, double *fmpc, ITG *ipobody, ITG *ibody, - double *xbody, ITG *nbody, double *xbodyold, double *timepar, - double *thicke, char *jobnamec, char *tieset, ITG *ntie, - ITG *istep, ITG *nmat, ITG *ielprop, double *prop, char *typeboun, - ITG *mortar, ITG *mpcinfo, double *tietol, ITG *ics, - char *orname, ITG *itempuser, double *t0g, double *t1g, - ITG *jmax, - /* Adapter: Add variables for the participant name and the config file */ - char *preciceParticipantName, char *configFilename) -{ - - char description[13] = " ", *lakon = NULL, stiffmatrix[132] = "", - fneig[132] = "", jobnamef[396] = "", *labmpc2 = NULL; - - ITG *inum = NULL, k, *icol = NULL, *irow = NULL, ielas = 0, icmd = 0, iinc = 1, nasym = 0, i, j, ic, ir, - mass[2] = {0, 0}, stiffness = 1, buckling = 0, rhsi = 1, intscheme = 0, *ncocon = NULL, - *nshcon = NULL, mode = -1, noddiam = -1, coriolis = 0, iout, - *itg = NULL, ntg = 0, symmetryflag = 0, inputformat = 0, ngraph = 1, im, - mt = mi[1] + 1, ne0, *integerglob = NULL, iglob = 0, *ipneigh = NULL, *neigh = NULL, - icfd = 0, *inomat = NULL, *islavact = NULL, *islavnode = NULL, *nslavnode = NULL, - *islavsurf = NULL, nretain, *iretain = NULL, *noderetain = NULL, *ndirretain = NULL, - nmethodl, nintpoint, ifacecount, memmpc_, mpcfree, icascade, maxlenmpc, - ncont = 0, *itietri = NULL, *koncont = NULL, nslavs = 0, ismallsliding = 0, - *itiefac = NULL, *imastnode = NULL, *nmastnode = NULL, *imastop = NULL, iitsta, - *iponoels = NULL, *inoels = NULL, *ipe = NULL, *ime = NULL, iit = -1, iflagact = 0, - icutb = 0, *kon = NULL, *ipkon = NULL, *ielmat = NULL, ialeatoric = 0, kscale = 1, - *iponoel = NULL, *inoel = NULL, zero = 0, nherm = 1, nev = *nforc, node, idir, - *ielorien = NULL, network = 0, nrhs = 1, iperturbsav, mscalmethod = 0, *jqw = NULL, - *iroww = NULL, nzsw, *islavelinv = NULL, *irowtloc = NULL, *jqtloc = NULL, nboun2, - *ndirboun2 = NULL, *nodeboun2 = NULL, nmpc2, *ipompc2 = NULL, *nodempc2 = NULL, - *ikboun2 = NULL, *ilboun2 = NULL, *ikmpc2 = NULL, *ilmpc2 = NULL, mortartrafoflag = 0; - - double *stn = NULL, *v = NULL, *een = NULL, cam[5], *xstiff = NULL, *stiini = NULL, *tper, - *f = NULL, *fn = NULL, qa[4], *fext = NULL, *epn = NULL, *xstateini = NULL, - *vini = NULL, *stx = NULL, *enern = NULL, *xbounact = NULL, *xforcact = NULL, - *xloadact = NULL, *t1act = NULL, *ampli = NULL, *xstaten = NULL, *eei = NULL, - *enerini = NULL, *cocon = NULL, *shcon = NULL, *physcon = NULL, *qfx = NULL, - *qfn = NULL, sigma = 0., *cgr = NULL, *xbodyact = NULL, *vr = NULL, *vi = NULL, - *stnr = NULL, *stni = NULL, *vmax = NULL, *stnmax = NULL, *springarea = NULL, - *eenmax = NULL, *fnr = NULL, *fni = NULL, *emn = NULL, *clearini = NULL, ptime, - *emeini = NULL, *doubleglob = NULL, *au = NULL, *ad = NULL, *b = NULL, *aub = NULL, - *adb = NULL, *pslavsurf = NULL, *pmastsurf = NULL, *cdn = NULL, *cdnr = NULL, - *cdni = NULL, *submatrix = NULL, *xnoels = NULL, *cg = NULL, *straight = NULL, - *areaslav = NULL, *xmastnor = NULL, theta = 0., *ener = NULL, *xstate = NULL, - *fnext = NULL, *energyini = NULL, *energy = NULL, *d = NULL, alea = 0.1, *smscale = NULL, - *auw = NULL, *autloc = NULL, *xboun2 = NULL, *coefmpc2 = NULL; - - FILE *f1, *f2; - +void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, + ITG *ne, + ITG *nodeboun,ITG *ndirboun,double *xboun,ITG *nboun, + ITG *ipompc,ITG *nodempc,double *coefmpc,char *labmpc, + ITG *nmpc, + ITG *nodeforc,ITG *ndirforc,double *xforc,ITG *nforc, + ITG *nelemload,char *sideload,double *xload, + ITG *nload,ITG *nactdof, + ITG **icolp,ITG *jq,ITG **irowp,ITG *neq,ITG *nzl, + ITG *nmethod,ITG *ikmpc,ITG *ilmpc,ITG *ikboun, + ITG *ilboun, + double *elcon,ITG *nelcon,double *rhcon,ITG *nrhcon, + double *alcon,ITG *nalcon,double *alzero,ITG **ielmatp, + ITG **ielorienp,ITG *norien,double *orab,ITG *ntmat_, + double *t0,double *t1,double *t1old, + ITG *ithermal,double *prestr,ITG *iprestr, + double *vold,ITG *iperturb,double *sti,ITG *nzs, + ITG *kode,char *filab,double *eme, + ITG *iexpl,double *plicon,ITG *nplicon,double *plkcon, + ITG *nplkcon, + double **xstatep,ITG *npmat_,char *matname,ITG *isolver, + ITG *mi,ITG *ncmat_,ITG *nstate_,double *cs,ITG *mcs, + ITG *nkon,double **enerp,double *xbounold, + double *xforcold,double *xloadold, + char *amname,double *amta,ITG *namta, + ITG *nam,ITG *iamforc,ITG *iamload, + ITG *iamt1,ITG *iamboun,double *ttime,char *output, + char *set,ITG *nset,ITG *istartset, + ITG *iendset,ITG *ialset,ITG *nprint,char *prlab, + char *prset,ITG *nener,double *trab, + ITG *inotr,ITG *ntrans,double *fmpc,ITG *ipobody,ITG *ibody, + double *xbody,ITG *nbody,double *xbodyold,double *timepar, + double *thicke,char *jobnamec,char *tieset,ITG *ntie, + ITG *istep,ITG *nmat,ITG *ielprop,double *prop,char *typeboun, + ITG *mortar,ITG *mpcinfo,double *tietol,ITG *ics, + char *orname,ITG *itempuser,double *t0g,double *t1g, + ITG *jmax, + /* Adapter: Add variables for the participant name and the config file */ + char *preciceParticipantName, char *configFilename){ + + char description[13]=" ",*lakon=NULL,stiffmatrix[132]="", + fneig[132]="",jobnamef[396]="",*labmpc2=NULL; + + ITG *inum=NULL,k,*icol=NULL,*irow=NULL,ielas=0,icmd=0,iinc=1,nasym=0,i,j,ic,ir, + mass[2]={0,0},stiffness=1,buckling=0,rhsi=1,intscheme=0,*ncocon=NULL, + *nshcon=NULL,mode=-1,noddiam=-1,coriolis=0,iout, + *itg=NULL,ntg=0,symmetryflag=0,inputformat=0,ngraph=1,im, + mt=mi[1]+1,ne0,*integerglob=NULL,iglob=0,*ipneigh=NULL,*neigh=NULL, + icfd=0,*inomat=NULL,*islavact=NULL,*islavnode=NULL,*nslavnode=NULL, + *islavsurf=NULL,nretain,*iretain=NULL,*noderetain=NULL,*ndirretain=NULL, + nmethodl,nintpoint,ifacecount,memmpc_,mpcfree,icascade,maxlenmpc, + ncont=0,*itietri=NULL,*koncont=NULL,nslavs=0,ismallsliding=0, + *itiefac=NULL,*imastnode=NULL,*nmastnode=NULL,*imastop=NULL,iitsta, + *iponoels=NULL,*inoels=NULL,*ipe=NULL,*ime=NULL,iit=-1,iflagact=0, + icutb=0,*kon=NULL,*ipkon=NULL,*ielmat=NULL,ialeatoric=0,kscale=1, + *iponoel=NULL,*inoel=NULL,zero=0,nherm=1,nev=*nforc,node,idir, + *ielorien=NULL,network=0,nrhs=1,iperturbsav,mscalmethod=0,*jqw=NULL, + *iroww=NULL,nzsw,*islavelinv=NULL,*irowtloc=NULL,*jqtloc=NULL,nboun2, + *ndirboun2=NULL,*nodeboun2=NULL,nmpc2,*ipompc2=NULL,*nodempc2=NULL, + *ikboun2=NULL,*ilboun2=NULL,*ikmpc2=NULL,*ilmpc2=NULL,mortartrafoflag=0; + + double *stn=NULL,*v=NULL,*een=NULL,cam[5],*xstiff=NULL,*stiini=NULL,*tper, + *f=NULL,*fn=NULL,qa[4],*fext=NULL,*epn=NULL,*xstateini=NULL, + *vini=NULL,*stx=NULL,*enern=NULL,*xbounact=NULL,*xforcact=NULL, + *xloadact=NULL,*t1act=NULL,*ampli=NULL,*xstaten=NULL,*eei=NULL, + *enerini=NULL,*cocon=NULL,*shcon=NULL,*physcon=NULL,*qfx=NULL, + *qfn=NULL,sigma=0.,*cgr=NULL,*xbodyact=NULL,*vr=NULL,*vi=NULL, + *stnr=NULL,*stni=NULL,*vmax=NULL,*stnmax=NULL,*springarea=NULL, + *eenmax=NULL,*fnr=NULL,*fni=NULL,*emn=NULL,*clearini=NULL,ptime, + *emeini=NULL,*doubleglob=NULL,*au=NULL,*ad=NULL,*b=NULL,*aub=NULL, + *adb=NULL,*pslavsurf=NULL,*pmastsurf=NULL,*cdn=NULL,*cdnr=NULL, + *cdni=NULL,*submatrix=NULL,*xnoels=NULL,*cg=NULL,*straight=NULL, + *areaslav=NULL,*xmastnor=NULL,theta=0.,*ener=NULL,*xstate=NULL, + *fnext=NULL,*energyini=NULL,*energy=NULL,*d=NULL,alea=0.1,*smscale=NULL, + *auw=NULL,*autloc=NULL,*xboun2=NULL,*coefmpc2=NULL; + + FILE *f1,*f2; + #ifdef SGI ITG token; #endif /* dummy arguments for the results call */ - double *veold = NULL, *accold = NULL, bet, gam, dtime, time, reltime = 1.; + double *veold=NULL,*accold=NULL,bet,gam,dtime,time,reltime=1.; - irow = *irowp; - ener = *enerp; - xstate = *xstatep; - ipkon = *ipkonp; - lakon = *lakonp; - kon = *konp; - ielmat = *ielmatp; - ielorien = *ielorienp; - icol = *icolp; - - for (k = 0; k < 3; k++) { - strcpy1(&jobnamef[k * 132], &jobnamec[k * 132], 132); + irow=*irowp;ener=*enerp;xstate=*xstatep;ipkon=*ipkonp;lakon=*lakonp; + kon=*konp;ielmat=*ielmatp;ielorien=*ielorienp;icol=*icolp; + + for(k=0;k<3;k++){ + strcpy1(&jobnamef[k*132],&jobnamec[k*132],132); } - tper = &timepar[1]; + tper=&timepar[1]; - time = *tper; - dtime = *tper; + time=*tper; + dtime=*tper; - ne0 = *ne; + ne0=*ne; /* preCICE Adapter: Initialize the Calculix data structure */ struct SimulationData simulationData = { @@ -160,7 +152,7 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak .nset = *nset, .ikboun = ikboun, // .ikforc = ikforc, - .ilboun = ilboun, + .ilboun = ilboun, // .ilforc = ilforc, .nboun = *nboun, .nforc = *nforc, @@ -171,24 +163,24 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak .nk = *nk, .theta = &theta, // .dtheta = &dtheta, - .tper = tper, - .nmethod = nmethod, - .xload = xload, - .xforc = xforc, - .xboun = xboun, - .ntmat_ = ntmat_, - .vold = vold, - .veold = veold, - .fn = fn, - .cocon = cocon, - .ncocon = ncocon, - .mi = mi, + .tper = tper, + .nmethod = nmethod, + .xload = xload, + .xforc = xforc, + .xboun = xboun, + .ntmat_ = ntmat_, + .vold = vold, + .veold = veold, + .fn = fn, + .cocon = cocon, + .ncocon = ncocon, + .mi = mi, // .eei = &eei, // .stx = &stx, // .xstiff = xstiff - }; + }; - /* preCICE Adapter: Initialize */ + /* preCICE Adapter: Initialize */ Precice_Setup(configFilename, preciceParticipantName, &simulationData); Precice_AdjustSolverTimestep(&simulationData); @@ -199,38 +191,32 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak iglob=0 if no global results are used by boundary conditions iglob=1 if global results are from a *STATIC calculation */ - ITG irefine = 0; - getglobalresults(&jobnamec[396], &integerglob, &doubleglob, nboun, iamboun, xboun, - nload, sideload, iamload, &iglob, nforc, iamforc, xforc, - ithermal, nk, t1, iamt1, &sigma, &irefine); + ITG irefine=0; + getglobalresults(&jobnamec[396],&integerglob,&doubleglob,nboun,iamboun,xboun, + nload,sideload,iamload,&iglob,nforc,iamforc,xforc, + ithermal,nk,t1,iamt1,&sigma,&irefine); /* reading temperatures from frd-file */ - - if ((itempuser[0] == 2) && (itempuser[1] != itempuser[2])) { - utempread(t1, &itempuser[2], jobnamec); - } + + if((itempuser[0]==2)&&(itempuser[1]!=itempuser[2])) { + utempread(t1,&itempuser[2],jobnamec); + } /* allocating fields for the actual external loading */ - NNEW(xbounact, double, *nboun); - for (k = 0; k < *nboun; ++k) { - xbounact[k] = xbounold[k]; - } - NNEW(xforcact, double, *nforc); - NNEW(xloadact, double, 2 * *nload); - NNEW(xbodyact, double, 7 * *nbody); + NNEW(xbounact,double,*nboun); + for(k=0;k<*nboun;++k){xbounact[k]=xbounold[k];} + NNEW(xforcact,double,*nforc); + NNEW(xloadact,double,2**nload); + NNEW(xbodyact,double,7**nbody); /* copying the rotation axis and/or acceleration vector */ - for (k = 0; k < 7 * *nbody; k++) { - xbodyact[k] = xbody[k]; + for(k=0;k<7**nbody;k++){xbodyact[k]=xbody[k];} + if(*ithermal==1){ + NNEW(t1act,double,*nk); + for(k=0;k<*nk;++k){t1act[k]=t1old[k];} } - if (*ithermal == 1) { - NNEW(t1act, double, *nk); - for (k = 0; k < *nk; ++k) { - t1act[k] = t1old[k]; - } - } - - /* assigning the body forces to the elements */ + + /* assigning the body forces to the elements */ /* if(*nbody>0){ ifreebody=*ne+1; @@ -244,372 +230,365 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak }*/ /* contact conditions */ - + // if(*icontact==1){ - if (*mortar > -2) { - - memmpc_ = mpcinfo[0]; - mpcfree = mpcinfo[1]; - icascade = mpcinfo[2]; - maxlenmpc = mpcinfo[3]; + if(*mortar>-2){ - inicont(nk, &ncont, ntie, tieset, nset, set, istartset, iendset, ialset, &itietri, - lakon, ipkon, kon, &koncont, &nslavs, tietol, &ismallsliding, &itiefac, - &islavsurf, &islavnode, &imastnode, &nslavnode, &nmastnode, - mortar, &imastop, nkon, &iponoels, &inoels, &ipe, &ime, ne, &ifacecount, - iperturb, ikboun, nboun, co, istep, &xnoels); + memmpc_=mpcinfo[0];mpcfree=mpcinfo[1];icascade=mpcinfo[2]; + maxlenmpc=mpcinfo[3]; - if (ncont != 0) { + inicont(nk,&ncont,ntie,tieset,nset,set,istartset,iendset,ialset,&itietri, + lakon,ipkon,kon,&koncont,&nslavs,tietol,&ismallsliding,&itiefac, + &islavsurf,&islavnode,&imastnode,&nslavnode,&nmastnode, + mortar,&imastop,nkon,&iponoels,&inoels,&ipe,&ime,ne,&ifacecount, + iperturb,ikboun,nboun,co,istep,&xnoels); - NNEW(cg, double, 3 * ncont); - NNEW(straight, double, 16 * ncont); + if(ncont!=0){ + NNEW(cg,double,3*ncont); + NNEW(straight,double,16*ncont); + /* 11 instead of 10: last position is reserved for the - local contact spring element number; needed as - pointer into springarea */ - - if (*mortar == 0) { - RENEW(kon, ITG, *nkon + 11 * nslavs); - NNEW(springarea, double, 2 * nslavs); - if (*nener == 1) { - RENEW(ener, double, 2 * mi[0] * (*ne + nslavs)); - DMEMSET(ener, 2 * mi[0] * *ne, 2 * mi[0] * (*ne + nslavs), 0.); - } - RENEW(ipkon, ITG, *ne + nslavs); - RENEW(lakon, char, 8 * (*ne + nslavs)); - - if (*norien > 0) { - RENEW(ielorien, ITG, mi[2] * (*ne + nslavs)); - for (k = mi[2] * *ne; k < mi[2] * (*ne + nslavs); k++) - ielorien[k] = 0; - } - - RENEW(ielmat, ITG, mi[2] * (*ne + nslavs)); - for (k = mi[2] * *ne; k < mi[2] * (*ne + nslavs); k++) - ielmat[k] = 1; - - if (nslavs != 0) { - RENEW(xstate, double, *nstate_ *mi[0] * (*ne + nslavs)); - for (k = *nstate_ * mi[0] * *ne; k < *nstate_ * mi[0] * (*ne + nslavs); k++) { - xstate[k] = 0.; - } - } - - NNEW(areaslav, double, ifacecount); - NNEW(xmastnor, double, 3 * nmastnode[*ntie]); - } else if (*mortar == 1) { - NNEW(islavact, ITG, nslavnode[*ntie]); - DMEMSET(islavact, 0, nslavnode[*ntie], 1); - NNEW(clearini, double, 3 * 9 * ifacecount); - NNEW(xmastnor, double, 3 * nmastnode[*ntie]); - - nintpoint = 0; - - precontact(&ncont, ntie, tieset, nset, set, istartset, - iendset, ialset, itietri, lakon, ipkon, kon, koncont, ne, - cg, straight, co, vold, istep, &iinc, &iit, itiefac, - islavsurf, islavnode, imastnode, nslavnode, nmastnode, - imastop, mi, ipe, ime, tietol, &iflagact, - &nintpoint, &pslavsurf, xmastnor, cs, mcs, ics, clearini, - &nslavs); - - /* changing the dimension of element-related fields */ - - RENEW(kon, ITG, *nkon + 22 * nintpoint); - RENEW(springarea, double, 2 * nintpoint); - RENEW(pmastsurf, double, 6 * nintpoint); - - if (*nener == 1) { - RENEW(ener, double, 2 * mi[0] * (*ne + nintpoint)); - DMEMSET(ener, 2 * mi[0] * *ne, 2 * mi[0] * (*ne + nintpoint), 0.); - } - RENEW(ipkon, ITG, *ne + nintpoint); - RENEW(lakon, char, 8 * (*ne + nintpoint)); - - if (*norien > 0) { - RENEW(ielorien, ITG, mi[2] * (*ne + nintpoint)); - for (k = mi[2] * *ne; k < mi[2] * (*ne + nintpoint); k++) - ielorien[k] = 0; - } - RENEW(ielmat, ITG, mi[2] * (*ne + nintpoint)); - for (k = mi[2] * *ne; k < mi[2] * (*ne + nintpoint); k++) - ielmat[k] = 1; - - /* interpolating the state variables */ - - if (*nstate_ != 0) { - - RENEW(xstate, double, *nstate_ *mi[0] * (ne0 + nintpoint)); - for (k = *nstate_ * mi[0] * ne0; k < *nstate_ * mi[0] * (ne0 + nintpoint); k++) { - xstate[k] = 0.; - } - - RENEW(xstateini, double, *nstate_ *mi[0] * (ne0 + nintpoint)); - for (k = 0; k < *nstate_ * mi[0] * (ne0 + nintpoint); ++k) { - xstateini[k] = xstate[k]; - } - } + local contact spring element number; needed as + pointer into springarea */ + + if(*mortar==0){ + RENEW(kon,ITG,*nkon+11*nslavs); + NNEW(springarea,double,2*nslavs); + if(*nener==1){ + RENEW(ener,double,2*mi[0]*(*ne+nslavs)); + DMEMSET(ener,2*mi[0]**ne,2*mi[0]*(*ne+nslavs),0.); + } + RENEW(ipkon,ITG,*ne+nslavs); + RENEW(lakon,char,8*(*ne+nslavs)); + + if(*norien>0){ + RENEW(ielorien,ITG,mi[2]*(*ne+nslavs)); + for(k=mi[2]**ne;k0){ + RENEW(ielorien,ITG,mi[2]*(*ne+nintpoint)); + for(k=mi[2]**ne;k 0)) { - iperturbsav = iperturb[0]; - iperturb[0] = 0; + if((*nmethod==1)&&(iglob<0)&&(iperturb[0]>0)){ + iperturbsav=iperturb[0]; + iperturb[0]=0; } - iout = -1; - NNEW(v, double, mt **nk); - NNEW(fn, double, mt **nk); - NNEW(stx, double, 6 * mi[0] * *ne); - NNEW(inum, ITG, *nk); - NNEW(eei, double, 6 * mi[0] * *ne); - results(co, nk, kon, ipkon, lakon, ne, v, stn, inum, stx, - elcon, nelcon, rhcon, nrhcon, alcon, nalcon, alzero, ielmat, - ielorien, norien, orab, ntmat_, t0, t1act, ithermal, - prestr, iprestr, filab, eme, emn, een, iperturb, - f, fn, nactdof, &iout, qa, vold, b, nodeboun, - ndirboun, xbounact, nboun, ipompc, - nodempc, coefmpc, labmpc, nmpc, nmethod, cam, neq, veold, accold, - &bet, &gam, &dtime, &time, ttime, plicon, nplicon, plkcon, nplkcon, - xstateini, xstiff, xstate, npmat_, epn, matname, mi, &ielas, - &icmd, ncmat_, nstate_, stiini, vini, ikboun, ilboun, ener, enern, - emeini, xstaten, eei, enerini, cocon, ncocon, set, nset, istartset, - iendset, ialset, nprint, prlab, prset, qfx, qfn, trab, inotr, ntrans, - fmpc, nelemload, nload, ikmpc, ilmpc, istep, &iinc, springarea, - &reltime, &ne0, thicke, shcon, nshcon, - sideload, xloadact, xloadold, &icfd, inomat, pslavsurf, pmastsurf, - mortar, islavact, cdn, islavnode, nslavnode, ntie, clearini, - islavsurf, ielprop, prop, energyini, energy, &kscale, iponoel, - inoel, nener, orname, &network, ipobody, xbodyact, ibody, typeboun, - itiefac, tieset, smscale, &mscalmethod, nbody, t0g, t1g, - islavelinv, autloc, irowtloc, jqtloc, &nboun2, - ndirboun2, nodeboun2, xboun2, &nmpc2, ipompc2, nodempc2, coefmpc2, - labmpc2, ikboun2, ilboun2, ikmpc2, ilmpc2, &mortartrafoflag, - &intscheme, physcon); + iout=-1; + NNEW(v,double,mt**nk); + NNEW(fn,double,mt**nk); + NNEW(stx,double,6*mi[0]**ne); + NNEW(inum,ITG,*nk); + NNEW(eei,double,6*mi[0]**ne); + results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, + elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, + ielorien,norien,orab,ntmat_,t0,t1act,ithermal, + prestr,iprestr,filab,eme,emn,een,iperturb, + f,fn,nactdof,&iout,qa,vold,b,nodeboun, + ndirboun,xbounact,nboun,ipompc, + nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold,accold, + &bet,&gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, + xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas, + &icmd,ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern, + emeini,xstaten,eei,enerini,cocon,ncocon,set,nset,istartset, + iendset,ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans, + fmpc,nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea, + &reltime,&ne0,thicke,shcon,nshcon, + sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, + mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, + islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, + inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, + itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, + islavelinv,autloc,irowtloc,jqtloc,&nboun2, + ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, + labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, + &intscheme); + /* preCICE Adapter: Multiscale checkpoint*/ simulationData.xstiff = &xstiff; - simulationData.eei = &eei; - simulationData.stx = &stx; + simulationData.eei = &eei; + simulationData.stx = &stx; PreciceInterface_MultiscaleCheckpoint(&simulationData); + + SFREE(v);SFREE(fn);SFREE(stx);SFREE(inum); SFREE(eei); + iout=1; - SFREE(v); - SFREE(fn); - SFREE(stx); - SFREE(inum); - SFREE(eei); - iout = 1; - - if ((*nmethod == 1) && (iglob < 0) && (iperturb[0] > 0)) { - iperturb[0] = iperturbsav; + if((*nmethod==1)&&(iglob<0)&&(iperturb[0]>0)){ + iperturb[0]=iperturbsav; } - + /* determining the system matrix and the external forces */ - NNEW(ad, double, *neq); - NNEW(fext, double, *neq); - - if (*nmethod == 11) { + NNEW(ad,double,*neq); + NNEW(fext,double,*neq); + if(*nmethod==11){ + /* determining the nodes and the degrees of freedom in those nodes belonging to the substructure */ - - NNEW(iretain, ITG, *nk); - NNEW(noderetain, ITG, *nk); - NNEW(ndirretain, ITG, *nk); - nretain = 0; - - for (i = 0; i < *nboun; i++) { - if (strcmp1(&typeboun[i], "C") == 0) { - iretain[nretain] = i + 1; - noderetain[nretain] = nodeboun[i]; - ndirretain[nretain] = ndirboun[i]; - nretain++; + + NNEW(iretain,ITG,*nk); + NNEW(noderetain,ITG,*nk); + NNEW(ndirretain,ITG,*nk); + nretain=0; + + for(i=0;i<*nboun;i++){ + if(strcmp1(&typeboun[i],"C")==0){ + iretain[nretain]=i+1; + noderetain[nretain]=nodeboun[i]; + ndirretain[nretain]=ndirboun[i]; + nretain++; } } - + /* nretain!=0: substructure application */ - - RENEW(iretain, ITG, nretain); - RENEW(noderetain, ITG, nretain); - RENEW(ndirretain, ITG, nretain); - + + RENEW(iretain,ITG,nretain); + RENEW(noderetain,ITG,nretain); + RENEW(ndirretain,ITG,nretain); + /* creating the right size au */ - NNEW(au, double, nzs[2]); - rhsi = 0; - nmethodl = 2; + NNEW(au,double,nzs[2]); + rhsi=0; + nmethodl=2; - } else { + }else{ /* linear static calculation */ - NNEW(au, double, *nzs); - nmethodl = *nmethod; + NNEW(au,double,*nzs); + nmethodl=*nmethod; /* if submodel calculation with a global model obtained by a *FREQUENCY calculation: replace stiffness matrix K by K-sigma*M */ - if (iglob < 0) { - mass[0] = 1; - NNEW(adb, double, *neq); - NNEW(aub, double, nzs[1]); + if(iglob<0){ + mass[0]=1; + NNEW(adb,double,*neq); + NNEW(aub,double,nzs[1]); } + } - mafillsmmain(co, nk, kon, ipkon, lakon, ne, nodeboun, ndirboun, xbounact, nboun, - ipompc, nodempc, coefmpc, nmpc, nodeforc, ndirforc, xforcact, - nforc, nelemload, sideload, xloadact, nload, xbodyact, ipobody, - nbody, cgr, ad, au, fext, nactdof, icol, jq, irow, neq, nzl, &nmethodl, - ikmpc, ilmpc, ikboun, ilboun, - elcon, nelcon, rhcon, nrhcon, alcon, nalcon, alzero, ielmat, - ielorien, norien, orab, ntmat_, - t0, t1act, ithermal, prestr, iprestr, vold, iperturb, sti, - nzs, stx, adb, aub, iexpl, plicon, nplicon, plkcon, nplkcon, - xstiff, npmat_, &dtime, matname, mi, - ncmat_, mass, &stiffness, &buckling, &rhsi, &intscheme, physcon, - shcon, nshcon, cocon, ncocon, ttime, &time, istep, &iinc, &coriolis, - ibody, xloadold, &reltime, veold, springarea, nstate_, - xstateini, xstate, thicke, integerglob, doubleglob, - tieset, istartset, iendset, ialset, ntie, &nasym, pslavsurf, - pmastsurf, mortar, clearini, ielprop, prop, &ne0, fnext, &kscale, - iponoel, inoel, &network, ntrans, inotr, trab, smscale, &mscalmethod, - set, nset, islavelinv, autloc, irowtloc, jqtloc, &mortartrafoflag); + mafillsmmain(co,nk,kon,ipkon,lakon,ne,nodeboun,ndirboun,xbounact,nboun, + ipompc,nodempc,coefmpc,nmpc,nodeforc,ndirforc,xforcact, + nforc,nelemload,sideload,xloadact,nload,xbodyact,ipobody, + nbody,cgr,ad,au,fext,nactdof,icol,jq,irow,neq,nzl,&nmethodl, + ikmpc,ilmpc,ikboun,ilboun, + elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, + ielorien,norien,orab,ntmat_, + t0,t1act,ithermal,prestr,iprestr,vold,iperturb,sti, + nzs,stx,adb,aub,iexpl,plicon,nplicon,plkcon,nplkcon, + xstiff,npmat_,&dtime,matname,mi, + ncmat_,mass,&stiffness,&buckling,&rhsi,&intscheme,physcon, + shcon,nshcon,cocon,ncocon,ttime,&time,istep,&iinc,&coriolis, + ibody,xloadold,&reltime,veold,springarea,nstate_, + xstateini,xstate,thicke,integerglob,doubleglob, + tieset,istartset,iendset,ialset,ntie,&nasym,pslavsurf, + pmastsurf,mortar,clearini,ielprop,prop,&ne0,fnext,&kscale, + iponoel,inoel,&network,ntrans,inotr,trab,smscale,&mscalmethod, + set,nset,islavelinv,autloc,irowtloc,jqtloc,&mortartrafoflag); /* check for negative Jacobians */ - if (nmethodl == 0) - *nmethod = 0; - - if (nasym == 1) { - RENEW(au, double, 2 * nzs[1]); - symmetryflag = 2; - inputformat = 1; - - mafillsmasmain(co, nk, kon, ipkon, lakon, ne, nodeboun, - ndirboun, xbounact, nboun, - ipompc, nodempc, coefmpc, nmpc, nodeforc, ndirforc, xforcact, - nforc, nelemload, sideload, xloadact, nload, xbodyact, ipobody, - nbody, cgr, ad, au, fext, nactdof, icol, jq, irow, neq, nzl, - nmethod, ikmpc, ilmpc, ikboun, ilboun, - elcon, nelcon, rhcon, nrhcon, alcon, nalcon, alzero, - ielmat, ielorien, norien, orab, ntmat_, - t0, t1act, ithermal, prestr, iprestr, vold, iperturb, sti, - nzs, stx, adb, aub, iexpl, plicon, nplicon, plkcon, nplkcon, - xstiff, npmat_, &dtime, matname, mi, - ncmat_, mass, &stiffness, &buckling, &rhsi, &intscheme, - physcon, shcon, nshcon, cocon, ncocon, ttime, &time, istep, &iinc, - &coriolis, ibody, xloadold, &reltime, veold, springarea, nstate_, - xstateini, xstate, thicke, - integerglob, doubleglob, tieset, istartset, iendset, - ialset, ntie, &nasym, pslavsurf, pmastsurf, mortar, clearini, - ielprop, prop, &ne0, &kscale, iponoel, inoel, &network, set, nset); + if(nmethodl==0) *nmethod=0; + + if(nasym==1){ + RENEW(au,double,2*nzs[1]); + symmetryflag=2; + inputformat=1; + + mafillsmasmain(co,nk,kon,ipkon,lakon,ne,nodeboun, + ndirboun,xbounact,nboun, + ipompc,nodempc,coefmpc,nmpc,nodeforc,ndirforc,xforcact, + nforc,nelemload,sideload,xloadact,nload,xbodyact,ipobody, + nbody,cgr,ad,au,fext,nactdof,icol,jq,irow,neq,nzl, + nmethod,ikmpc,ilmpc,ikboun,ilboun, + elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero, + ielmat,ielorien,norien,orab,ntmat_, + t0,t1act,ithermal,prestr,iprestr,vold,iperturb,sti, + nzs,stx,adb,aub,iexpl,plicon,nplicon,plkcon,nplkcon, + xstiff,npmat_,&dtime,matname,mi, + ncmat_,mass,&stiffness,&buckling,&rhsi,&intscheme, + physcon,shcon,nshcon,cocon,ncocon,ttime,&time,istep,&iinc, + &coriolis,ibody,xloadold,&reltime,veold,springarea,nstate_, + xstateini,xstate,thicke, + integerglob,doubleglob,tieset,istartset,iendset, + ialset,ntie,&nasym,pslavsurf,pmastsurf,mortar,clearini, + ielprop,prop,&ne0,&kscale,iponoel,inoel,&network,set,nset); } /* determining the right hand side */ - NNEW(b, double, *neq); - for (k = 0; k < *neq; ++k) { - b[k] = fext[k] - f[k]; + NNEW(b,double,*neq); + for(k=0;k<*neq;++k){ + b[k]=fext[k]-f[k]; } - SFREE(fext); - SFREE(f); + SFREE(fext);SFREE(f); /* generation of a substructure stiffness matrix */ - if (*nmethod == 11) { + if(*nmethod==11){ /* factorizing the matrix */ - if (*neq > 0) { - if (*isolver == 0) { + if(*neq>0){ + if(*isolver==0){ #ifdef SPOOLES - spooles_factor(ad, au, adb, aub, &sigma, icol, irow, neq, nzs, &symmetryflag, - &inputformat, &nzs[2]); + spooles_factor(ad,au,adb,aub,&sigma,icol,irow,neq,nzs,&symmetryflag, + &inputformat,&nzs[2]); #else - printf(" *ERROR in linstatic: the SPOOLES library is not linked\n\n"); - FORTRAN(stop, ()); + printf(" *ERROR in linstatic: the SPOOLES library is not linked\n\n"); + FORTRAN(stop,()); #endif - } else if (*isolver == 7) { + } + else if(*isolver==7){ #ifdef PARDISO - pardiso_factor(ad, au, adb, aub, &sigma, icol, irow, neq, nzs, - &symmetryflag, &inputformat, jq, &nzs[2]); + pardiso_factor(ad,au,adb,aub,&sigma,icol,irow,neq,nzs, + &symmetryflag,&inputformat,jq,&nzs[2]); #else - printf(" *ERROR in linstatic: the PARDISO library is not linked\n\n"); - FORTRAN(stop, ()); + printf(" *ERROR in linstatic: the PARDISO library is not linked\n\n"); + FORTRAN(stop,()); #endif - } else if (*isolver == 8) { + } + else if(*isolver==8){ #ifdef PASTIX - pastix_factor_main(ad, au, adb, aub, &sigma, icol, irow, neq, nzs, - &symmetryflag, &inputformat, jq, &nzs[2]); + pastix_factor_main(ad,au,adb,aub,&sigma,icol,irow,neq,nzs, + &symmetryflag,&inputformat,jq,&nzs[2]); #else - printf(" *ERROR in linstatic: the PASTIX library is not linked\n\n"); - FORTRAN(stop, ()); + printf(" *ERROR in linstatic: the PASTIX library is not linked\n\n"); + FORTRAN(stop,()); #endif } } @@ -618,528 +597,444 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak /* substructure calculations */ - NNEW(submatrix, double, nretain *nretain); - - for (i = 0; i < nretain; i++) { - DMEMSET(b, 0, *neq, 0.); - ic = *neq + iretain[i] - 1; - for (j = jq[ic] - 1; j < jq[ic + 1] - 1; j++) { - ir = irow[j] - 1; - b[ir] -= au[j]; + NNEW(submatrix,double,nretain*nretain); + + for(i=0;i 0) { - if (*isolver == 0) { + + if(*neq>0){ + if(*isolver==0){ #ifdef SPOOLES - spooles_solve(b, neq); + spooles_solve(b,neq); #endif - } else if (*isolver == 7) { + } + else if(*isolver==7){ #ifdef PARDISO - pardiso_solve(b, neq, &symmetryflag, &inputformat, &nrhs); + pardiso_solve(b,neq,&symmetryflag,&inputformat,&nrhs); #endif - - } else if (*isolver == 8) { + + } + else if(*isolver==8){ #ifdef PASTIX - pastix_solve(b, neq, &symmetryflag, &nrhs); + pastix_solve(b,neq,&symmetryflag,&nrhs); #endif - } + + } } - + /* calculating the internal forces */ - - NNEW(v, double, mt **nk); - NNEW(fn, double, mt **nk); - NNEW(stn, double, 6 * *nk); - NNEW(inum, ITG, *nk); - NNEW(stx, double, 6 * mi[0] * *ne); - - if (strcmp1(&filab[261], "E ") == 0) - NNEW(een, double, 6 * *nk); - if (strcmp1(&filab[2697], "ME ") == 0) - NNEW(emn, double, 6 * *nk); - if (strcmp1(&filab[522], "ENER") == 0) - NNEW(enern, double, *nk); - - NNEW(eei, double, 6 * mi[0] * *ne); - if (*nener == 1) { - NNEW(stiini, double, 6 * mi[0] * *ne); - NNEW(emeini, double, 6 * mi[0] * *ne); - NNEW(enerini, double, 2 * mi[0] * *ne); - } - + + NNEW(v,double,mt**nk); + NNEW(fn,double,mt**nk); + NNEW(stn,double,6**nk); + NNEW(inum,ITG,*nk); + NNEW(stx,double,6*mi[0]**ne); + + if(strcmp1(&filab[261],"E ")==0) NNEW(een,double,6**nk); + if(strcmp1(&filab[2697],"ME ")==0) NNEW(emn,double,6**nk); + if(strcmp1(&filab[522],"ENER")==0) NNEW(enern,double,*nk); + + NNEW(eei,double,6*mi[0]**ne); + if(*nener==1){ + NNEW(stiini,double,6*mi[0]**ne); + NNEW(emeini,double,6*mi[0]**ne); + NNEW(enerini,double,2*mi[0]**ne);} + /* replacing the appropriate boundary value by unity */ - - xbounact[iretain[i] - 1] = 1.; - - results(co, nk, kon, ipkon, lakon, ne, v, stn, inum, stx, - elcon, nelcon, rhcon, nrhcon, alcon, nalcon, alzero, ielmat, - ielorien, norien, orab, ntmat_, t0, t1act, ithermal, - prestr, iprestr, filab, eme, emn, een, iperturb, - f, fn, nactdof, &iout, qa, vold, b, nodeboun, ndirboun, - xbounact, nboun, ipompc, - nodempc, coefmpc, labmpc, nmpc, nmethod, cam, neq, veold, - accold, &bet, - &gam, &dtime, &time, ttime, plicon, nplicon, plkcon, nplkcon, - xstateini, xstiff, xstate, npmat_, epn, matname, mi, &ielas, &icmd, - ncmat_, nstate_, stiini, vini, ikboun, ilboun, ener, enern, emeini, - xstaten, eei, enerini, cocon, ncocon, set, nset, istartset, iendset, - ialset, nprint, prlab, prset, qfx, qfn, trab, inotr, ntrans, fmpc, - nelemload, nload, ikmpc, ilmpc, istep, &iinc, springarea, &reltime, - &ne0, thicke, shcon, nshcon, - sideload, xloadact, xloadold, &icfd, inomat, pslavsurf, pmastsurf, - mortar, islavact, cdn, islavnode, nslavnode, ntie, clearini, - islavsurf, ielprop, prop, energyini, energy, &kscale, iponoel, - inoel, nener, orname, &network, ipobody, xbodyact, ibody, typeboun, - itiefac, tieset, smscale, &mscalmethod, nbody, t0g, t1g, - islavelinv, autloc, irowtloc, jqtloc, &nboun2, - ndirboun2, nodeboun2, xboun2, &nmpc2, ipompc2, nodempc2, coefmpc2, - labmpc2, ikboun2, ilboun2, ikmpc2, ilmpc2, &mortartrafoflag, - &intscheme, physcon); - - xbounact[iretain[i] - 1] = 0.; - - SFREE(v); - SFREE(stn); - SFREE(inum); - SFREE(stx); - - if (strcmp1(&filab[261], "E ") == 0) - SFREE(een); - if (strcmp1(&filab[2697], "ME ") == 0) - SFREE(emn); - if (strcmp1(&filab[522], "ENER") == 0) - SFREE(enern); - - SFREE(eei); - if (*nener == 1) { - SFREE(stiini); - SFREE(emeini); - SFREE(enerini); - } - + + xbounact[iretain[i]-1]=1.; + + results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, + elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, + ielorien,norien,orab,ntmat_,t0,t1act,ithermal, + prestr,iprestr,filab,eme,emn,een,iperturb, + f,fn,nactdof,&iout,qa,vold,b,nodeboun,ndirboun, + xbounact,nboun,ipompc, + nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold, + accold,&bet, + &gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, + xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas,&icmd, + ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern,emeini, + xstaten,eei,enerini,cocon,ncocon,set,nset,istartset,iendset, + ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans,fmpc, + nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea,&reltime, + &ne0,thicke,shcon,nshcon, + sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, + mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, + islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, + inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, + itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, + islavelinv,autloc,irowtloc,jqtloc,&nboun2, + ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, + labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, + &intscheme); + + xbounact[iretain[i]-1]=0.; + + SFREE(v);SFREE(stn);SFREE(inum);SFREE(stx); + + if(strcmp1(&filab[261],"E ")==0) SFREE(een); + if(strcmp1(&filab[2697],"ME ")==0) SFREE(emn); + if(strcmp1(&filab[522],"ENER")==0) SFREE(enern); + + SFREE(eei);if(*nener==1){SFREE(stiini);SFREE(emeini);SFREE(enerini);} + /* storing the internal forces in the substructure - stiffness matrix */ - - for (j = 0; j < nretain; j++) { - submatrix[i * nretain + j] = fn[mt * (noderetain[j] - 1) + ndirretain[j]]; + stiffness matrix */ + + for(j=0;j 0) { - if (*isolver == 0) { + /* cleanup */ + + if(*neq>0){ + if(*isolver==0){ #ifdef SPOOLES - spooles_cleanup(); + spooles_cleanup(); #endif - } else if (*isolver == 7) { + } + else if(*isolver==7){ #ifdef PARDISO - pardiso_cleanup(&neq[0], &symmetryflag, &inputformat); + pardiso_cleanup(&neq[0],&symmetryflag,&inputformat); #endif - } else if (*isolver == 8) { + } + else if(*isolver==8){ #ifdef PASTIX #endif } } - + SFREE(iretain); - - FORTRAN(writesubmatrix, (submatrix, noderetain, ndirretain, &nretain, jobnamec, - jmax)); - - SFREE(submatrix); - SFREE(noderetain); - SFREE(ndirretain); - - SFREE(au); - SFREE(ad); - SFREE(b); - - SFREE(xbounact); - SFREE(xforcact); - SFREE(xloadact); - SFREE(t1act); - SFREE(ampli); + + FORTRAN(writesubmatrix,(submatrix,noderetain,ndirretain,&nretain,jobnamec)); + + SFREE(submatrix);SFREE(noderetain);SFREE(ndirretain); + + SFREE(au);SFREE(ad);SFREE(b); + + SFREE(xbounact);SFREE(xforcact);SFREE(xloadact);SFREE(t1act);SFREE(ampli); SFREE(xbodyact); // if(*nbody>0) SFREE(ipobody); SFREE(xstiff); - - if (iglob != 0) { - SFREE(integerglob); - SFREE(doubleglob); - } - + + if(iglob!=0){SFREE(integerglob);SFREE(doubleglob);} + return; - } else if (*nmethod != 0) { + + }else if(*nmethod!=0){ /* linear static applications */ - if (*isolver == 0) { + if(*isolver==0){ #ifdef SPOOLES - spooles(ad, au, adb, aub, &sigma, b, icol, irow, neq, nzs, &symmetryflag, - &inputformat, &nzs[2]); + spooles(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs,&symmetryflag, + &inputformat,&nzs[2]); #else printf(" *ERROR in linstatic: the SPOOLES library is not linked\n\n"); - FORTRAN(stop, ()); + FORTRAN(stop,()); #endif - } else if ((*isolver == 2) || (*isolver == 3)) { - if (nasym > 0) { - printf(" *ERROR in nonlingeo: the iterative solver cannot be used for asymmetric matrices\n\n"); - FORTRAN(stop, ()); + } + else if((*isolver==2)||(*isolver==3)){ + if(nasym>0){ + printf(" *ERROR in nonlingeo: the iterative solver cannot be used for asymmetric matrices\n\n"); + FORTRAN(stop,()); } - preiter(ad, &au, b, &icol, &irow, neq, nzs, isolver, iperturb); - } else if (*isolver == 4) { + preiter(ad,&au,b,&icol,&irow,neq,nzs,isolver,iperturb); + } + else if(*isolver==4){ #ifdef SGI - if (nasym > 0) { - printf(" *ERROR in nonlingeo: the SGI solver cannot be used for asymmetric matrices\n\n"); - FORTRAN(stop, ()); + if(nasym>0){ + printf(" *ERROR in nonlingeo: the SGI solver cannot be used for asymmetric matrices\n\n"); + FORTRAN(stop,()); } - token = 1; - sgi_main(ad, au, adb, aub, &sigma, b, icol, irow, neq, nzs, token); + token=1; + sgi_main(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs,token); #else printf(" *ERROR in linstatic: the SGI library is not linked\n\n"); - FORTRAN(stop, ()); + FORTRAN(stop,()); #endif - } else if (*isolver == 5) { + } + else if(*isolver==5){ #ifdef TAUCS - if (nasym > 0) { - printf(" *ERROR in nonlingeo: the TAUCS solver cannot be used for asymmetric matrices\n\n"); - FORTRAN(stop, ()); + if(nasym>0){ + printf(" *ERROR in nonlingeo: the TAUCS solver cannot be used for asymmetric matrices\n\n"); + FORTRAN(stop,()); } - tau(ad, &au, adb, aub, &sigma, b, icol, &irow, neq, nzs); + tau(ad,&au,adb,aub,&sigma,b,icol,&irow,neq,nzs); #else printf(" *ERROR in linstatic: the TAUCS library is not linked\n\n"); - FORTRAN(stop, ()); + FORTRAN(stop,()); #endif - } else if (*isolver == 7) { + } + else if(*isolver==7){ #ifdef PARDISO - pardiso_main(ad, au, adb, aub, &sigma, b, icol, irow, neq, nzs, - &symmetryflag, &inputformat, jq, &nzs[2], &nrhs); + pardiso_main(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs, + &symmetryflag,&inputformat,jq,&nzs[2],&nrhs); #else printf(" *ERROR in linstatic: the PARDISO library is not linked\n\n"); - FORTRAN(stop, ()); + FORTRAN(stop,()); #endif - } else if (*isolver == 8) { + } + else if(*isolver==8){ #ifdef PASTIX - pastix_main(ad, au, adb, aub, &sigma, b, icol, irow, neq, nzs, - &symmetryflag, &inputformat, jq, &nzs[2], &nrhs); + pastix_main(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs, + &symmetryflag,&inputformat,jq,&nzs[2],&nrhs); #else printf(" *ERROR in linstatic: the PASTIX library is not linked\n\n"); - FORTRAN(stop, ()); + FORTRAN(stop,()); #endif } /* saving of ad and au for sensitivity analysis */ - for (i = 0; i < *ntie; i++) { - if (strcmp1(&tieset[i * 243 + 80], "D") == 0) { - - strcpy2(stiffmatrix, jobnamec, 132); - strcat(stiffmatrix, ".stm"); - - if ((f1 = fopen(stiffmatrix, "wb")) == NULL) { - printf(" *ERROR in linstatic: cannot open stiffness matrix file for writing..."); - exit(0); - } - - /* storing the stiffness matrix */ - - /* nzs,irow,jq and icol have to be stored too, since the static analysis - can involve contact, whereas in the sensitivity analysis contact is not - taken into account while determining the structure of the stiffness - matrix (in mastruct.c) - */ - - if (fwrite(&nasym, sizeof(ITG), 1, f1) != 1) { - printf(" *ERROR saving the symmetry flag to the stiffness matrix file..."); - exit(0); - } - if (fwrite(nzs, sizeof(ITG), 3, f1) != 3) { - printf(" *ERROR saving the number of subdiagonal nonzeros to the stiffness matrix file..."); - exit(0); - } - if (fwrite(irow, sizeof(ITG), nzs[2], f1) != nzs[2]) { - printf(" *ERROR saving irow to the stiffness matrix file..."); - exit(0); - } - if (fwrite(jq, sizeof(ITG), neq[1] + 1, f1) != neq[1] + 1) { - printf(" *ERROR saving jq to the stiffness matrix file..."); - exit(0); - } - if (fwrite(icol, sizeof(ITG), neq[1], f1) != neq[1]) { - printf(" *ERROR saving icol to the stiffness matrix file..."); - exit(0); - } - if (fwrite(ad, sizeof(double), neq[1], f1) != neq[1]) { - printf(" *ERROR saving the diagonal of the stiffness matrix to the stiffness matrix file..."); - exit(0); - } - if (fwrite(au, sizeof(double), nzs[2], f1) != nzs[2]) { - printf(" *ERROR saving the off-diagonal terms of the stiffness matrix to the tiffness matrix file..."); - exit(0); - } - fclose(f1); - - break; + for(i=0;i<*ntie;i++){ + if(strcmp1(&tieset[i*243+80],"D")==0){ + + strcpy2(stiffmatrix,jobnamec,132); + strcat(stiffmatrix,".stm"); + + if((f1=fopen(stiffmatrix,"wb"))==NULL){ + printf(" *ERROR in linstatic: cannot open stiffness matrix file for writing..."); + exit(0); + } + + /* storing the stiffness matrix */ + + /* nzs,irow,jq and icol have to be stored too, since the static analysis + can involve contact, whereas in the sensitivity analysis contact is not + taken into account while determining the structure of the stiffness + matrix (in mastruct.c) + */ + + if(fwrite(&nasym,sizeof(ITG),1,f1)!=1){ + printf(" *ERROR saving the symmetry flag to the stiffness matrix file..."); + exit(0); + } + if(fwrite(nzs,sizeof(ITG),3,f1)!=3){ + printf(" *ERROR saving the number of subdiagonal nonzeros to the stiffness matrix file..."); + exit(0); + } + if(fwrite(irow,sizeof(ITG),nzs[2],f1)!=nzs[2]){ + printf(" *ERROR saving irow to the stiffness matrix file..."); + exit(0); + } + if(fwrite(jq,sizeof(ITG),neq[1]+1,f1)!=neq[1]+1){ + printf(" *ERROR saving jq to the stiffness matrix file..."); + exit(0); + } + if(fwrite(icol,sizeof(ITG),neq[1],f1)!=neq[1]){ + printf(" *ERROR saving icol to the stiffness matrix file..."); + exit(0); + } + if(fwrite(ad,sizeof(double),neq[1],f1)!=neq[1]){ + printf(" *ERROR saving the diagonal of the stiffness matrix to the stiffness matrix file..."); + exit(0); + } + if(fwrite(au,sizeof(double),nzs[2],f1)!=nzs[2]){ + printf(" *ERROR saving the off-diagonal terms of the stiffness matrix to the tiffness matrix file..."); + exit(0); + } + fclose(f1); + + break; } } - - SFREE(ad); - SFREE(au); - if (iglob < 0) { - SFREE(adb); - SFREE(aub); - } + + SFREE(ad);SFREE(au); + if(iglob<0){SFREE(adb);SFREE(aub);} /* calculating the displacements and the stresses and storing */ /* the results in frd format for each valid eigenmode */ - NNEW(v, double, mt **nk); - NNEW(fn, double, mt **nk); - NNEW(stn, double, 6 * *nk); - NNEW(inum, ITG, *nk); - NNEW(stx, double, 6 * mi[0] * *ne); - - if (strcmp1(&filab[261], "E ") == 0) - NNEW(een, double, 6 * *nk); - if (strcmp1(&filab[2697], "ME ") == 0) - NNEW(emn, double, 6 * *nk); - if (strcmp1(&filab[522], "ENER") == 0) - NNEW(enern, double, *nk); - if (strcmp1(&filab[2175], "CONT") == 0) - NNEW(cdn, double, 6 * *nk); - - NNEW(eei, double, 6 * mi[0] * *ne); - if (*nener == 1) { - NNEW(stiini, double, 6 * mi[0] * *ne); - NNEW(emeini, double, 6 * mi[0] * *ne); - NNEW(enerini, double, 2 * mi[0] * *ne); - } - - results(co, nk, kon, ipkon, lakon, ne, v, stn, inum, stx, - elcon, nelcon, rhcon, nrhcon, alcon, nalcon, alzero, ielmat, - ielorien, norien, orab, ntmat_, t0, t1act, ithermal, - prestr, iprestr, filab, eme, emn, een, iperturb, - f, fn, nactdof, &iout, qa, vold, b, nodeboun, ndirboun, xbounact, nboun, - ipompc, - nodempc, coefmpc, labmpc, nmpc, nmethod, cam, neq, veold, accold, &bet, - &gam, &dtime, &time, ttime, plicon, nplicon, plkcon, nplkcon, - xstateini, xstiff, xstate, npmat_, epn, matname, mi, &ielas, &icmd, - ncmat_, nstate_, stiini, vini, ikboun, ilboun, ener, enern, emeini, - xstaten, eei, enerini, cocon, ncocon, set, nset, istartset, iendset, - ialset, nprint, prlab, prset, qfx, qfn, trab, inotr, ntrans, fmpc, - nelemload, nload, ikmpc, ilmpc, istep, &iinc, springarea, &reltime, - &ne0, thicke, shcon, nshcon, - sideload, xloadact, xloadold, &icfd, inomat, pslavsurf, pmastsurf, - mortar, islavact, cdn, islavnode, nslavnode, ntie, clearini, - islavsurf, ielprop, prop, energyini, energy, &kscale, iponoel, - inoel, nener, orname, &network, ipobody, xbodyact, ibody, typeboun, - itiefac, tieset, smscale, &mscalmethod, nbody, t0g, t1g, - islavelinv, autloc, irowtloc, jqtloc, &nboun2, - ndirboun2, nodeboun2, xboun2, &nmpc2, ipompc2, nodempc2, coefmpc2, - labmpc2, ikboun2, ilboun2, ikmpc2, ilmpc2, &mortartrafoflag, - &intscheme, physcon); + NNEW(v,double,mt**nk); + NNEW(fn,double,mt**nk); + NNEW(stn,double,6**nk); + NNEW(inum,ITG,*nk); + NNEW(stx,double,6*mi[0]**ne); + + if(strcmp1(&filab[261],"E ")==0) NNEW(een,double,6**nk); + if(strcmp1(&filab[2697],"ME ")==0) NNEW(emn,double,6**nk); + if(strcmp1(&filab[522],"ENER")==0) NNEW(enern,double,*nk); + if(strcmp1(&filab[2175],"CONT")==0) NNEW(cdn,double,6**nk); + + NNEW(eei,double,6*mi[0]**ne); + if(*nener==1){ + NNEW(stiini,double,6*mi[0]**ne); + NNEW(emeini,double,6*mi[0]**ne); + NNEW(enerini,double,2*mi[0]**ne);} + + results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, + elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, + ielorien,norien,orab,ntmat_,t0,t1act,ithermal, + prestr,iprestr,filab,eme,emn,een,iperturb, + f,fn,nactdof,&iout,qa,vold,b,nodeboun,ndirboun,xbounact,nboun, + ipompc, + nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold,accold,&bet, + &gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, + xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas,&icmd, + ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern,emeini, + xstaten,eei,enerini,cocon,ncocon,set,nset,istartset,iendset, + ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans,fmpc, + nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea,&reltime, + &ne0,thicke,shcon,nshcon, + sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, + mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, + islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, + inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, + itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, + islavelinv,autloc,irowtloc,jqtloc,&nboun2, + ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, + labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, + &intscheme); SFREE(eei); - if (*nener == 1) { - SFREE(stiini); - SFREE(emeini); - SFREE(enerini); - } + if(*nener==1){ + SFREE(stiini);SFREE(emeini);SFREE(enerini);} - memcpy(&vold[0], &v[0], sizeof(double) * mt * *nk); - memcpy(&sti[0], &stx[0], sizeof(double) * 6 * mi[0] * ne0); + memcpy(&vold[0],&v[0],sizeof(double)*mt**nk); + memcpy(&sti[0],&stx[0],sizeof(double)*6*mi[0]*ne0); ++*kode; /* for cyclic symmetric sectors: duplicating the results */ - if (*mcs > 0) { - ptime = *ttime + time; - frdcyc(co, nk, kon, ipkon, lakon, ne, v, stn, inum, nmethod, kode, filab, een, t1act, - fn, &ptime, epn, ielmat, matname, cs, mcs, nkon, enern, xstaten, - nstate_, istep, &iinc, iperturb, ener, mi, output, ithermal, - qfn, ialset, istartset, iendset, trab, inotr, ntrans, orab, - ielorien, norien, sti, veold, &noddiam, set, nset, emn, thicke, - jobnamec, &ne0, cdn, mortar, nmat, qfx, ielprop, prop); - } else { - if (strcmp1(&filab[1044], "ZZS") == 0) { - NNEW(neigh, ITG, 40 * *ne); - NNEW(ipneigh, ITG, *nk); - } - ptime = *ttime + time; - frd(co, nk, kon, ipkon, lakon, ne, v, stn, inum, nmethod, - kode, filab, een, t1act, fn, &ptime, epn, ielmat, matname, enern, xstaten, - nstate_, istep, &iinc, ithermal, qfn, &mode, &noddiam, trab, inotr, - ntrans, orab, ielorien, norien, description, ipneigh, neigh, - mi, stx, vr, vi, stnr, stni, vmax, stnmax, &ngraph, veold, ener, ne, - cs, set, nset, istartset, iendset, ialset, eenmax, fnr, fni, emn, - thicke, jobnamec, output, qfx, cdn, mortar, cdnr, cdni, nmat, ielprop, - prop, sti); - if (strcmp1(&filab[1044], "ZZS") == 0) { - SFREE(ipneigh); - SFREE(neigh); + if(*mcs>0){ + ptime=*ttime+time; + frdcyc(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod,kode,filab,een,t1act, + fn,&ptime,epn,ielmat,matname,cs,mcs,nkon,enern,xstaten, + nstate_,istep,&iinc,iperturb,ener,mi,output,ithermal, + qfn,ialset,istartset,iendset,trab,inotr,ntrans,orab, + ielorien,norien,sti,veold,&noddiam,set,nset,emn,thicke, + jobnamec,&ne0,cdn,mortar,nmat,qfx,ielprop,prop); + } + else{ + if(strcmp1(&filab[1044],"ZZS")==0){ + NNEW(neigh,ITG,40**ne); + NNEW(ipneigh,ITG,*nk); } + ptime=*ttime+time; + frd(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod, + kode,filab,een,t1act,fn,&ptime,epn,ielmat,matname,enern,xstaten, + nstate_,istep,&iinc,ithermal,qfn,&mode,&noddiam,trab,inotr, + ntrans,orab,ielorien,norien,description,ipneigh,neigh, + mi,stx,vr,vi,stnr,stni,vmax,stnmax,&ngraph,veold,ener,ne, + cs,set,nset,istartset,iendset,ialset,eenmax,fnr,fni,emn, + thicke,jobnamec,output,qfx,cdn,mortar,cdnr,cdni,nmat,ielprop, + prop,sti); + if(strcmp1(&filab[1044],"ZZS")==0){SFREE(ipneigh);SFREE(neigh);} } /* updating the .sta file */ - iitsta = 1; - FORTRAN(writesta, (istep, &iinc, &icutb, &iitsta, ttime, &time, &dtime)); + iitsta=1; + FORTRAN(writesta,(istep,&iinc,&icutb,&iitsta,ttime,&time,&dtime)); - SFREE(v); - SFREE(stn); - SFREE(inum); - SFREE(b); - SFREE(stx); - SFREE(fn); + SFREE(v);SFREE(stn);SFREE(inum); + SFREE(b);SFREE(stx);SFREE(fn); - if (strcmp1(&filab[261], "E ") == 0) - SFREE(een); - if (strcmp1(&filab[2697], "ME ") == 0) - SFREE(emn); - if (strcmp1(&filab[522], "ENER") == 0) - SFREE(enern); - if (strcmp1(&filab[2175], "CONT") == 0) - SFREE(cdn); + if(strcmp1(&filab[261],"E ")==0) SFREE(een); + if(strcmp1(&filab[2697],"ME ")==0) SFREE(emn); + if(strcmp1(&filab[522],"ENER")==0) SFREE(enern); + if(strcmp1(&filab[2175],"CONT")==0) SFREE(cdn); - } else { + } + else { /* error occurred in mafill: storing the geometry in frd format */ ++*kode; - NNEW(inum, ITG, *nk); - for (k = 0; k < *nk; k++) - inum[k] = 1; - if (strcmp1(&filab[1044], "ZZS") == 0) { - NNEW(neigh, ITG, 40 * *ne); - NNEW(ipneigh, ITG, *nk); - } - ptime = *ttime + time; - frd(co, nk, kon, ipkon, lakon, ne, v, stn, inum, nmethod, - kode, filab, een, t1, fn, &ptime, epn, ielmat, matname, enern, xstaten, - nstate_, istep, &iinc, ithermal, qfn, &mode, &noddiam, trab, inotr, - ntrans, orab, ielorien, norien, description, ipneigh, neigh, - mi, sti, vr, vi, stnr, stni, vmax, stnmax, &ngraph, veold, ener, ne, - cs, set, nset, istartset, iendset, ialset, eenmax, fnr, fni, emn, - thicke, jobnamec, output, qfx, cdn, mortar, cdnr, cdni, nmat, ielprop, - prop, sti); - if (strcmp1(&filab[1044], "ZZS") == 0) { - SFREE(ipneigh); - SFREE(neigh); + NNEW(inum,ITG,*nk);for(k=0;k<*nk;k++) inum[k]=1; + if(strcmp1(&filab[1044],"ZZS")==0){ + NNEW(neigh,ITG,40**ne); + NNEW(ipneigh,ITG,*nk); } - SFREE(inum); - FORTRAN(stop, ()); + ptime=*ttime+time; + frd(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod, + kode,filab,een,t1,fn,&ptime,epn,ielmat,matname,enern,xstaten, + nstate_,istep,&iinc,ithermal,qfn,&mode,&noddiam,trab,inotr, + ntrans,orab,ielorien,norien,description,ipneigh,neigh, + mi,sti,vr,vi,stnr,stni,vmax,stnmax,&ngraph,veold,ener,ne, + cs,set,nset,istartset,iendset,ialset,eenmax,fnr,fni,emn, + thicke,jobnamec,output,qfx,cdn,mortar,cdnr,cdni,nmat,ielprop, + prop,sti); + if(strcmp1(&filab[1044],"ZZS")==0){SFREE(ipneigh);SFREE(neigh);} + SFREE(inum);FORTRAN(stop,()); + } - if (*mortar > -2) { - if (ncont != 0) { - *ne = ne0; - if (*nener == 1) - RENEW(ener, double, 2 * mi[0] * *ne); - RENEW(ipkon, ITG, *ne); - RENEW(lakon, char, 8 * *ne); - RENEW(kon, ITG, *nkon); - if (*norien > 0) { - RENEW(ielorien, ITG, mi[2] * *ne); + if(*mortar>-2){ + if(ncont!=0){ + *ne=ne0; + if(*nener==1) RENEW(ener,double,2*mi[0]**ne); + RENEW(ipkon,ITG,*ne); + RENEW(lakon,char,8**ne); + RENEW(kon,ITG,*nkon); + if(*norien>0){ + RENEW(ielorien,ITG,mi[2]**ne); } - RENEW(ielmat, ITG, mi[2] * *ne); - SFREE(cg); - SFREE(straight); - SFREE(imastop); - SFREE(itiefac); - SFREE(islavnode); - SFREE(islavsurf); - SFREE(nslavnode); - SFREE(iponoels); - SFREE(inoels); - SFREE(imastnode); - SFREE(nmastnode); - SFREE(itietri); - SFREE(koncont); - SFREE(xnoels); - SFREE(springarea); - SFREE(xmastnor); - - if (*mortar == 0) { - SFREE(areaslav); - } else if (*mortar == 1) { - SFREE(pmastsurf); - SFREE(ipe); - SFREE(ime); - SFREE(pslavsurf); - SFREE(islavact); - SFREE(clearini); + RENEW(ielmat,ITG,mi[2]**ne); + SFREE(cg);SFREE(straight); + SFREE(imastop);SFREE(itiefac);SFREE(islavnode);SFREE(islavsurf); + SFREE(nslavnode);SFREE(iponoels);SFREE(inoels);SFREE(imastnode); + SFREE(nmastnode);SFREE(itietri);SFREE(koncont);SFREE(xnoels); + SFREE(springarea);SFREE(xmastnor); + + if(*mortar==0){ + SFREE(areaslav); + }else if(*mortar==1){ + SFREE(pmastsurf);SFREE(ipe);SFREE(ime);SFREE(pslavsurf); + SFREE(islavact);SFREE(clearini); } } - mpcinfo[0] = memmpc_; - mpcinfo[1] = mpcfree; - mpcinfo[2] = icascade; - mpcinfo[3] = maxlenmpc; + mpcinfo[0]=memmpc_;mpcinfo[1]=mpcfree;mpcinfo[2]=icascade; + mpcinfo[3]=maxlenmpc; } - /* updating the loading at the end of the step; + /* updating the loading at the end of the step; important in case the amplitude at the end of the step is not equal to one */ - for (k = 0; k < *nboun; ++k) { - xbounold[k] = xbounact[k]; - } - for (k = 0; k < *nforc; ++k) { - xforcold[k] = xforcact[k]; - } - for (k = 0; k < 2 * *nload; ++k) { - xloadold[k] = xloadact[k]; - } - for (k = 0; k < 7 * *nbody; k = k + 7) { - xbodyold[k] = xbodyact[k]; - } - if (*ithermal == 1) { - for (k = 0; k < *nk; ++k) { - t1old[k] = t1act[k]; - } - for (k = 0; k < *nk; ++k) { - vold[mt * k] = t1act[k]; - } + for(k=0;k<*nboun;++k){xbounold[k]=xbounact[k];} + for(k=0;k<*nforc;++k){xforcold[k]=xforcact[k];} + for(k=0;k<2**nload;++k){xloadold[k]=xloadact[k];} + for(k=0;k<7**nbody;k=k+7){xbodyold[k]=xbodyact[k];} + if(*ithermal==1){ + for(k=0;k<*nk;++k){t1old[k]=t1act[k];} + for(k=0;k<*nk;++k){vold[mt*k]=t1act[k];} } - SFREE(xbounact); - SFREE(xforcact); - SFREE(xloadact); - SFREE(t1act); - SFREE(ampli); + SFREE(xbounact);SFREE(xforcact);SFREE(xloadact);SFREE(t1act);SFREE(ampli); SFREE(xbodyact); // if(*nbody>0) SFREE(ipobody); SFREE(xstiff); - if (iglob != 0) { - SFREE(integerglob); - SFREE(doubleglob); - } - - *irowp = irow; - *enerp = ener; - *xstatep = xstate; - *ipkonp = ipkon; - *lakonp = lakon; - *konp = kon; - *ielmatp = ielmat; - *ielorienp = ielorien; - *icolp = icol; + if(iglob!=0){SFREE(integerglob);SFREE(doubleglob);} - (*ttime) += (*tper); + *irowp=irow;*enerp=ener;*xstatep=xstate;*ipkonp=ipkon;*lakonp=lakon; + *konp=kon;*ielmatp=ielmat;*ielorienp=ielorien;*icolp=icol; + (*ttime)+=(*tper); + return; } From 1c3febc4f7ca0f6fd598e1234ae607b6350d8252 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Wed, 7 Aug 2024 16:24:52 +0200 Subject: [PATCH 14/55] Revert nonlingeo_precice.c to old state --- nonlingeo_precice.c | 494 +++++++++++++++++++++++++------------------- 1 file changed, 282 insertions(+), 212 deletions(-) diff --git a/nonlingeo_precice.c b/nonlingeo_precice.c index cfb60fcd..256bbbf9 100644 --- a/nonlingeo_precice.c +++ b/nonlingeo_precice.c @@ -1,5 +1,5 @@ /* CalculiX - A 3-dimensional finite element program */ -/* Copyright (C) 1998-2021 Guido Dhondt */ +/* Copyright (C) 1998-2022 Guido Dhondt */ /* This program is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU General Public License as */ @@ -48,10 +48,10 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l ITG *nmpc, ITG *nodeforc, ITG *ndirforc, double *xforc, ITG *nforc, ITG **nelemloadp, char **sideloadp, double *xload, ITG *nload, - ITG *nactdof, + ITG * nactdof, ITG **icolp, ITG *jq, ITG **irowp, ITG *neq, ITG *nzl, ITG *nmethod, ITG **ikmpcp, ITG **ilmpcp, ITG *ikboun, - ITG *ilboun, + ITG * ilboun, double *elcon, ITG *nelcon, double *rhcon, ITG *nrhcon, double *alcon, ITG *nalcon, double *alzero, ITG **ielmatp, ITG **ielorienp, ITG *norien, double *orab, ITG *ntmat_, @@ -67,12 +67,12 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l ITG *iamforc, ITG **iamloadp, ITG *iamt1, double *alpha, ITG *iexpl, ITG *iamboun, double *plicon, ITG *nplicon, double *plkcon, - ITG *nplkcon, + ITG * nplkcon, double **xstatep, ITG *npmat_, ITG *istep, double *ttime, char *matname, double *qaold, ITG *mi, ITG *isolver, ITG *ncmat_, ITG *nstate_, ITG *iumat, double *cs, ITG *mcs, ITG *nkon, double **enerp, ITG *mpcinfo, - char *output, + char * output, double *shcon, ITG *nshcon, double *cocon, ITG *ncocon, double *physcon, ITG *nflow, double *ctrl, char *set, ITG *nset, ITG *istartset, @@ -99,7 +99,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l *sideloadref = NULL, *sideload = NULL, stiffmatrix[132] = "", *sideloadf = NULL; - ITG *inum = NULL, k, iout = 0, icntrl, iinc = 0, jprint = 0, iit = -1, jnz = 0, + ITG *inum = NULL, k, l, iout = 0, icntrl, iinc = 0, jprint = 0, iit = -1, jnz = 0, icutb = 0, istab = 0, uncoupled, n1, n2, itruecontact, iperturb_sav[2], ilin, *icol = NULL, *irow = NULL, ielas = 0, icmd = 0, memmpc_, mpcfree, icascade, maxlenmpc, *nodempc = NULL, *iaux = NULL, @@ -123,7 +123,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l coriolis = 0, *ipneigh = NULL, *neigh = NULL, maxprevcontel, nslavs_prev_step, *nelemface = NULL, *ipoface = NULL, *nodface = NULL, *ifreestream = NULL, *isolidsurf = NULL, *neighsolidsurf = NULL, *iponoel = NULL, *inoel = NULL, - nface, nfreestream, nsolidsurf, i, icfd = 0, id, + nface, nfreestream, nsolidsurf, i, icfd = 0, id, mortarsav = 0, node, networknode, iflagact = 0, *nodorig = NULL, *ipivr = NULL, iglob = 0, *inomat = NULL, *ipnei = NULL, ntrimax, *nx = NULL, *ny = NULL, *nz = NULL, idampingwithoutcontact = 0, *nactdoh = NULL, *nactdohinv = NULL, *ipkonf = NULL, @@ -140,7 +140,9 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l *nelemloadf = NULL, *ipobodyf = NULL, nkf, nkonf, memmpcf, nbounf, nloadf, nmpcf, *ikbounf = NULL, *ilbounf = NULL, *ikmpcf = NULL, *ilmpcf = NULL, *iambounf = NULL, *iamloadf = NULL, *inotrf = NULL, *jqtherm = NULL, *jqw = NULL, *iroww = NULL, nzsw, - *kslav = NULL, *lslav = NULL, *ktot = NULL, *ltot = NULL, nmasts, neqslav, neqtot; + *kslav = NULL, *lslav = NULL, *ktot = NULL, *ltot = NULL, nmasts, neqtot, + intpointvarm, calcul_fn, calcul_f, calcul_qa, calcul_cauchy, ikin, + intpointvart; double *stn = NULL, *v = NULL, *een = NULL, cam[5], *epn = NULL, *cg = NULL, *cdn = NULL, *pslavsurfold = NULL, @@ -177,7 +179,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l *smscale = NULL, dtset, energym = 0., energymold = 0., *voldf = NULL, *coefmpcf = NULL, *xbounf = NULL, *xloadf = NULL, *xbounoldf = NULL, *xbounactf = NULL, *xloadoldf = NULL, *xloadactf = NULL, *auw = NULL, *volddof = NULL, - *qb = NULL; + *qb = NULL, *aloc = NULL, dtmin, *fric = NULL; FILE *f1; @@ -308,42 +310,47 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l /* Adapter: Put all the CalculiX data that is needed for the coupling into an array */ struct SimulationData simulationData = { - .ialset = ialset, - .ielmat = ielmat, - .istartset = istartset, - .iendset = iendset, - .kon = kon, - .ipkon = ipkon, - .lakon = &lakon, - .co = co, - .set = set, - .nset = *nset, - .ikboun = ikboun, - .ikforc = ikforc, - .ilboun = ilboun, - .ilforc = ilforc, - .nboun = *nboun, - .nforc = *nforc, - .nelemload = nelemload, - .nload = *nload, - .sideload = sideload, - .mt = mt, - .nk = *nk, - .theta = &theta, - .dtheta = &dtheta, - .tper = tper, - .nmethod = nmethod, - .xload = xload, - .xforc = xforc, - .xboun = xboun, - .ntmat_ = ntmat_, - .vold = vold, - .veold = veold, - .fn = fn, - .cocon = cocon, - .ncocon = ncocon, - .mi = mi, - .eei = &eei}; + .ialset = ialset, + .ielmat = ielmat, + .istartset = istartset, + .iendset = iendset, + .kon = kon, + .ipkon = ipkon, + .lakon = lakon, + .co = co, + .set = set, + .nset = *nset, + .ikboun = ikboun, + .ikforc = ikforc, + .ilboun = ilboun, + .ilforc = ilforc, + .nboun = *nboun, + .nforc = *nforc, + .nelemload = nelemload, + .nload = *nload, + .sideload = sideload, + .mt = mt, + .nk = *nk, + .ne = *ne, + .theta = &theta, + .dtheta = &dtheta, + .tper = tper, + .nmethod = nmethod, + .xload = xload, + .xforc = xforc, + .xboun = xboun, + .ntmat_ = ntmat_, + .vold = vold, + .veold = veold, + .fn = fn, + .cocon = cocon, + .ncocon = ncocon, + .mi = mi, + .isModalDynamic = 0, + .eigenDOFs = NULL, + .eigenDOFsDerivatives = NULL, + .stored_iinc = iinc, + .stored_jprint = jprint}; if (*ithermal == 4) { uncoupled = 1; @@ -352,6 +359,14 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l uncoupled = 0; } + /* for massless explicit dynamics a static step in the same + calculation is performed with node-to-face contact */ + + if ((*nmethod == 1) && (*mortar == -1)) { + mortarsav = -1; + *mortar = 0; + } + if (*mortar != 1) { maxprevcontel = *nslavs; } else if (*mortar == 1) { @@ -369,7 +384,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l } nslavs_prev_step = *nslavs; - /* turbulence model + /* turbulence model iturbulent==0: laminar iturbulent==1: k-epsilon iturbulent==2: q-omega @@ -426,12 +441,13 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l /* explicit dynamics */ - if (fabs(alpham) > 1.e-30) { + if ((fabs(alpham) > 1.e-30) || ((fabs(betam) > 1.e-30) && (*mortar == -1))) { idamping = 1; idampingwithoutcontact = 1; } - if (fabs(betam) > 1.e-30) { // TODO cmt adapt to massless: we can take BETA - printf(" *ERROR: in explicit dynamic calculations the damping is only\n"); + if ((fabs(betam) > 1.e-30) && (*mortar != -1)) { + printf(" *ERROR in nonlingeo: in explicit dynamic calculations\n"); + printf(" without massless contact the damping is only\n"); printf(" allowed to be mass proportional: the coefficient beta\n"); printf(" of the stiffness proportional term must be zero\n"); FORTRAN(stop, ()); @@ -481,11 +497,11 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l /* invert nactdof */ - NNEW(nactdofinv, ITG, mt * *nk); - MNEW(nodorig, ITG, *nk); - FORTRAN(gennactdofinv, (nactdof, nactdofinv, nk, mi, nodorig, - ipkon, lakon, kon, ne)); - SFREE(nodorig); + /* NNEW(nactdofinv,ITG,mt**nk); + MNEW(nodorig,ITG,*nk); + FORTRAN(gennactdofinv,(nactdof,nactdofinv,nk,mi,nodorig, + ipkon,lakon,kon,ne)); + SFREE(nodorig);*/ /* allocating a field for the stiffness matrix */ @@ -561,7 +577,8 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l nodeboun, nacteq, nboun, ielprop, prop, &nteq, v, network, physcon, shcon, ntmat_, co, vold, set, nshcon, rhcon, nrhcon, mi, nmpc, nodempc, - ipompc, labmpc, ikboun, &nasym, ttime, &time, iaxial)); + ipompc, labmpc, ikboun, &nasym, ttime, &time, + iaxial)); SFREE(v); if ((*mcs > 0) && (ntr > 0)) { @@ -594,6 +611,8 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l if (*network > 0) { FORTRAN(networkelementpernode, (iponoel, inoel, lakon, ipkon, kon, &inoelsize, nflow, ieg, ne, network)); + FORTRAN(checkforhomnet, (ieg, nflow, lakon, ipkon, kon, itg, &ntg, + iponoel, inoel)); } RENEW(inoel, ITG, 2 * inoelsize); } @@ -668,7 +687,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l SFREE(nactdohinv); /* rearranging the fluid nodes and elements such that - no gaps occur */ + no gaps occur */ NNEW(ipkonf, ITG, *nef); NNEW(lakonf, char, 8 * *nef); @@ -763,11 +782,10 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l NNEW(inoelf, ITG, 2 * 8 * *nef); NNEW(inomat, ITG, nkftot); FORTRAN(topocfdfem, (nelemface, sideface, &nface, ipoface, nodface, nef, ipkonf, - konf, lakonf, &nkf, - isolidsurf, &nsolidsurf, ifreestream, &nfreestream, - neighsolidsurf, iponoelf, inoelf, &inoelfree, cof, - set, istartset, iendset, - ialset, nset, &iturbulent, inomat, ielmatf, ipface)); + konf, lakonf, &nkf, isolidsurf, &nsolidsurf, ifreestream, + &nfreestream, neighsolidsurf, iponoelf, inoelf, + &inoelfree, cof, set, istartset, iendset, ialset, nset, + &iturbulent, inomat, ielmatf, ipface, nknew)); RENEW(sideface, char, nface); RENEW(nelemface, ITG, nface); SFREE(ipoface); @@ -847,7 +865,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l NNEW(clearini, double, 3 * 9 * *ifacecount); /* check whether at least one contact definition involves true contact - and not just tied contact */ + and not just tied contact */ FORTRAN(checktruecontact, (ntie, tieset, tietol, elcon, &itruecontact, ncmat_, ntmat_)); @@ -986,7 +1004,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l } } - /* storing the element and topology information before introducing + /* storing the element and topology information before introducing contact elements */ ne0 = *ne; @@ -1006,7 +1024,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l /* initialization of the energy */ - if (ithermal[0] <= 1) { + if ((ithermal[0] <= 1) && (*nener == 1)) { isiz = mi[0] * ne0; cpypardou(enerini, ener, &isiz, &num_cpus); } @@ -1033,8 +1051,8 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l dtime = 1.; /* updating the nonlinear mpc's (also affects the boundary - conditions through the nonhomogeneous part of the mpc's) - if contact arises the number of MPC's can also change */ + conditions through the nonhomogeneous part of the mpc's) + if contact arises the number of MPC's can also change */ cam[0] = 0.; cam[1] = 0.; @@ -1084,7 +1102,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l /* invert nactdof */ - SFREE(nactdofinv); + // SFREE(nactdofinv); NNEW(nactdofinv, ITG, 1); iout = -1; @@ -1142,15 +1160,15 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l mscalmethod = 0; /* Explicit: Calculation of stable time increment according to - Courant's Law Carlo Monjaraz Tec (CMT) and Selctive Mass Scaling CC*/ + Courant's Law Carlo Monjaraz Tec (CMT) and Selctive Mass Scaling CC*/ /*Mass Scaling - mscalmethod < 0: no explicit dynamics - mscalmethod = 0: no mass scaling - mscalmethod = 1: selective mass scaling for nonlinearity after - Olovsson et. al 2005 + mscalmethod < 0: no explicit dynamics + mscalmethod = 0: no mass scaling + mscalmethod = 1: selective mass scaling for nonlinearity after + Olovsson et. al 2005 - mscalmethod=2 and mscalmethod=3 correspond to 0 and 1, + mscalmethod=2 and mscalmethod=3 correspond to 0 and 1, respectively with in addition contact scaling active; contact scaling is activated if the user time increment cannot be satisfied */ @@ -1162,11 +1180,12 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l nplicon, plkcon, nplkcon, npmat_, mi, &dtime, xstiff, ncmat_, vold, ielmat, t0, t1, matname, lakon, wavespeed, nmat, ipkon, co, kon, &dtvol, - alpha, smscale, &dtset, &mscalmethod)); + alpha, smscale, &dtset, &mscalmethod, mortar, + jobnamef)); - // printf("\033[1;33m"); // yellow - printf("Explicit time integration: Volumetric COURANT initial stable time increment:%e\n\n", dtvol); - // printf("\033[0m"); // reset color + //printf("\033[1;33m"); // yellow + printf(" Explicit time integration: Volumetric COURANT initial stable time increment:%e\n\n", dtvol); + //printf("\033[0m"); // reset color if (dtvol > (*tmax * (*tper))) { *tinc = *tmax * (*tper); @@ -1178,19 +1197,19 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l dtheta = (*tinc) / (*tper); dthetaref = dtheta; - // printf("\033[1;33m"); // yellow - printf("SELECTED time increment:%e\n\n", *tinc); - // printf("\033[0m"); // reset color + //printf("\033[1;33m"); // yellow + printf(" SELECTED time increment:%e\n\n", *tinc); + //printf("\033[0m"); // reset color } /* in mafillsm the stiffness and mass matrix are computed; - The primary aim is to calculate the mass matrix (not + The primary aim is to calculate the mass matrix (not lumped for an implicit dynamic calculation, lumped for an explicit dynamic calculation). However: - for an implicit calculation the mass matrix is "doped" with a small amount of stiffness matrix, therefore the calculation of the stiffness matrix is needed. - - for an explicit calculation the stiffness matrix is not + - for an explicit calculation the stiffness matrix is not needed at all. Since the calculation of the mass matrix alone is not possible in mafillsm, the determination of the stiffness matrix is taken as unavoidable "ballast". */ @@ -1259,14 +1278,18 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l NNEW(lslav, ITG, 3 * *nslavs); NNEW(ktot, ITG, 3 * *nslavs + 3 * nmasts); NNEW(ltot, ITG, 3 * *nslavs + 3 * nmasts); + NNEW(fric, double, *nslavs); - /* Create set of slave and slave+master contact DOFS (sorted) */ + /* Create set of slave and slave+master contact DOFS (sorted); + assign a friction coefficient to each slave node */ FORTRAN(create_contactdofs, (kslav, lslav, ktot, ltot, nslavs, islavnode, - &nmasts, imastnode, nactdof, mi, &neqslav, &neqtot)); + &nmasts, imastnode, nactdof, mi, &neqtot, + nslavnode, fric, tieset, tietol, ntie, elcon, + ncmat_, ntmat_)); - RENEW(kslav, ITG, neqslav); - RENEW(lslav, ITG, neqslav); + RENEW(kslav, ITG, 3 * *nslavs); + RENEW(lslav, ITG, 3 * *nslavs); RENEW(ktot, ITG, neqtot); RENEW(ltot, ITG, neqtot); @@ -1343,9 +1366,13 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l #endif } - } // endif massless + // Storing contact force vector initial solution + + NNEW(aloc, double, 3 * *nslavs); - /* mass x acceleration = f(external)-f(internal) + } //endif massless + + /* mass x acceleration = f(external)-f(internal) only for the mechanical loading*/ /* not needed for massless contact */ @@ -1359,8 +1386,8 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l if (*iexpl <= 1) { /* a small amount of stiffness is added to the mass matrix - otherwise the system leads to huge accelerations in - case of discontinuous load changes at the start of the step */ + otherwise the system leads to huge accelerations in + case of discontinuous load changes at the start of the step */ dtime = *tinc / 10.; scal1 = bet * dtime * dtime * (1. + alpha[0]); @@ -1440,7 +1467,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l &symmetryflag, &inputformat, &nzs[2]); spooles_solve(b, &neq[0]); #else - printf("*ERROR in arpack: the SPOOLES library is not linked\n\n"); + printf(" *ERROR in nonlingeo: the SPOOLES library is not linked\n\n"); FORTRAN(stop, ()); #endif } else if (*isolver == 4) { @@ -1449,7 +1476,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l sgi_factor(adb, aub, adb, aub, &sigma, icol, irow, &neq[0], &nzs[0], token); sgi_solve(b, token); #else - printf("*ERROR in arpack: the SGI library is not linked\n\n"); + printf(" *ERROR in nonlingeo: the SGI library is not linked\n\n"); FORTRAN(stop, ()); #endif } else if (*isolver == 5) { @@ -1457,7 +1484,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l tau_factor(adb, &aub, adb, aub, &sigma, icol, &irow, &neq[0], &nzs[0]); tau_solve(b, &neq[0]); #else - printf("*ERROR in arpack: the TAUCS library is not linked\n\n"); + printf(" *ERROR in nonlingeo: the TAUCS library is not linked\n\n"); FORTRAN(stop, ()); #endif } else if (*isolver == 7) { @@ -1467,7 +1494,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l pardiso_solve(b, &neq[0], &symmetryflag, &inputformat, &nrhs); #else - printf("*ERROR in arpack: the PARDISO library is not linked\n\n"); + printf(" *ERROR in nonlingeo: the PARDISO library is not linked\n\n"); FORTRAN(stop, ()); #endif } else if (*isolver == 8) { @@ -1477,7 +1504,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l pastix_solve(b, &neq[0], &symmetryflag, &nrhs); #else - printf("*ERROR in arpack: the PASTIX library is not linked\n\n"); + printf(" *ERROR in nonlingeo: the PASTIX library is not linked\n\n"); FORTRAN(stop, ()); #endif } @@ -1501,8 +1528,8 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l MNEW(fn, double, mt **nk); /* setting a "special" time consisting of the first primes; - used to recognize the initial acceleration procedure - in file resultsini.f */ + used to recognize the initial acceleration procedure + in file resultsini.f */ if (ne1d2d == 1) NNEW(inum, ITG, *nk); @@ -1560,8 +1587,8 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l // # # # # # # # # # # # # # # # # # # # # # # # # # # # # # // MPADD start - /* lumping of the mass matrix for implicit calculations to - modify the increment time when contact is involved + /* lumping of the mass matrix for implicit calculations to + modify the increment time when contact is involved */ NNEW(tmp, double, neq[1]); @@ -1588,9 +1615,9 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l /* starting the loop over the increments */ /**************************************************************/ - // printf("\033[0;34m"); // blue - // printf("Starting the loop over the increments\n"); - // printf("\033[0m"); // reset color + //printf("\033[0;34m"); // blue + //printf("Starting the loop over the increments\n"); + //printf("\033[0m"); // reset color newstep = 1; @@ -1645,7 +1672,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l jprint++; /* store number of elements (important for implicit dynamic - contact */ + contact */ neini = *ne; @@ -1728,7 +1755,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l /* check for max. # of increments */ if (iinc > jmax[0]) { - printf(" *ERROR: max. # of increments reached\n\n"); + printf(" *ERROR in nonlingeo: max. # of increments reached\n\n"); FORTRAN(stop, ()); } @@ -1802,7 +1829,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l iamload, jqrad, irowrad, &nzsrad, icolrad, ne, iaxial, qa, cocon, ncocon, iponoel, - inoel, nprop, amname, namta, amta); + inoel, nprop, amname, namta, amta, iexpl); /* check whether network iterations converged */ @@ -1825,8 +1852,8 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l &dampwkini, energystartstep); /* the divergence is flagged by icntrl!=0 - icutb is reset to zero in order to generate - regular contact elements etc.. */ + icutb is reset to zero in order to generate + regular contact elements etc.. */ icutb--; } @@ -1876,17 +1903,17 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l if ((ncont != 0) && (*mortar <= 1) && /* for purely thermal calculations: determine contact integration - points only at the start of a step */ + points only at the start of a step */ ((*ithermal != 2) || (iit == -1))) { *ne = ne0; *nkon = nkon0; - /* at start of new increment: - - copy state variables (node-to-face) - - determine slave integration points (face-to-face) - - interpolate state variables (face-to-face) */ + /* at start of new increment: + - copy state variables (node-to-face) + - determine slave integration points (face-to-face) + - interpolate state variables (face-to-face) */ if (icutb == 0) { if (*mortar == 1) { @@ -1907,7 +1934,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l *nintpoint = 0; /* determine the location of the slave integration - points */ + points */ precontact(&ncont, ntie, tieset, nset, set, istartset, iendset, ialset, itietri, lakon, ipkon, kon, koncont, ne, @@ -1994,7 +2021,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l contact(&ncont, ntie, tieset, nset, set, istartset, iendset, ialset, itietri, lakon, ipkon, kon, koncont, ne, cg, straight, nkon, co, vold, ielmat, cs, elcon, istep, &iinc, &iit, ncmat_, ntmat_, - &ne0, vini, nmethod, + &ne0, nmethod, iperturb, ikboun, nboun, mi, imastop, nslavnode, islavnode, islavsurf, itiefac, areaslav, iponoels, inoels, springarea, tietol, &reltime, @@ -2003,8 +2030,8 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l xstateini, xstate, nstate_, &icutb, &ialeatoric, jobnamef, &alea, auw, jqw, iroww, &nzsw); - /* check whether, for a dynamic calculation, contact damping - is involved */ + /* check whether, for a dynamic calculation, contact damping + is involved */ if (*nmethod == 4) { if (*iexpl <= 1) { @@ -2033,10 +2060,10 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l /* carlo start */ - /* dynamic time step estimation for explicit dynamics under penalty - contact(CMT) start */ + /* dynamic time step estimation for explicit dynamics under penalty + contact(CMT) start */ - if ((*iexpl > 1)) { + if ((*iexpl > 1) && (*mortar != -1)) { if ((*ne - ne0) < ncontacts) { @@ -2054,14 +2081,20 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l mortar, adb, alpha, nactdof, springarea, &ne0, ntmat_, ncmat_, &dtcont, smscale, &dtset, &mscalmethod)); + if (dtcont < dtvol) { + dtmin = dtcont; + } else { + dtmin = dtvol; + } - if (dtcont > (*tmax * (*tper))) { + if (dtmin > (*tmax * (*tper))) { *tinc = *tmax * (*tper); - } else if (dtcont < dtset) { + } else if (dtmin < dtset) { *tinc = dtset; } else { - *tinc = dtcont; + *tinc = dtmin; } + dtheta = (*tinc) / (*tper); dthetaref = dtheta; @@ -2090,7 +2123,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l } /* updating the nonlinear mpc's (also affects the boundary - conditions through the nonhomogeneous part of the mpc's) */ + conditions through the nonhomogeneous part of the mpc's) */ FORTRAN(nonlinmpc, (co, vold, ipompc, nodempc, coefmpc, labmpc, nmpc, ikboun, ilboun, nboun, xbounact, aux, iaux, @@ -2105,9 +2138,13 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l cpypardou(coefmpcref, coefmpc, &isiz, &num_cpus); } - /* recalculating the matrix structure */ + /* recalculating the matrix structure; only needed if: + 1) MPC's are cascaded + 2) contact occurs in an implicit calculation + (in penalty explicit no matrices are needed, in massless + explicit no contact elements are generated) */ - if ((icascade > 0) || (ncont != 0)) + if ((icascade > 0) || ((ncont != 0) && (*iexpl <= 1))) remastruct(ipompc, &coefmpc, &nodempc, nmpc, &mpcfree, nodeboun, ndirboun, nboun, ikmpc, ilmpc, ikboun, ilboun, labmpc, nk, &memmpc_, &icascade, &maxlenmpc, @@ -2117,14 +2154,16 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l typeboun, &cv, &cvini, &iit, network, itiefac, &ne0, &nkon0, nintpoint, islavsurf, pmastsurf, tieset, ntie, &num_cpus); - /* invert nactdof */ + /* invert nactdof (not for dynamic explicit calculations) */ - SFREE(nactdofinv); - NNEW(nactdofinv, ITG, mt * *nk); - MNEW(nodorig, ITG, *nk); - FORTRAN(gennactdofinv, (nactdof, nactdofinv, nk, mi, nodorig, - ipkon, lakon, kon, ne)); - SFREE(nodorig); + if (*iexpl <= 1) { + SFREE(nactdofinv); + NNEW(nactdofinv, ITG, mt * *nk); + MNEW(nodorig, ITG, *nk); + FORTRAN(gennactdofinv, (nactdof, nactdofinv, nk, mi, nodorig, + ipkon, lakon, kon, ne)); + SFREE(nodorig); + } /* check whether the forced displacements changed; if so, and if the procedure is static, the first iteration has to be @@ -2168,29 +2207,29 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l NNEW(stx, double, 6 * mi[0] * *ne); /* determining the internal forces at the start of the increment - + for a static calculation with increased forced displacements the linear strains are calculated corresponding to - + the displacements at the end of the previous increment, extrapolated if appropriate (for nondispersive media) + the forced displacements at the end of the present increment + the temperatures at the end of the present increment (this sum is v) - the displacements at the end of the previous increment (this is vold) - + these linear strains are converted in stresses by multiplication with the tangent element stiffness matrix and converted into nodal - forces. - + forces. + this boils down to the fact that the effect of forced displacements should be handled in a purely linear way at the start of a new increment, in order to speed up the convergence and (for dissipative media) guarantee smooth loading within the increment. - + for all other cases the nodal force calculation is based on the true stresses derived from the appropriate strain tensor taking - into account the extrapolated displacements at the end of the + into account the extrapolated displacements at the end of the previous increment + the forced displacements and the temperatures at the end of the present increment */ @@ -2241,7 +2280,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l SFREE(inum); /* check whether any displacements or temperatures are changed - in the new increment */ + in the new increment */ for (k = 0; k < neq[1]; ++k) { f[k] = f[k] + b[k]; @@ -2331,14 +2370,14 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l #endif /* updating the nonlinear mpc's (also affects the boundary - conditions through the nonhomogeneous part of the mpc's) */ + conditions through the nonhomogeneous part of the mpc's) */ if ((iit != 1) || ((uncoupled) && (*ithermal == 1))) { printf(" iteration %" ITGFORMAT "\n\n", iit); /* restoring the distributed loading before adding the - friction heating */ + friction heating */ if ((*ithermal == 3) && (ncont != 0) && (*mortar == 1) && (*ncmat_ >= 11)) { *nload = nloadref; @@ -2383,7 +2422,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l set, mi, istartset, iendset, ialset, nset, ineighe, nmpc, nodempc, ipompc, coefmpc, labmpc, &iemchange, nam, iamload, jqrad, irowrad, &nzsrad, icolrad, ne, iaxial, qa, cocon, ncocon, - iponoel, inoel, nprop, amname, namta, amta); + iponoel, inoel, nprop, amname, namta, amta, iexpl); /* check whether network iterations converged */ @@ -2422,10 +2461,10 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l if ((ncont != 0) && (*mortar <= 1) && (ismallsliding == 0) && /* for node-to-face contact: freeze contact elements for - iterations 8 and higher */ + iterations 8 and higher */ ((iit <= 8) || (*mortar == 1)) && /* for purely thermal calculations: freeze contact elements - during complete step */ + during complete step */ ((*ithermal != 2) || (iit == -1))) { neold = *ne; @@ -2435,7 +2474,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l ialset, itietri, lakon, ipkon, kon, koncont, ne, cg, straight, nkon, co, vold, ielmat, cs, elcon, istep, &iinc, &iit, ncmat_, ntmat_, &ne0, - vini, nmethod, iperturb, + nmethod, iperturb, ikboun, nboun, mi, imastop, nslavnode, islavnode, islavsurf, itiefac, areaslav, iponoels, inoels, springarea, tietol, &reltime, imastnode, nmastnode, xmastnor, @@ -2443,8 +2482,8 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l clearini, &theta, xstateini, xstate, nstate_, &icutb, &ialeatoric, jobnamef, &alea, auw, jqw, iroww, &nzsw); - /* check whether, for a dynamic calculation, contact damping is - involved */ + /* check whether, for a dynamic calculation, contact damping is + involved */ if (*nmethod == 4) { if (*iexpl <= 1) { @@ -2505,7 +2544,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l /* recalculating the matrix structure */ /* for face-to-face contact (mortar=1) this is only done if - the dependent term in nonlinear MPC's changed */ + the dependent term in nonlinear MPC's changed */ if ((icascade > 0) || (ncont != 0)) { if ((*mortar != 1) || (kchdep == 1)) { @@ -2675,9 +2714,9 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l } else { - /* calculating the external loading + /* calculating the external loading - This is only done once per increment. In reality, the + This is only done once per increment. In reality, the external loading is a function of vold (specifically, the body forces and surface loading). This effect is neglected, since the increment size in dynamic explicit @@ -2695,13 +2734,13 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l npmat_, ttime, &time, istep, &iinc, &dtime, physcon, ibody, xbodyold, &reltime, veold, matname, mi, ikactmech, &nactmech, ielprop, prop, sti, xstateini, xstate, nstate_, - ntrans, inotr, trab); + ntrans, inotr, trab, fnext); } - /* for(k=0;k 1) { /* restoring the structure of the original stiffness - matrix */ + matrix */ for (i = 0; i < 3; i++) { nzs[i] = nzstemp[i]; @@ -3295,6 +3342,14 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l NNEW(stx, double, 6 * mi[0] * *ne); MNEW(fn, double, mt **nk); + /* if((*nmethod==4)&&(*iexpl>1)&&(*nener==0)){ + resultsini(nk,v,ithermal,filab,iperturb,f,fn, + nactdof,&iout,qa,vold,b,nodeboun,ndirboun, + xboun,nboun,ipompc,nodempc,coefmpc,labmpc,nmpc,nmethod,cam, + &neq[1],veold,accold,&bet,&gam,&dtime,mi,vini,nprint,prlab, + &intpointvarm,&calcul_fn,&calcul_f,&calcul_qa,&calcul_cauchy, + &ikin,&intpointvart,typeboun,&num_cpus,mortar,nener); + }else{*/ if (ne1d2d == 1) NNEW(inum, ITG, *nk); results(co, nk, kon, ipkon, lakon, ne, v, stn, inum, stx, @@ -3322,6 +3377,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l &intscheme); if (ne1d2d == 1) SFREE(inum); + // } /* implicit dynamics (Matteo Pacher) */ @@ -3333,7 +3389,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l /* updating the external work (only for dynamic calculations) */ - if ((*nmethod == 4) && (*ithermal < 2)) { + if ((*nmethod == 4) && (*ithermal < 2) && (*nener == 1)) { allwk = allwkini; worparll(&allwk, fnext, &mt, fnextini, v, vini, nk, &num_cpus); @@ -3430,11 +3486,14 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l /* calculating the residual */ - calcresidual(nmethod, neq, b, fext, f, iexpl, nactdof, aux2, vold, - vini, &dtime, accold, nk, adb, aub, jq, irow, nzl, alpha, fextini, fini, - islavnode, nslavnode, mortar, ntie, f_cm, f_cs, mi, - nzs, &nasym, &idamping, veold, adc, auc, cvini, cv, &alpham, - &num_cpus); + // next line: change on 19072022 + if ((*iexpl <= 1) || (*nener == 1)) { + calcresidual(nmethod, neq, b, fext, f, iexpl, nactdof, aux2, vold, vini, &dtime, + accold, nk, adb, aub, jq, irow, nzl, alpha, fextini, fini, + islavnode, nslavnode, mortar, ntie, f_cm, f_cs, mi, + nzs, &nasym, &idamping, veold, adc, auc, cvini, cv, &alpham, + &num_cpus); + } /* fix residuals for mortar contact, add contact forces */ @@ -3446,7 +3505,9 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l isiz = mt * *nk; cpypardou(vold, v, &isiz, &num_cpus); - if (*ithermal != 2) { + // if(*ithermal!=2){ + // next line: change on 19072022 + if ((*ithermal != 2) && ((*iexpl <= 1) || (*nener == 1))) { for (k = 0; k < 6 * mi[0] * ne0; ++k) { sti[k] = stx[k]; } @@ -3538,7 +3599,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l } /* next line is inserted to cope with stress-less - temperature calculations */ + temperature calculations */ if (*ithermal != 2) { if (ram[0] < 1.e-6) { @@ -3546,11 +3607,11 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l } printf(" average force= %f\n", qa[0]); printf(" time avg. forc= %f\n", qam[0]); - if ((ITG) ((double) nactdofinv[(ITG) ram[2]] / mt) + 1 == 0) { + if ((ITG)((double) nactdofinv[(ITG) ram[2]] / mt) + 1 == 0) { printf(" largest residual force= %f\n", ram[0]); } else { - inode = (ITG) ((double) nactdofinv[(ITG) ram[2]] / mt) + 1; + inode = (ITG)((double) nactdofinv[(ITG) ram[2]] / mt) + 1; idir = nactdofinv[(ITG) ram[2]] - mt * (inode - 1); printf(" largest residual force= %f in node %" ITGFORMAT " and dof %" ITGFORMAT "\n", @@ -3561,7 +3622,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l printf(" largest correction to disp= %e\n\n", cam[0]); } else { - inode = (ITG) ((double) nactdofinv[(ITG) cam[3]] / mt) + 1; + inode = (ITG)((double) nactdofinv[(ITG) cam[3]] / mt) + 1; idir = nactdofinv[(ITG) cam[3]] - mt * (inode - 1); printf(" largest correction to disp= %e in node %" ITGFORMAT " and dof %" ITGFORMAT "\n\n", @@ -3574,11 +3635,11 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l } printf(" average flux= %f\n", qa[1]); printf(" time avg. flux= %f\n", qam[1]); - if ((ITG) ((double) nactdofinv[(ITG) ram[3]] / mt) + 1 == 0) { + if ((ITG)((double) nactdofinv[(ITG) ram[3]] / mt) + 1 == 0) { printf(" largest residual flux= %f\n", ram[1]); } else { - inode = (ITG) ((double) nactdofinv[(ITG) ram[3]] / mt) + 1; + inode = (ITG)((double) nactdofinv[(ITG) ram[3]] / mt) + 1; idir = nactdofinv[(ITG) ram[3]] - mt * (inode - 1); printf(" largest residual flux= %f in node %" ITGFORMAT " and dof %" ITGFORMAT "\n", @@ -3589,7 +3650,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l printf(" largest correction to temp= %e\n\n", cam[1]); } else { - inode = (ITG) ((double) nactdofinv[(ITG) cam[4]] / mt) + 1; + inode = (ITG)((double) nactdofinv[(ITG) cam[4]] / mt) + 1; idir = nactdofinv[(ITG) cam[4]] - mt * (inode - 1); printf(" largest correction to temp= %e in node %" ITGFORMAT " and dof %" ITGFORMAT "\n\n", @@ -3693,7 +3754,6 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l /* Adapter: Copy necessary data for coupling */ simulationData.fn = fn; - memcpy(&vold[0], &v[0], sizeof(double) * mt * *nk); Precice_WriteCouplingData(&simulationData); /* Adapter: Advance the coupling */ @@ -3707,7 +3767,8 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l } /* printing the energies (only for dynamic calculations) */ - if ((icutb == 0) && (*nmethod == 4) && (*ithermal < 2) && (jout[0] == jprint)) { + if ((icutb == 0) && (*nmethod == 4) && (*ithermal < 2) && (jout[0] == jprint) && + (*nener == 1)) { if (*iexpl > 1) { printf(" actual total time=%e\n\n", *ttime + theta * *tper); @@ -4052,7 +4113,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l if (jprint != 0) { - /* calculating the displacements and the stresses and storing + /* calculating the displacements and the stresses and storing the results in frd format */ MNEW(v, double, mt **nk); @@ -4197,7 +4258,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l strcat(stiffmatrix, ".stm"); if ((f1 = fopen(stiffmatrix, "wb")) == NULL) { - printf("*ERROR in linstatic: cannot open stiffness matrix file for writing..."); + printf(" *ERROR in nonlingeo: cannot open stiffness matrix file for writing..."); exit(0); } @@ -4210,31 +4271,31 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l */ if (fwrite(&nasym, sizeof(ITG), 1, f1) != 1) { - printf("*ERROR saving the symmetry flag to the stiffness matrix file..."); + printf(" *ERROR in nonlingeo saving the symmetry flag to the stiffness matrix file..."); exit(0); } if (fwrite(nzs, sizeof(ITG), 3, f1) != 3) { - printf("*ERROR saving the number of subdiagonal nonzeros to the stiffness matrix file..."); + printf(" *ERROR in nonlingeo saving the number of subdiagonal nonzeros to the stiffness matrix file..."); exit(0); } if (fwrite(irow, sizeof(ITG), nzs[2], f1) != nzs[2]) { - printf("*ERROR saving irow to the stiffness matrix file..."); + printf(" *ERROR in nonlingeo saving irow to the stiffness matrix file..."); exit(0); } if (fwrite(jq, sizeof(ITG), neq[1] + 1, f1) != neq[1] + 1) { - printf("*ERROR saving jq to the stiffness matrix file..."); + printf(" *ERROR in nonlingeo saving jq to the stiffness matrix file..."); exit(0); } if (fwrite(icol, sizeof(ITG), neq[1], f1) != neq[1]) { - printf("*ERROR saving icol to the stiffness matrix file..."); + printf(" *ERROR in nonlingeo saving icol to the stiffness matrix file..."); exit(0); } if (fwrite(adcpy, sizeof(double), neq[1], f1) != neq[1]) { - printf("*ERROR saving the diagonal of the stiffness matrix to the stiffness matrix file..."); + printf(" *ERROR in nonlingeo saving the diagonal of the stiffness matrix to the stiffness matrix file..."); exit(0); } if (fwrite(aucpy, sizeof(double), (nasym + 1) * nzs[2], f1) != (nasym + 1) * nzs[2]) { - printf("*ERROR saving the off-diagonal terms of the stiffness matrix to the stiffness matrix file..."); + printf(" *ERROR in nonlingeo saving the off-diagonal terms of the stiffness matrix to the stiffness matrix file..."); exit(0); } fclose(f1); @@ -4276,7 +4337,7 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l } } - /* updating the loading at the end of the step; + /* updating the loading at the end of the step; important in case the amplitude at the end of the step is not equal to one */ @@ -4290,8 +4351,8 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l continue; /* mechanical boundary conditions are updated only - if the step was not thermal or the node is a - network node */ + if the step was not thermal or the node is a + network node */ } else if ((ndirboun[k] > 0) && (ndirboun[k] < 4)) { node = nodeboun[k]; @@ -4568,9 +4629,11 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l SFREE(lslav); SFREE(ktot); SFREE(ltot); + SFREE(aloc); SFREE(adc); SFREE(auc); SFREE(areaslav); + SFREE(fric); } else if (*mortar == 0) { SFREE(areaslav); } else if (*mortar == 1) { @@ -4720,6 +4783,13 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l } // MPADD end + /* restore node-to-face contact to massless contact for massless + explicit dynamic calculations */ + + if ((*nmethod == 1) && (mortarsav == -1)) { + *mortar = -1; + } + (*ttime) += (*tper); /* Adapter: Free the memory */ From cde18e943774edee11cdaeaa520653f74e2263c7 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Wed, 7 Aug 2024 17:17:02 +0200 Subject: [PATCH 15/55] Re-add functions which read and write modal checkpoints --- adapter/PreciceInterface.c | 34 ++++++++++++++++++++++++++++++++++ adapter/PreciceInterface.h | 19 +++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index a636af64..6a5b6c2a 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -159,6 +159,40 @@ void Precice_WriteIterationCheckpoint(SimulationData *sim, double *v) memcpy(sim->coupling_init_v, v, sizeof(double) * sim->mt * sim->nk); } +void Precice_ReadIterationCheckpointModal(SimulationData *sim, double *dofs, double *derivatives, int nev) +{ + + printf("Adapter reading checkpoint...\n"); + fflush(stdout); + + // Reload time + *(sim->theta) = sim->coupling_init_theta; + + // Reload step size + *(sim->dtheta) = sim->coupling_init_dtheta; + + // Reload DOFs in eigenmodes space & counters + memcpy(dofs, sim->eigenDOFs, sizeof(double) * nev); + memcpy(derivatives, sim->eigenDOFsDerivatives, sizeof(double) * nev); +} + +void Precice_WriteIterationCheckpointModal(SimulationData *sim, const double *dofs, const double *derivatives, int nev) +{ + + printf("Adapter writing checkpoint...\n"); + fflush(stdout); + + // Save time + sim->coupling_init_theta = *(sim->theta); + + // Save step size + sim->coupling_init_dtheta = *(sim->dtheta); + + // Save DOFs in eigenmodes space & counters + memcpy(sim->eigenDOFs, dofs, sizeof(double) * nev); + memcpy(sim->eigenDOFsDerivatives, derivatives, sizeof(double) * nev); +} + void Precice_ReadCouplingData(SimulationData *sim) { diff --git a/adapter/PreciceInterface.h b/adapter/PreciceInterface.h index fbd6bb25..08a34590 100644 --- a/adapter/PreciceInterface.h +++ b/adapter/PreciceInterface.h @@ -141,6 +141,7 @@ typedef struct SimulationData { int nload; char * sideload; double nk; + double ne; // new variable added ITG mt; double *theta; double *dtheta; @@ -236,6 +237,24 @@ void Precice_ReadIterationCheckpoint(SimulationData *sim, double *v); */ void Precice_WriteIterationCheckpoint(SimulationData *sim, double *v); +/** + * @brief Reads iteration checkpoint (in dyna_precice) + * @param sim: Structure with CalculiX data + * @param dofs: array containing the degrees of freedom in eigenspace + * @param derivatives: array containing the time derivatives (velocities) of the dofs + * @param nev: number of eigenvalues used (i.e. array size) + */ +void Precice_ReadIterationCheckpointModal(SimulationData *sim, double *dofs, double *derivatives, int nev); + +/** + * @brief Writes iteration checkpoint + * @param sim: Structure with CalculiX data (in dyna_precice) + * @param dofs: array containing the degrees of freedom in eigenspace + * @param derivatives: array containing the time derivatives (velocities) of the dofs + * @param nev: number of eigenvalues used (i.e. array size) + */ +void Precice_WriteIterationCheckpointModal(SimulationData *sim, const double *dofs, const double *derivatives, int nev); + /** * @brief Reads the coupling data for all interfaces * @param sim From 0c32ca5ba2498ffcbb95ae5854bf75182d2731ce Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Wed, 7 Aug 2024 17:22:17 +0200 Subject: [PATCH 16/55] Apply clang-format to linstatic_precice.c --- linstatic_precice.c | 1556 +++++++++++++++++++++++-------------------- 1 file changed, 830 insertions(+), 726 deletions(-) diff --git a/linstatic_precice.c b/linstatic_precice.c index 301134ce..b4f4a5d1 100644 --- a/linstatic_precice.c +++ b/linstatic_precice.c @@ -7,7 +7,7 @@ /* */ /* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /* GNU General Public License for more details. */ @@ -15,8 +15,8 @@ /* along with this program; if not, write to the Free Software */ /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include #include +#include #include #include "CalculiX.h" #ifdef SPOOLES @@ -38,105 +38,113 @@ /* Adapter: Add header */ #include "adapter/PreciceInterface.h" -void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, - ITG *ne, - ITG *nodeboun,ITG *ndirboun,double *xboun,ITG *nboun, - ITG *ipompc,ITG *nodempc,double *coefmpc,char *labmpc, - ITG *nmpc, - ITG *nodeforc,ITG *ndirforc,double *xforc,ITG *nforc, - ITG *nelemload,char *sideload,double *xload, - ITG *nload,ITG *nactdof, - ITG **icolp,ITG *jq,ITG **irowp,ITG *neq,ITG *nzl, - ITG *nmethod,ITG *ikmpc,ITG *ilmpc,ITG *ikboun, - ITG *ilboun, - double *elcon,ITG *nelcon,double *rhcon,ITG *nrhcon, - double *alcon,ITG *nalcon,double *alzero,ITG **ielmatp, - ITG **ielorienp,ITG *norien,double *orab,ITG *ntmat_, - double *t0,double *t1,double *t1old, - ITG *ithermal,double *prestr,ITG *iprestr, - double *vold,ITG *iperturb,double *sti,ITG *nzs, - ITG *kode,char *filab,double *eme, - ITG *iexpl,double *plicon,ITG *nplicon,double *plkcon, - ITG *nplkcon, - double **xstatep,ITG *npmat_,char *matname,ITG *isolver, - ITG *mi,ITG *ncmat_,ITG *nstate_,double *cs,ITG *mcs, - ITG *nkon,double **enerp,double *xbounold, - double *xforcold,double *xloadold, - char *amname,double *amta,ITG *namta, - ITG *nam,ITG *iamforc,ITG *iamload, - ITG *iamt1,ITG *iamboun,double *ttime,char *output, - char *set,ITG *nset,ITG *istartset, - ITG *iendset,ITG *ialset,ITG *nprint,char *prlab, - char *prset,ITG *nener,double *trab, - ITG *inotr,ITG *ntrans,double *fmpc,ITG *ipobody,ITG *ibody, - double *xbody,ITG *nbody,double *xbodyold,double *timepar, - double *thicke,char *jobnamec,char *tieset,ITG *ntie, - ITG *istep,ITG *nmat,ITG *ielprop,double *prop,char *typeboun, - ITG *mortar,ITG *mpcinfo,double *tietol,ITG *ics, - char *orname,ITG *itempuser,double *t0g,double *t1g, - ITG *jmax, - /* Adapter: Add variables for the participant name and the config file */ - char *preciceParticipantName, char *configFilename){ - - char description[13]=" ",*lakon=NULL,stiffmatrix[132]="", - fneig[132]="",jobnamef[396]="",*labmpc2=NULL; - - ITG *inum=NULL,k,*icol=NULL,*irow=NULL,ielas=0,icmd=0,iinc=1,nasym=0,i,j,ic,ir, - mass[2]={0,0},stiffness=1,buckling=0,rhsi=1,intscheme=0,*ncocon=NULL, - *nshcon=NULL,mode=-1,noddiam=-1,coriolis=0,iout, - *itg=NULL,ntg=0,symmetryflag=0,inputformat=0,ngraph=1,im, - mt=mi[1]+1,ne0,*integerglob=NULL,iglob=0,*ipneigh=NULL,*neigh=NULL, - icfd=0,*inomat=NULL,*islavact=NULL,*islavnode=NULL,*nslavnode=NULL, - *islavsurf=NULL,nretain,*iretain=NULL,*noderetain=NULL,*ndirretain=NULL, - nmethodl,nintpoint,ifacecount,memmpc_,mpcfree,icascade,maxlenmpc, - ncont=0,*itietri=NULL,*koncont=NULL,nslavs=0,ismallsliding=0, - *itiefac=NULL,*imastnode=NULL,*nmastnode=NULL,*imastop=NULL,iitsta, - *iponoels=NULL,*inoels=NULL,*ipe=NULL,*ime=NULL,iit=-1,iflagact=0, - icutb=0,*kon=NULL,*ipkon=NULL,*ielmat=NULL,ialeatoric=0,kscale=1, - *iponoel=NULL,*inoel=NULL,zero=0,nherm=1,nev=*nforc,node,idir, - *ielorien=NULL,network=0,nrhs=1,iperturbsav,mscalmethod=0,*jqw=NULL, - *iroww=NULL,nzsw,*islavelinv=NULL,*irowtloc=NULL,*jqtloc=NULL,nboun2, - *ndirboun2=NULL,*nodeboun2=NULL,nmpc2,*ipompc2=NULL,*nodempc2=NULL, - *ikboun2=NULL,*ilboun2=NULL,*ikmpc2=NULL,*ilmpc2=NULL,mortartrafoflag=0; - - double *stn=NULL,*v=NULL,*een=NULL,cam[5],*xstiff=NULL,*stiini=NULL,*tper, - *f=NULL,*fn=NULL,qa[4],*fext=NULL,*epn=NULL,*xstateini=NULL, - *vini=NULL,*stx=NULL,*enern=NULL,*xbounact=NULL,*xforcact=NULL, - *xloadact=NULL,*t1act=NULL,*ampli=NULL,*xstaten=NULL,*eei=NULL, - *enerini=NULL,*cocon=NULL,*shcon=NULL,*physcon=NULL,*qfx=NULL, - *qfn=NULL,sigma=0.,*cgr=NULL,*xbodyact=NULL,*vr=NULL,*vi=NULL, - *stnr=NULL,*stni=NULL,*vmax=NULL,*stnmax=NULL,*springarea=NULL, - *eenmax=NULL,*fnr=NULL,*fni=NULL,*emn=NULL,*clearini=NULL,ptime, - *emeini=NULL,*doubleglob=NULL,*au=NULL,*ad=NULL,*b=NULL,*aub=NULL, - *adb=NULL,*pslavsurf=NULL,*pmastsurf=NULL,*cdn=NULL,*cdnr=NULL, - *cdni=NULL,*submatrix=NULL,*xnoels=NULL,*cg=NULL,*straight=NULL, - *areaslav=NULL,*xmastnor=NULL,theta=0.,*ener=NULL,*xstate=NULL, - *fnext=NULL,*energyini=NULL,*energy=NULL,*d=NULL,alea=0.1,*smscale=NULL, - *auw=NULL,*autloc=NULL,*xboun2=NULL,*coefmpc2=NULL; - - FILE *f1,*f2; - +void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lakonp, + ITG *ne, + ITG *nodeboun, ITG *ndirboun, double *xboun, ITG *nboun, + ITG *ipompc, ITG *nodempc, double *coefmpc, char *labmpc, + ITG *nmpc, + ITG *nodeforc, ITG *ndirforc, double *xforc, ITG *nforc, + ITG *nelemload, char *sideload, double *xload, + ITG *nload, ITG *nactdof, + ITG **icolp, ITG *jq, ITG **irowp, ITG *neq, ITG *nzl, + ITG *nmethod, ITG *ikmpc, ITG *ilmpc, ITG *ikboun, + ITG *ilboun, + double *elcon, ITG *nelcon, double *rhcon, ITG *nrhcon, + double *alcon, ITG *nalcon, double *alzero, ITG **ielmatp, + ITG **ielorienp, ITG *norien, double *orab, ITG *ntmat_, + double *t0, double *t1, double *t1old, + ITG *ithermal, double *prestr, ITG *iprestr, + double *vold, ITG *iperturb, double *sti, ITG *nzs, + ITG *kode, char *filab, double *eme, + ITG *iexpl, double *plicon, ITG *nplicon, double *plkcon, + ITG *nplkcon, + double **xstatep, ITG *npmat_, char *matname, ITG *isolver, + ITG *mi, ITG *ncmat_, ITG *nstate_, double *cs, ITG *mcs, + ITG *nkon, double **enerp, double *xbounold, + double *xforcold, double *xloadold, + char *amname, double *amta, ITG *namta, + ITG *nam, ITG *iamforc, ITG *iamload, + ITG *iamt1, ITG *iamboun, double *ttime, char *output, + char *set, ITG *nset, ITG *istartset, + ITG *iendset, ITG *ialset, ITG *nprint, char *prlab, + char *prset, ITG *nener, double *trab, + ITG *inotr, ITG *ntrans, double *fmpc, ITG *ipobody, ITG *ibody, + double *xbody, ITG *nbody, double *xbodyold, double *timepar, + double *thicke, char *jobnamec, char *tieset, ITG *ntie, + ITG *istep, ITG *nmat, ITG *ielprop, double *prop, char *typeboun, + ITG *mortar, ITG *mpcinfo, double *tietol, ITG *ics, + char *orname, ITG *itempuser, double *t0g, double *t1g, + ITG *jmax, + /* Adapter: Add variables for the participant name and the config file */ + char *preciceParticipantName, char *configFilename) +{ + + char description[13] = " ", *lakon = NULL, stiffmatrix[132] = "", + fneig[132] = "", jobnamef[396] = "", *labmpc2 = NULL; + + ITG *inum = NULL, k, *icol = NULL, *irow = NULL, ielas = 0, icmd = 0, iinc = 1, nasym = 0, i, j, ic, ir, + mass[2] = {0, 0}, stiffness = 1, buckling = 0, rhsi = 1, intscheme = 0, *ncocon = NULL, + *nshcon = NULL, mode = -1, noddiam = -1, coriolis = 0, iout, + *itg = NULL, ntg = 0, symmetryflag = 0, inputformat = 0, ngraph = 1, im, + mt = mi[1] + 1, ne0, *integerglob = NULL, iglob = 0, *ipneigh = NULL, *neigh = NULL, + icfd = 0, *inomat = NULL, *islavact = NULL, *islavnode = NULL, *nslavnode = NULL, + *islavsurf = NULL, nretain, *iretain = NULL, *noderetain = NULL, *ndirretain = NULL, + nmethodl, nintpoint, ifacecount, memmpc_, mpcfree, icascade, maxlenmpc, + ncont = 0, *itietri = NULL, *koncont = NULL, nslavs = 0, ismallsliding = 0, + *itiefac = NULL, *imastnode = NULL, *nmastnode = NULL, *imastop = NULL, iitsta, + *iponoels = NULL, *inoels = NULL, *ipe = NULL, *ime = NULL, iit = -1, iflagact = 0, + icutb = 0, *kon = NULL, *ipkon = NULL, *ielmat = NULL, ialeatoric = 0, kscale = 1, + *iponoel = NULL, *inoel = NULL, zero = 0, nherm = 1, nev = *nforc, node, idir, + *ielorien = NULL, network = 0, nrhs = 1, iperturbsav, mscalmethod = 0, *jqw = NULL, + *iroww = NULL, nzsw, *islavelinv = NULL, *irowtloc = NULL, *jqtloc = NULL, nboun2, + *ndirboun2 = NULL, *nodeboun2 = NULL, nmpc2, *ipompc2 = NULL, *nodempc2 = NULL, + *ikboun2 = NULL, *ilboun2 = NULL, *ikmpc2 = NULL, *ilmpc2 = NULL, mortartrafoflag = 0; + + double *stn = NULL, *v = NULL, *een = NULL, cam[5], *xstiff = NULL, *stiini = NULL, *tper, + *f = NULL, *fn = NULL, qa[4], *fext = NULL, *epn = NULL, *xstateini = NULL, + *vini = NULL, *stx = NULL, *enern = NULL, *xbounact = NULL, *xforcact = NULL, + *xloadact = NULL, *t1act = NULL, *ampli = NULL, *xstaten = NULL, *eei = NULL, + *enerini = NULL, *cocon = NULL, *shcon = NULL, *physcon = NULL, *qfx = NULL, + *qfn = NULL, sigma = 0., *cgr = NULL, *xbodyact = NULL, *vr = NULL, *vi = NULL, + *stnr = NULL, *stni = NULL, *vmax = NULL, *stnmax = NULL, *springarea = NULL, + *eenmax = NULL, *fnr = NULL, *fni = NULL, *emn = NULL, *clearini = NULL, ptime, + *emeini = NULL, *doubleglob = NULL, *au = NULL, *ad = NULL, *b = NULL, *aub = NULL, + *adb = NULL, *pslavsurf = NULL, *pmastsurf = NULL, *cdn = NULL, *cdnr = NULL, + *cdni = NULL, *submatrix = NULL, *xnoels = NULL, *cg = NULL, *straight = NULL, + *areaslav = NULL, *xmastnor = NULL, theta = 0., *ener = NULL, *xstate = NULL, + *fnext = NULL, *energyini = NULL, *energy = NULL, *d = NULL, alea = 0.1, *smscale = NULL, + *auw = NULL, *autloc = NULL, *xboun2 = NULL, *coefmpc2 = NULL; + + FILE *f1, *f2; + #ifdef SGI ITG token; #endif /* dummy arguments for the results call */ - double *veold=NULL,*accold=NULL,bet,gam,dtime,time,reltime=1.; + double *veold = NULL, *accold = NULL, bet, gam, dtime, time, reltime = 1.; - irow=*irowp;ener=*enerp;xstate=*xstatep;ipkon=*ipkonp;lakon=*lakonp; - kon=*konp;ielmat=*ielmatp;ielorien=*ielorienp;icol=*icolp; - - for(k=0;k<3;k++){ - strcpy1(&jobnamef[k*132],&jobnamec[k*132],132); + irow = *irowp; + ener = *enerp; + xstate = *xstatep; + ipkon = *ipkonp; + lakon = *lakonp; + kon = *konp; + ielmat = *ielmatp; + ielorien = *ielorienp; + icol = *icolp; + + for (k = 0; k < 3; k++) { + strcpy1(&jobnamef[k * 132], &jobnamec[k * 132], 132); } - tper=&timepar[1]; + tper = &timepar[1]; - time=*tper; - dtime=*tper; + time = *tper; + dtime = *tper; - ne0=*ne; + ne0 = *ne; /* preCICE Adapter: Initialize the Calculix data structure */ struct SimulationData simulationData = { @@ -152,7 +160,7 @@ void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, .nset = *nset, .ikboun = ikboun, // .ikforc = ikforc, - .ilboun = ilboun, + .ilboun = ilboun, // .ilforc = ilforc, .nboun = *nboun, .nforc = *nforc, @@ -163,24 +171,24 @@ void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, .nk = *nk, .theta = &theta, // .dtheta = &dtheta, - .tper = tper, - .nmethod = nmethod, - .xload = xload, - .xforc = xforc, - .xboun = xboun, - .ntmat_ = ntmat_, - .vold = vold, - .veold = veold, - .fn = fn, - .cocon = cocon, - .ncocon = ncocon, - .mi = mi, + .tper = tper, + .nmethod = nmethod, + .xload = xload, + .xforc = xforc, + .xboun = xboun, + .ntmat_ = ntmat_, + .vold = vold, + .veold = veold, + .fn = fn, + .cocon = cocon, + .ncocon = ncocon, + .mi = mi, // .eei = &eei, // .stx = &stx, // .xstiff = xstiff - }; + }; - /* preCICE Adapter: Initialize */ + /* preCICE Adapter: Initialize */ Precice_Setup(configFilename, preciceParticipantName, &simulationData); Precice_AdjustSolverTimestep(&simulationData); @@ -191,32 +199,38 @@ void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, iglob=0 if no global results are used by boundary conditions iglob=1 if global results are from a *STATIC calculation */ - ITG irefine=0; - getglobalresults(&jobnamec[396],&integerglob,&doubleglob,nboun,iamboun,xboun, - nload,sideload,iamload,&iglob,nforc,iamforc,xforc, - ithermal,nk,t1,iamt1,&sigma,&irefine); + ITG irefine = 0; + getglobalresults(&jobnamec[396], &integerglob, &doubleglob, nboun, iamboun, xboun, + nload, sideload, iamload, &iglob, nforc, iamforc, xforc, + ithermal, nk, t1, iamt1, &sigma, &irefine); /* reading temperatures from frd-file */ - - if((itempuser[0]==2)&&(itempuser[1]!=itempuser[2])) { - utempread(t1,&itempuser[2],jobnamec); - } + + if ((itempuser[0] == 2) && (itempuser[1] != itempuser[2])) { + utempread(t1, &itempuser[2], jobnamec); + } /* allocating fields for the actual external loading */ - NNEW(xbounact,double,*nboun); - for(k=0;k<*nboun;++k){xbounact[k]=xbounold[k];} - NNEW(xforcact,double,*nforc); - NNEW(xloadact,double,2**nload); - NNEW(xbodyact,double,7**nbody); + NNEW(xbounact, double, *nboun); + for (k = 0; k < *nboun; ++k) { + xbounact[k] = xbounold[k]; + } + NNEW(xforcact, double, *nforc); + NNEW(xloadact, double, 2 * *nload); + NNEW(xbodyact, double, 7 * *nbody); /* copying the rotation axis and/or acceleration vector */ - for(k=0;k<7**nbody;k++){xbodyact[k]=xbody[k];} - if(*ithermal==1){ - NNEW(t1act,double,*nk); - for(k=0;k<*nk;++k){t1act[k]=t1old[k];} + for (k = 0; k < 7 * *nbody; k++) { + xbodyact[k] = xbody[k]; } - - /* assigning the body forces to the elements */ + if (*ithermal == 1) { + NNEW(t1act, double, *nk); + for (k = 0; k < *nk; ++k) { + t1act[k] = t1old[k]; + } + } + + /* assigning the body forces to the elements */ /* if(*nbody>0){ ifreebody=*ne+1; @@ -230,365 +244,372 @@ void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, }*/ /* contact conditions */ - + // if(*icontact==1){ - if(*mortar>-2){ + if (*mortar > -2) { + + memmpc_ = mpcinfo[0]; + mpcfree = mpcinfo[1]; + icascade = mpcinfo[2]; + maxlenmpc = mpcinfo[3]; - memmpc_=mpcinfo[0];mpcfree=mpcinfo[1];icascade=mpcinfo[2]; - maxlenmpc=mpcinfo[3]; + inicont(nk, &ncont, ntie, tieset, nset, set, istartset, iendset, ialset, &itietri, + lakon, ipkon, kon, &koncont, &nslavs, tietol, &ismallsliding, &itiefac, + &islavsurf, &islavnode, &imastnode, &nslavnode, &nmastnode, + mortar, &imastop, nkon, &iponoels, &inoels, &ipe, &ime, ne, &ifacecount, + iperturb, ikboun, nboun, co, istep, &xnoels); - inicont(nk,&ncont,ntie,tieset,nset,set,istartset,iendset,ialset,&itietri, - lakon,ipkon,kon,&koncont,&nslavs,tietol,&ismallsliding,&itiefac, - &islavsurf,&islavnode,&imastnode,&nslavnode,&nmastnode, - mortar,&imastop,nkon,&iponoels,&inoels,&ipe,&ime,ne,&ifacecount, - iperturb,ikboun,nboun,co,istep,&xnoels); + if (ncont != 0) { - if(ncont!=0){ + NNEW(cg, double, 3 * ncont); + NNEW(straight, double, 16 * ncont); - NNEW(cg,double,3*ncont); - NNEW(straight,double,16*ncont); - /* 11 instead of 10: last position is reserved for the - local contact spring element number; needed as - pointer into springarea */ - - if(*mortar==0){ - RENEW(kon,ITG,*nkon+11*nslavs); - NNEW(springarea,double,2*nslavs); - if(*nener==1){ - RENEW(ener,double,2*mi[0]*(*ne+nslavs)); - DMEMSET(ener,2*mi[0]**ne,2*mi[0]*(*ne+nslavs),0.); - } - RENEW(ipkon,ITG,*ne+nslavs); - RENEW(lakon,char,8*(*ne+nslavs)); - - if(*norien>0){ - RENEW(ielorien,ITG,mi[2]*(*ne+nslavs)); - for(k=mi[2]**ne;k0){ - RENEW(ielorien,ITG,mi[2]*(*ne+nintpoint)); - for(k=mi[2]**ne;k 0) { + RENEW(ielorien, ITG, mi[2] * (*ne + nslavs)); + for (k = mi[2] * *ne; k < mi[2] * (*ne + nslavs); k++) + ielorien[k] = 0; + } + + RENEW(ielmat, ITG, mi[2] * (*ne + nslavs)); + for (k = mi[2] * *ne; k < mi[2] * (*ne + nslavs); k++) + ielmat[k] = 1; + + if (nslavs != 0) { + RENEW(xstate, double, *nstate_ *mi[0] * (*ne + nslavs)); + for (k = *nstate_ * mi[0] * *ne; k < *nstate_ * mi[0] * (*ne + nslavs); k++) { + xstate[k] = 0.; + } + } + + NNEW(areaslav, double, ifacecount); + NNEW(xmastnor, double, 3 * nmastnode[*ntie]); + } else if (*mortar == 1) { + NNEW(islavact, ITG, nslavnode[*ntie]); + DMEMSET(islavact, 0, nslavnode[*ntie], 1); + NNEW(clearini, double, 3 * 9 * ifacecount); + NNEW(xmastnor, double, 3 * nmastnode[*ntie]); + + nintpoint = 0; + + precontact(&ncont, ntie, tieset, nset, set, istartset, + iendset, ialset, itietri, lakon, ipkon, kon, koncont, ne, + cg, straight, co, vold, istep, &iinc, &iit, itiefac, + islavsurf, islavnode, imastnode, nslavnode, nmastnode, + imastop, mi, ipe, ime, tietol, &iflagact, + &nintpoint, &pslavsurf, xmastnor, cs, mcs, ics, clearini, + &nslavs); + + /* changing the dimension of element-related fields */ + + RENEW(kon, ITG, *nkon + 22 * nintpoint); + RENEW(springarea, double, 2 * nintpoint); + RENEW(pmastsurf, double, 6 * nintpoint); + + if (*nener == 1) { + RENEW(ener, double, 2 * mi[0] * (*ne + nintpoint)); + DMEMSET(ener, 2 * mi[0] * *ne, 2 * mi[0] * (*ne + nintpoint), 0.); + } + RENEW(ipkon, ITG, *ne + nintpoint); + RENEW(lakon, char, 8 * (*ne + nintpoint)); + + if (*norien > 0) { + RENEW(ielorien, ITG, mi[2] * (*ne + nintpoint)); + for (k = mi[2] * *ne; k < mi[2] * (*ne + nintpoint); k++) + ielorien[k] = 0; + } + RENEW(ielmat, ITG, mi[2] * (*ne + nintpoint)); + for (k = mi[2] * *ne; k < mi[2] * (*ne + nintpoint); k++) + ielmat[k] = 1; + + /* interpolating the state variables */ + + if (*nstate_ != 0) { + + RENEW(xstate, double, *nstate_ *mi[0] * (ne0 + nintpoint)); + for (k = *nstate_ * mi[0] * ne0; k < *nstate_ * mi[0] * (ne0 + nintpoint); k++) { + xstate[k] = 0.; + } + + RENEW(xstateini, double, *nstate_ *mi[0] * (ne0 + nintpoint)); + for (k = 0; k < *nstate_ * mi[0] * (ne0 + nintpoint); ++k) { + xstateini[k] = xstate[k]; + } + } } - + /* generating contact spring elements */ - contact(&ncont,ntie,tieset,nset,set,istartset,iendset, - ialset,itietri,lakon,ipkon,kon,koncont,ne,cg,straight,nkon, - co,vold,ielmat,cs,elcon,istep,&iinc,&iit,ncmat_,ntmat_, - &ne0,nmethod, - iperturb,ikboun,nboun,mi,imastop,nslavnode,islavnode,islavsurf, - itiefac,areaslav,iponoels,inoels,springarea,tietol,&reltime, - imastnode,nmastnode,xmastnor,filab,mcs,ics,&nasym, - xnoels,mortar,pslavsurf,pmastsurf,clearini,&theta, - xstateini,xstate,nstate_,&icutb,&ialeatoric,jobnamef, - &alea,auw,jqw,iroww,&nzsw); - - printf("number of contact spring elements=%" ITGFORMAT "\n\n",*ne-ne0); - + contact(&ncont, ntie, tieset, nset, set, istartset, iendset, + ialset, itietri, lakon, ipkon, kon, koncont, ne, cg, straight, nkon, + co, vold, ielmat, cs, elcon, istep, &iinc, &iit, ncmat_, ntmat_, + &ne0, nmethod, + iperturb, ikboun, nboun, mi, imastop, nslavnode, islavnode, islavsurf, + itiefac, areaslav, iponoels, inoels, springarea, tietol, &reltime, + imastnode, nmastnode, xmastnor, filab, mcs, ics, &nasym, + xnoels, mortar, pslavsurf, pmastsurf, clearini, &theta, + xstateini, xstate, nstate_, &icutb, &ialeatoric, jobnamef, + &alea, auw, jqw, iroww, &nzsw); + + printf("number of contact spring elements=%" ITGFORMAT "\n\n", *ne - ne0); + /* determining the structure of the stiffness/mass matrix */ - - remastructar(ipompc,&coefmpc,&nodempc,nmpc, - &mpcfree,nodeboun,ndirboun,nboun,ikmpc,ilmpc,ikboun,ilboun, - labmpc,nk,&memmpc_,&icascade,&maxlenmpc, - kon,ipkon,lakon,ne,nactdof,icol,jq,&irow,isolver, - neq,nzs,nmethod,ithermal,iperturb,mass,mi,ics,cs, - mcs,mortar,typeboun,&iit,&network,iexpl); + + remastructar(ipompc, &coefmpc, &nodempc, nmpc, + &mpcfree, nodeboun, ndirboun, nboun, ikmpc, ilmpc, ikboun, ilboun, + labmpc, nk, &memmpc_, &icascade, &maxlenmpc, + kon, ipkon, lakon, ne, nactdof, icol, jq, &irow, isolver, + neq, nzs, nmethod, ithermal, iperturb, mass, mi, ics, cs, + mcs, mortar, typeboun, &iit, &network, iexpl); } /* field for initial values of state variables (needed for contact */ - if((*nstate_!=0)&&((*mortar==0)||(ncont==0))){ - NNEW(xstateini,double,*nstate_*mi[0]*(ne0+nslavs)); - for(k=0;k<*nstate_*mi[0]*(ne0+nslavs);++k){ - xstateini[k]=xstate[k]; + if ((*nstate_ != 0) && ((*mortar == 0) || (ncont == 0))) { + NNEW(xstateini, double, *nstate_ *mi[0] * (ne0 + nslavs)); + for (k = 0; k < *nstate_ * mi[0] * (ne0 + nslavs); ++k) { + xstateini[k] = xstate[k]; } } } /* allocating a field for the instantaneous amplitude */ - NNEW(ampli,double,*nam); - - FORTRAN(tempload,(xforcold,xforc,xforcact,iamforc,nforc,xloadold,xload, - xloadact,iamload,nload,ibody,xbody,nbody,xbodyold,xbodyact, - t1old,t1,t1act,iamt1,nk,amta, - namta,nam,ampli,&time,&reltime,ttime,&dtime,ithermal,nmethod, - xbounold,xboun,xbounact,iamboun,nboun, - nodeboun,ndirboun,nodeforc,ndirforc,istep,&iinc, - co,vold,itg,&ntg,amname,ikboun,ilboun,nelemload,sideload,mi, - ntrans,trab,inotr,veold,integerglob,doubleglob,tieset,istartset, - iendset,ialset,ntie,nmpc,ipompc,ikmpc,ilmpc,nodempc,coefmpc, - ipobody,iponoel,inoel,ipkon,kon,ielprop,prop,ielmat, - shcon,nshcon,rhcon,nrhcon,cocon,ncocon,ntmat_,lakon, - set,nset)); + NNEW(ampli, double, *nam); + + FORTRAN(tempload, (xforcold, xforc, xforcact, iamforc, nforc, xloadold, xload, + xloadact, iamload, nload, ibody, xbody, nbody, xbodyold, xbodyact, + t1old, t1, t1act, iamt1, nk, amta, + namta, nam, ampli, &time, &reltime, ttime, &dtime, ithermal, nmethod, + xbounold, xboun, xbounact, iamboun, nboun, + nodeboun, ndirboun, nodeforc, ndirforc, istep, &iinc, + co, vold, itg, &ntg, amname, ikboun, ilboun, nelemload, sideload, mi, + ntrans, trab, inotr, veold, integerglob, doubleglob, tieset, istartset, + iendset, ialset, ntie, nmpc, ipompc, ikmpc, ilmpc, nodempc, coefmpc, + ipobody, iponoel, inoel, ipkon, kon, ielprop, prop, ielmat, + shcon, nshcon, rhcon, nrhcon, cocon, ncocon, ntmat_, lakon, + set, nset)); /* determining the internal forces and the stiffness coefficients */ - NNEW(f,double,*neq); + NNEW(f, double, *neq); /* allocating a field for the stiffness matrix */ - NNEW(xstiff,double,(long long)27*mi[0]**ne); + NNEW(xstiff, double, (long long) 27 * mi[0] * *ne); /* for a *STATIC,PERTURBATION analysis with submodel boundary conditions from a *FREQUENCY analysis iperturb[0]=1 has to be temporarily set to iperturb[0]=0 in order for f to be calculated in resultsini and subsequent results* routines */ - if((*nmethod==1)&&(iglob<0)&&(iperturb[0]>0)){ - iperturbsav=iperturb[0]; - iperturb[0]=0; + if ((*nmethod == 1) && (iglob < 0) && (iperturb[0] > 0)) { + iperturbsav = iperturb[0]; + iperturb[0] = 0; } - iout=-1; - NNEW(v,double,mt**nk); - NNEW(fn,double,mt**nk); - NNEW(stx,double,6*mi[0]**ne); - NNEW(inum,ITG,*nk); - NNEW(eei,double,6*mi[0]**ne); - results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, - elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, - ielorien,norien,orab,ntmat_,t0,t1act,ithermal, - prestr,iprestr,filab,eme,emn,een,iperturb, - f,fn,nactdof,&iout,qa,vold,b,nodeboun, - ndirboun,xbounact,nboun,ipompc, - nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold,accold, - &bet,&gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, - xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas, - &icmd,ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern, - emeini,xstaten,eei,enerini,cocon,ncocon,set,nset,istartset, - iendset,ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans, - fmpc,nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea, - &reltime,&ne0,thicke,shcon,nshcon, - sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, - mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, - islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, - inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, - itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, - islavelinv,autloc,irowtloc,jqtloc,&nboun2, - ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, - labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, - &intscheme); - + iout = -1; + NNEW(v, double, mt **nk); + NNEW(fn, double, mt **nk); + NNEW(stx, double, 6 * mi[0] * *ne); + NNEW(inum, ITG, *nk); + NNEW(eei, double, 6 * mi[0] * *ne); + results(co, nk, kon, ipkon, lakon, ne, v, stn, inum, stx, + elcon, nelcon, rhcon, nrhcon, alcon, nalcon, alzero, ielmat, + ielorien, norien, orab, ntmat_, t0, t1act, ithermal, + prestr, iprestr, filab, eme, emn, een, iperturb, + f, fn, nactdof, &iout, qa, vold, b, nodeboun, + ndirboun, xbounact, nboun, ipompc, + nodempc, coefmpc, labmpc, nmpc, nmethod, cam, neq, veold, accold, + &bet, &gam, &dtime, &time, ttime, plicon, nplicon, plkcon, nplkcon, + xstateini, xstiff, xstate, npmat_, epn, matname, mi, &ielas, + &icmd, ncmat_, nstate_, stiini, vini, ikboun, ilboun, ener, enern, + emeini, xstaten, eei, enerini, cocon, ncocon, set, nset, istartset, + iendset, ialset, nprint, prlab, prset, qfx, qfn, trab, inotr, ntrans, + fmpc, nelemload, nload, ikmpc, ilmpc, istep, &iinc, springarea, + &reltime, &ne0, thicke, shcon, nshcon, + sideload, xloadact, xloadold, &icfd, inomat, pslavsurf, pmastsurf, + mortar, islavact, cdn, islavnode, nslavnode, ntie, clearini, + islavsurf, ielprop, prop, energyini, energy, &kscale, iponoel, + inoel, nener, orname, &network, ipobody, xbodyact, ibody, typeboun, + itiefac, tieset, smscale, &mscalmethod, nbody, t0g, t1g, + islavelinv, autloc, irowtloc, jqtloc, &nboun2, + ndirboun2, nodeboun2, xboun2, &nmpc2, ipompc2, nodempc2, coefmpc2, + labmpc2, ikboun2, ilboun2, ikmpc2, ilmpc2, &mortartrafoflag, + &intscheme); /* preCICE Adapter: Multiscale checkpoint*/ simulationData.xstiff = &xstiff; - simulationData.eei = &eei; - simulationData.stx = &stx; + simulationData.eei = &eei; + simulationData.stx = &stx; PreciceInterface_MultiscaleCheckpoint(&simulationData); - - SFREE(v);SFREE(fn);SFREE(stx);SFREE(inum); SFREE(eei); - iout=1; - if((*nmethod==1)&&(iglob<0)&&(iperturb[0]>0)){ - iperturb[0]=iperturbsav; + SFREE(v); + SFREE(fn); + SFREE(stx); + SFREE(inum); + SFREE(eei); + iout = 1; + + if ((*nmethod == 1) && (iglob < 0) && (iperturb[0] > 0)) { + iperturb[0] = iperturbsav; } - + /* determining the system matrix and the external forces */ - NNEW(ad,double,*neq); - NNEW(fext,double,*neq); + NNEW(ad, double, *neq); + NNEW(fext, double, *neq); + + if (*nmethod == 11) { - if(*nmethod==11){ - /* determining the nodes and the degrees of freedom in those nodes belonging to the substructure */ - - NNEW(iretain,ITG,*nk); - NNEW(noderetain,ITG,*nk); - NNEW(ndirretain,ITG,*nk); - nretain=0; - - for(i=0;i<*nboun;i++){ - if(strcmp1(&typeboun[i],"C")==0){ - iretain[nretain]=i+1; - noderetain[nretain]=nodeboun[i]; - ndirretain[nretain]=ndirboun[i]; - nretain++; + + NNEW(iretain, ITG, *nk); + NNEW(noderetain, ITG, *nk); + NNEW(ndirretain, ITG, *nk); + nretain = 0; + + for (i = 0; i < *nboun; i++) { + if (strcmp1(&typeboun[i], "C") == 0) { + iretain[nretain] = i + 1; + noderetain[nretain] = nodeboun[i]; + ndirretain[nretain] = ndirboun[i]; + nretain++; } } - + /* nretain!=0: substructure application */ - - RENEW(iretain,ITG,nretain); - RENEW(noderetain,ITG,nretain); - RENEW(ndirretain,ITG,nretain); - + + RENEW(iretain, ITG, nretain); + RENEW(noderetain, ITG, nretain); + RENEW(ndirretain, ITG, nretain); + /* creating the right size au */ - NNEW(au,double,nzs[2]); - rhsi=0; - nmethodl=2; + NNEW(au, double, nzs[2]); + rhsi = 0; + nmethodl = 2; - }else{ + } else { /* linear static calculation */ - NNEW(au,double,*nzs); - nmethodl=*nmethod; + NNEW(au, double, *nzs); + nmethodl = *nmethod; /* if submodel calculation with a global model obtained by a *FREQUENCY calculation: replace stiffness matrix K by K-sigma*M */ - if(iglob<0){ - mass[0]=1; - NNEW(adb,double,*neq); - NNEW(aub,double,nzs[1]); + if (iglob < 0) { + mass[0] = 1; + NNEW(adb, double, *neq); + NNEW(aub, double, nzs[1]); } - } - mafillsmmain(co,nk,kon,ipkon,lakon,ne,nodeboun,ndirboun,xbounact,nboun, - ipompc,nodempc,coefmpc,nmpc,nodeforc,ndirforc,xforcact, - nforc,nelemload,sideload,xloadact,nload,xbodyact,ipobody, - nbody,cgr,ad,au,fext,nactdof,icol,jq,irow,neq,nzl,&nmethodl, - ikmpc,ilmpc,ikboun,ilboun, - elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, - ielorien,norien,orab,ntmat_, - t0,t1act,ithermal,prestr,iprestr,vold,iperturb,sti, - nzs,stx,adb,aub,iexpl,plicon,nplicon,plkcon,nplkcon, - xstiff,npmat_,&dtime,matname,mi, - ncmat_,mass,&stiffness,&buckling,&rhsi,&intscheme,physcon, - shcon,nshcon,cocon,ncocon,ttime,&time,istep,&iinc,&coriolis, - ibody,xloadold,&reltime,veold,springarea,nstate_, - xstateini,xstate,thicke,integerglob,doubleglob, - tieset,istartset,iendset,ialset,ntie,&nasym,pslavsurf, - pmastsurf,mortar,clearini,ielprop,prop,&ne0,fnext,&kscale, - iponoel,inoel,&network,ntrans,inotr,trab,smscale,&mscalmethod, - set,nset,islavelinv,autloc,irowtloc,jqtloc,&mortartrafoflag); + mafillsmmain(co, nk, kon, ipkon, lakon, ne, nodeboun, ndirboun, xbounact, nboun, + ipompc, nodempc, coefmpc, nmpc, nodeforc, ndirforc, xforcact, + nforc, nelemload, sideload, xloadact, nload, xbodyact, ipobody, + nbody, cgr, ad, au, fext, nactdof, icol, jq, irow, neq, nzl, &nmethodl, + ikmpc, ilmpc, ikboun, ilboun, + elcon, nelcon, rhcon, nrhcon, alcon, nalcon, alzero, ielmat, + ielorien, norien, orab, ntmat_, + t0, t1act, ithermal, prestr, iprestr, vold, iperturb, sti, + nzs, stx, adb, aub, iexpl, plicon, nplicon, plkcon, nplkcon, + xstiff, npmat_, &dtime, matname, mi, + ncmat_, mass, &stiffness, &buckling, &rhsi, &intscheme, physcon, + shcon, nshcon, cocon, ncocon, ttime, &time, istep, &iinc, &coriolis, + ibody, xloadold, &reltime, veold, springarea, nstate_, + xstateini, xstate, thicke, integerglob, doubleglob, + tieset, istartset, iendset, ialset, ntie, &nasym, pslavsurf, + pmastsurf, mortar, clearini, ielprop, prop, &ne0, fnext, &kscale, + iponoel, inoel, &network, ntrans, inotr, trab, smscale, &mscalmethod, + set, nset, islavelinv, autloc, irowtloc, jqtloc, &mortartrafoflag); /* check for negative Jacobians */ - if(nmethodl==0) *nmethod=0; - - if(nasym==1){ - RENEW(au,double,2*nzs[1]); - symmetryflag=2; - inputformat=1; - - mafillsmasmain(co,nk,kon,ipkon,lakon,ne,nodeboun, - ndirboun,xbounact,nboun, - ipompc,nodempc,coefmpc,nmpc,nodeforc,ndirforc,xforcact, - nforc,nelemload,sideload,xloadact,nload,xbodyact,ipobody, - nbody,cgr,ad,au,fext,nactdof,icol,jq,irow,neq,nzl, - nmethod,ikmpc,ilmpc,ikboun,ilboun, - elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero, - ielmat,ielorien,norien,orab,ntmat_, - t0,t1act,ithermal,prestr,iprestr,vold,iperturb,sti, - nzs,stx,adb,aub,iexpl,plicon,nplicon,plkcon,nplkcon, - xstiff,npmat_,&dtime,matname,mi, - ncmat_,mass,&stiffness,&buckling,&rhsi,&intscheme, - physcon,shcon,nshcon,cocon,ncocon,ttime,&time,istep,&iinc, - &coriolis,ibody,xloadold,&reltime,veold,springarea,nstate_, - xstateini,xstate,thicke, - integerglob,doubleglob,tieset,istartset,iendset, - ialset,ntie,&nasym,pslavsurf,pmastsurf,mortar,clearini, - ielprop,prop,&ne0,&kscale,iponoel,inoel,&network,set,nset); + if (nmethodl == 0) + *nmethod = 0; + + if (nasym == 1) { + RENEW(au, double, 2 * nzs[1]); + symmetryflag = 2; + inputformat = 1; + + mafillsmasmain(co, nk, kon, ipkon, lakon, ne, nodeboun, + ndirboun, xbounact, nboun, + ipompc, nodempc, coefmpc, nmpc, nodeforc, ndirforc, xforcact, + nforc, nelemload, sideload, xloadact, nload, xbodyact, ipobody, + nbody, cgr, ad, au, fext, nactdof, icol, jq, irow, neq, nzl, + nmethod, ikmpc, ilmpc, ikboun, ilboun, + elcon, nelcon, rhcon, nrhcon, alcon, nalcon, alzero, + ielmat, ielorien, norien, orab, ntmat_, + t0, t1act, ithermal, prestr, iprestr, vold, iperturb, sti, + nzs, stx, adb, aub, iexpl, plicon, nplicon, plkcon, nplkcon, + xstiff, npmat_, &dtime, matname, mi, + ncmat_, mass, &stiffness, &buckling, &rhsi, &intscheme, + physcon, shcon, nshcon, cocon, ncocon, ttime, &time, istep, &iinc, + &coriolis, ibody, xloadold, &reltime, veold, springarea, nstate_, + xstateini, xstate, thicke, + integerglob, doubleglob, tieset, istartset, iendset, + ialset, ntie, &nasym, pslavsurf, pmastsurf, mortar, clearini, + ielprop, prop, &ne0, &kscale, iponoel, inoel, &network, set, nset); } /* determining the right hand side */ - NNEW(b,double,*neq); - for(k=0;k<*neq;++k){ - b[k]=fext[k]-f[k]; + NNEW(b, double, *neq); + for (k = 0; k < *neq; ++k) { + b[k] = fext[k] - f[k]; } - SFREE(fext);SFREE(f); + SFREE(fext); + SFREE(f); /* generation of a substructure stiffness matrix */ - if(*nmethod==11){ + if (*nmethod == 11) { /* factorizing the matrix */ - if(*neq>0){ - if(*isolver==0){ + if (*neq > 0) { + if (*isolver == 0) { #ifdef SPOOLES - spooles_factor(ad,au,adb,aub,&sigma,icol,irow,neq,nzs,&symmetryflag, - &inputformat,&nzs[2]); + spooles_factor(ad, au, adb, aub, &sigma, icol, irow, neq, nzs, &symmetryflag, + &inputformat, &nzs[2]); #else - printf(" *ERROR in linstatic: the SPOOLES library is not linked\n\n"); - FORTRAN(stop,()); + printf(" *ERROR in linstatic: the SPOOLES library is not linked\n\n"); + FORTRAN(stop, ()); #endif - } - else if(*isolver==7){ + } else if (*isolver == 7) { #ifdef PARDISO - pardiso_factor(ad,au,adb,aub,&sigma,icol,irow,neq,nzs, - &symmetryflag,&inputformat,jq,&nzs[2]); + pardiso_factor(ad, au, adb, aub, &sigma, icol, irow, neq, nzs, + &symmetryflag, &inputformat, jq, &nzs[2]); #else - printf(" *ERROR in linstatic: the PARDISO library is not linked\n\n"); - FORTRAN(stop,()); + printf(" *ERROR in linstatic: the PARDISO library is not linked\n\n"); + FORTRAN(stop, ()); #endif - } - else if(*isolver==8){ + } else if (*isolver == 8) { #ifdef PASTIX - pastix_factor_main(ad,au,adb,aub,&sigma,icol,irow,neq,nzs, - &symmetryflag,&inputformat,jq,&nzs[2]); + pastix_factor_main(ad, au, adb, aub, &sigma, icol, irow, neq, nzs, + &symmetryflag, &inputformat, jq, &nzs[2]); #else - printf(" *ERROR in linstatic: the PASTIX library is not linked\n\n"); - FORTRAN(stop,()); + printf(" *ERROR in linstatic: the PASTIX library is not linked\n\n"); + FORTRAN(stop, ()); #endif } } @@ -597,444 +618,527 @@ void linstatic_precice(double *co,ITG *nk,ITG **konp,ITG **ipkonp,char **lakonp, /* substructure calculations */ - NNEW(submatrix,double,nretain*nretain); - - for(i=0;i0){ - if(*isolver==0){ + + if (*neq > 0) { + if (*isolver == 0) { #ifdef SPOOLES - spooles_solve(b,neq); + spooles_solve(b, neq); #endif - } - else if(*isolver==7){ + } else if (*isolver == 7) { #ifdef PARDISO - pardiso_solve(b,neq,&symmetryflag,&inputformat,&nrhs); + pardiso_solve(b, neq, &symmetryflag, &inputformat, &nrhs); #endif - - } - else if(*isolver==8){ + + } else if (*isolver == 8) { #ifdef PASTIX - pastix_solve(b,neq,&symmetryflag,&nrhs); + pastix_solve(b, neq, &symmetryflag, &nrhs); #endif - - } + } } - + /* calculating the internal forces */ - - NNEW(v,double,mt**nk); - NNEW(fn,double,mt**nk); - NNEW(stn,double,6**nk); - NNEW(inum,ITG,*nk); - NNEW(stx,double,6*mi[0]**ne); - - if(strcmp1(&filab[261],"E ")==0) NNEW(een,double,6**nk); - if(strcmp1(&filab[2697],"ME ")==0) NNEW(emn,double,6**nk); - if(strcmp1(&filab[522],"ENER")==0) NNEW(enern,double,*nk); - - NNEW(eei,double,6*mi[0]**ne); - if(*nener==1){ - NNEW(stiini,double,6*mi[0]**ne); - NNEW(emeini,double,6*mi[0]**ne); - NNEW(enerini,double,2*mi[0]**ne);} - + + NNEW(v, double, mt **nk); + NNEW(fn, double, mt **nk); + NNEW(stn, double, 6 * *nk); + NNEW(inum, ITG, *nk); + NNEW(stx, double, 6 * mi[0] * *ne); + + if (strcmp1(&filab[261], "E ") == 0) + NNEW(een, double, 6 * *nk); + if (strcmp1(&filab[2697], "ME ") == 0) + NNEW(emn, double, 6 * *nk); + if (strcmp1(&filab[522], "ENER") == 0) + NNEW(enern, double, *nk); + + NNEW(eei, double, 6 * mi[0] * *ne); + if (*nener == 1) { + NNEW(stiini, double, 6 * mi[0] * *ne); + NNEW(emeini, double, 6 * mi[0] * *ne); + NNEW(enerini, double, 2 * mi[0] * *ne); + } + /* replacing the appropriate boundary value by unity */ - - xbounact[iretain[i]-1]=1.; - - results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, - elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, - ielorien,norien,orab,ntmat_,t0,t1act,ithermal, - prestr,iprestr,filab,eme,emn,een,iperturb, - f,fn,nactdof,&iout,qa,vold,b,nodeboun,ndirboun, - xbounact,nboun,ipompc, - nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold, - accold,&bet, - &gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, - xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas,&icmd, - ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern,emeini, - xstaten,eei,enerini,cocon,ncocon,set,nset,istartset,iendset, - ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans,fmpc, - nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea,&reltime, - &ne0,thicke,shcon,nshcon, - sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, - mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, - islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, - inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, - itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, - islavelinv,autloc,irowtloc,jqtloc,&nboun2, - ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, - labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, - &intscheme); - - xbounact[iretain[i]-1]=0.; - - SFREE(v);SFREE(stn);SFREE(inum);SFREE(stx); - - if(strcmp1(&filab[261],"E ")==0) SFREE(een); - if(strcmp1(&filab[2697],"ME ")==0) SFREE(emn); - if(strcmp1(&filab[522],"ENER")==0) SFREE(enern); - - SFREE(eei);if(*nener==1){SFREE(stiini);SFREE(emeini);SFREE(enerini);} - + + xbounact[iretain[i] - 1] = 1.; + + results(co, nk, kon, ipkon, lakon, ne, v, stn, inum, stx, + elcon, nelcon, rhcon, nrhcon, alcon, nalcon, alzero, ielmat, + ielorien, norien, orab, ntmat_, t0, t1act, ithermal, + prestr, iprestr, filab, eme, emn, een, iperturb, + f, fn, nactdof, &iout, qa, vold, b, nodeboun, ndirboun, + xbounact, nboun, ipompc, + nodempc, coefmpc, labmpc, nmpc, nmethod, cam, neq, veold, + accold, &bet, + &gam, &dtime, &time, ttime, plicon, nplicon, plkcon, nplkcon, + xstateini, xstiff, xstate, npmat_, epn, matname, mi, &ielas, &icmd, + ncmat_, nstate_, stiini, vini, ikboun, ilboun, ener, enern, emeini, + xstaten, eei, enerini, cocon, ncocon, set, nset, istartset, iendset, + ialset, nprint, prlab, prset, qfx, qfn, trab, inotr, ntrans, fmpc, + nelemload, nload, ikmpc, ilmpc, istep, &iinc, springarea, &reltime, + &ne0, thicke, shcon, nshcon, + sideload, xloadact, xloadold, &icfd, inomat, pslavsurf, pmastsurf, + mortar, islavact, cdn, islavnode, nslavnode, ntie, clearini, + islavsurf, ielprop, prop, energyini, energy, &kscale, iponoel, + inoel, nener, orname, &network, ipobody, xbodyact, ibody, typeboun, + itiefac, tieset, smscale, &mscalmethod, nbody, t0g, t1g, + islavelinv, autloc, irowtloc, jqtloc, &nboun2, + ndirboun2, nodeboun2, xboun2, &nmpc2, ipompc2, nodempc2, coefmpc2, + labmpc2, ikboun2, ilboun2, ikmpc2, ilmpc2, &mortartrafoflag, + &intscheme); + + xbounact[iretain[i] - 1] = 0.; + + SFREE(v); + SFREE(stn); + SFREE(inum); + SFREE(stx); + + if (strcmp1(&filab[261], "E ") == 0) + SFREE(een); + if (strcmp1(&filab[2697], "ME ") == 0) + SFREE(emn); + if (strcmp1(&filab[522], "ENER") == 0) + SFREE(enern); + + SFREE(eei); + if (*nener == 1) { + SFREE(stiini); + SFREE(emeini); + SFREE(enerini); + } + /* storing the internal forces in the substructure - stiffness matrix */ - - for(j=0;j0){ - if(*isolver==0){ + + if (*neq > 0) { + if (*isolver == 0) { #ifdef SPOOLES - spooles_cleanup(); + spooles_cleanup(); #endif - } - else if(*isolver==7){ + } else if (*isolver == 7) { #ifdef PARDISO - pardiso_cleanup(&neq[0],&symmetryflag,&inputformat); + pardiso_cleanup(&neq[0], &symmetryflag, &inputformat); #endif - } - else if(*isolver==8){ + } else if (*isolver == 8) { #ifdef PASTIX #endif } } - + SFREE(iretain); - - FORTRAN(writesubmatrix,(submatrix,noderetain,ndirretain,&nretain,jobnamec)); - - SFREE(submatrix);SFREE(noderetain);SFREE(ndirretain); - - SFREE(au);SFREE(ad);SFREE(b); - - SFREE(xbounact);SFREE(xforcact);SFREE(xloadact);SFREE(t1act);SFREE(ampli); + + FORTRAN(writesubmatrix, (submatrix, noderetain, ndirretain, &nretain, jobnamec)); + + SFREE(submatrix); + SFREE(noderetain); + SFREE(ndirretain); + + SFREE(au); + SFREE(ad); + SFREE(b); + + SFREE(xbounact); + SFREE(xforcact); + SFREE(xloadact); + SFREE(t1act); + SFREE(ampli); SFREE(xbodyact); // if(*nbody>0) SFREE(ipobody); SFREE(xstiff); - - if(iglob!=0){SFREE(integerglob);SFREE(doubleglob);} - - return; + if (iglob != 0) { + SFREE(integerglob); + SFREE(doubleglob); + } - }else if(*nmethod!=0){ + return; + + } else if (*nmethod != 0) { /* linear static applications */ - if(*isolver==0){ + if (*isolver == 0) { #ifdef SPOOLES - spooles(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs,&symmetryflag, - &inputformat,&nzs[2]); + spooles(ad, au, adb, aub, &sigma, b, icol, irow, neq, nzs, &symmetryflag, + &inputformat, &nzs[2]); #else printf(" *ERROR in linstatic: the SPOOLES library is not linked\n\n"); - FORTRAN(stop,()); + FORTRAN(stop, ()); #endif - } - else if((*isolver==2)||(*isolver==3)){ - if(nasym>0){ - printf(" *ERROR in nonlingeo: the iterative solver cannot be used for asymmetric matrices\n\n"); - FORTRAN(stop,()); + } else if ((*isolver == 2) || (*isolver == 3)) { + if (nasym > 0) { + printf(" *ERROR in nonlingeo: the iterative solver cannot be used for asymmetric matrices\n\n"); + FORTRAN(stop, ()); } - preiter(ad,&au,b,&icol,&irow,neq,nzs,isolver,iperturb); - } - else if(*isolver==4){ + preiter(ad, &au, b, &icol, &irow, neq, nzs, isolver, iperturb); + } else if (*isolver == 4) { #ifdef SGI - if(nasym>0){ - printf(" *ERROR in nonlingeo: the SGI solver cannot be used for asymmetric matrices\n\n"); - FORTRAN(stop,()); + if (nasym > 0) { + printf(" *ERROR in nonlingeo: the SGI solver cannot be used for asymmetric matrices\n\n"); + FORTRAN(stop, ()); } - token=1; - sgi_main(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs,token); + token = 1; + sgi_main(ad, au, adb, aub, &sigma, b, icol, irow, neq, nzs, token); #else printf(" *ERROR in linstatic: the SGI library is not linked\n\n"); - FORTRAN(stop,()); + FORTRAN(stop, ()); #endif - } - else if(*isolver==5){ + } else if (*isolver == 5) { #ifdef TAUCS - if(nasym>0){ - printf(" *ERROR in nonlingeo: the TAUCS solver cannot be used for asymmetric matrices\n\n"); - FORTRAN(stop,()); + if (nasym > 0) { + printf(" *ERROR in nonlingeo: the TAUCS solver cannot be used for asymmetric matrices\n\n"); + FORTRAN(stop, ()); } - tau(ad,&au,adb,aub,&sigma,b,icol,&irow,neq,nzs); + tau(ad, &au, adb, aub, &sigma, b, icol, &irow, neq, nzs); #else printf(" *ERROR in linstatic: the TAUCS library is not linked\n\n"); - FORTRAN(stop,()); + FORTRAN(stop, ()); #endif - } - else if(*isolver==7){ + } else if (*isolver == 7) { #ifdef PARDISO - pardiso_main(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs, - &symmetryflag,&inputformat,jq,&nzs[2],&nrhs); + pardiso_main(ad, au, adb, aub, &sigma, b, icol, irow, neq, nzs, + &symmetryflag, &inputformat, jq, &nzs[2], &nrhs); #else printf(" *ERROR in linstatic: the PARDISO library is not linked\n\n"); - FORTRAN(stop,()); + FORTRAN(stop, ()); #endif - } - else if(*isolver==8){ + } else if (*isolver == 8) { #ifdef PASTIX - pastix_main(ad,au,adb,aub,&sigma,b,icol,irow,neq,nzs, - &symmetryflag,&inputformat,jq,&nzs[2],&nrhs); + pastix_main(ad, au, adb, aub, &sigma, b, icol, irow, neq, nzs, + &symmetryflag, &inputformat, jq, &nzs[2], &nrhs); #else printf(" *ERROR in linstatic: the PASTIX library is not linked\n\n"); - FORTRAN(stop,()); + FORTRAN(stop, ()); #endif } /* saving of ad and au for sensitivity analysis */ - for(i=0;i<*ntie;i++){ - if(strcmp1(&tieset[i*243+80],"D")==0){ - - strcpy2(stiffmatrix,jobnamec,132); - strcat(stiffmatrix,".stm"); - - if((f1=fopen(stiffmatrix,"wb"))==NULL){ - printf(" *ERROR in linstatic: cannot open stiffness matrix file for writing..."); - exit(0); - } - - /* storing the stiffness matrix */ - - /* nzs,irow,jq and icol have to be stored too, since the static analysis - can involve contact, whereas in the sensitivity analysis contact is not - taken into account while determining the structure of the stiffness - matrix (in mastruct.c) - */ - - if(fwrite(&nasym,sizeof(ITG),1,f1)!=1){ - printf(" *ERROR saving the symmetry flag to the stiffness matrix file..."); - exit(0); - } - if(fwrite(nzs,sizeof(ITG),3,f1)!=3){ - printf(" *ERROR saving the number of subdiagonal nonzeros to the stiffness matrix file..."); - exit(0); - } - if(fwrite(irow,sizeof(ITG),nzs[2],f1)!=nzs[2]){ - printf(" *ERROR saving irow to the stiffness matrix file..."); - exit(0); - } - if(fwrite(jq,sizeof(ITG),neq[1]+1,f1)!=neq[1]+1){ - printf(" *ERROR saving jq to the stiffness matrix file..."); - exit(0); - } - if(fwrite(icol,sizeof(ITG),neq[1],f1)!=neq[1]){ - printf(" *ERROR saving icol to the stiffness matrix file..."); - exit(0); - } - if(fwrite(ad,sizeof(double),neq[1],f1)!=neq[1]){ - printf(" *ERROR saving the diagonal of the stiffness matrix to the stiffness matrix file..."); - exit(0); - } - if(fwrite(au,sizeof(double),nzs[2],f1)!=nzs[2]){ - printf(" *ERROR saving the off-diagonal terms of the stiffness matrix to the tiffness matrix file..."); - exit(0); - } - fclose(f1); - - break; + for (i = 0; i < *ntie; i++) { + if (strcmp1(&tieset[i * 243 + 80], "D") == 0) { + + strcpy2(stiffmatrix, jobnamec, 132); + strcat(stiffmatrix, ".stm"); + + if ((f1 = fopen(stiffmatrix, "wb")) == NULL) { + printf(" *ERROR in linstatic: cannot open stiffness matrix file for writing..."); + exit(0); + } + + /* storing the stiffness matrix */ + + /* nzs,irow,jq and icol have to be stored too, since the static analysis + can involve contact, whereas in the sensitivity analysis contact is not + taken into account while determining the structure of the stiffness + matrix (in mastruct.c) + */ + + if (fwrite(&nasym, sizeof(ITG), 1, f1) != 1) { + printf(" *ERROR saving the symmetry flag to the stiffness matrix file..."); + exit(0); + } + if (fwrite(nzs, sizeof(ITG), 3, f1) != 3) { + printf(" *ERROR saving the number of subdiagonal nonzeros to the stiffness matrix file..."); + exit(0); + } + if (fwrite(irow, sizeof(ITG), nzs[2], f1) != nzs[2]) { + printf(" *ERROR saving irow to the stiffness matrix file..."); + exit(0); + } + if (fwrite(jq, sizeof(ITG), neq[1] + 1, f1) != neq[1] + 1) { + printf(" *ERROR saving jq to the stiffness matrix file..."); + exit(0); + } + if (fwrite(icol, sizeof(ITG), neq[1], f1) != neq[1]) { + printf(" *ERROR saving icol to the stiffness matrix file..."); + exit(0); + } + if (fwrite(ad, sizeof(double), neq[1], f1) != neq[1]) { + printf(" *ERROR saving the diagonal of the stiffness matrix to the stiffness matrix file..."); + exit(0); + } + if (fwrite(au, sizeof(double), nzs[2], f1) != nzs[2]) { + printf(" *ERROR saving the off-diagonal terms of the stiffness matrix to the tiffness matrix file..."); + exit(0); + } + fclose(f1); + + break; } } - - SFREE(ad);SFREE(au); - if(iglob<0){SFREE(adb);SFREE(aub);} + + SFREE(ad); + SFREE(au); + if (iglob < 0) { + SFREE(adb); + SFREE(aub); + } /* calculating the displacements and the stresses and storing */ /* the results in frd format for each valid eigenmode */ - NNEW(v,double,mt**nk); - NNEW(fn,double,mt**nk); - NNEW(stn,double,6**nk); - NNEW(inum,ITG,*nk); - NNEW(stx,double,6*mi[0]**ne); - - if(strcmp1(&filab[261],"E ")==0) NNEW(een,double,6**nk); - if(strcmp1(&filab[2697],"ME ")==0) NNEW(emn,double,6**nk); - if(strcmp1(&filab[522],"ENER")==0) NNEW(enern,double,*nk); - if(strcmp1(&filab[2175],"CONT")==0) NNEW(cdn,double,6**nk); - - NNEW(eei,double,6*mi[0]**ne); - if(*nener==1){ - NNEW(stiini,double,6*mi[0]**ne); - NNEW(emeini,double,6*mi[0]**ne); - NNEW(enerini,double,2*mi[0]**ne);} - - results(co,nk,kon,ipkon,lakon,ne,v,stn,inum,stx, - elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,ielmat, - ielorien,norien,orab,ntmat_,t0,t1act,ithermal, - prestr,iprestr,filab,eme,emn,een,iperturb, - f,fn,nactdof,&iout,qa,vold,b,nodeboun,ndirboun,xbounact,nboun, - ipompc, - nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,veold,accold,&bet, - &gam,&dtime,&time,ttime,plicon,nplicon,plkcon,nplkcon, - xstateini,xstiff,xstate,npmat_,epn,matname,mi,&ielas,&icmd, - ncmat_,nstate_,stiini,vini,ikboun,ilboun,ener,enern,emeini, - xstaten,eei,enerini,cocon,ncocon,set,nset,istartset,iendset, - ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans,fmpc, - nelemload,nload,ikmpc,ilmpc,istep,&iinc,springarea,&reltime, - &ne0,thicke,shcon,nshcon, - sideload,xloadact,xloadold,&icfd,inomat,pslavsurf,pmastsurf, - mortar,islavact,cdn,islavnode,nslavnode,ntie,clearini, - islavsurf,ielprop,prop,energyini,energy,&kscale,iponoel, - inoel,nener,orname,&network,ipobody,xbodyact,ibody,typeboun, - itiefac,tieset,smscale,&mscalmethod,nbody,t0g,t1g, - islavelinv,autloc,irowtloc,jqtloc,&nboun2, - ndirboun2,nodeboun2,xboun2,&nmpc2,ipompc2,nodempc2,coefmpc2, - labmpc2,ikboun2,ilboun2,ikmpc2,ilmpc2,&mortartrafoflag, - &intscheme); + NNEW(v, double, mt **nk); + NNEW(fn, double, mt **nk); + NNEW(stn, double, 6 * *nk); + NNEW(inum, ITG, *nk); + NNEW(stx, double, 6 * mi[0] * *ne); + + if (strcmp1(&filab[261], "E ") == 0) + NNEW(een, double, 6 * *nk); + if (strcmp1(&filab[2697], "ME ") == 0) + NNEW(emn, double, 6 * *nk); + if (strcmp1(&filab[522], "ENER") == 0) + NNEW(enern, double, *nk); + if (strcmp1(&filab[2175], "CONT") == 0) + NNEW(cdn, double, 6 * *nk); + + NNEW(eei, double, 6 * mi[0] * *ne); + if (*nener == 1) { + NNEW(stiini, double, 6 * mi[0] * *ne); + NNEW(emeini, double, 6 * mi[0] * *ne); + NNEW(enerini, double, 2 * mi[0] * *ne); + } + + results(co, nk, kon, ipkon, lakon, ne, v, stn, inum, stx, + elcon, nelcon, rhcon, nrhcon, alcon, nalcon, alzero, ielmat, + ielorien, norien, orab, ntmat_, t0, t1act, ithermal, + prestr, iprestr, filab, eme, emn, een, iperturb, + f, fn, nactdof, &iout, qa, vold, b, nodeboun, ndirboun, xbounact, nboun, + ipompc, + nodempc, coefmpc, labmpc, nmpc, nmethod, cam, neq, veold, accold, &bet, + &gam, &dtime, &time, ttime, plicon, nplicon, plkcon, nplkcon, + xstateini, xstiff, xstate, npmat_, epn, matname, mi, &ielas, &icmd, + ncmat_, nstate_, stiini, vini, ikboun, ilboun, ener, enern, emeini, + xstaten, eei, enerini, cocon, ncocon, set, nset, istartset, iendset, + ialset, nprint, prlab, prset, qfx, qfn, trab, inotr, ntrans, fmpc, + nelemload, nload, ikmpc, ilmpc, istep, &iinc, springarea, &reltime, + &ne0, thicke, shcon, nshcon, + sideload, xloadact, xloadold, &icfd, inomat, pslavsurf, pmastsurf, + mortar, islavact, cdn, islavnode, nslavnode, ntie, clearini, + islavsurf, ielprop, prop, energyini, energy, &kscale, iponoel, + inoel, nener, orname, &network, ipobody, xbodyact, ibody, typeboun, + itiefac, tieset, smscale, &mscalmethod, nbody, t0g, t1g, + islavelinv, autloc, irowtloc, jqtloc, &nboun2, + ndirboun2, nodeboun2, xboun2, &nmpc2, ipompc2, nodempc2, coefmpc2, + labmpc2, ikboun2, ilboun2, ikmpc2, ilmpc2, &mortartrafoflag, + &intscheme); SFREE(eei); - if(*nener==1){ - SFREE(stiini);SFREE(emeini);SFREE(enerini);} + if (*nener == 1) { + SFREE(stiini); + SFREE(emeini); + SFREE(enerini); + } - memcpy(&vold[0],&v[0],sizeof(double)*mt**nk); - memcpy(&sti[0],&stx[0],sizeof(double)*6*mi[0]*ne0); + memcpy(&vold[0], &v[0], sizeof(double) * mt * *nk); + memcpy(&sti[0], &stx[0], sizeof(double) * 6 * mi[0] * ne0); ++*kode; /* for cyclic symmetric sectors: duplicating the results */ - if(*mcs>0){ - ptime=*ttime+time; - frdcyc(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod,kode,filab,een,t1act, - fn,&ptime,epn,ielmat,matname,cs,mcs,nkon,enern,xstaten, - nstate_,istep,&iinc,iperturb,ener,mi,output,ithermal, - qfn,ialset,istartset,iendset,trab,inotr,ntrans,orab, - ielorien,norien,sti,veold,&noddiam,set,nset,emn,thicke, - jobnamec,&ne0,cdn,mortar,nmat,qfx,ielprop,prop); - } - else{ - if(strcmp1(&filab[1044],"ZZS")==0){ - NNEW(neigh,ITG,40**ne); - NNEW(ipneigh,ITG,*nk); + if (*mcs > 0) { + ptime = *ttime + time; + frdcyc(co, nk, kon, ipkon, lakon, ne, v, stn, inum, nmethod, kode, filab, een, t1act, + fn, &ptime, epn, ielmat, matname, cs, mcs, nkon, enern, xstaten, + nstate_, istep, &iinc, iperturb, ener, mi, output, ithermal, + qfn, ialset, istartset, iendset, trab, inotr, ntrans, orab, + ielorien, norien, sti, veold, &noddiam, set, nset, emn, thicke, + jobnamec, &ne0, cdn, mortar, nmat, qfx, ielprop, prop); + } else { + if (strcmp1(&filab[1044], "ZZS") == 0) { + NNEW(neigh, ITG, 40 * *ne); + NNEW(ipneigh, ITG, *nk); + } + ptime = *ttime + time; + frd(co, nk, kon, ipkon, lakon, ne, v, stn, inum, nmethod, + kode, filab, een, t1act, fn, &ptime, epn, ielmat, matname, enern, xstaten, + nstate_, istep, &iinc, ithermal, qfn, &mode, &noddiam, trab, inotr, + ntrans, orab, ielorien, norien, description, ipneigh, neigh, + mi, stx, vr, vi, stnr, stni, vmax, stnmax, &ngraph, veold, ener, ne, + cs, set, nset, istartset, iendset, ialset, eenmax, fnr, fni, emn, + thicke, jobnamec, output, qfx, cdn, mortar, cdnr, cdni, nmat, ielprop, + prop, sti); + if (strcmp1(&filab[1044], "ZZS") == 0) { + SFREE(ipneigh); + SFREE(neigh); } - ptime=*ttime+time; - frd(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod, - kode,filab,een,t1act,fn,&ptime,epn,ielmat,matname,enern,xstaten, - nstate_,istep,&iinc,ithermal,qfn,&mode,&noddiam,trab,inotr, - ntrans,orab,ielorien,norien,description,ipneigh,neigh, - mi,stx,vr,vi,stnr,stni,vmax,stnmax,&ngraph,veold,ener,ne, - cs,set,nset,istartset,iendset,ialset,eenmax,fnr,fni,emn, - thicke,jobnamec,output,qfx,cdn,mortar,cdnr,cdni,nmat,ielprop, - prop,sti); - if(strcmp1(&filab[1044],"ZZS")==0){SFREE(ipneigh);SFREE(neigh);} } /* updating the .sta file */ - iitsta=1; - FORTRAN(writesta,(istep,&iinc,&icutb,&iitsta,ttime,&time,&dtime)); + iitsta = 1; + FORTRAN(writesta, (istep, &iinc, &icutb, &iitsta, ttime, &time, &dtime)); - SFREE(v);SFREE(stn);SFREE(inum); - SFREE(b);SFREE(stx);SFREE(fn); + SFREE(v); + SFREE(stn); + SFREE(inum); + SFREE(b); + SFREE(stx); + SFREE(fn); - if(strcmp1(&filab[261],"E ")==0) SFREE(een); - if(strcmp1(&filab[2697],"ME ")==0) SFREE(emn); - if(strcmp1(&filab[522],"ENER")==0) SFREE(enern); - if(strcmp1(&filab[2175],"CONT")==0) SFREE(cdn); + if (strcmp1(&filab[261], "E ") == 0) + SFREE(een); + if (strcmp1(&filab[2697], "ME ") == 0) + SFREE(emn); + if (strcmp1(&filab[522], "ENER") == 0) + SFREE(enern); + if (strcmp1(&filab[2175], "CONT") == 0) + SFREE(cdn); - } - else { + } else { /* error occurred in mafill: storing the geometry in frd format */ ++*kode; - NNEW(inum,ITG,*nk);for(k=0;k<*nk;k++) inum[k]=1; - if(strcmp1(&filab[1044],"ZZS")==0){ - NNEW(neigh,ITG,40**ne); - NNEW(ipneigh,ITG,*nk); + NNEW(inum, ITG, *nk); + for (k = 0; k < *nk; k++) + inum[k] = 1; + if (strcmp1(&filab[1044], "ZZS") == 0) { + NNEW(neigh, ITG, 40 * *ne); + NNEW(ipneigh, ITG, *nk); } - ptime=*ttime+time; - frd(co,nk,kon,ipkon,lakon,ne,v,stn,inum,nmethod, - kode,filab,een,t1,fn,&ptime,epn,ielmat,matname,enern,xstaten, - nstate_,istep,&iinc,ithermal,qfn,&mode,&noddiam,trab,inotr, - ntrans,orab,ielorien,norien,description,ipneigh,neigh, - mi,sti,vr,vi,stnr,stni,vmax,stnmax,&ngraph,veold,ener,ne, - cs,set,nset,istartset,iendset,ialset,eenmax,fnr,fni,emn, - thicke,jobnamec,output,qfx,cdn,mortar,cdnr,cdni,nmat,ielprop, - prop,sti); - if(strcmp1(&filab[1044],"ZZS")==0){SFREE(ipneigh);SFREE(neigh);} - SFREE(inum);FORTRAN(stop,()); - + ptime = *ttime + time; + frd(co, nk, kon, ipkon, lakon, ne, v, stn, inum, nmethod, + kode, filab, een, t1, fn, &ptime, epn, ielmat, matname, enern, xstaten, + nstate_, istep, &iinc, ithermal, qfn, &mode, &noddiam, trab, inotr, + ntrans, orab, ielorien, norien, description, ipneigh, neigh, + mi, sti, vr, vi, stnr, stni, vmax, stnmax, &ngraph, veold, ener, ne, + cs, set, nset, istartset, iendset, ialset, eenmax, fnr, fni, emn, + thicke, jobnamec, output, qfx, cdn, mortar, cdnr, cdni, nmat, ielprop, + prop, sti); + if (strcmp1(&filab[1044], "ZZS") == 0) { + SFREE(ipneigh); + SFREE(neigh); + } + SFREE(inum); + FORTRAN(stop, ()); } - if(*mortar>-2){ - if(ncont!=0){ - *ne=ne0; - if(*nener==1) RENEW(ener,double,2*mi[0]**ne); - RENEW(ipkon,ITG,*ne); - RENEW(lakon,char,8**ne); - RENEW(kon,ITG,*nkon); - if(*norien>0){ - RENEW(ielorien,ITG,mi[2]**ne); + if (*mortar > -2) { + if (ncont != 0) { + *ne = ne0; + if (*nener == 1) + RENEW(ener, double, 2 * mi[0] * *ne); + RENEW(ipkon, ITG, *ne); + RENEW(lakon, char, 8 * *ne); + RENEW(kon, ITG, *nkon); + if (*norien > 0) { + RENEW(ielorien, ITG, mi[2] * *ne); } - RENEW(ielmat,ITG,mi[2]**ne); - SFREE(cg);SFREE(straight); - SFREE(imastop);SFREE(itiefac);SFREE(islavnode);SFREE(islavsurf); - SFREE(nslavnode);SFREE(iponoels);SFREE(inoels);SFREE(imastnode); - SFREE(nmastnode);SFREE(itietri);SFREE(koncont);SFREE(xnoels); - SFREE(springarea);SFREE(xmastnor); - - if(*mortar==0){ - SFREE(areaslav); - }else if(*mortar==1){ - SFREE(pmastsurf);SFREE(ipe);SFREE(ime);SFREE(pslavsurf); - SFREE(islavact);SFREE(clearini); + RENEW(ielmat, ITG, mi[2] * *ne); + SFREE(cg); + SFREE(straight); + SFREE(imastop); + SFREE(itiefac); + SFREE(islavnode); + SFREE(islavsurf); + SFREE(nslavnode); + SFREE(iponoels); + SFREE(inoels); + SFREE(imastnode); + SFREE(nmastnode); + SFREE(itietri); + SFREE(koncont); + SFREE(xnoels); + SFREE(springarea); + SFREE(xmastnor); + + if (*mortar == 0) { + SFREE(areaslav); + } else if (*mortar == 1) { + SFREE(pmastsurf); + SFREE(ipe); + SFREE(ime); + SFREE(pslavsurf); + SFREE(islavact); + SFREE(clearini); } } - mpcinfo[0]=memmpc_;mpcinfo[1]=mpcfree;mpcinfo[2]=icascade; - mpcinfo[3]=maxlenmpc; + mpcinfo[0] = memmpc_; + mpcinfo[1] = mpcfree; + mpcinfo[2] = icascade; + mpcinfo[3] = maxlenmpc; } - /* updating the loading at the end of the step; + /* updating the loading at the end of the step; important in case the amplitude at the end of the step is not equal to one */ - for(k=0;k<*nboun;++k){xbounold[k]=xbounact[k];} - for(k=0;k<*nforc;++k){xforcold[k]=xforcact[k];} - for(k=0;k<2**nload;++k){xloadold[k]=xloadact[k];} - for(k=0;k<7**nbody;k=k+7){xbodyold[k]=xbodyact[k];} - if(*ithermal==1){ - for(k=0;k<*nk;++k){t1old[k]=t1act[k];} - for(k=0;k<*nk;++k){vold[mt*k]=t1act[k];} + for (k = 0; k < *nboun; ++k) { + xbounold[k] = xbounact[k]; + } + for (k = 0; k < *nforc; ++k) { + xforcold[k] = xforcact[k]; + } + for (k = 0; k < 2 * *nload; ++k) { + xloadold[k] = xloadact[k]; + } + for (k = 0; k < 7 * *nbody; k = k + 7) { + xbodyold[k] = xbodyact[k]; + } + if (*ithermal == 1) { + for (k = 0; k < *nk; ++k) { + t1old[k] = t1act[k]; + } + for (k = 0; k < *nk; ++k) { + vold[mt * k] = t1act[k]; + } } - SFREE(xbounact);SFREE(xforcact);SFREE(xloadact);SFREE(t1act);SFREE(ampli); + SFREE(xbounact); + SFREE(xforcact); + SFREE(xloadact); + SFREE(t1act); + SFREE(ampli); SFREE(xbodyact); // if(*nbody>0) SFREE(ipobody); SFREE(xstiff); - if(iglob!=0){SFREE(integerglob);SFREE(doubleglob);} + if (iglob != 0) { + SFREE(integerglob); + SFREE(doubleglob); + } + + *irowp = irow; + *enerp = ener; + *xstatep = xstate; + *ipkonp = ipkon; + *lakonp = lakon; + *konp = kon; + *ielmatp = ielmat; + *ielorienp = ielorien; + *icolp = icol; - *irowp=irow;*enerp=ener;*xstatep=xstate;*ipkonp=ipkon;*lakonp=lakon; - *konp=kon;*ielmatp=ielmat;*ielorienp=ielorien;*icolp=icol; + (*ttime) += (*tper); - (*ttime)+=(*tper); - return; } From cef5846480e0fb9ec5bd9183063cdf3c9befa79c Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Wed, 7 Aug 2024 17:29:32 +0200 Subject: [PATCH 17/55] Revert Makefile to older state --- Makefile | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index cc124848..a201b03e 100644 --- a/Makefile +++ b/Makefile @@ -2,29 +2,19 @@ # https://precice.org/adapter-calculix-get-calculix.html # Set the following variables before building: # Path to original CalculiX source (e.g. $(HOME)/ccx_2.xx/src ) -CCX_VERSION = 2.20 +CCX_VERSION = 2.20 CCX = $(HOME)/CalculiX/ccx_$(CCX_VERSION)/src -CCX_FLAGS = -DPARDISO -DMATRIXSTORAGE -DUSE_MT ### Change these if you built SPOOLES, ARPACK, or yaml-cpp from source ### # SPOOLES include flags (e.g. -I$(HOME)/SPOOLES.2.2 ) -# SPOOLES library flags (e.g. $(HOME)/SPOOLES.2.2/spooles.a) SPOOLES_INCLUDE = -I/usr/include/spooles/ +# SPOOLES library flags (e.g. $(HOME)/SPOOLES.2.2/spooles.a) SPOOLES_LIBS = -lspooles -CCX_FLAGS += -DSPOOLES - +# # ARPACK include flags (e.g. -I$(HOME)/ARPACK) -# ARPACK library flags (e.g. $(HOME)/ARPACK/libarpack_INTEL.a) ARPACK_INCLUDE = +# ARPACK library flags (e.g. $(HOME)/ARPACK/libarpack_INTEL.a) ARPACK_LIBS = -larpack -llapack -lblas -CCX_FLAGS += -DARPACK - -# PARDISO (MKL) include flags (e.g. -I/opt/intel/mkl/include) -# PARDISO (MKL) library flags (e.g. -L/opt/intel/mkl/lib/intel64 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl) -PARDISO_INCLUDE = -I/opt/intel/oneapi/mkl/2023.1.0/include -PARDISO_LIBS = -L/opt/intel/oneapi/mkl/2023.1.0/lib/intel64 -Wl,--no-as-needed -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -lmkl_blacs_intelmpi_lp64 -lgomp -lpthread -lm -ldl -CCX_FLAGS += -DPARDISO - # # yaml-cpp include flags (e.g. -I$(HOME)/yaml-cpp/include) YAML_INCLUDE = -I/usr/include/ @@ -47,7 +37,6 @@ INCLUDES = \ -I$(CCX) \ $(SPOOLES_INCLUDE) \ $(PKGCONF_CFLAGS) \ - $(PARDISO_INCLUDE) \ $(ARPACK_INCLUDE) \ $(YAML_INCLUDE) @@ -57,14 +46,13 @@ LIBS = \ -lstdc++ \ $(YAML_LIBS) \ $(ARPACK_LIBS) \ - $(PARDISO_LIBS) \ -lpthread -lm -lc # Compilers and flags #CFLAGS = -g -Wall -std=c++11 -O0 -fopenmp $(INCLUDES) -DARCH="Linux" -DSPOOLES -DARPACK -DMATRIXSTORAGE #FFLAGS = -g -Wall -O0 -fopenmp $(INCLUDES) -CFLAGS = -Wall -O0 -fopenmp $(INCLUDES) -DARCH="Linux" $(CCX_FLAGS) +CFLAGS = -Wall -O3 -fopenmp $(INCLUDES) -DARCH="Linux" -DSPOOLES -DARPACK -DMATRIXSTORAGE -DUSE_MT # OS-specific options UNAME_S := $(shell uname -s) @@ -74,20 +62,21 @@ else CC = mpicc endif -FFLAGS = -Wall -O0 -fopenmp -fallow-argument-mismatch $(INCLUDES) ${ADDITIONAL_FFLAGS} +FFLAGS = -Wall -O3 -fopenmp $(INCLUDES) ${ADDITIONAL_FFLAGS} # Note for GCC 10 or newer: add -fallow-argument-mismatch in the above flags -# FC = mpifort +FC = mpifort # FC = mpif90 -FC = gfortran +# FC = gfortran # Include a list of all the source files include $(CCX)/Makefile.inc SCCXMAIN = ccx_$(CCX_VERSION).c # Append additional sources -SCCXC += nonlingeo_precice.c linstatic_precice.c dyna_precice.c CCXHelpers.c PreciceInterface.c -# SCCXC += linstatic_precice.c CCXHelpers.c PreciceInterface.c -SCCXF += getflux.f getkdeltatemp.f multiscale_routines.f +SCCXC += nonlingeo_precice.c dyna_precice.c CCXHelpers.c PreciceInterface.c +SCCXF += getflux.f getkdeltatemp.f + + # Source files in this folder and in the adapter directory $(OBJDIR)/%.o : %.c @@ -115,7 +104,7 @@ OCCXC += $(OBJDIR)/ConfigReader.o $(OBJDIR)/2D3DCoupling.o $(OBJDIR)/OutputBuffe $(OBJDIR)/ccx_preCICE: $(OBJDIR) $(OCCXMAIN) $(OBJDIR)/ccx_$(CCX_VERSION).a - $(FC) -fopenmp -Wall -O0 -o $@ $(OCCXMAIN) $(OBJDIR)/ccx_$(CCX_VERSION).a $(LIBS) + $(FC) -fopenmp -Wall -O3 -o $@ $(OCCXMAIN) $(OBJDIR)/ccx_$(CCX_VERSION).a $(LIBS) $(OBJDIR)/ccx_$(CCX_VERSION).a: $(OCCXF) $(OCCXC) ar vr $@ $? From 9552f6a6a33725edbe31cec0c709d8e391b641b8 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Thu, 8 Aug 2024 12:51:46 +0200 Subject: [PATCH 18/55] First compiling version --- Makefile | 6 +- getstrain.f | 626 +++++++++++++++++++++++++--------------------------- 2 files changed, 307 insertions(+), 325 deletions(-) diff --git a/Makefile b/Makefile index a201b03e..f6b3b25d 100644 --- a/Makefile +++ b/Makefile @@ -62,7 +62,7 @@ else CC = mpicc endif -FFLAGS = -Wall -O3 -fopenmp $(INCLUDES) ${ADDITIONAL_FFLAGS} +FFLAGS = -Wall -O3 -fopenmp $(INCLUDES) ${ADDITIONAL_FFLAGS} -fallow-argument-mismatch # Note for GCC 10 or newer: add -fallow-argument-mismatch in the above flags FC = mpifort # FC = mpif90 @@ -73,8 +73,8 @@ include $(CCX)/Makefile.inc SCCXMAIN = ccx_$(CCX_VERSION).c # Append additional sources -SCCXC += nonlingeo_precice.c dyna_precice.c CCXHelpers.c PreciceInterface.c -SCCXF += getflux.f getkdeltatemp.f +SCCXC += nonlingeo_precice.c dyna_precice.c CCXHelpers.c PreciceInterface.c linstatic_precice.c +SCCXF += getflux.f getkdeltatemp.f getgausspointscoords.f getelementgausspointcoords.f getstrain.f multiscale_routines.f diff --git a/getstrain.f b/getstrain.f index f7259a6e..bc3d2501 100755 --- a/getstrain.f +++ b/getstrain.f @@ -17,327 +17,309 @@ ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! subroutine getstrain(co,ntmat_,vold, - & cocon,ncocon,iset,istartset,iendset,ipkon,lakon,kon, - & ialset,ielmat,mi,kdelta,reftemp) - ! - ! returns the strain vector for given set of elements and corresponding gauss points. - ! Each set consists of the following: [element_id, gp_id, mat_id, eps_11, eps_22, eps_33, eps_12, eps_13, eps_23] - implicit none - ! -! character*8 lakonl,lakon(*) -! ! -! integer konl(20),ifaceq(8,6),nelem,ii,i,j,i1,i2,j1, -! & ncocon(2,*),k1,jj,ig,ntmat_,nope,nopes,imat, -! & mint2d,ifacet(6,4),ifacew(8,5),iflag,indexe,jface,istartset(*), -! & iendset(*),ipkon(*),kon(*),iset,ialset(*),nset, -! & mi(*),ielmat(mi(3),*),fidx -! ! -! real*8 co(3,*),xl(3,20),shp(4,20),xs2(3,7),dvi,f(0:3), -! & vkl(0:3,3),t(3,3),div, -! & voldl(0:mi(2),20),cocon(0:6,ntmat_,*),xl2(3,8),xsj2(3), -! & shp2(7,8),vold(0:mi(2),*),xi,et,xsj,temp,xi3d,et3d,ze3d,weight, -! & xlocal20(3,9,6),xlocal4(3,1,4),xlocal10(3,3,4),xlocal6(3,1,5), -! & xlocal15(3,4,5),xlocal8(3,4,6),xlocal8r(3,1,6),pres, -! & tf(0:3),tn,tt,dd,coords(3),cond, kdelta(*), reftemp(*), -! & avgkdelta, avgreftemp -! ! -! include "gauss.f" -! include "xlocal.f" -! ! -! data ifaceq /4,3,2,1,11,10,9,12, -! & 5,6,7,8,13,14,15,16, -! & 1,2,6,5,9,18,13,17, -! & 2,3,7,6,10,19,14,18, -! & 3,4,8,7,11,20,15,19, -! & 4,1,5,8,12,17,16,20/ -! data ifacet /1,3,2,7,6,5, -! & 1,2,4,5,9,8, -! & 2,3,4,6,10,9, -! & 1,4,3,8,10,7/ -! data ifacew /1,3,2,9,8,7,0,0, -! & 4,5,6,10,11,12,0,0, -! & 1,2,5,4,7,14,10,13, -! & 2,3,6,5,8,15,11,14, -! & 4,6,3,1,12,15,9,13/ -! data iflag /3/ -! ! -! ! -! ! -! ! initialisierung of the flux -! ! -! f(0)=0.d0 + & cocon,ncocon,iset,istartset,iendset,ipkon,lakon,kon, + & ialset,ielmat,mi,kdelta,reftemp) +! returns the strain vector for given set of elements and corresponding gauss points. +! Each set consists of the following: [element_id, gp_id, mat_id, eps_11, eps_22, eps_33, eps_12, eps_13, eps_23] + implicit none + + character*8 lakonl,lakon(*) + + integer konl(20),ifaceq(8,6),nelem,ii,i,j,i1,i2,j1, + & ncocon(2,*),k1,jj,ig,ntmat_,nope,nopes,imat, + & mint2d,ifacet(6,4),ifacew(8,5),iflag,indexe,jface,istartset(*), + & iendset(*),ipkon(*),kon(*),iset,ialset(*),nset, + & mi(*),ielmat(mi(3),*),fidx + + real*8 co(3,*),xl(3,20),shp(4,20),xs2(3,7),dvi,f(0:3), + & vkl(0:3,3),t(3,3),div, + & voldl(0:mi(2),20),cocon(0:6,ntmat_,*),xl2(3,8),xsj2(3), + & shp2(7,8),vold(0:mi(2),*),xi,et,xsj,temp,xi3d,et3d,ze3d,weight, + & xlocal20(3,9,6),xlocal4(3,1,4),xlocal10(3,3,4),xlocal6(3,1,5), + & xlocal15(3,4,5),xlocal8(3,4,6),xlocal8r(3,1,6),pres, + & tf(0:3),tn,tt,dd,coords(3),cond, kdelta(*), reftemp(*), + & avgkdelta, avgreftemp + + include "gauss.f" + include "xlocal.f" + + data ifaceq /4,3,2,1,11,10,9,12, + & 5,6,7,8,13,14,15,16, + & 1,2,6,5,9,18,13,17, + & 2,3,7,6,10,19,14,18, + & 3,4,8,7,11,20,15,19, + & 4,1,5,8,12,17,16,20/ + data ifacet /1,3,2,7,6,5, + & 1,2,4,5,9,8, + & 2,3,4,6,10,9, + & 1,4,3,8,10,7/ + data ifacew /1,3,2,9,8,7,0,0, + & 4,5,6,10,11,12,0,0, + & 1,2,5,4,7,14,10,13, + & 2,3,6,5,8,15,11,14, + & 4,6,3,1,12,15,9,13/ + data iflag /3/ + +! initialisierung of the flux + + f(0)=0.d0 + +! index for the output array + fidx=1 + + do jj=istartset(iset),iendset(iset) + jface=ialset(jj) + + nelem=int(jface/10.d0) + ig=jface-10*nelem + lakonl=lakon(nelem) + indexe=ipkon(nelem) + imat=ielmat(1,nelem) ! what is this? + + if(lakonl(4:4).eq.'2') then + nope=20 + nopes=8 + elseif(lakonl(4:4).eq.'8') then + nope=8 + nopes=4 + elseif(lakonl(4:5).eq.'10') then + nope=10 + nopes=6 + elseif(lakonl(4:4).eq.'4') then + nope=4 + nopes=3 + elseif(lakonl(4:5).eq.'15') then + nope=15 + elseif(lakonl(4:4).eq.'6') then + nope=6 + endif + + if(lakonl(4:5).eq.'8R') then + mint2d=1 + elseif((lakonl(4:4).eq.'8').or.(lakonl(4:6).eq.'20R')) + & then + if((lakonl(7:7).eq.'A').or.(lakonl(7:7).eq.'S').or. + & (lakonl(7:7).eq.'E')) then + mint2d=2 + else + mint2d=4 + endif + elseif(lakonl(4:4).eq.'2') then + mint2d=9 + elseif(lakonl(4:5).eq.'10') then + mint2d=3 + elseif(lakonl(4:4).eq.'4') then + mint2d=1 + endif + ! + ! local topology + ! + do i=1,nope + konl(i)=kon(indexe+i) + enddo + ! + ! computation of the coordinates of the local nodes + ! + do i=1,nope + do j=1,3 + xl(j,i)=co(j,konl(i)) + enddo + enddo + ! + ! temperature, velocity and auxiliary variables + ! (rho*energy density, rho*velocity and rho) + ! + do i1=1,nope + do i2=0,mi(2) + voldl(i2,i1)=vold(i2,konl(i1)) + enddo + enddo + ! + ! treatment of wedge faces + ! + if(lakonl(4:4).eq.'6') then + mint2d=1 + if(ig.le.2) then + nopes=3 + else + nopes=4 + endif + endif + + if(lakonl(4:5).eq.'15') then + if(ig.le.2) then + mint2d=3 + nopes=6 + else + mint2d=4 + nopes=8 + endif + endif + + if((nope.eq.20).or.(nope.eq.8)) then + do i=1,nopes + do j=1,3 + xl2(j,i)=co(j,konl(ifaceq(i,ig))) + enddo + enddo + elseif((nope.eq.10).or.(nope.eq.4)) then + do i=1,nopes + do j=1,3 + xl2(j,i)=co(j,konl(ifacet(i,ig))) + enddo + enddo + else + do i=1,nopes + do j=1,3 + xl2(j,i)=co(j,konl(ifacew(i,ig))) + enddo + enddo + endif + + ! very simple averaging over the integration points!! + ! TODO: check whether this needs to be improved! + avgkdelta=0 + avgreftemp=0 + + do i=1,mint2d + ! + ! local coordinates of the surface integration + ! point within the surface local coordinate system + ! + if((lakonl(4:5).eq.'8R').or. + & ((lakonl(4:4).eq.'6').and.(nopes.eq.4))) then + xi=gauss2d1(1,i) + et=gauss2d1(2,i) + weight=weight2d1(i) + elseif((lakonl(4:4).eq.'8').or. + & (lakonl(4:6).eq.'20R').or. + & ((lakonl(4:5).eq.'15').and.(nopes.eq.8))) then + xi=gauss2d2(1,i) + et=gauss2d2(2,i) + weight=weight2d2(i) + elseif(lakonl(4:4).eq.'2') then + xi=gauss2d3(1,i) + et=gauss2d3(2,i) + weight=weight2d3(i) + elseif((lakonl(4:5).eq.'10').or. + & ((lakonl(4:5).eq.'15').and.(nopes.eq.6))) then + xi=gauss2d5(1,i) + et=gauss2d5(2,i) + weight=weight2d5(i) + elseif((lakonl(4:4).eq.'4').or. + & ((lakonl(4:4).eq.'6').and.(nopes.eq.3))) then + xi=gauss2d4(1,i) + et=gauss2d4(2,i) + weight=weight2d4(i) + endif + ! + ! local surface normal + ! + if(nopes.eq.8) then + call shape8q(xi,et,xl2,xsj2,xs2,shp2,iflag) + elseif(nopes.eq.4) then + call shape4q(xi,et,xl2,xsj2,xs2,shp2,iflag) + elseif(nopes.eq.6) then + call shape6tri(xi,et,xl2,xsj2,xs2,shp2,iflag) + else + call shape3tri(xi,et,xl2,xsj2,xs2,shp2,iflag) + endif + ! + ! global coordinates of the integration point + ! + do j1=1,3 + coords(j1)=0.d0 + do i1=1,nopes + coords(j1)=coords(j1)+shp2(4,i1)*xl2(j1,i1) + enddo + enddo + ! + ! local coordinates of the surface integration + ! point within the element local coordinate system + ! + if(lakonl(4:5).eq.'8R') then + xi3d=xlocal8r(1,i,ig) + et3d=xlocal8r(2,i,ig) + ze3d=xlocal8r(3,i,ig) + call shape8h(xi3d,et3d,ze3d,xl,xsj,shp,iflag) + elseif(lakonl(4:4).eq.'8') then + xi3d=xlocal8(1,i,ig) + et3d=xlocal8(2,i,ig) + ze3d=xlocal8(3,i,ig) + call shape8h(xi3d,et3d,ze3d,xl,xsj,shp,iflag) + elseif(lakonl(4:6).eq.'20R') then + xi3d=xlocal8(1,i,ig) + et3d=xlocal8(2,i,ig) + ze3d=xlocal8(3,i,ig) + call shape20h(xi3d,et3d,ze3d,xl,xsj,shp,iflag) + elseif(lakonl(4:4).eq.'2') then + xi3d=xlocal20(1,i,ig) + et3d=xlocal20(2,i,ig) + ze3d=xlocal20(3,i,ig) + call shape20h(xi3d,et3d,ze3d,xl,xsj,shp,iflag) + elseif(lakonl(4:5).eq.'10') then + xi3d=xlocal10(1,i,ig) + et3d=xlocal10(2,i,ig) + ze3d=xlocal10(3,i,ig) + call shape10tet(xi3d,et3d,ze3d,xl,xsj,shp,iflag) + elseif(lakonl(4:4).eq.'4') then + xi3d=xlocal4(1,i,ig) + et3d=xlocal4(2,i,ig) + ze3d=xlocal4(3,i,ig) + call shape4tet(xi3d,et3d,ze3d,xl,xsj,shp,iflag) + elseif(lakonl(4:5).eq.'15') then + xi3d=xlocal15(1,i,ig) + et3d=xlocal15(2,i,ig) + ze3d=xlocal15(3,i,ig) + call shape15w(xi3d,et3d,ze3d,xl,xsj,shp,iflag) + elseif(lakonl(4:4).eq.'6') then + xi3d=xlocal6(1,i,ig) + et3d=xlocal6(2,i,ig) + ze3d=xlocal6(3,i,ig) + call shape6w(xi3d,et3d,ze3d,xl,xsj,shp,iflag) + endif + ! + ! calculating of + ! the temperature temp + ! in the integration point + ! + temp=0.d0 + do j1=1,3 + vkl(0,j1)=0.d0 + enddo + do i1=1,nope + temp=temp+shp(4,i1)*voldl(0,i1) + do k1=1,3 + vkl(0,k1)=vkl(0,k1)+shp(k1,i1)*voldl(0,i1) + enddo + enddo + ! + ! material data (conductivity) + ! + call materialdata_cond(imat,ntmat_,temp,cocon,ncocon,cond) + ! + ! determining the stress + ! + dd=dsqrt(xsj2(1)*xsj2(1)+xsj2(2)*xsj2(2)+xsj2(3)*xsj2(3)) + ! + tf(0)=-cond*(vkl(0,1)*xsj2(1)+vkl(0,2)*xsj2(2)+ + & vkl(0,3)*xsj2(3)) + f(0)=f(0)+tf(0)*weight + tf(0)=tf(0)/dd + ! dd = .1; + ! print *, temp, tf(0), dd, temp+tf(0)/cond + avgreftemp = avgreftemp + (temp + tf(0) / cond * dd) + avgkdelta = avgkdelta + cond / dd + ! + ! print *, fidx, avgreftemp, avgkdelta, tf(0), cond + enddo -! ! index for the output array -! fidx=1 + reftemp(fidx) = avgreftemp / mint2d + kdelta(fidx) = avgkdelta / mint2d -! ! -! ! -! do jj=istartset(iset),iendset(iset) -! ! -! jface=ialset(jj) -! ! -! nelem=int(jface/10.d0) -! ig=jface-10*nelem -! lakonl=lakon(nelem) -! indexe=ipkon(nelem) -! imat=ielmat(1,nelem) ! what is this? -! ! -! if(lakonl(4:4).eq.'2') then -! nope=20 -! nopes=8 -! elseif(lakonl(4:4).eq.'8') then -! nope=8 -! nopes=4 -! elseif(lakonl(4:5).eq.'10') then -! nope=10 -! nopes=6 -! elseif(lakonl(4:4).eq.'4') then -! nope=4 -! nopes=3 -! elseif(lakonl(4:5).eq.'15') then -! nope=15 -! elseif(lakonl(4:4).eq.'6') then -! nope=6 -! endif -! ! -! if(lakonl(4:5).eq.'8R') then -! mint2d=1 -! elseif((lakonl(4:4).eq.'8').or.(lakonl(4:6).eq.'20R')) -! & then -! if((lakonl(7:7).eq.'A').or.(lakonl(7:7).eq.'S').or. -! & (lakonl(7:7).eq.'E')) then -! mint2d=2 -! else -! mint2d=4 -! endif -! elseif(lakonl(4:4).eq.'2') then -! mint2d=9 -! elseif(lakonl(4:5).eq.'10') then -! mint2d=3 -! elseif(lakonl(4:4).eq.'4') then -! mint2d=1 -! endif -! ! -! ! local topology -! ! -! do i=1,nope -! konl(i)=kon(indexe+i) -! enddo -! ! -! ! computation of the coordinates of the local nodes -! ! -! do i=1,nope -! do j=1,3 -! xl(j,i)=co(j,konl(i)) -! enddo -! enddo -! ! -! ! temperature, velocity and auxiliary variables -! ! (rho*energy density, rho*velocity and rho) -! ! -! do i1=1,nope -! do i2=0,mi(2) -! voldl(i2,i1)=vold(i2,konl(i1)) -! enddo -! enddo -! ! -! ! treatment of wedge faces -! ! -! if(lakonl(4:4).eq.'6') then -! mint2d=1 -! if(ig.le.2) then -! nopes=3 -! else -! nopes=4 -! endif -! endif -! if(lakonl(4:5).eq.'15') then -! if(ig.le.2) then -! mint2d=3 -! nopes=6 -! else -! mint2d=4 -! nopes=8 -! endif -! endif -! ! -! if((nope.eq.20).or.(nope.eq.8)) then -! do i=1,nopes -! do j=1,3 -! xl2(j,i)=co(j,konl(ifaceq(i,ig))) -! enddo -! enddo -! elseif((nope.eq.10).or.(nope.eq.4)) then -! do i=1,nopes -! do j=1,3 -! xl2(j,i)=co(j,konl(ifacet(i,ig))) -! enddo -! enddo -! else -! do i=1,nopes -! do j=1,3 -! xl2(j,i)=co(j,konl(ifacew(i,ig))) -! enddo -! enddo -! endif -! ! - - - -! ! very simple averaging over the integration points!! -! ! TODO: check whether this needs to be improved! -! avgkdelta=0 -! avgreftemp=0 - - -! do i=1,mint2d -! ! -! ! local coordinates of the surface integration -! ! point within the surface local coordinate system -! ! -! if((lakonl(4:5).eq.'8R').or. -! & ((lakonl(4:4).eq.'6').and.(nopes.eq.4))) then -! xi=gauss2d1(1,i) -! et=gauss2d1(2,i) -! weight=weight2d1(i) -! elseif((lakonl(4:4).eq.'8').or. -! & (lakonl(4:6).eq.'20R').or. -! & ((lakonl(4:5).eq.'15').and.(nopes.eq.8))) then -! xi=gauss2d2(1,i) -! et=gauss2d2(2,i) -! weight=weight2d2(i) -! elseif(lakonl(4:4).eq.'2') then -! xi=gauss2d3(1,i) -! et=gauss2d3(2,i) -! weight=weight2d3(i) -! elseif((lakonl(4:5).eq.'10').or. -! & ((lakonl(4:5).eq.'15').and.(nopes.eq.6))) then -! xi=gauss2d5(1,i) -! et=gauss2d5(2,i) -! weight=weight2d5(i) -! elseif((lakonl(4:4).eq.'4').or. -! & ((lakonl(4:4).eq.'6').and.(nopes.eq.3))) then -! xi=gauss2d4(1,i) -! et=gauss2d4(2,i) -! weight=weight2d4(i) -! endif -! ! -! ! local surface normal -! ! -! if(nopes.eq.8) then -! call shape8q(xi,et,xl2,xsj2,xs2,shp2,iflag) -! elseif(nopes.eq.4) then -! call shape4q(xi,et,xl2,xsj2,xs2,shp2,iflag) -! elseif(nopes.eq.6) then -! call shape6tri(xi,et,xl2,xsj2,xs2,shp2,iflag) -! else -! call shape3tri(xi,et,xl2,xsj2,xs2,shp2,iflag) -! endif -! ! -! ! global coordinates of the integration point -! ! -! do j1=1,3 -! coords(j1)=0.d0 -! do i1=1,nopes -! coords(j1)=coords(j1)+shp2(4,i1)*xl2(j1,i1) -! enddo -! enddo -! ! -! ! local coordinates of the surface integration -! ! point within the element local coordinate system -! ! -! if(lakonl(4:5).eq.'8R') then -! xi3d=xlocal8r(1,i,ig) -! et3d=xlocal8r(2,i,ig) -! ze3d=xlocal8r(3,i,ig) -! call shape8h(xi3d,et3d,ze3d,xl,xsj,shp,iflag) -! elseif(lakonl(4:4).eq.'8') then -! xi3d=xlocal8(1,i,ig) -! et3d=xlocal8(2,i,ig) -! ze3d=xlocal8(3,i,ig) -! call shape8h(xi3d,et3d,ze3d,xl,xsj,shp,iflag) -! elseif(lakonl(4:6).eq.'20R') then -! xi3d=xlocal8(1,i,ig) -! et3d=xlocal8(2,i,ig) -! ze3d=xlocal8(3,i,ig) -! call shape20h(xi3d,et3d,ze3d,xl,xsj,shp,iflag) -! elseif(lakonl(4:4).eq.'2') then -! xi3d=xlocal20(1,i,ig) -! et3d=xlocal20(2,i,ig) -! ze3d=xlocal20(3,i,ig) -! call shape20h(xi3d,et3d,ze3d,xl,xsj,shp,iflag) -! elseif(lakonl(4:5).eq.'10') then -! xi3d=xlocal10(1,i,ig) -! et3d=xlocal10(2,i,ig) -! ze3d=xlocal10(3,i,ig) -! call shape10tet(xi3d,et3d,ze3d,xl,xsj,shp,iflag) -! elseif(lakonl(4:4).eq.'4') then -! xi3d=xlocal4(1,i,ig) -! et3d=xlocal4(2,i,ig) -! ze3d=xlocal4(3,i,ig) -! call shape4tet(xi3d,et3d,ze3d,xl,xsj,shp,iflag) -! elseif(lakonl(4:5).eq.'15') then -! xi3d=xlocal15(1,i,ig) -! et3d=xlocal15(2,i,ig) -! ze3d=xlocal15(3,i,ig) -! call shape15w(xi3d,et3d,ze3d,xl,xsj,shp,iflag) -! elseif(lakonl(4:4).eq.'6') then -! xi3d=xlocal6(1,i,ig) -! et3d=xlocal6(2,i,ig) -! ze3d=xlocal6(3,i,ig) -! call shape6w(xi3d,et3d,ze3d,xl,xsj,shp,iflag) -! endif -! ! -! ! calculating of -! ! the temperature temp -! ! in the integration point -! ! - -! temp=0.d0 -! do j1=1,3 -! vkl(0,j1)=0.d0 -! enddo -! do i1=1,nope -! temp=temp+shp(4,i1)*voldl(0,i1) -! do k1=1,3 -! vkl(0,k1)=vkl(0,k1)+shp(k1,i1)*voldl(0,i1) -! enddo -! enddo -! ! -! ! material data (conductivity) -! ! -! call materialdata_cond(imat,ntmat_,temp,cocon, -! & ncocon,cond) -! ! -! ! determining the stress -! ! -! dd=dsqrt(xsj2(1)*xsj2(1)+xsj2(2)*xsj2(2)+ -! & xsj2(3)*xsj2(3)) -! ! -! tf(0)=-cond*(vkl(0,1)*xsj2(1)+ -! & vkl(0,2)*xsj2(2)+ -! & vkl(0,3)*xsj2(3)) -! f(0)=f(0)+tf(0)*weight -! tf(0)=tf(0)/dd -! ! dd = .1; -! ! print *, temp, tf(0), dd, temp+tf(0)/cond -! avgreftemp = avgreftemp + (temp + tf(0) / cond * dd) -! avgkdelta = avgkdelta + cond / dd -! ! -! ! print *, fidx, avgreftemp, avgkdelta, tf(0), cond -! enddo - -! reftemp(fidx) = avgreftemp / mint2d -! kdelta(fidx) = avgkdelta / mint2d - -! fidx=fidx+1 - -! enddo - ! - ! - return - end - - - - \ No newline at end of file + fidx=fidx+1 + + enddo +! + return + end From 06be8bb5d51a57e59503a22a8b163f3f77e40035 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Thu, 8 Aug 2024 15:56:34 +0200 Subject: [PATCH 19/55] Add call to linstatic_precice to ccx_2.20.c --- ccx_2.20.c | 53 ++++++++++++++++++++++++++++++++++++++++++++- linstatic_precice.c | 4 ++-- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/ccx_2.20.c b/ccx_2.20.c index 84466232..fa4b6856 100644 --- a/ccx_2.20.c +++ b/ccx_2.20.c @@ -1308,7 +1308,7 @@ int main(int argc, char *argv[]) /* nmethod=15: Crack propagation */ /* nmethod=16: Feasible direction based on sensitivity information */ if (preciceUsed) { - int isStaticOrDynamic = ((nmethod == 1) || (nmethod == 4)) && (iperturb[0] > 1); + int isStaticOrDynamic = ((nmethod == 1) || (nmethod == 4)); //&& (iperturb[0] > 1); int isDynamic = ((nmethod == 4) && (iperturb[0] > 1)); int isThermalAnalysis = ithermal[0] >= 2; int isModalDynamic = ((nmethod == 4) && (iperturb[0] < 2)); @@ -1428,10 +1428,60 @@ int main(int argc, char *argv[]) mpcfree = mpcinfo[1]; icascade = mpcinfo[2]; maxlenmpc = mpcinfo[3]; + } else { printf("ERROR: This simulation type is not available with preCICE"); exit(0); } + + } else if (isStaticOrDynamic) { + + mpcinfo[0] = memmpc_; + mpcinfo[1] = mpcfree; + mpcinfo[2] = icascade; + mpcinfo[3] = maxlenmpc; + + if (icascade != 0) { + printf(" *ERROR in CalculiX: the matrix structure may"); + printf(" change due to nonlinear equations;"); + printf(" a purely linear calculation is not"); + printf(" feasible; use NLGEOM on the *STEP card."); + FORTRAN(stop, ()); + } + + printf("Starting Multiscale Linear Static Analysis via preCICE...\n"); + + linstatic_precice(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, + &nboun, + ipompc, nodempc, coefmpc, labmpc, &nmpc, nodeforc, ndirforc, xforc, + &nforc, nelemload, sideload, xload, &nload, + nactdof, &icol, jq, &irow, neq, &nzl, &nmethod, ikmpc, + ilmpc, ikboun, ilboun, elcon, nelcon, rhcon, nrhcon, + alcon, nalcon, alzero, &ielmat, &ielorien, &norien, orab, &ntmat_, + t0, t1, t1old, ithermal, prestr, &iprestr, vold, iperturb, sti, nzs, + &kode, filab, eme, &iexpl, plicon, + nplicon, plkcon, nplkcon, &xstate, &npmat_, matname, + &isolver, mi, &ncmat_, &nstate_, cs, &mcs, &nkon, &ener, + xbounold, xforcold, xloadold, amname, amta, namta, + &nam, iamforc, iamload, iamt1, iamboun, &ttime, + output, set, &nset, istartset, iendset, ialset, &nprint, prlab, + prset, &nener, trab, inotr, &ntrans, fmpc, ipobody, ibody, xbody, + &nbody, + xbodyold, timepar, thicke, jobnamec, tieset, &ntie, &istep, &nmat, + ielprop, prop, typeboun, &mortar, mpcinfo, tietol, ics, + orname, itempuser, t0g, t1g, + /* PreCICE args */ + preciceParticipantName, configFilename); + + for (i = 0; i < 3; i++) { + nzsprevstep[i] = nzs[i]; + } + + memmpc_ = mpcinfo[0]; + mpcfree = mpcinfo[1]; + icascade = mpcinfo[2]; + maxlenmpc = mpcinfo[3]; + } else if (isStaticNLGEOM) { printf("Starting STATIC analysis via preCICE...\n"); @@ -1506,6 +1556,7 @@ int main(int argc, char *argv[]) t0g, t1g, preciceParticipantName, configFilename); } else { + //printf("DEBUG: nmethod=%d, iperturb[0]=%d, iperturb[1]=%d\n", nmethod, iperturb[0], iperturb[1]); printf("ERROR: Only thermal coupling or FSI is available with preCICE"); exit(0); } diff --git a/linstatic_precice.c b/linstatic_precice.c index b4f4a5d1..d23299e0 100644 --- a/linstatic_precice.c +++ b/linstatic_precice.c @@ -74,7 +74,6 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak ITG *istep, ITG *nmat, ITG *ielprop, double *prop, char *typeboun, ITG *mortar, ITG *mpcinfo, double *tietol, ITG *ics, char *orname, ITG *itempuser, double *t0g, double *t1g, - ITG *jmax, /* Adapter: Add variables for the participant name and the config file */ char *preciceParticipantName, char *configFilename) { @@ -189,6 +188,7 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak }; /* preCICE Adapter: Initialize */ + printf("configFilename: %s\n", configFilename); Precice_Setup(configFilename, preciceParticipantName, &simulationData); Precice_AdjustSolverTimestep(&simulationData); @@ -843,7 +843,7 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak for (i = 0; i < *ntie; i++) { if (strcmp1(&tieset[i * 243 + 80], "D") == 0) { - strcpy2(stiffmatrix, jobnamec, 132); + // strcpy2(stiffmatrix, jobnamec, 132); strcat(stiffmatrix, ".stm"); if ((f1 = fopen(stiffmatrix, "wb")) == NULL) { From c3c8b46349cfeca418d1f42c52fd7ea1d71e5b68 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Wed, 14 Aug 2024 22:49:24 +0200 Subject: [PATCH 20/55] Add functionality to write variables rve_id, mod_id, and ruc_size to preCICE --- adapter/CCXHelpers.c | 44 +++++--- adapter/CCXHelpers.h | 14 ++- adapter/PreciceInterface.c | 213 ++++++++++++++++++++++--------------- adapter/PreciceInterface.h | 5 +- 4 files changed, 173 insertions(+), 103 deletions(-) diff --git a/adapter/CCXHelpers.c b/adapter/CCXHelpers.c index 99f3d874..4ae87909 100644 --- a/adapter/CCXHelpers.c +++ b/adapter/CCXHelpers.c @@ -123,22 +123,6 @@ void getNodeForces(ITG *nodes, ITG numNodes, int dim, double *fn, ITG mt, double } } -void getElementStrain(int strainIdx, int *mi, int nelem, double *eei, double *strainData) -{ - - int i, count, idx; - - // Loop through all element and respective gauss points - count = 0; - for (i = 0; i < mi[0] * nelem; i++) { - idx = i * 6 + strainIdx; - strainData[count] = eei[idx]; - strainData[count + 1] = eei[idx + 1]; - strainData[count + 2] = eei[idx + 2]; - count = count + 3; - } -} - void getNodeDisplacements(ITG *nodes, ITG numNodes, int dim, double *v, ITG mt, double *displacements) { @@ -448,6 +432,34 @@ int getXloadIndexOffset(enum xloadVariable xloadVar) } } +void getElementStrain(int strainIdx, int *mi, int nelem, double *eei, double *strainData) +{ + int i, count, idx; + + // Set strainData values to zero, because there is a nan value somewhere + count = 0; + for (i = 0; i < mi[0] * nelem; i++) { + idx = i * 6 + strainIdx; + printf("eei[%d]: %f\n", idx, eei[idx]); + printf("eei[%d]: %f\n", idx + 1, eei[idx + 1]); + printf("eei[%d]: %f\n", idx + 2, eei[idx + 2]); + } + + // printf("Manually setting eei[10] to 0.0, because it is somehow -nan\n"); + + eei[10] = 0.0; + + // Loop through all element and respective gauss points + count = 0; + for (i = 0; i < mi[0] * nelem; i++) { + idx = i * 6 + strainIdx; + strainData[count] = eei[idx]; + strainData[count + 1] = eei[idx + 1]; + strainData[count + 2] = eei[idx + 2]; + count = count + 3; + } +} + void setXload(double *xload, int *xloadIndices, double *values, int numValues, enum xloadVariable xloadVar) { ITG i; diff --git a/adapter/CCXHelpers.h b/adapter/CCXHelpers.h index ade1ec81..181d63dd 100644 --- a/adapter/CCXHelpers.h +++ b/adapter/CCXHelpers.h @@ -52,7 +52,9 @@ enum CouplingDataType { TEMPERATURE, POSITIONS, PRESSURE, MACRO_IP_ID, - INPUT_ID, + RVE_ID, + MOD_ID, + RUC_SIZE, CONV_FLAG, STRAIN1TO3, STRAIN4TO6, @@ -232,6 +234,16 @@ void getXbounIndices(ITG *nodes, ITG numNodes, int nboun, int *ikboun, int *ilbo */ void getXforcIndices(ITG *nodes, ITG numNodes, int nforc, int *ikforc, int *ilforc, int *xforcIndices); +/** + * @brief Gets the strain values at each Gauss point of each element + * @param strainIdx: CalculiX variable for the index of the strain values + * @param mi: CalculiX variable for the number of integration points + * @param nelem: CalculiX variable for the number of elements + * @param eei: CalculiX array for the element integration information + * @param strainData: CalculiX array for the strain values + */ +void getElementStrain(int strainIdx, int *mi, int nelem, double *eei, double *strainData); + /** * @brief Modifies the values of a DFLUX or FILM boundary condition * @param xload: CalculiX array for the loads diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index 6a5b6c2a..38aa4551 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -276,7 +276,7 @@ void Precice_ReadCouplingData(SimulationData *sim) // VOLUMETRIC COUPLING - MULTISCALE case CONV_FLAG: // READ CONVERGENCE FLAG - // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->macroInputData, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPScalarData); + precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->conv, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPScalarData); printf("Reading CONVERGENCE FLAG coupling data.\n"); break; @@ -284,9 +284,9 @@ void Precice_ReadCouplingData(SimulationData *sim) // READ MATERIAL MATRIX COMPONENTS - C11, C12, C13 idx = 1; precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent1Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - // for (int k = 0; k < interfaces[i]->numIPTotal; k++) { + //for (int k = 0; k < interfaces[i]->numIPTotal; k++) { // printf( " %i, %e, %e, %e \n", k, interfaces[i]->elementIPVectorData[k*3], interfaces[i]->elementIPVectorData[k*3+1], interfaces[i]->elementIPVectorData[k*3+2]); - // } + //} FORTRAN(precice_multiscale_set_xstiff, (sim->mi, idx, interfaces[i]->numElements, @@ -297,97 +297,97 @@ void Precice_ReadCouplingData(SimulationData *sim) case CMAT2: // READ MATERIAL MATRIX COMPONENTS - C14, C15, C16 - // idx=4; - // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent2Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - // FORTRAN(precice_multiscale_set_xstiff, (sim->mi, - // &idx, - // &interfaces[i]->numElements, - // interfaces[i]->elementIPVectorData, - // sim->xstiff)); + idx = 4; + precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent2Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); + FORTRAN(precice_multiscale_set_xstiff, (sim->mi, + &idx, + &interfaces[i]->numElements, + interfaces[i]->elementIPVectorData, + sim->xstiff)); printf("Reading MATERIAL TANGENT 2 coupling data.\n"); break; case CMAT3: // READ MATERIAL MATRIX COMPONENTS - C22, C23, C24 - // idx=7; - // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent3Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - // FORTRAN(precice_multiscale_set_xstiff, (sim->mi, - // &idx, - // &interfaces[i]->numElements, - // interfaces[i]->elementIPVectorData, - // sim->xstiff)); + idx = 7; + precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent3Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); + FORTRAN(precice_multiscale_set_xstiff, (sim->mi, + &idx, + &interfaces[i]->numElements, + interfaces[i]->elementIPVectorData, + sim->xstiff)); printf("Reading MATERIAL TANGENT 3 coupling data.\n"); break; case CMAT4: // READ MATERIAL MATRIX COMPONENTS - C25, C26, C33 - // idx=10; - // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent4Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - // FORTRAN(precice_multiscale_set_xstiff, (sim->mi, - // &idx, - // &interfaces[i]->numElements, - // interfaces[i]->elementIPVectorData, - // sim->xstiff)); + idx = 10; + precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent4Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); + FORTRAN(precice_multiscale_set_xstiff, (sim->mi, + &idx, + &interfaces[i]->numElements, + interfaces[i]->elementIPVectorData, + sim->xstiff)); printf("Reading MATERIAL TANGENT 4 coupling data.\n"); break; case CMAT5: // READ MATERIAL MATRIX COMPONENTS - C34, C35, C36 - // idx=13; - // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent5Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - // FORTRAN(precice_multiscale_set_xstiff, (sim->mi, - // &idx, - // &interfaces[i]->numElements, - // interfaces[i]->elementIPVectorData, - // sim->xstiff)); + idx = 13; + precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent5Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); + FORTRAN(precice_multiscale_set_xstiff, (sim->mi, + &idx, + &interfaces[i]->numElements, + interfaces[i]->elementIPVectorData, + sim->xstiff)); printf("Reading MATERIAL TANGENT 5 coupling data.\n"); break; case CMAT6: // READ MATERIAL MATRIX COMPONENTS - C44, C45, C46 - // idx=16; - // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent6Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - // FORTRAN(precice_multiscale_set_xstiff, (sim->mi, - // &idx, - // &interfaces[i]->numElements, - // interfaces[i]->elementIPVectorData, - // sim->xstiff)); + idx = 16; + precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent6Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); + FORTRAN(precice_multiscale_set_xstiff, (sim->mi, + &idx, + &interfaces[i]->numElements, + interfaces[i]->elementIPVectorData, + sim->xstiff)); printf("Reading MATERIAL TANGENT 6 coupling data.\n"); break; case CMAT7: // READ MATERIAL MATRIX COMPONENTS - C55, C56, C66 - // idx=19; - // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent7Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - // FORTRAN(precice_multiscale_set_xstiff, (sim->mi, - // &idx, - // &interfaces[i]->numElements, - // interfaces[i]->elementIPVectorData, - // sim->xstiff)); + idx = 19; + precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent7Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); + FORTRAN(precice_multiscale_set_xstiff, (sim->mi, + &idx, + &interfaces[i]->numElements, + interfaces[i]->elementIPVectorData, + sim->xstiff)); printf("Reading MATERIAL TANGENT 7 coupling data.\n"); break; case STRESS1TO3: // READ STRESS COMPONENTS - S11, S22, S33 idx = 1; - // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->stress1to3Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - // FORTRAN(precice_multiscale_set_stx, (sim->mi, - // &idx, - // &interfaces[i]->numElements, - // interfaces[i]->elementIPVectorData, - // sim->stx)); + precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->stress1to3Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); + FORTRAN(precice_multiscale_set_stx, (sim->mi, + &idx, + &interfaces[i]->numElements, + interfaces[i]->elementIPVectorData, + sim->stx)); printf("Reading STRESS1TO3 coupling data.\n"); break; case STRESS4TO6: // READ STRESS COMPONENTS - S23, S13, S12 - // idx=4; - // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->stress4to6Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - // FORTRAN(precice_multiscale_set_stx, (sim->mi, - // &idx, - // &interfaces[i]->numElements, - // interfaces[i]->elementIPVectorData, - // sim->stx)); + idx = 4; + precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->stress4to6Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); + FORTRAN(precice_multiscale_set_stx, (sim->mi, + &idx, + &interfaces[i]->numElements, + interfaces[i]->elementIPVectorData, + sim->stx)); printf("Reading STRESS4TO6 coupling data.\n"); break; @@ -411,8 +411,18 @@ void Precice_ReadCouplingData(SimulationData *sim) fflush(stdout); exit(EXIT_FAILURE); break; - case INPUT_ID: - printf("Input ID cannot be used as read data.\n"); + case RVE_ID: + printf("RVE ID cannot be used as read data.\n"); + fflush(stdout); + exit(EXIT_FAILURE); + break; + case MOD_ID: + printf("MOD ID cannot be used as read data.\n"); + fflush(stdout); + exit(EXIT_FAILURE); + break; + case RUC_SIZE: + printf("RUC size cannot be used as read data.\n"); fflush(stdout); exit(EXIT_FAILURE); break; @@ -554,23 +564,40 @@ void Precice_WriteCouplingData(SimulationData *sim) printf("Writing FORCES coupling data.\n"); break; /* VOLUMETRIC COUPLING - MULTISCALE */ - case INPUT_ID: - // WRITE INPUT ID + case RVE_ID: + for (int k = 0; k < interfaces[i]->numIPTotal; k++) { + interfaces[i]->elementIPScalarData[k] = k; + }; + precicec_writeData(interfaces[i]->couplingMeshName, interfaces[i]->rveid, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, interfaces[i]->elementIPScalarData); + printf("Writing RVE ID coupling data.\n"); + break; + case MOD_ID: + /* Solve GMC 102 on all Gauss points */ + for (int k = 0; k < interfaces[i]->numIPTotal; k++) { + interfaces[i]->elementIPScalarData[k] = 102.0; + }; + precicec_writeData(interfaces[i]->couplingMeshName, interfaces[i]->modid, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, interfaces[i]->elementIPScalarData); + printf("Writing MOD ID coupling data.\n"); + break; + case RUC_SIZE: + /* Solve GMC problem with 4 sub cells in each axis */ for (int k = 0; k < interfaces[i]->numIPTotal; k++) { - interfaces[i]->elementIPScalarData[k] = 1; + interfaces[i]->elementIPScalarData[k] = 5; }; - precicec_writeData(interfaces[i]->couplingMeshName, interfaces[i]->macroInputData, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, interfaces[i]->elementIPScalarData); - printf("Writing INPUT ID coupling data.\n"); + precicec_writeData(interfaces[i]->couplingMeshName, interfaces[i]->rucsize, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, interfaces[i]->elementIPScalarData); + printf("Writing RUC_SIZE coupling data.\n"); break; case STRAIN1TO3: idx = 0; getElementStrain(idx, sim->mi, interfaces[i]->numElements, sim->eei, interfaces[i]->elementIPVectorData); + //printf("strain1to3 values: %d\n", interfaces[i]->elementIPVectorData[0]); precicec_writeData(interfaces[i]->couplingMeshName, interfaces[i]->strain1to3Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, interfaces[i]->elementIPVectorData); printf("Writing STRAIN1TO3 coupling data.\n"); break; case STRAIN4TO6: idx = 3; getElementStrain(idx, sim->mi, interfaces[i]->numElements, sim->eei, interfaces[i]->elementIPVectorData); + //printf("strain4to6 values: %d\n", interfaces[i]->elementIPVectorData[0]); precicec_writeData(interfaces[i]->couplingMeshName, interfaces[i]->strain4to6Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, interfaces[i]->elementIPVectorData); printf("Writing STRAIN4TO6 coupling data.\n"); break; @@ -642,6 +669,10 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I interface->xloadIndices = NULL; interface->xforcIndices = NULL; + // Initialize element data points as NULL + interface->elementIPScalarData = NULL; + interface->elementIPVectorData = NULL; + // Initialize preCICE mesh name as NULL interface->couplingMeshName = NULL; @@ -658,18 +689,21 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I interface->velocities = NULL; interface->forces = NULL; interface->pressure = NULL; - interface->macroInputData = NULL; - interface->strain1to3Data = NULL; - interface->strain4to6Data = NULL; - interface->stress1to3Data = NULL; - interface->stress4to6Data = NULL; - interface->materialTangent1Data = NULL; - interface->materialTangent2Data = NULL; - interface->materialTangent3Data = NULL; - interface->materialTangent4Data = NULL; - interface->materialTangent5Data = NULL; - interface->materialTangent6Data = NULL; - interface->materialTangent7Data = NULL; + interface->rveid = NULL; + interface->modid = NULL; + interface->rucsize = NULL; + + interface->strain1to3Data = NULL; + interface->strain4to6Data = NULL; + interface->stress1to3Data = NULL; + interface->stress4to6Data = NULL; + interface->materialTangent1Data = NULL; + interface->materialTangent2Data = NULL; + interface->materialTangent3Data = NULL; + interface->materialTangent4Data = NULL; + interface->materialTangent5Data = NULL; + interface->materialTangent6Data = NULL; + interface->materialTangent7Data = NULL; // Check if quasi 2D-3D coupling needs to be implemented if (interface->dim == 2) { @@ -995,16 +1029,17 @@ void PreciceInterface_ConfigureCouplingData(PreciceInterface *interface, Simulat interface->readData[i] = CMAT7; interface->materialTangent7Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); - } else if (startsWith(config->readDataNames[i], "conv_flag")) { + } else if (startsWith(config->readDataNames[i], "conv")) { PreciceInterface_EnsureValidRead(interface, CONV_FLAG); interface->readData[i] = CONV_FLAG; + interface->conv = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); - } else if (startsWith(config->readDataNames[i], "stress1to3")) { + } else if (startsWith(config->readDataNames[i], "stresses1to3")) { PreciceInterface_EnsureValidRead(interface, STRESS1TO3); interface->readData[i] = STRESS1TO3; interface->stress1to3Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); - } else if (startsWith(config->readDataNames[i], "stress4to6")) { + } else if (startsWith(config->readDataNames[i], "stresses4to6")) { PreciceInterface_EnsureValidRead(interface, STRESS4TO6); interface->readData[i] = STRESS4TO6; interface->stress4to6Data = strdup(config->readDataNames[i]); @@ -1058,15 +1093,23 @@ void PreciceInterface_ConfigureCouplingData(PreciceInterface *interface, Simulat interface->writeData[i] = FORCES; interface->forces = strdup(config->writeDataNames[i]); printf("Write data '%s' found.\n", interface->forces); - } else if (isEqual(config->writeDataNames[i], "input_id")) { - interface->writeData[i] = INPUT_ID; - interface->macroInputData = strdup(config->writeDataNames[i]); + } else if (isEqual(config->writeDataNames[i], "rve_id")) { + interface->writeData[i] = RVE_ID; + interface->rveid = strdup(config->writeDataNames[i]); + printf("Write data '%s' found.\n", config->writeDataNames[i]); + } else if (isEqual(config->writeDataNames[i], "mod_id")) { + interface->writeData[i] = MOD_ID; + interface->modid = strdup(config->writeDataNames[i]); + printf("Write data '%s' found.\n", config->writeDataNames[i]); + } else if (isEqual(config->writeDataNames[i], "ruc_size")) { + interface->writeData[i] = RUC_SIZE; + interface->rucsize = strdup(config->writeDataNames[i]); printf("Write data '%s' found.\n", config->writeDataNames[i]); - } else if (isEqual(config->writeDataNames[i], "strain1to3")) { + } else if (isEqual(config->writeDataNames[i], "strains1to3")) { interface->writeData[i] = STRAIN1TO3; interface->strain1to3Data = strdup(config->writeDataNames[i]); printf("Write data '%s' found.\n", config->writeDataNames[i]); - } else if (isEqual(config->writeDataNames[i], "strain4to6")) { + } else if (isEqual(config->writeDataNames[i], "strains4to6")) { interface->writeData[i] = STRAIN4TO6; interface->strain4to6Data = strdup(config->writeDataNames[i]); printf("Write data '%s' found.\n", config->writeDataNames[i]); diff --git a/adapter/PreciceInterface.h b/adapter/PreciceInterface.h index 08a34590..6c5d1e74 100644 --- a/adapter/PreciceInterface.h +++ b/adapter/PreciceInterface.h @@ -81,7 +81,10 @@ typedef struct PreciceInterface { char *velocities; char *forces; char *pressure; - char *macroInputData; + char *rveid; + char *modid; + char *rucsize; + char *conv; char *strain1to3Data; char *strain4to6Data; char *stress1to3Data; From a56a7cf166b9b559cd14421e8a3cf74a7b977a22 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Thu, 15 Aug 2024 21:46:35 +0200 Subject: [PATCH 21/55] Handle pointers to strain and stress data consistently in the linear static solver --- Makefile | 6 +- adapter/CCXHelpers.c | 14 ----- adapter/PreciceInterface.c | 110 ++++++++++++++++++++----------------- adapter/PreciceInterface.h | 4 +- linstatic_precice.c | 57 ++++++++++++++++--- 5 files changed, 114 insertions(+), 77 deletions(-) diff --git a/Makefile b/Makefile index f6b3b25d..4bd1638c 100644 --- a/Makefile +++ b/Makefile @@ -52,7 +52,7 @@ LIBS = \ #CFLAGS = -g -Wall -std=c++11 -O0 -fopenmp $(INCLUDES) -DARCH="Linux" -DSPOOLES -DARPACK -DMATRIXSTORAGE #FFLAGS = -g -Wall -O0 -fopenmp $(INCLUDES) -CFLAGS = -Wall -O3 -fopenmp $(INCLUDES) -DARCH="Linux" -DSPOOLES -DARPACK -DMATRIXSTORAGE -DUSE_MT +CFLAGS = -Wall -O0 -fopenmp $(INCLUDES) -DARCH="Linux" -DSPOOLES -DARPACK -DMATRIXSTORAGE -DUSE_MT -fbounds-check -g # OS-specific options UNAME_S := $(shell uname -s) @@ -62,7 +62,7 @@ else CC = mpicc endif -FFLAGS = -Wall -O3 -fopenmp $(INCLUDES) ${ADDITIONAL_FFLAGS} -fallow-argument-mismatch +FFLAGS = -Wall -O0 -fopenmp $(INCLUDES) ${ADDITIONAL_FFLAGS} -fallow-argument-mismatch -fbounds-check -g # Note for GCC 10 or newer: add -fallow-argument-mismatch in the above flags FC = mpifort # FC = mpif90 @@ -104,7 +104,7 @@ OCCXC += $(OBJDIR)/ConfigReader.o $(OBJDIR)/2D3DCoupling.o $(OBJDIR)/OutputBuffe $(OBJDIR)/ccx_preCICE: $(OBJDIR) $(OCCXMAIN) $(OBJDIR)/ccx_$(CCX_VERSION).a - $(FC) -fopenmp -Wall -O3 -o $@ $(OCCXMAIN) $(OBJDIR)/ccx_$(CCX_VERSION).a $(LIBS) + $(FC) -fopenmp -Wall -O0 -g -o $@ $(OCCXMAIN) $(OBJDIR)/ccx_$(CCX_VERSION).a $(LIBS) $(OBJDIR)/ccx_$(CCX_VERSION).a: $(OCCXF) $(OCCXC) ar vr $@ $? diff --git a/adapter/CCXHelpers.c b/adapter/CCXHelpers.c index 4ae87909..af74f783 100644 --- a/adapter/CCXHelpers.c +++ b/adapter/CCXHelpers.c @@ -435,20 +435,6 @@ int getXloadIndexOffset(enum xloadVariable xloadVar) void getElementStrain(int strainIdx, int *mi, int nelem, double *eei, double *strainData) { int i, count, idx; - - // Set strainData values to zero, because there is a nan value somewhere - count = 0; - for (i = 0; i < mi[0] * nelem; i++) { - idx = i * 6 + strainIdx; - printf("eei[%d]: %f\n", idx, eei[idx]); - printf("eei[%d]: %f\n", idx + 1, eei[idx + 1]); - printf("eei[%d]: %f\n", idx + 2, eei[idx + 2]); - } - - // printf("Manually setting eei[10] to 0.0, because it is somehow -nan\n"); - - eei[10] = 0.0; - // Loop through all element and respective gauss points count = 0; for (i = 0; i < mi[0] * nelem; i++) { diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index 38aa4551..6e54cfe4 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -282,88 +282,86 @@ void Precice_ReadCouplingData(SimulationData *sim) case CMAT1: // READ MATERIAL MATRIX COMPONENTS - C11, C12, C13 - idx = 1; precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent1Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - //for (int k = 0; k < interfaces[i]->numIPTotal; k++) { - // printf( " %i, %e, %e, %e \n", k, interfaces[i]->elementIPVectorData[k*3], interfaces[i]->elementIPVectorData[k*3+1], interfaces[i]->elementIPVectorData[k*3+2]); - //} - FORTRAN(precice_multiscale_set_xstiff, (sim->mi, - idx, - interfaces[i]->numElements, - interfaces[i]->elementIPVectorData, - sim->xstiff)); + + for (int k = 0; k < interfaces[i]->numIPTotal; k++) { + idx = k * 27 + 0; + sim->xstiff[idx] = interfaces[i]->elementIPVectorData[k * 3]; + sim->xstiff[idx + 1] = interfaces[i]->elementIPVectorData[k * 3 + 1]; + sim->xstiff[idx + 2] = interfaces[i]->elementIPVectorData[k * 3 + 2]; + } printf("Reading MATERIAL TANGENT 1 coupling data.\n"); break; case CMAT2: - // READ MATERIAL MATRIX COMPONENTS - C14, C15, C16 - idx = 4; + // // READ MATERIAL MATRIX COMPONENTS - C14, C15, C16 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent2Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - FORTRAN(precice_multiscale_set_xstiff, (sim->mi, - &idx, - &interfaces[i]->numElements, - interfaces[i]->elementIPVectorData, - sim->xstiff)); + for (int k = 0; k < interfaces[i]->numIPTotal; k++) { + idx = k * 27 + 3; + sim->xstiff[idx] = interfaces[i]->elementIPVectorData[k * 3]; + sim->xstiff[idx + 1] = interfaces[i]->elementIPVectorData[k * 3 + 1]; + sim->xstiff[idx + 2] = interfaces[i]->elementIPVectorData[k * 3 + 2]; + } printf("Reading MATERIAL TANGENT 2 coupling data.\n"); break; case CMAT3: - // READ MATERIAL MATRIX COMPONENTS - C22, C23, C24 - idx = 7; + // // READ MATERIAL MATRIX COMPONENTS - C22, C23, C24 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent3Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - FORTRAN(precice_multiscale_set_xstiff, (sim->mi, - &idx, - &interfaces[i]->numElements, - interfaces[i]->elementIPVectorData, - sim->xstiff)); + for (int k = 0; k < interfaces[i]->numIPTotal; k++) { + idx = k * 27 + 6; + sim->xstiff[idx] = interfaces[i]->elementIPVectorData[k * 3]; + sim->xstiff[idx + 1] = interfaces[i]->elementIPVectorData[k * 3 + 1]; + sim->xstiff[idx + 2] = interfaces[i]->elementIPVectorData[k * 3 + 2]; + } printf("Reading MATERIAL TANGENT 3 coupling data.\n"); break; case CMAT4: - // READ MATERIAL MATRIX COMPONENTS - C25, C26, C33 - idx = 10; + // // READ MATERIAL MATRIX COMPONENTS - C25, C26, C33 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent4Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - FORTRAN(precice_multiscale_set_xstiff, (sim->mi, - &idx, - &interfaces[i]->numElements, - interfaces[i]->elementIPVectorData, - sim->xstiff)); + for (int k = 0; k < interfaces[i]->numIPTotal; k++) { + idx = k * 27 + 9; + sim->xstiff[idx] = interfaces[i]->elementIPVectorData[k * 3]; + sim->xstiff[idx + 1] = interfaces[i]->elementIPVectorData[k * 3 + 1]; + sim->xstiff[idx + 2] = interfaces[i]->elementIPVectorData[k * 3 + 2]; + } printf("Reading MATERIAL TANGENT 4 coupling data.\n"); break; case CMAT5: - // READ MATERIAL MATRIX COMPONENTS - C34, C35, C36 - idx = 13; + // // READ MATERIAL MATRIX COMPONENTS - C34, C35, C36 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent5Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - FORTRAN(precice_multiscale_set_xstiff, (sim->mi, - &idx, - &interfaces[i]->numElements, - interfaces[i]->elementIPVectorData, - sim->xstiff)); + for (int k = 0; k < interfaces[i]->numIPTotal; k++) { + idx = k * 27 + 12; + sim->xstiff[idx] = interfaces[i]->elementIPVectorData[k * 3]; + sim->xstiff[idx + 1] = interfaces[i]->elementIPVectorData[k * 3 + 1]; + sim->xstiff[idx + 2] = interfaces[i]->elementIPVectorData[k * 3 + 2]; + } printf("Reading MATERIAL TANGENT 5 coupling data.\n"); break; case CMAT6: - // READ MATERIAL MATRIX COMPONENTS - C44, C45, C46 - idx = 16; + // // READ MATERIAL MATRIX COMPONENTS - C44, C45, C46 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent6Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - FORTRAN(precice_multiscale_set_xstiff, (sim->mi, - &idx, - &interfaces[i]->numElements, - interfaces[i]->elementIPVectorData, - sim->xstiff)); + for (int k = 0; k < interfaces[i]->numIPTotal; k++) { + idx = k * 27 + 15; + sim->xstiff[idx] = interfaces[i]->elementIPVectorData[k * 3]; + sim->xstiff[idx + 1] = interfaces[i]->elementIPVectorData[k * 3 + 1]; + sim->xstiff[idx + 2] = interfaces[i]->elementIPVectorData[k * 3 + 2]; + } printf("Reading MATERIAL TANGENT 6 coupling data.\n"); break; case CMAT7: - // READ MATERIAL MATRIX COMPONENTS - C55, C56, C66 - idx = 19; + // // READ MATERIAL MATRIX COMPONENTS - C55, C56, C66 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent7Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - FORTRAN(precice_multiscale_set_xstiff, (sim->mi, - &idx, - &interfaces[i]->numElements, - interfaces[i]->elementIPVectorData, - sim->xstiff)); + for (int k = 0; k < interfaces[i]->numIPTotal; k++) { + idx = k * 27 + 18; + sim->xstiff[idx] = interfaces[i]->elementIPVectorData[k * 3]; + sim->xstiff[idx + 1] = interfaces[i]->elementIPVectorData[k * 3 + 1]; + sim->xstiff[idx + 2] = interfaces[i]->elementIPVectorData[k * 3 + 2]; + } printf("Reading MATERIAL TANGENT 7 coupling data.\n"); break; @@ -670,6 +668,9 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I interface->xforcIndices = NULL; // Initialize element data points as NULL + interface->elementMeshName = NULL; + interface->elemIPID = NULL; + interface->elemIPCoordinates = NULL; interface->elementIPScalarData = NULL; interface->elementIPVectorData = NULL; @@ -1139,11 +1140,18 @@ void PreciceInterface_FreeData(PreciceInterface *preciceInterface) free(preciceInterface->xloadIndices); free(preciceInterface->xforcIndices); + // Volumteric element related data + free(preciceInterface->elemIPCoordinates); + free(preciceInterface->elemIPID); + free(preciceInterface->elementIPScalarData); + free(preciceInterface->elementIPVectorData); + freeMapping(preciceInterface->mappingQuasi2D3D); // Mesh names free(preciceInterface->faceCentersMeshName); free(preciceInterface->nodesMeshName); + free(preciceInterface->elementMeshName); // Data names free(preciceInterface->displacementDeltas); diff --git a/adapter/PreciceInterface.h b/adapter/PreciceInterface.h index 6c5d1e74..f1b0d317 100644 --- a/adapter/PreciceInterface.h +++ b/adapter/PreciceInterface.h @@ -61,8 +61,8 @@ typedef struct PreciceInterface { double *nodeVectorData; // Forces, displacements, velocities, positions and displacementDeltas are vector quantities double *node2DVectorData; // Vector quantities in 2D in case quasi 2D-3D coupling is done double *faceCenterData; - double *elementIPScalarData; - double *elementIPVectorData; + double *elementIPScalarData; // Scalar quantities at the integration points + double *elementIPVectorData; // Vector quantities at the integration points // preCICE mesh name char *couplingMeshName; diff --git a/linstatic_precice.c b/linstatic_precice.c index d23299e0..dbb3e82d 100644 --- a/linstatic_precice.c +++ b/linstatic_precice.c @@ -181,10 +181,7 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak .fn = fn, .cocon = cocon, .ncocon = ncocon, - .mi = mi, - // .eei = &eei, - // .stx = &stx, - // .xstiff = xstiff + .mi = mi }; /* preCICE Adapter: Initialize */ @@ -427,6 +424,7 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak NNEW(stx, double, 6 * mi[0] * *ne); NNEW(inum, ITG, *nk); NNEW(eei, double, 6 * mi[0] * *ne); + results(co, nk, kon, ipkon, lakon, ne, v, stn, inum, stx, elcon, nelcon, rhcon, nrhcon, alcon, nalcon, alzero, ielmat, ielorien, norien, orab, ntmat_, t0, t1act, ithermal, @@ -452,11 +450,16 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak &intscheme); /* preCICE Adapter: Multiscale checkpoint*/ - simulationData.xstiff = &xstiff; - simulationData.eei = &eei; - simulationData.stx = &stx; + simulationData.xstiff = xstiff; + simulationData.eei = eei; + simulationData.stx = stx; + PreciceInterface_MultiscaleCheckpoint(&simulationData); + simulationData.eei = NULL; + simulationData.stx = NULL; + simulationData.xstiff = NULL; + SFREE(v); SFREE(fn); SFREE(stx); @@ -468,11 +471,13 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak iperturb[0] = iperturbsav; } + /* determining the system matrix and the external forces */ NNEW(ad, double, *neq); NNEW(fext, double, *neq); + if (*nmethod == 11) { /* determining the nodes and the degrees of freedom in those nodes @@ -700,6 +705,25 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak xbounact[iretain[i] - 1] = 0.; + /* preCICE Adapter: Multiscale checkpoint*/ + simulationData.xstiff = xstiff; + simulationData.eei = eei; + simulationData.stx = stx; + + // for (k = 0; k < 6 * mi[0] * *ne; k++) { + // printf("eei[%d]: %f\n", k, eei[k]); + // } + + PreciceInterface_MultiscaleCheckpoint(&simulationData); + + // for (k = 0; k < 6 * mi[0] * *ne; k++) { + // printf("stx[%d]: %f\n", k, stx[k]); + // } + + simulationData.eei = NULL; + simulationData.stx = NULL; + simulationData.xstiff = NULL; + SFREE(v); SFREE(stn); SFREE(inum); @@ -956,6 +980,25 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak SFREE(enerini); } + /* preCICE Adapter: Multiscale checkpoint*/ + simulationData.xstiff = xstiff; + simulationData.eei = eei; + simulationData.stx = stx; + + // for (k = 0; k < 6 * mi[0] * *ne; k++) { + // printf("eei[%d]: %f\n", k, eei[k]); + // } + + PreciceInterface_MultiscaleCheckpoint(&simulationData); + + // for (k = 0; k < 6 * mi[0] * *ne; k++) { + // printf("stx[%d]: %f\n", k, stx[k]); + // } + + simulationData.eei = NULL; + simulationData.stx = NULL; + simulationData.xstiff = NULL; + memcpy(&vold[0], &v[0], sizeof(double) * mt * *nk); memcpy(&sti[0], &stx[0], sizeof(double) * 6 * mi[0] * ne0); From 38fa1b8432e2119b6497d4d43d39dcef30a86b0a Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 19 Aug 2024 17:37:25 +0200 Subject: [PATCH 22/55] Trying to get gauss point coorindates from the FORTRAN side --- adapter/CCXHelpers.c | 41 ++++++------------------ adapter/PreciceInterface.c | 56 ++++++++++++++++++++++---------- getelementgausspointcoords.f | 62 +++++++++++++++++------------------- linstatic_precice.c | 57 +++++++++++++++++++++------------ 4 files changed, 116 insertions(+), 100 deletions(-) diff --git a/adapter/CCXHelpers.c b/adapter/CCXHelpers.c index af74f783..9164b057 100644 --- a/adapter/CCXHelpers.c +++ b/adapter/CCXHelpers.c @@ -93,11 +93,15 @@ void getNodeCoordinates(ITG *nodes, ITG numNodes, int dim, double *co, double *v } } -//, d -void getElementGaussPointCoordinates(int numElements, int numGPTotal, int *elementIDs, double *co, ITG *kon, char *lakon, ITG *ipkon, int *gp_id, double *gp_coord) -{ - // FORTRAN(getelementgausspointcoords, (&numElements, &numGPTotal, elementIDs, co, &lakon, kon, ipkon, gp_id, gp_coord)); -} +// void getElementGaussPointCoordinates(int numElements, int numGPTotal, int *elementIDs, double *co, ITG *kon, char *lakon, ITG *ipkon, int *gp_id, double *gp_coord) +// { +// FORTRAN(getelementgausspointcoords, (&numElements, &numGPTotal, elementIDs, co, &lakon, kon, ipkon, gp_id, gp_coord)); + +// printf("Element coordinates inside CCXHelpers.c\n"); +// for (int j = 0; j < numGPTotal; j++) { +// printf(" %d, element coordinates: %f, %f, %f \n", j, gp_coord[j * 3], gp_coord[j * 3 + 1], gp_coord[j * 3 + 2]); +// } +// } void getNodeTemperatures(ITG *nodes, ITG numNodes, double *v, int mt, double *temperatures) { @@ -502,33 +506,6 @@ void setNodeDisplacements(double *displacements, ITG numNodes, int dim, int *xbo } } -void setElementXstiff(int nelem, ITG *mi, double *cmatData, double *xstiff) -{ - printf("bbbefore setting xstiff\n"); - - // int i, count, j,xstiffSize, nSize; - // xstiffSize = 27; - // nSize = mi[0]*nelem; - // cidx = 15; - - printf("before setting xstiff\n"); - for (int i = 0; i < mi[0] * nelem * 27; i++) { - xstiff[i] = 1.0; - } - printf("after setting xstiff\n"); - - // // Loop through all element and respective gauss points - // count=0; - // for (i = 0; i < nSize; i++) { - // j = i*xstiffSize+cidx; - // printf("idx: %ld\n",j); - // xstiff[j] = 1.0; //cmatData[count]; - // xstiff[j+1] = 1.0; //cmatData[count+1]; - // xstiff[j+2] = 1.0; //cmatData[count+2]; - // count = count + 3; - // } -} - bool isSteadyStateSimulation(ITG *nmethod) { return *nmethod == 1; diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index 6e54cfe4..5a6f2ed0 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -651,11 +651,11 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I // Initialize pointers as NULL interface->elementIDs = NULL; interface->faceIDs = NULL; + interface->nodeIDs = NULL; interface->faceCenterCoordinates = NULL; interface->preciceFaceCenterIDs = NULL; interface->nodeCoordinates = NULL; interface->node2DCoordinates = NULL; - interface->nodeIDs = NULL; interface->mapping2D3D = NULL; interface->preciceNodeIDs = NULL; interface->nodeScalarData = NULL; @@ -767,25 +767,40 @@ void PreciceInterface_ConfigureElementsMesh(PreciceInterface *interface, Simulat interface->elementIDs = malloc(interface->numElements * sizeof(ITG)); getElementsIDs(interface->elementSetID, sim->ialset, sim->istartset, sim->iendset, interface->elementIDs); - for (int j = 0; j < interface->numElements; j++) { - printf(" %d, element id: %d \n", j, interface->elementIDs[j]); - } - // Find guass point coordinates of the element -> Serves as mesh for data transfer - int numElt = interface->numElements; - interface->numIPTotal = 8 * interface->numElements; // Gauss point mesh coordinate -Each element 8 gauss points + interface->numIPTotal = 8 * interface->numElements; // Gauss point mesh coordinate - each element 8 gauss points interface->elemIPCoordinates = malloc(interface->numIPTotal * 3 * sizeof(double)); interface->elemIPID = malloc(interface->numIPTotal * sizeof(int)); for (int j = 0; j < interface->numIPTotal; j++) { - interface->elemIPID[j] = j; - interface->elemIPCoordinates[j * 3] = j; - interface->elemIPCoordinates[j * 3 + 1] = 0.0; - interface->elemIPCoordinates[j * 3 + 2] = 0.0; + interface->elemIPID[j] = j; } - // getElementGaussPointCoordinates(interface->numElements, interface->numIPTotal, interface->elementIDs, sim->co, - // sim->kon, sim->lakon, sim->ipkon, interface->elemIPID, interface->elemIPCoordinates); + //getElementGaussPointCoordinates(interface->numElements, interface->numIPTotal, interface->elementIDs, sim->co, + // sim->kon, sim->lakon, sim->ipkon, interface->elemIPID, interface->elemIPCoordinates); + + int *elem_ids = malloc(interface->numElements * sizeof(ITG)); + + printf("num elements: %d\n", interface->numElements); + + int numElements = interface->numElements; + + FORTRAN(getelementgausspointcoords, (&numElements, + interface->numIPTotal, + interface->elementIDs, + sim->co, + sim->lakon, + sim->kon, + sim->ipkon, + elem_ids, + interface->elemIPCoordinates)); + + free(elem_ids); + + // print element coordinates + for (int j = 0; j < interface->numIPTotal; j++) { + printf(" %d, element coordinates: %f, %f, %f \n", j, interface->elemIPCoordinates[j * 3], interface->elemIPCoordinates[j * 3 + 1], interface->elemIPCoordinates[j * 3 + 2]); + } precicec_setMeshVertices(interface->elementMeshName, interface->numIPTotal, interface->elemIPCoordinates, interface->elemIPID); } @@ -1127,9 +1142,11 @@ void PreciceInterface_FreeData(PreciceInterface *preciceInterface) free(preciceInterface->writeData); free(preciceInterface->elementIDs); free(preciceInterface->faceIDs); + free(preciceInterface->nodeIDs); free(preciceInterface->preciceFaceCenterIDs); free(preciceInterface->faceCenterCoordinates); free(preciceInterface->nodeCoordinates); + free(preciceInterface->node2DCoordinates); free(preciceInterface->preciceNodeIDs); free(preciceInterface->nodeScalarData); free(preciceInterface->node2DScalarData); @@ -1146,12 +1163,15 @@ void PreciceInterface_FreeData(PreciceInterface *preciceInterface) free(preciceInterface->elementIPScalarData); free(preciceInterface->elementIPVectorData); + // Quasi 2D-3D coupling + free(preciceInterface->mapping2D3D); freeMapping(preciceInterface->mappingQuasi2D3D); // Mesh names free(preciceInterface->faceCentersMeshName); free(preciceInterface->nodesMeshName); free(preciceInterface->elementMeshName); + free(preciceInterface->couplingMeshName); // Data names free(preciceInterface->displacementDeltas); @@ -1177,6 +1197,10 @@ void PreciceInterface_FreeData(PreciceInterface *preciceInterface) free(preciceInterface->materialTangent5Data); free(preciceInterface->materialTangent6Data); free(preciceInterface->materialTangent7Data); + free(preciceInterface->rveid); + free(preciceInterface->modid); + free(preciceInterface->rucsize); + free(preciceInterface->conv); } void PreciceInterface_MultiscaleCheckpoint(SimulationData *sim) @@ -1187,10 +1211,10 @@ void PreciceInterface_MultiscaleCheckpoint(SimulationData *sim) // Write strain data Precice_WriteCouplingData(sim); - // Advance time - Precice_Advance(sim); - // Read stress, material tangent data Precice_ReadCouplingData(sim); + + // Advance time + Precice_Advance(sim); } } diff --git a/getelementgausspointcoords.f b/getelementgausspointcoords.f index 75b8f9fe..adb689b0 100755 --- a/getelementgausspointcoords.f +++ b/getelementgausspointcoords.f @@ -242,19 +242,17 @@ subroutine getelementgausspointcoords(NELEM, NGP, ELEM_IDS,CO, implicit none - !Input/Output variables - integer :: NELEM ! Number of elements - integer :: NGP ! Total number of elements (nelem * 8) - integer :: ELEM_IDS(*) ! Element Ids - Need to increment by 1 for C->Fortran conversion - real(8) :: CO(3,*) ! Nodal coordinates of all nodes + integer :: NELEM ! Number of elements + integer :: NGP ! Total number of elements (nelem * 8) + integer :: ELEM_IDS(*) ! Element IDs + real(8) :: CO(3,*) ! Nodal coordinates of all nodes character(8):: LAKON(*) integer :: KON(*) integer :: IPKON(*) - integer :: ELEM_GP_ID(*) ! GP ID - real :: ELEM_GP_COORD(*) ! GP coords - + integer :: ELEM_GP_ID(*) ! GP ID + real :: ELEM_GP_COORD(*) ! GP coords ! !Internal variables INTEGER(4) :: IEL, EL_ID, INDEXE, I,J,K,L, KONL(8), GP_ID @@ -262,15 +260,21 @@ subroutine getelementgausspointcoords(NELEM, NGP, ELEM_IDS,CO, CHARACTER(8) :: LAKONL REAL(8) :: XL(3,8), XI, ET, ZE, xsj,shp(4,20) - include "gauss.f" data iflag /1/ + WRITE(*,*) "STEP 1" + + WRITE(*,*) "NELEM: ", NELEM + GP_TOT = 1 DO IEL = 1, NELEM + WRITE(*,*) "IEL: ", IEL EL_ID = ELEM_IDS(IEL) + WRITE(*,*) "EL_ID: ", EL_ID + LAKONL=LAKON(EL_ID) INDEXE=ipkon(EL_ID) @@ -286,7 +290,7 @@ subroutine getelementgausspointcoords(NELEM, NGP, ELEM_IDS,CO, enddo enddo - ! Loop through gauss points fo each element + ! Loop through gauss points of each element DO GP_ID = 1,8 ELEM_GP_ID(GP_TOT) = GP_TOT-1 @@ -300,37 +304,31 @@ subroutine getelementgausspointcoords(NELEM, NGP, ELEM_IDS,CO, ! GAUSS POINT COORDINATES - ! do k=1,3 - ! do l=1,8 - ! ELEM_GP_COORD(k,GP_TOT)=ELEM_GP_COORD(k,GP_TOT) - ! & +xl(k,l)*shp(4,l) - ! enddo - ! enddo + !do k=1,3 + ! do l=1,8 + ! ELEM_GP_COORD(k*l)=ELEM_GP_COORD(k*l) + ! & +xl(k,l)*shp(4,l) + ! enddo + !enddo ELEM_GP_COORD((GP_TOT-1)*3+1) = GP_TOT-1 ! ELEM_GP_COORD(1,GP_TOT)=GP_TOT-1 - write(*,*) ELEM_GP_ID(GP_TOT), ELEM_GP_COORD((GP_TOT-1)*3+1) GP_TOT = GP_TOT+1 - - + ENDDO - - - - - - - - - ENDDO + write(*,*) "ELEMENT COORDS IN FORTRAN" + write(*,*) "=========================" + GP_TOT = 1 + do iel = 1, NELEM + do j = 1, 8 + write(*,*) ELEM_GP_ID(GP_TOT), ELEM_GP_COORD((GP_TOT-1)*3+1) + GP_TOT = GP_TOT+1 + enddo + enddo RETURN end subroutine getelementgausspointcoords - - - - diff --git a/linstatic_precice.c b/linstatic_precice.c index dbb3e82d..961d71be 100644 --- a/linstatic_precice.c +++ b/linstatic_precice.c @@ -454,8 +454,12 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak simulationData.eei = eei; simulationData.stx = stx; + printf("Before PreciceInterface_MultiscaleCheckpoint call (1)\n"); + PreciceInterface_MultiscaleCheckpoint(&simulationData); + printf("After PreciceInterface_MultiscaleCheckpoint call (1)\n"); + simulationData.eei = NULL; simulationData.stx = NULL; simulationData.xstiff = NULL; @@ -471,7 +475,6 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak iperturb[0] = iperturbsav; } - /* determining the system matrix and the external forces */ NNEW(ad, double, *neq); @@ -523,7 +526,9 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak if (iglob < 0) { mass[0] = 1; NNEW(adb, double, *neq); + printf("adb is allocated\n"); NNEW(aub, double, nzs[1]); + printf("aub is allocated\n"); } } @@ -710,15 +715,11 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak simulationData.eei = eei; simulationData.stx = stx; - // for (k = 0; k < 6 * mi[0] * *ne; k++) { - // printf("eei[%d]: %f\n", k, eei[k]); - // } + printf("Before PreciceInterface_MultiscaleCheckpoint call (2)\n"); PreciceInterface_MultiscaleCheckpoint(&simulationData); - // for (k = 0; k < 6 * mi[0] * *ne; k++) { - // printf("stx[%d]: %f\n", k, stx[k]); - // } + printf("After PreciceInterface_MultiscaleCheckpoint call (2)\n"); simulationData.eei = NULL; simulationData.stx = NULL; @@ -728,6 +729,7 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak SFREE(stn); SFREE(inum); SFREE(stx); + SFREE(eei); if (strcmp1(&filab[261], "E ") == 0) SFREE(een); @@ -806,11 +808,27 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak } else if (*nmethod != 0) { /* linear static applications */ + printf("DEBUGGING STEP 1\n"); if (*isolver == 0) { #ifdef SPOOLES + printf("Before spooles\n"); + printf("ad[0] = %f\n", ad[0]); + printf("au[0] = %f\n", au[0]); + //printf("adb[0] = %f\n", adb[0]); + //printf("aub[0] = %f\n", aub[0]); + printf("sigma = %f\n", sigma); + printf("b[0] = %f\n", b[0]); + printf("icol[0] = %d\n", icol[0]); + printf("irow[0] = %d\n", irow[0]); + printf("neq[0] = %d\n", neq[0]); + printf("nzs[0] = %d\n", nzs[0]); + printf("symmetryflag = %d\n", symmetryflag); + printf("inputformat = %d\n", inputformat); + printf("nzs[2] = %d\n", nzs[2]); spooles(ad, au, adb, aub, &sigma, b, icol, irow, neq, nzs, &symmetryflag, &inputformat, &nzs[2]); + printf("After spooles\n"); #else printf(" *ERROR in linstatic: the SPOOLES library is not linked\n\n"); FORTRAN(stop, ()); @@ -876,6 +894,7 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak } /* storing the stiffness matrix */ + printf("DEBUGGING STEP 2\n"); /* nzs,irow,jq and icol have to be stored too, since the static analysis can involve contact, whereas in the sensitivity analysis contact is not @@ -981,23 +1000,21 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak } /* preCICE Adapter: Multiscale checkpoint*/ - simulationData.xstiff = xstiff; - simulationData.eei = eei; - simulationData.stx = stx; + simulationData.xstiff = xstiff; + simulationData.eei = eei; + simulationData.stx = stx; - // for (k = 0; k < 6 * mi[0] * *ne; k++) { - // printf("eei[%d]: %f\n", k, eei[k]); - // } + printf("Before PreciceInterface_MultiscaleCheckpoint call (3)\n"); - PreciceInterface_MultiscaleCheckpoint(&simulationData); + PreciceInterface_MultiscaleCheckpoint(&simulationData); - // for (k = 0; k < 6 * mi[0] * *ne; k++) { - // printf("stx[%d]: %f\n", k, stx[k]); - // } + printf("After PreciceInterface_MultiscaleCheckpoint call (3)\n"); - simulationData.eei = NULL; - simulationData.stx = NULL; - simulationData.xstiff = NULL; + simulationData.eei = NULL; + simulationData.stx = NULL; + simulationData.xstiff = NULL; + + SFREE(eei); memcpy(&vold[0], &v[0], sizeof(double) * mt * *nk); memcpy(&sti[0], &stx[0], sizeof(double) * 6 * mi[0] * ne0); From 7dc1468954d9e55850f7d040dee60ac8518418cc Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Thu, 22 Aug 2024 18:01:25 +0200 Subject: [PATCH 23/55] Working version of the subroutine getelementgausspointcoords.f and related C code --- adapter/CCXHelpers.c | 10 - adapter/CCXHelpers.h | 10 + getelementgausspointcoords.f | 343 ++++++----------------------------- 3 files changed, 65 insertions(+), 298 deletions(-) diff --git a/adapter/CCXHelpers.c b/adapter/CCXHelpers.c index 9164b057..1c7600dd 100644 --- a/adapter/CCXHelpers.c +++ b/adapter/CCXHelpers.c @@ -93,16 +93,6 @@ void getNodeCoordinates(ITG *nodes, ITG numNodes, int dim, double *co, double *v } } -// void getElementGaussPointCoordinates(int numElements, int numGPTotal, int *elementIDs, double *co, ITG *kon, char *lakon, ITG *ipkon, int *gp_id, double *gp_coord) -// { -// FORTRAN(getelementgausspointcoords, (&numElements, &numGPTotal, elementIDs, co, &lakon, kon, ipkon, gp_id, gp_coord)); - -// printf("Element coordinates inside CCXHelpers.c\n"); -// for (int j = 0; j < numGPTotal; j++) { -// printf(" %d, element coordinates: %f, %f, %f \n", j, gp_coord[j * 3], gp_coord[j * 3 + 1], gp_coord[j * 3 + 2]); -// } -// } - void getNodeTemperatures(ITG *nodes, ITG numNodes, double *v, int mt, double *temperatures) { diff --git a/adapter/CCXHelpers.h b/adapter/CCXHelpers.h index 181d63dd..876c0c89 100644 --- a/adapter/CCXHelpers.h +++ b/adapter/CCXHelpers.h @@ -107,6 +107,16 @@ ITG getNumSetElements(ITG setID, ITG *istartset, ITG *iendset); */ void getSurfaceElementsAndFaces(ITG setID, ITG *ialset, ITG *istartset, ITG *iendset, ITG *elements, ITG *faces); +/** + * @brief Gets the element IDs given a set ID + * @param setID: input set id + * @param ialset: CalculiX variable + * @param istartset: CalculiX variable + * @param iendset: CalculiX variable + * @param elements: output element IDs + */ +void getElementsIDs(ITG setID, ITG *ialset, ITG *istartset, ITG *iendset, ITG *elements); + /** * @brief Gets the coordinates of a list of input node IDs * @param nodes: input node IDs diff --git a/getelementgausspointcoords.f b/getelementgausspointcoords.f index adb689b0..664f9c3f 100755 --- a/getelementgausspointcoords.f +++ b/getelementgausspointcoords.f @@ -16,319 +16,86 @@ ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! -! subroutine getgausspointscoords(co, -! & iset,istartset,iendset,ipkon,lakon,kon, -! & ialset) -! ! -! ! calculation and printout of the lift and drag forces -! ! -! implicit none -! ! -! character*8 lakonl,lakon(*) -! ! -! integer konl(20),ifaceq(8,6),nelem,ii,i,j,i1,i2,j1, -! & k1,jj,ig,nope,nopes, -! & mint2d,ifacet(6,4),ifacew(8,5),iflag,indexe,jface,istartset(*), -! & iendset(*),ipkon(*),kon(*),iset,ialset(*), -! & fidx -! ! -! real*8 co(3,*),xl(3,20),shp(4,20),xs2(3,7),dvi,f(0:3), -! & vkl(0:3,3),t(3,3),div, -! & xl2(3,8),xsj2(3), -! & shp2(7,8),xi,et,xsj,temp,xi3d,et3d,ze3d,weight, -! & xlocal20(3,9,6),xlocal4(3,1,4),xlocal10(3,3,4),xlocal6(3,1,5), -! & xlocal15(3,4,5),xlocal8(3,4,6),xlocal8r(3,1,6),pres, -! & tf(0:3),tn,tt,dd,coords(3) -! ! -! include "gauss.f" -! include "xlocal.f" -! ! -! data ifaceq /4,3,2,1,11,10,9,12, -! & 5,6,7,8,13,14,15,16, -! & 1,2,6,5,9,18,13,17, -! & 2,3,7,6,10,19,14,18, -! & 3,4,8,7,11,20,15,19, -! & 4,1,5,8,12,17,16,20/ -! data ifacet /1,3,2,7,6,5, -! & 1,2,4,5,9,8, -! & 2,3,4,6,10,9, -! & 1,4,3,8,10,7/ -! data ifacew /1,3,2,9,8,7,0,0, -! & 4,5,6,10,11,12,0,0, -! & 1,2,5,4,7,14,10,13, -! & 2,3,6,5,8,15,11,14, -! & 4,6,3,1,12,15,9,13/ -! data iflag /3/ -! ! -! ! -! ! -! ! initialisierung of the flux -! ! -! f(0)=0.d0 - -! ! index for the output array -! fidx=1 - -! ! -! ! -! do jj=istartset(iset),iendset(iset) -! ! -! jface=ialset(jj) -! ! -! nelem=int(jface/10.d0) -! ig=jface-10*nelem -! lakonl=lakon(nelem) -! indexe=ipkon(nelem) -! ! -! if(lakonl(4:4).eq.'2') then -! nope=20 -! nopes=8 -! elseif(lakonl(4:4).eq.'8') then -! nope=8 -! nopes=4 -! elseif(lakonl(4:5).eq.'10') then -! nope=10 -! nopes=6 -! elseif(lakonl(4:4).eq.'4') then -! nope=4 -! nopes=3 -! elseif(lakonl(4:5).eq.'15') then -! nope=15 -! elseif(lakonl(4:4).eq.'6') then -! nope=6 -! endif -! ! -! if(lakonl(4:5).eq.'8R') then -! mint2d=1 -! elseif((lakonl(4:4).eq.'8').or.(lakonl(4:6).eq.'20R')) -! & then -! if((lakonl(7:7).eq.'A').or.(lakonl(7:7).eq.'S').or. -! & (lakonl(7:7).eq.'E')) then -! mint2d=2 -! else -! mint2d=4 -! endif -! elseif(lakonl(4:4).eq.'2') then -! mint2d=9 -! elseif(lakonl(4:5).eq.'10') then -! mint2d=3 -! elseif(lakonl(4:4).eq.'4') then -! mint2d=1 -! endif -! ! -! ! local topology -! ! -! do i=1,nope -! konl(i)=kon(indexe+i) -! enddo -! ! -! ! computation of the coordinates of the local nodes -! ! -! do i=1,nope -! do j=1,3 -! xl(j,i)=co(j,konl(i)) -! enddo -! enddo -! ! -! ! treatment of wedge faces -! ! -! if(lakonl(4:4).eq.'6') then -! mint2d=1 -! if(ig.le.2) then -! nopes=3 -! else -! nopes=4 -! endif -! endif -! if(lakonl(4:5).eq.'15') then -! if(ig.le.2) then -! mint2d=3 -! nopes=6 -! else -! mint2d=4 -! nopes=8 -! endif -! endif -! ! -! if((nope.eq.20).or.(nope.eq.8)) then -! do i=1,nopes -! do j=1,3 -! xl2(j,i)=co(j,konl(ifaceq(i,ig))) -! enddo -! enddo -! elseif((nope.eq.10).or.(nope.eq.4)) then -! do i=1,nopes -! do j=1,3 -! xl2(j,i)=co(j,konl(ifacet(i,ig))) -! enddo -! enddo -! else -! do i=1,nopes -! do j=1,3 -! xl2(j,i)=co(j,konl(ifacew(i,ig))) -! enddo -! enddo -! endif -! ! - - -! do i=1,mint2d -! ! -! ! local coordinates of the surface integration -! ! point within the surface local coordinate system -! ! -! if((lakonl(4:5).eq.'8R').or. -! & ((lakonl(4:4).eq.'6').and.(nopes.eq.4))) then -! xi=gauss2d1(1,i) -! et=gauss2d1(2,i) -! weight=weight2d1(i) -! elseif((lakonl(4:4).eq.'8').or. -! & (lakonl(4:6).eq.'20R').or. -! & ((lakonl(4:5).eq.'15').and.(nopes.eq.8))) then -! xi=gauss2d2(1,i) -! et=gauss2d2(2,i) -! weight=weight2d2(i) -! elseif(lakonl(4:4).eq.'2') then -! xi=gauss2d3(1,i) -! et=gauss2d3(2,i) -! weight=weight2d3(i) -! elseif((lakonl(4:5).eq.'10').or. -! & ((lakonl(4:5).eq.'15').and.(nopes.eq.6))) then -! xi=gauss2d5(1,i) -! et=gauss2d5(2,i) -! weight=weight2d5(i) -! elseif((lakonl(4:4).eq.'4').or. -! & ((lakonl(4:4).eq.'6').and.(nopes.eq.3))) then -! xi=gauss2d4(1,i) -! et=gauss2d4(2,i) -! weight=weight2d4(i) -! endif -! ! -! ! local surface normal -! ! -! if(nopes.eq.8) then -! call shape8q(xi,et,xl2,xsj2,xs2,shp2,iflag) -! elseif(nopes.eq.4) then -! call shape4q(xi,et,xl2,xsj2,xs2,shp2,iflag) -! elseif(nopes.eq.6) then -! call shape6tri(xi,et,xl2,xsj2,xs2,shp2,iflag) -! else -! call shape3tri(xi,et,xl2,xsj2,xs2,shp2,iflag) -! endif -! ! -! ! global coordinates of the integration point -! ! -! do j1=1,3 -! coords(j1)=0.d0 -! do i1=1,nopes -! coords(j1)=coords(j1)+shp2(4,i1)*xl2(j1,i1) -! enddo -! enddo - -! print *, coords(1), coords(2), coords(3) - -! ! -! enddo - - -! enddo -! ! -! ! -! return -! end -!, NGP, ELEM_IDS, CO, LAKON, KON, ELEM_GP_ID, ELEM_GP_COORD - subroutine getelementgausspointcoords(NELEM, NGP, ELEM_IDS,CO, - & LAKON, KON, IPKON, ELEM_GP_ID, ELEM_GP_COORD) +! This function is a copy of the function for calculation and printout of the lift and drag forces +! + subroutine getelementgausspointcoords(nelem, ngp, elem_ids, co, + & lakon, kon, ipkon, elem_gp_id, elem_gp_coord) implicit none !Input/Output variables - integer :: NELEM ! Number of elements - integer :: NGP ! Total number of elements (nelem * 8) - integer :: ELEM_IDS(*) ! Element IDs - real(8) :: CO(3,*) ! Nodal coordinates of all nodes - character(8):: LAKON(*) - integer :: KON(*) - integer :: IPKON(*) - - integer :: ELEM_GP_ID(*) ! GP ID - real :: ELEM_GP_COORD(*) ! GP coords - - ! !Internal variables - INTEGER(4) :: IEL, EL_ID, INDEXE, I,J,K,L, KONL(8), GP_ID - INTEGER(4) :: GP_TOT,IFLAG - CHARACTER(8) :: LAKONL - REAL(8) :: XL(3,8), XI, ET, ZE, xsj,shp(4,20) + integer :: nelem ! Number of elements + integer :: ngp ! Total number of elements (nelem * 8) + integer :: elem_ids(*) ! Element IDs, need to be adjusted for Fortran + real(8) :: co(3,*) ! Nodal coordinates of all nodes + character(8):: lakon(*) + integer :: kon(*) + integer :: ipkon(*) + + integer :: elem_gp_id(*) ! GP ID + real(8) :: elem_gp_coord(*) ! GP coords + + ! Internal variables + integer(4) :: iel, el_id, indexe, i, j, k, l + integer(4) :: iflag, idx, konl(8), gp_id + REAL(8) :: xl(3,8), xi, et, ze, xsj, shp(4,20) include "gauss.f" data iflag /1/ - WRITE(*,*) "STEP 1" + ! Increment element IDs by one to match Fortran indexing + do iel = 1, nelem + elem_ids(iel) = elem_ids(iel) + 1 + end do - WRITE(*,*) "NELEM: ", NELEM + ! Initialize gauss point coordinates to zero + do l = 1, nelem*8*3 + elem_gp_coord(l) = 0.0 + end do - GP_TOT = 1 - DO IEL = 1, NELEM - WRITE(*,*) "IEL: ", IEL - EL_ID = ELEM_IDS(IEL) + do iel = 1, nelem + el_id = elem_ids(iel) - WRITE(*,*) "EL_ID: ", EL_ID + indexe=ipkon(el_id) - LAKONL=LAKON(EL_ID) - INDEXE=ipkon(EL_ID) - - ! Connectivity - do i=1,8 + ! connectivity + do i = 1, 8 konl(i)=kon(indexe+i) - enddo + end do ! Local nodal coordinates - do i=1,8 - do j=1,3 + do i = 1, 8 + do j = 1, 3 xl(j,i)=co(j,konl(i)) - enddo - enddo + end do + end do ! Loop through gauss points of each element - DO GP_ID = 1,8 - ELEM_GP_ID(GP_TOT) = GP_TOT-1 + do gp_id = 1,8 + elem_gp_id((el_id - 1)*8 + gp_id) = + & (el_id - 1)*8 + gp_id - 1 - ! GAUSS POINTS - xi=gauss3d2(1,GP_ID) - et=gauss3d2(2,GP_ID) - ze=gauss3d2(3,GP_ID) + xi = gauss3d2(1,gp_id) + et = gauss3d2(2,gp_id) + ze = gauss3d2(3,gp_id) - ! SHAPE FUNCTION + ! Get the shape function call shape8h(xi,et,ze,xl,xsj,shp,iflag) - ! GAUSS POINT COORDINATES - - !do k=1,3 - ! do l=1,8 - ! ELEM_GP_COORD(k*l)=ELEM_GP_COORD(k*l) - ! & +xl(k,l)*shp(4,l) - ! enddo - !enddo - ELEM_GP_COORD((GP_TOT-1)*3+1) = GP_TOT-1 - ! ELEM_GP_COORD(1,GP_TOT)=GP_TOT-1 - - GP_TOT = GP_TOT+1 - - ENDDO + ! Calculate the Gauss point coordinates + do k = 1, 3 + do l = 1, 8 + idx = (el_id - 1)*24 + (gp_id - 1)*3 + k + elem_gp_coord(idx)=elem_gp_coord(idx) + & +xl(k,l)*shp(4,l) + end do + end do - ENDDO + end do - write(*,*) "ELEMENT COORDS IN FORTRAN" - write(*,*) "=========================" - GP_TOT = 1 - do iel = 1, NELEM - do j = 1, 8 - write(*,*) ELEM_GP_ID(GP_TOT), ELEM_GP_COORD((GP_TOT-1)*3+1) - GP_TOT = GP_TOT+1 - enddo - enddo + end do - RETURN + RetURN end subroutine getelementgausspointcoords From b36a9680100f31f9d645072baa228f89f6953335 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Tue, 5 Nov 2024 16:35:32 +0100 Subject: [PATCH 24/55] Working version for a linear static problem --- .pre-commit-config.yaml | 2 +- adapter/PreciceInterface.c | 115 ++++++++++++++++--------------------- adapter/PreciceInterface.h | 77 ++++++++++++++----------- linstatic_precice.c | 66 +++++++-------------- 4 files changed, 113 insertions(+), 147 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3556f370..3ea640e4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ repos: # Official repo for the clang-format hook - repo: https://github.com/pre-commit/mirrors-clang-format - rev: 'v8.0.1' + rev: 'v19.1.2' hooks: - id: clang-format files: "^adapter" diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index 5a6f2ed0..25f57231 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -284,6 +284,13 @@ void Precice_ReadCouplingData(SimulationData *sim) // READ MATERIAL MATRIX COMPONENTS - C11, C12, C13 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent1Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); + printf("Reading MATERIAL TANGENT 1 coupling data.\n"); + + // for (int k = 0; k < interfaces[i]->numIPTotal; k++) { + // idx = k * 27 + 0; + // printf("idx: %d, read stiffness: %f, %f, %f\n", idx, interfaces[i]->elementIPVectorData[k * 3], interfaces[i]->elementIPVectorData[k * 3 + 1], interfaces[i]->elementIPVectorData[k * 3 + 2]); + // } + for (int k = 0; k < interfaces[i]->numIPTotal; k++) { idx = k * 27 + 0; sim->xstiff[idx] = interfaces[i]->elementIPVectorData[k * 3]; @@ -294,7 +301,7 @@ void Precice_ReadCouplingData(SimulationData *sim) break; case CMAT2: - // // READ MATERIAL MATRIX COMPONENTS - C14, C15, C16 + // READ MATERIAL MATRIX COMPONENTS - C14, C15, C16 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent2Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); for (int k = 0; k < interfaces[i]->numIPTotal; k++) { idx = k * 27 + 3; @@ -306,7 +313,7 @@ void Precice_ReadCouplingData(SimulationData *sim) break; case CMAT3: - // // READ MATERIAL MATRIX COMPONENTS - C22, C23, C24 + // READ MATERIAL MATRIX COMPONENTS - C22, C23, C24 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent3Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); for (int k = 0; k < interfaces[i]->numIPTotal; k++) { idx = k * 27 + 6; @@ -318,7 +325,7 @@ void Precice_ReadCouplingData(SimulationData *sim) break; case CMAT4: - // // READ MATERIAL MATRIX COMPONENTS - C25, C26, C33 + // READ MATERIAL MATRIX COMPONENTS - C25, C26, C33 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent4Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); for (int k = 0; k < interfaces[i]->numIPTotal; k++) { idx = k * 27 + 9; @@ -330,7 +337,7 @@ void Precice_ReadCouplingData(SimulationData *sim) break; case CMAT5: - // // READ MATERIAL MATRIX COMPONENTS - C34, C35, C36 + // READ MATERIAL MATRIX COMPONENTS - C34, C35, C36 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent5Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); for (int k = 0; k < interfaces[i]->numIPTotal; k++) { idx = k * 27 + 12; @@ -342,7 +349,7 @@ void Precice_ReadCouplingData(SimulationData *sim) break; case CMAT6: - // // READ MATERIAL MATRIX COMPONENTS - C44, C45, C46 + // READ MATERIAL MATRIX COMPONENTS - C44, C45, C46 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent6Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); for (int k = 0; k < interfaces[i]->numIPTotal; k++) { idx = k * 27 + 15; @@ -354,7 +361,7 @@ void Precice_ReadCouplingData(SimulationData *sim) break; case CMAT7: - // // READ MATERIAL MATRIX COMPONENTS - C55, C56, C66 + // READ MATERIAL MATRIX COMPONENTS - C55, C56, C66 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent7Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); for (int k = 0; k < interfaces[i]->numIPTotal; k++) { idx = k * 27 + 18; @@ -588,14 +595,14 @@ void Precice_WriteCouplingData(SimulationData *sim) case STRAIN1TO3: idx = 0; getElementStrain(idx, sim->mi, interfaces[i]->numElements, sim->eei, interfaces[i]->elementIPVectorData); - //printf("strain1to3 values: %d\n", interfaces[i]->elementIPVectorData[0]); + // printf("strain1to3 values: %d\n", interfaces[i]->elementIPVectorData[0]); precicec_writeData(interfaces[i]->couplingMeshName, interfaces[i]->strain1to3Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, interfaces[i]->elementIPVectorData); printf("Writing STRAIN1TO3 coupling data.\n"); break; case STRAIN4TO6: idx = 3; getElementStrain(idx, sim->mi, interfaces[i]->numElements, sim->eei, interfaces[i]->elementIPVectorData); - //printf("strain4to6 values: %d\n", interfaces[i]->elementIPVectorData[0]); + // printf("strain4to6 values: %d\n", interfaces[i]->elementIPVectorData[0]); precicec_writeData(interfaces[i]->couplingMeshName, interfaces[i]->strain4to6Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, interfaces[i]->elementIPVectorData); printf("Writing STRAIN4TO6 coupling data.\n"); break; @@ -693,18 +700,18 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I interface->rveid = NULL; interface->modid = NULL; interface->rucsize = NULL; - - interface->strain1to3Data = NULL; - interface->strain4to6Data = NULL; - interface->stress1to3Data = NULL; - interface->stress4to6Data = NULL; - interface->materialTangent1Data = NULL; - interface->materialTangent2Data = NULL; - interface->materialTangent3Data = NULL; - interface->materialTangent4Data = NULL; - interface->materialTangent5Data = NULL; - interface->materialTangent6Data = NULL; - interface->materialTangent7Data = NULL; + interface->conv = NULL; + interface->strain1to3Data = NULL; + interface->strain4to6Data = NULL; + interface->stress1to3Data = NULL; + interface->stress4to6Data = NULL; + interface->materialTangent1Data = NULL; + interface->materialTangent2Data = NULL; + interface->materialTangent3Data = NULL; + interface->materialTangent4Data = NULL; + interface->materialTangent5Data = NULL; + interface->materialTangent6Data = NULL; + interface->materialTangent7Data = NULL; // Check if quasi 2D-3D coupling needs to be implemented if (interface->dim == 2) { @@ -716,8 +723,8 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I interface->dimCCX = interface->dim; } - //Mapping Type - // The patch identifies the set used as interface in Calculix + // Mapping Type + // The patch identifies the set used as interface in Calculix interface->name = strdup(config->patchName); // Calculix needs to know if nearest-projection mapping is implemented. config->map = 1 is for nearest-projection, config->map = 0 is for everything else interface->mapNPType = config->map; @@ -757,13 +764,10 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I void PreciceInterface_ConfigureElementsMesh(PreciceInterface *interface, SimulationData *sim) { printf("Entering ConfigureElementsMesh \n"); - char *elementSetName = interface->name; //toFaceSetName(interface->name); + char *elementSetName = interface->name; // toFaceSetName(interface->name); interface->elementSetID = getSetID(elementSetName, sim->set, sim->nset); interface->numElements = getNumSetElements(interface->elementSetID, sim->istartset, sim->iendset); - printf("element set id : %d\n", interface->elementSetID); - printf("num elements : %d\n", interface->numElements); - interface->elementIDs = malloc(interface->numElements * sizeof(ITG)); getElementsIDs(interface->elementSetID, sim->ialset, sim->istartset, sim->iendset, interface->elementIDs); @@ -776,38 +780,27 @@ void PreciceInterface_ConfigureElementsMesh(PreciceInterface *interface, Simulat interface->elemIPID[j] = j; } - //getElementGaussPointCoordinates(interface->numElements, interface->numIPTotal, interface->elementIDs, sim->co, - // sim->kon, sim->lakon, sim->ipkon, interface->elemIPID, interface->elemIPCoordinates); - - int *elem_ids = malloc(interface->numElements * sizeof(ITG)); - - printf("num elements: %d\n", interface->numElements); - - int numElements = interface->numElements; + int numElements = interface->numElements; + int numIPTotal = interface->numIPTotal; + char **lakon = sim->lakon; + // Directly call Fortran function from getelementgausspointcoords.f FORTRAN(getelementgausspointcoords, (&numElements, - interface->numIPTotal, + &numIPTotal, interface->elementIDs, sim->co, - sim->lakon, + &lakon, sim->kon, sim->ipkon, - elem_ids, + interface->elemIPID, interface->elemIPCoordinates)); - free(elem_ids); - - // print element coordinates - for (int j = 0; j < interface->numIPTotal; j++) { - printf(" %d, element coordinates: %f, %f, %f \n", j, interface->elemIPCoordinates[j * 3], interface->elemIPCoordinates[j * 3 + 1], interface->elemIPCoordinates[j * 3 + 2]); - } - precicec_setMeshVertices(interface->elementMeshName, interface->numIPTotal, interface->elemIPCoordinates, interface->elemIPID); } void PreciceInterface_ConfigureFaceCentersMesh(PreciceInterface *interface, SimulationData *sim) { - //printf("Entering ConfigureFaceCentersMesh \n"); + // printf("Entering ConfigureFaceCentersMesh \n"); char *faceSetName = toFaceSetName(interface->name); interface->faceSetID = getSetID(faceSetName, sim->set, sim->nset); interface->numElements = getNumSetElements(interface->faceSetID, sim->istartset, sim->iendset); @@ -844,11 +837,11 @@ void sendFaceCentersVertices(PreciceInterface *interface) void PreciceInterface_ConfigureNodesMesh(PreciceInterface *interface, SimulationData *sim) { - //printf("Entering configureNodesMesh \n"); + // printf("Entering configureNodesMesh \n"); char *nodeSetName = toNodeSetName(interface->name); interface->nodeSetID = getSetID(nodeSetName, sim->set, sim->nset); interface->numNodes = getNumSetElements(interface->nodeSetID, sim->istartset, sim->iendset); - interface->nodeIDs = &sim->ialset[sim->istartset[interface->nodeSetID] - 1]; //Lucia: make a copy + interface->nodeIDs = &sim->ialset[sim->istartset[interface->nodeSetID] - 1]; // Lucia: make a copy interface->nodeCoordinates = malloc(interface->numNodes * interface->dimCCX * sizeof(double)); getNodeCoordinates(interface->nodeIDs, interface->numNodes, interface->dimCCX, sim->co, sim->vold, sim->mt, interface->nodeCoordinates); @@ -875,8 +868,8 @@ void PreciceInterface_ConfigureNodesMesh(PreciceInterface *interface, Simulation } if (interface->nodesMeshName != NULL) { - //printf("nodesMeshName is not null \n"); - // interface->nodesMeshID = precicec_getMeshID(interface->nodesMeshName); + // printf("nodesMeshName is not null \n"); + // interface->nodesMeshID = precicec_getMeshID(interface->nodesMeshName); if (isQuasi2D3D(interface->quasi2D3D)) { interface->mappingQuasi2D3D = createMapping(interface->nodeCoordinates, interface->numNodes, interface->nodesMeshName); } else { @@ -1165,13 +1158,17 @@ void PreciceInterface_FreeData(PreciceInterface *preciceInterface) // Quasi 2D-3D coupling free(preciceInterface->mapping2D3D); - freeMapping(preciceInterface->mappingQuasi2D3D); + if (preciceInterface->quasi2D3D) { + freeMapping(preciceInterface->mappingQuasi2D3D); + } + printf("Freeing mesh names\n"); // Mesh names free(preciceInterface->faceCentersMeshName); free(preciceInterface->nodesMeshName); free(preciceInterface->elementMeshName); - free(preciceInterface->couplingMeshName); + + printf("Freeing data names\n"); // Data names free(preciceInterface->displacementDeltas); @@ -1201,20 +1198,6 @@ void PreciceInterface_FreeData(PreciceInterface *preciceInterface) free(preciceInterface->modid); free(preciceInterface->rucsize); free(preciceInterface->conv); -} - -void PreciceInterface_MultiscaleCheckpoint(SimulationData *sim) -{ - if (Precice_IsCouplingOngoing()) { - - // Write strain data - Precice_WriteCouplingData(sim); - - // Read stress, material tangent data - Precice_ReadCouplingData(sim); - - // Advance time - Precice_Advance(sim); - } + printf("Freed all data\n"); } diff --git a/adapter/PreciceInterface.h b/adapter/PreciceInterface.h index f1b0d317..510f549f 100644 --- a/adapter/PreciceInterface.h +++ b/adapter/PreciceInterface.h @@ -28,32 +28,32 @@ typedef struct PreciceInterface { // Interface nodes int numNodes; int num2DNodes; // Nodes in a single plane in case of quasi 2D-3D coupling - int * nodeIDs; - int * mapping2D3D; // Node IDs to filter out 2D place in quasi 2D-3D coupling + int *nodeIDs; + int *mapping2D3D; // Node IDs to filter out 2D place in quasi 2D-3D coupling Mapping2D3D *mappingQuasi2D3D; - double * nodeCoordinates; - double * node2DCoordinates; // 2D coordinates for quasi 2D-3D coupling + double *nodeCoordinates; + double *node2DCoordinates; // 2D coordinates for quasi 2D-3D coupling int nodeSetID; - int * preciceNodeIDs; + int *preciceNodeIDs; int nodesMeshID; - char * nodesMeshName; + char *nodesMeshName; // Interface face elements int numElements; - int * elementIDs; - int * faceIDs; + int *elementIDs; + int *faceIDs; double *faceCenterCoordinates; int faceSetID; - char * faceCentersMeshName; - int * preciceFaceCenterIDs; + char *faceCentersMeshName; + int *preciceFaceCenterIDs; // Interface volumetric elements int elementMeshID; - char * elementMeshName; + char *elementMeshName; int elementSetID; int numIPTotal; double *elemIPCoordinates; - int * elemIPID; + int *elemIPID; // Arrays to store the coupling data double *nodeScalarData; @@ -124,44 +124,44 @@ typedef struct PreciceInterface { typedef struct SimulationData { // CalculiX data - ITG * ialset; - ITG * ielmat; - ITG * istartset; - ITG * iendset; - char ** lakon; - ITG * kon; - ITG * ipkon; + ITG *ialset; + ITG *ielmat; + ITG *istartset; + ITG *iendset; + char **lakon; + ITG *kon; + ITG *ipkon; ITG nset; - char * set; + char *set; double *co; ITG nboun; - ITG nforc; //total number of forces - ITG * ikboun; - ITG * ikforc; //the DoFs are all stored here in an array in numerical order - ITG * ilboun; - ITG * ilforc; //number of the force is stored here - ITG * nelemload; + ITG nforc; // total number of forces + ITG *ikboun; + ITG *ikforc; // the DoFs are all stored here in an array in numerical order + ITG *ilboun; + ITG *ilforc; // number of the force is stored here + ITG *nelemload; int nload; - char * sideload; + char *sideload; double nk; double ne; // new variable added ITG mt; double *theta; double *dtheta; double *tper; - ITG * nmethod; + ITG *nmethod; double *xload; - double *xforc; //scalar value of the force in one direction + double *xforc; // scalar value of the force in one direction double *xboun; - ITG * ntmat_; + ITG *ntmat_; double *vold; double *veold; - double *fn; //values of forces read from calculix + double *fn; // values of forces read from calculix double *cocon; - ITG * ncocon; - ITG * mi; - ITG * nea; // element bounds in each thread - start - ITG * neb; // element bounds in each thread - end + ITG *ncocon; + ITG *mi; + ITG *nea; // element bounds in each thread - start + ITG *neb; // element bounds in each thread - end double *eei; // Strain values for multiscale double *stx; // Stress values for multiscale double *xstiff; // Strain values for multiscale @@ -290,6 +290,13 @@ void Precice_FreeData(SimulationData *sim); */ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, InterfaceConfig const *config); +/** + * @brief Configures the elements mesh and calls setMeshVertices on preCICE + * @param interface + * @param sim + */ +void PreciceInterface_ConfigureElementsMesh(PreciceInterface *interface, SimulationData *sim); + /** * @brief Configures the face centers mesh and calls setMeshVertices on preCICE * @param interface diff --git a/linstatic_precice.c b/linstatic_precice.c index 961d71be..e0065359 100644 --- a/linstatic_precice.c +++ b/linstatic_precice.c @@ -449,16 +449,20 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak labmpc2, ikboun2, ilboun2, ikmpc2, ilmpc2, &mortartrafoflag, &intscheme); - /* preCICE Adapter: Multiscale checkpoint*/ simulationData.xstiff = xstiff; simulationData.eei = eei; simulationData.stx = stx; - printf("Before PreciceInterface_MultiscaleCheckpoint call (1)\n"); + if (Precice_IsCouplingOngoing()) { + printf("Write coupling data\n"); + Precice_WriteCouplingData(&simulationData); - PreciceInterface_MultiscaleCheckpoint(&simulationData); + printf("Advancing the coupling\n"); + Precice_Advance(&simulationData); - printf("After PreciceInterface_MultiscaleCheckpoint call (1)\n"); + printf("Read the coupling\n"); + Precice_ReadCouplingData(&simulationData); + } simulationData.eei = NULL; simulationData.stx = NULL; @@ -526,9 +530,7 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak if (iglob < 0) { mass[0] = 1; NNEW(adb, double, *neq); - printf("adb is allocated\n"); NNEW(aub, double, nzs[1]); - printf("aub is allocated\n"); } } @@ -710,21 +712,6 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak xbounact[iretain[i] - 1] = 0.; - /* preCICE Adapter: Multiscale checkpoint*/ - simulationData.xstiff = xstiff; - simulationData.eei = eei; - simulationData.stx = stx; - - printf("Before PreciceInterface_MultiscaleCheckpoint call (2)\n"); - - PreciceInterface_MultiscaleCheckpoint(&simulationData); - - printf("After PreciceInterface_MultiscaleCheckpoint call (2)\n"); - - simulationData.eei = NULL; - simulationData.stx = NULL; - simulationData.xstiff = NULL; - SFREE(v); SFREE(stn); SFREE(inum); @@ -806,26 +793,11 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak return; } else if (*nmethod != 0) { - /* linear static applications */ - printf("DEBUGGING STEP 1\n"); + printf("Solve the linear static problem\n"); if (*isolver == 0) { #ifdef SPOOLES - printf("Before spooles\n"); - printf("ad[0] = %f\n", ad[0]); - printf("au[0] = %f\n", au[0]); - //printf("adb[0] = %f\n", adb[0]); - //printf("aub[0] = %f\n", aub[0]); - printf("sigma = %f\n", sigma); - printf("b[0] = %f\n", b[0]); - printf("icol[0] = %d\n", icol[0]); - printf("irow[0] = %d\n", irow[0]); - printf("neq[0] = %d\n", neq[0]); - printf("nzs[0] = %d\n", nzs[0]); - printf("symmetryflag = %d\n", symmetryflag); - printf("inputformat = %d\n", inputformat); - printf("nzs[2] = %d\n", nzs[2]); spooles(ad, au, adb, aub, &sigma, b, icol, irow, neq, nzs, &symmetryflag, &inputformat, &nzs[2]); printf("After spooles\n"); @@ -999,23 +971,26 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak SFREE(enerini); } - /* preCICE Adapter: Multiscale checkpoint*/ simulationData.xstiff = xstiff; simulationData.eei = eei; simulationData.stx = stx; - printf("Before PreciceInterface_MultiscaleCheckpoint call (3)\n"); + if (Precice_IsCouplingOngoing()) { + printf("Write coupling data\n"); + Precice_WriteCouplingData(&simulationData); - PreciceInterface_MultiscaleCheckpoint(&simulationData); + printf("Advance coupling\n"); + Precice_Advance(&simulationData); - printf("After PreciceInterface_MultiscaleCheckpoint call (3)\n"); + // Last read command is not necessary as the data read is never used. + //printf("Read coupling data\n"); + //Precice_ReadCouplingData(&simulationData); + } simulationData.eei = NULL; simulationData.stx = NULL; simulationData.xstiff = NULL; - SFREE(eei); - memcpy(&vold[0], &v[0], sizeof(double) * mt * *nk); memcpy(&sti[0], &stx[0], sizeof(double) * 6 * mi[0] * ne0); @@ -1181,8 +1156,6 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak // if(*nbody>0) SFREE(ipobody); - SFREE(xstiff); - if (iglob != 0) { SFREE(integerglob); SFREE(doubleglob); @@ -1200,5 +1173,8 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak (*ttime) += (*tper); + /* preCICE Adapter: Free the memory */ + Precice_FreeData(&simulationData); + return; } From bfc0f580dea599c13aff62da40f3bb15b38eb35e Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Wed, 6 Nov 2024 13:21:18 +0100 Subject: [PATCH 25/55] Remove debugging print statements --- adapter/PreciceInterface.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index 25f57231..7b477015 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -1162,14 +1162,11 @@ void PreciceInterface_FreeData(PreciceInterface *preciceInterface) freeMapping(preciceInterface->mappingQuasi2D3D); } - printf("Freeing mesh names\n"); // Mesh names free(preciceInterface->faceCentersMeshName); free(preciceInterface->nodesMeshName); free(preciceInterface->elementMeshName); - printf("Freeing data names\n"); - // Data names free(preciceInterface->displacementDeltas); free(preciceInterface->displacements); From 3755875f3e1fc45ce12d3cb0d96026e20b649c2b Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Wed, 6 Nov 2024 18:51:14 +0100 Subject: [PATCH 26/55] Revert to older clang-format to test things --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3ea640e4..3556f370 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ repos: # Official repo for the clang-format hook - repo: https://github.com/pre-commit/mirrors-clang-format - rev: 'v19.1.2' + rev: 'v8.0.1' hooks: - id: clang-format files: "^adapter" From fdf8be019fead67459066232b2646871460d4098 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Wed, 6 Nov 2024 21:08:51 +0100 Subject: [PATCH 27/55] Remove print statement at the end of freeing data, and formatting --- adapter/PreciceInterface.c | 2 -- adapter/PreciceInterface.h | 64 +++++++++++++++++++------------------- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index 7b477015..e644483a 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -1195,6 +1195,4 @@ void PreciceInterface_FreeData(PreciceInterface *preciceInterface) free(preciceInterface->modid); free(preciceInterface->rucsize); free(preciceInterface->conv); - - printf("Freed all data\n"); } diff --git a/adapter/PreciceInterface.h b/adapter/PreciceInterface.h index 510f549f..662a7ef5 100644 --- a/adapter/PreciceInterface.h +++ b/adapter/PreciceInterface.h @@ -28,32 +28,32 @@ typedef struct PreciceInterface { // Interface nodes int numNodes; int num2DNodes; // Nodes in a single plane in case of quasi 2D-3D coupling - int *nodeIDs; - int *mapping2D3D; // Node IDs to filter out 2D place in quasi 2D-3D coupling + int * nodeIDs; + int * mapping2D3D; // Node IDs to filter out 2D place in quasi 2D-3D coupling Mapping2D3D *mappingQuasi2D3D; - double *nodeCoordinates; - double *node2DCoordinates; // 2D coordinates for quasi 2D-3D coupling + double * nodeCoordinates; + double * node2DCoordinates; // 2D coordinates for quasi 2D-3D coupling int nodeSetID; - int *preciceNodeIDs; + int * preciceNodeIDs; int nodesMeshID; - char *nodesMeshName; + char * nodesMeshName; // Interface face elements int numElements; - int *elementIDs; - int *faceIDs; + int * elementIDs; + int * faceIDs; double *faceCenterCoordinates; int faceSetID; - char *faceCentersMeshName; - int *preciceFaceCenterIDs; + char * faceCentersMeshName; + int * preciceFaceCenterIDs; // Interface volumetric elements int elementMeshID; - char *elementMeshName; + char * elementMeshName; int elementSetID; int numIPTotal; double *elemIPCoordinates; - int *elemIPID; + int * elemIPID; // Arrays to store the coupling data double *nodeScalarData; @@ -124,44 +124,44 @@ typedef struct PreciceInterface { typedef struct SimulationData { // CalculiX data - ITG *ialset; - ITG *ielmat; - ITG *istartset; - ITG *iendset; - char **lakon; - ITG *kon; - ITG *ipkon; + ITG * ialset; + ITG * ielmat; + ITG * istartset; + ITG * iendset; + char ** lakon; + ITG * kon; + ITG * ipkon; ITG nset; - char *set; + char * set; double *co; ITG nboun; ITG nforc; // total number of forces - ITG *ikboun; - ITG *ikforc; // the DoFs are all stored here in an array in numerical order - ITG *ilboun; - ITG *ilforc; // number of the force is stored here - ITG *nelemload; + ITG * ikboun; + ITG * ikforc; // the DoFs are all stored here in an array in numerical order + ITG * ilboun; + ITG * ilforc; // number of the force is stored here + ITG * nelemload; int nload; - char *sideload; + char * sideload; double nk; double ne; // new variable added ITG mt; double *theta; double *dtheta; double *tper; - ITG *nmethod; + ITG * nmethod; double *xload; double *xforc; // scalar value of the force in one direction double *xboun; - ITG *ntmat_; + ITG * ntmat_; double *vold; double *veold; double *fn; // values of forces read from calculix double *cocon; - ITG *ncocon; - ITG *mi; - ITG *nea; // element bounds in each thread - start - ITG *neb; // element bounds in each thread - end + ITG * ncocon; + ITG * mi; + ITG * nea; // element bounds in each thread - start + ITG * neb; // element bounds in each thread - end double *eei; // Strain values for multiscale double *stx; // Stress values for multiscale double *xstiff; // Strain values for multiscale From 9b7bdb43f10999d39da34dc530cba8e6dbde9b41 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 18 Nov 2024 12:49:30 +0100 Subject: [PATCH 28/55] Fix error in getting Gauss point coordinates for C3D8 elements --- Makefile | 2 +- adapter/CCXHelpers.c | 2 +- adapter/PreciceInterface.c | 23 +- adapter/PreciceInterface.h | 2 + ...ords.f => getc3d8elementgausspointcoords.f | 15 +- getgausspointscoords.f | 241 ------------------ 6 files changed, 22 insertions(+), 263 deletions(-) rename getelementgausspointcoords.f => getc3d8elementgausspointcoords.f (88%) delete mode 100644 getgausspointscoords.f diff --git a/Makefile b/Makefile index 4bd1638c..344aa69c 100644 --- a/Makefile +++ b/Makefile @@ -74,7 +74,7 @@ SCCXMAIN = ccx_$(CCX_VERSION).c # Append additional sources SCCXC += nonlingeo_precice.c dyna_precice.c CCXHelpers.c PreciceInterface.c linstatic_precice.c -SCCXF += getflux.f getkdeltatemp.f getgausspointscoords.f getelementgausspointcoords.f getstrain.f multiscale_routines.f +SCCXF += getflux.f getkdeltatemp.f getc3d8elementgausspointcoords.f getstrain.f multiscale_routines.f diff --git a/adapter/CCXHelpers.c b/adapter/CCXHelpers.c index 1c7600dd..3de602d3 100644 --- a/adapter/CCXHelpers.c +++ b/adapter/CCXHelpers.c @@ -74,7 +74,7 @@ void getElementsIDs(ITG setID, ITG *ialset, ITG *istartset, ITG *iendset, ITG *e ITG i, k = 0; for (i = istartset[setID] - 1; i < iendset[setID]; i++) { - elements[k] = ialset[i] / 10; + elements[k] = ialset[i]; k++; } } diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index e644483a..1518c3a4 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -784,16 +784,19 @@ void PreciceInterface_ConfigureElementsMesh(PreciceInterface *interface, Simulat int numIPTotal = interface->numIPTotal; char **lakon = sim->lakon; - // Directly call Fortran function from getelementgausspointcoords.f - FORTRAN(getelementgausspointcoords, (&numElements, - &numIPTotal, - interface->elementIDs, - sim->co, - &lakon, - sim->kon, - sim->ipkon, - interface->elemIPID, - interface->elemIPCoordinates)); + FORTRAN(getc3d8elementgausspointcoords, (&numElements, + &numIPTotal, + interface->elementIDs, + sim->co, + &lakon, + sim->kon, + sim->ipkon, + interface->elemIPID, + interface->elemIPCoordinates)); + + for (int i = 0; i < interface->numIPTotal; i++) { + printf("Gauss point coordinates: %f, %f, %f\n", interface->elemIPCoordinates[3 * i], interface->elemIPCoordinates[3 * i + 1], interface->elemIPCoordinates[3 * i + 2]); + } precicec_setMeshVertices(interface->elementMeshName, interface->numIPTotal, interface->elemIPCoordinates, interface->elemIPID); } diff --git a/adapter/PreciceInterface.h b/adapter/PreciceInterface.h index 662a7ef5..02082e46 100644 --- a/adapter/PreciceInterface.h +++ b/adapter/PreciceInterface.h @@ -124,6 +124,8 @@ typedef struct PreciceInterface { typedef struct SimulationData { // CalculiX data + ITG *iset; + ITG * ialset; ITG * ielmat; ITG * istartset; diff --git a/getelementgausspointcoords.f b/getc3d8elementgausspointcoords.f similarity index 88% rename from getelementgausspointcoords.f rename to getc3d8elementgausspointcoords.f index 664f9c3f..1273552b 100755 --- a/getelementgausspointcoords.f +++ b/getc3d8elementgausspointcoords.f @@ -18,8 +18,8 @@ ! ! This function is a copy of the function for calculation and printout of the lift and drag forces ! - subroutine getelementgausspointcoords(nelem, ngp, elem_ids, co, - & lakon, kon, ipkon, elem_gp_id, elem_gp_coord) + subroutine getc3d8elementgausspointcoords(nelem, ngp, elem_ids, + & co, lakon, kon, ipkon, elem_gp_id, elem_gp_coord) implicit none @@ -44,11 +44,6 @@ subroutine getelementgausspointcoords(nelem, ngp, elem_ids, co, data iflag /1/ - ! Increment element IDs by one to match Fortran indexing - do iel = 1, nelem - elem_ids(iel) = elem_ids(iel) + 1 - end do - ! Initialize gauss point coordinates to zero do l = 1, nelem*8*3 elem_gp_coord(l) = 0.0 @@ -72,7 +67,7 @@ subroutine getelementgausspointcoords(nelem, ngp, elem_ids, co, end do ! Loop through gauss points of each element - do gp_id = 1,8 + do gp_id = 1, 8 elem_gp_id((el_id - 1)*8 + gp_id) = & (el_id - 1)*8 + gp_id - 1 @@ -96,6 +91,6 @@ subroutine getelementgausspointcoords(nelem, ngp, elem_ids, co, end do - RetURN + return - end subroutine getelementgausspointcoords + end subroutine getc3d8elementgausspointcoords diff --git a/getgausspointscoords.f b/getgausspointscoords.f deleted file mode 100644 index 3979491d..00000000 --- a/getgausspointscoords.f +++ /dev/null @@ -1,241 +0,0 @@ -! -! CalculiX - A 3-dimensional finite element program -! Copyright (C) 1998-2015 Guido Dhondt -! -! This program is free software; you can redistribute it and/or -! modify it under the terms of the GNU General Public License as -! published by the Free Software Foundation(version 2); -! -! -! This program is distributed in the hope that it will be useful, -! but WITHOUT ANY WARRANTY; without even the implied warranty of -! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -! GNU General Public License for more details. -! -! You should have received a copy of the GNU General Public License -! along with this program; if not, write to the Free Software -! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -! - subroutine getgausspointscoords(co, - & iset,istartset,iendset,ipkon,lakon,kon, - & ialset) -! -! calculation and printout of the lift and drag forces -! - implicit none -! - character*8 lakonl,lakon(*) -! - integer konl(20),ifaceq(8,6),nelem,ii,i,j,i1,i2,j1, - & k1,jj,ig,nope,nopes, - & mint2d,ifacet(6,4),ifacew(8,5),iflag,indexe,jface,istartset(*), - & iendset(*),ipkon(*),kon(*),iset,ialset(*), - & fidx -! - real*8 co(3,*),xl(3,20),shp(4,20),xs2(3,7),dvi,f(0:3), - & vkl(0:3,3),t(3,3),div, - & xl2(3,8),xsj2(3), - & shp2(7,8),xi,et,xsj,temp,xi3d,et3d,ze3d,weight, - & xlocal20(3,9,6),xlocal4(3,1,4),xlocal10(3,3,4),xlocal6(3,1,5), - & xlocal15(3,4,5),xlocal8(3,4,6),xlocal8r(3,1,6),pres, - & tf(0:3),tn,tt,dd,coords(3) -! - include "gauss.f" - include "xlocal.f" -! - data ifaceq /4,3,2,1,11,10,9,12, - & 5,6,7,8,13,14,15,16, - & 1,2,6,5,9,18,13,17, - & 2,3,7,6,10,19,14,18, - & 3,4,8,7,11,20,15,19, - & 4,1,5,8,12,17,16,20/ - data ifacet /1,3,2,7,6,5, - & 1,2,4,5,9,8, - & 2,3,4,6,10,9, - & 1,4,3,8,10,7/ - data ifacew /1,3,2,9,8,7,0,0, - & 4,5,6,10,11,12,0,0, - & 1,2,5,4,7,14,10,13, - & 2,3,6,5,8,15,11,14, - & 4,6,3,1,12,15,9,13/ - data iflag /3/ -! -! -! -! initialisierung of the flux -! - f(0)=0.d0 - -! index for the output array - fidx=1 - -! -! - do jj=istartset(iset),iendset(iset) -! - jface=ialset(jj) -! - nelem=int(jface/10.d0) - ig=jface-10*nelem - lakonl=lakon(nelem) - indexe=ipkon(nelem) -! - if(lakonl(4:4).eq.'2') then - nope=20 - nopes=8 - elseif(lakonl(4:4).eq.'8') then - nope=8 - nopes=4 - elseif(lakonl(4:5).eq.'10') then - nope=10 - nopes=6 - elseif(lakonl(4:4).eq.'4') then - nope=4 - nopes=3 - elseif(lakonl(4:5).eq.'15') then - nope=15 - elseif(lakonl(4:4).eq.'6') then - nope=6 - endif -! - if(lakonl(4:5).eq.'8R') then - mint2d=1 - elseif((lakonl(4:4).eq.'8').or.(lakonl(4:6).eq.'20R')) - & then - if((lakonl(7:7).eq.'A').or.(lakonl(7:7).eq.'S').or. - & (lakonl(7:7).eq.'E')) then - mint2d=2 - else - mint2d=4 - endif - elseif(lakonl(4:4).eq.'2') then - mint2d=9 - elseif(lakonl(4:5).eq.'10') then - mint2d=3 - elseif(lakonl(4:4).eq.'4') then - mint2d=1 - endif -! -! local topology -! - do i=1,nope - konl(i)=kon(indexe+i) - enddo -! -! computation of the coordinates of the local nodes -! - do i=1,nope - do j=1,3 - xl(j,i)=co(j,konl(i)) - enddo - enddo -! -! treatment of wedge faces -! - if(lakonl(4:4).eq.'6') then - mint2d=1 - if(ig.le.2) then - nopes=3 - else - nopes=4 - endif - endif - if(lakonl(4:5).eq.'15') then - if(ig.le.2) then - mint2d=3 - nopes=6 - else - mint2d=4 - nopes=8 - endif - endif -! - if((nope.eq.20).or.(nope.eq.8)) then - do i=1,nopes - do j=1,3 - xl2(j,i)=co(j,konl(ifaceq(i,ig))) - enddo - enddo - elseif((nope.eq.10).or.(nope.eq.4)) then - do i=1,nopes - do j=1,3 - xl2(j,i)=co(j,konl(ifacet(i,ig))) - enddo - enddo - else - do i=1,nopes - do j=1,3 - xl2(j,i)=co(j,konl(ifacew(i,ig))) - enddo - enddo - endif -! - - - do i=1,mint2d -! -! local coordinates of the surface integration -! point within the surface local coordinate system -! - if((lakonl(4:5).eq.'8R').or. - & ((lakonl(4:4).eq.'6').and.(nopes.eq.4))) then - xi=gauss2d1(1,i) - et=gauss2d1(2,i) - weight=weight2d1(i) - elseif((lakonl(4:4).eq.'8').or. - & (lakonl(4:6).eq.'20R').or. - & ((lakonl(4:5).eq.'15').and.(nopes.eq.8))) then - xi=gauss2d2(1,i) - et=gauss2d2(2,i) - weight=weight2d2(i) - elseif(lakonl(4:4).eq.'2') then - xi=gauss2d3(1,i) - et=gauss2d3(2,i) - weight=weight2d3(i) - elseif((lakonl(4:5).eq.'10').or. - & ((lakonl(4:5).eq.'15').and.(nopes.eq.6))) then - xi=gauss2d5(1,i) - et=gauss2d5(2,i) - weight=weight2d5(i) - elseif((lakonl(4:4).eq.'4').or. - & ((lakonl(4:4).eq.'6').and.(nopes.eq.3))) then - xi=gauss2d4(1,i) - et=gauss2d4(2,i) - weight=weight2d4(i) - endif -! -! local surface normal -! - if(nopes.eq.8) then - call shape8q(xi,et,xl2,xsj2,xs2,shp2,iflag) - elseif(nopes.eq.4) then - call shape4q(xi,et,xl2,xsj2,xs2,shp2,iflag) - elseif(nopes.eq.6) then - call shape6tri(xi,et,xl2,xsj2,xs2,shp2,iflag) - else - call shape3tri(xi,et,xl2,xsj2,xs2,shp2,iflag) - endif -! -! global coordinates of the integration point -! - do j1=1,3 - coords(j1)=0.d0 - do i1=1,nopes - coords(j1)=coords(j1)+shp2(4,i1)*xl2(j1,i1) - enddo - enddo - - print *, coords(1), coords(2), coords(3) - -! - enddo - - - enddo -! -! - return - end - - - From afde18606c053e7aa3673e64a5d758e010105189 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 18 Nov 2024 12:54:48 +0100 Subject: [PATCH 29/55] Remove old 2D-3D mapping functions that were added by mistake --- adapter/CCXHelpers.c | 43 ------------------------------------------- 1 file changed, 43 deletions(-) diff --git a/adapter/CCXHelpers.c b/adapter/CCXHelpers.c index 3de602d3..5c6dff1b 100644 --- a/adapter/CCXHelpers.c +++ b/adapter/CCXHelpers.c @@ -562,49 +562,6 @@ void printVectorData(const double *values, const int nv, const int dim) } } -void mapData2Dto3DVector(const double *values2D, const int *mapping2D3D, const int numNodes3D, double *values3D) -{ - ITG id, i; - - for (i = 0; i < numNodes3D; i++) { - id = mapping2D3D[i]; - values3D[i * 3] = values2D[id * 2] * 0.5; - values3D[i * 3 + 1] = values2D[id * 2 + 1] * 0.5; - values3D[i * 3 + 2] = 0; - } -} - -void mapData3Dto2DVector(const double *values3D, const int *mapping2D3D, const int numNodes3D, double *values2D) -{ - ITG id, i; - - for (i = 0; i < numNodes3D; i++) { - id = mapping2D3D[i]; - values2D[id * 2] += values3D[i * 3] * 0.5; - values2D[id * 2 + 1] += values3D[i * 3 + 1] * 0.5; - } -} - -void mapData2Dto3DScalar(const double *values2D, const int *mapping2D3D, const int numNodes3D, double *values3D) -{ - ITG id, i; - - for (i = 0; i < numNodes3D; i++) { - id = mapping2D3D[i]; - values3D[i] = values2D[id] * 0.5; - } -} - -void mapData3Dto2DScalar(const double *values3D, const int *mapping2D3D, const int numNodes3D, double *values2D) -{ - ITG id, i; - - for (i = 0; i < numNodes3D; i++) { - id = mapping2D3D[i]; - values2D[id] += values3D[i] * 0.5; - } -} - /* Errors messages */ void nodeSetNotFoundError(char const *setName) From af14bb40b0de83f65cd58859e0d2bea4d0ed4754 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 18 Nov 2024 13:16:50 +0100 Subject: [PATCH 30/55] Cleaning up functions which may have been remnants of resolving merge conflicts --- adapter/CCXHelpers.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/adapter/CCXHelpers.c b/adapter/CCXHelpers.c index 5c6dff1b..82fc698f 100644 --- a/adapter/CCXHelpers.c +++ b/adapter/CCXHelpers.c @@ -549,19 +549,6 @@ void setDoubleArrayZero(double *values, const int length, const int dim) } } -void printVectorData(const double *values, const int nv, const int dim) -{ - ITG i, j; - - for (i = 0; i < nv; i++) { - printf("["); - for (j = 0; j < dim; j++) { - printf("%f, ", values[i * dim + j]); - } - printf("]\n"); - } -} - /* Errors messages */ void nodeSetNotFoundError(char const *setName) From 6aa96aa7a007b48562afb74ef65db13be8e58fe2 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 18 Nov 2024 13:26:23 +0100 Subject: [PATCH 31/55] Further reverting of unnecesarily pushed changes --- adapter/CCXHelpers.c | 17 +++++++++++++++++ adapter/CCXHelpers.h | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/adapter/CCXHelpers.c b/adapter/CCXHelpers.c index 82fc698f..1c6def34 100644 --- a/adapter/CCXHelpers.c +++ b/adapter/CCXHelpers.c @@ -465,6 +465,11 @@ void setFaceSinkTemperatures(double *sinkTemperatures, ITG numFaces, int *xloadI setXload(xload, xloadIndices, sinkTemperatures, numFaces, FILM_T); } +void setFacePressure(double *pressure, ITG numFaces, int *xloadIndices, double *xload) +{ + setXload(xload, xloadIndices, pressure, numFaces, PRESSUREDLOAD); +} + void setNodeTemperatures(double *temperatures, ITG numNodes, int *xbounIndices, double *xboun) { ITG i; @@ -595,8 +600,20 @@ void missingFilmBCError() exit(EXIT_FAILURE); } +void missingPressureError() +{ + printf("ERROR: Cannot apply Pressure to one or more interface elements. Please make sure that a .dlo file is provided for the interface, when using Pressure and DLOAD.\n"); + exit(EXIT_FAILURE); +} + void unreachableError() { printf("ERROR: The preCICE adapter just entered an unreachable state. Something is very wrong!\n"); exit(EXIT_FAILURE); } + +void supportedElementError() +{ + printf("ERROR: Cannot use the given surface elements to configure a faces mesh!\n"); + exit(EXIT_FAILURE); +} diff --git a/adapter/CCXHelpers.h b/adapter/CCXHelpers.h index 876c0c89..99579e78 100644 --- a/adapter/CCXHelpers.h +++ b/adapter/CCXHelpers.h @@ -28,7 +28,8 @@ */ enum xloadVariable { DFLUX, FILM_H, - FILM_T }; + FILM_T, + PRESSUREDLOAD }; /** * @brief Type of coupling data From 1229dea78c2fe7a59d553b53166659d0cfc12b54 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 18 Nov 2024 13:27:17 +0100 Subject: [PATCH 32/55] Add the file getgausspointscoords.f again --- getgausspointscoords.f | 241 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 241 insertions(+) create mode 100644 getgausspointscoords.f diff --git a/getgausspointscoords.f b/getgausspointscoords.f new file mode 100644 index 00000000..3979491d --- /dev/null +++ b/getgausspointscoords.f @@ -0,0 +1,241 @@ +! +! CalculiX - A 3-dimensional finite element program +! Copyright (C) 1998-2015 Guido Dhondt +! +! This program is free software; you can redistribute it and/or +! modify it under the terms of the GNU General Public License as +! published by the Free Software Foundation(version 2); +! +! +! This program is distributed in the hope that it will be useful, +! but WITHOUT ANY WARRANTY; without even the implied warranty of +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +! GNU General Public License for more details. +! +! You should have received a copy of the GNU General Public License +! along with this program; if not, write to the Free Software +! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +! + subroutine getgausspointscoords(co, + & iset,istartset,iendset,ipkon,lakon,kon, + & ialset) +! +! calculation and printout of the lift and drag forces +! + implicit none +! + character*8 lakonl,lakon(*) +! + integer konl(20),ifaceq(8,6),nelem,ii,i,j,i1,i2,j1, + & k1,jj,ig,nope,nopes, + & mint2d,ifacet(6,4),ifacew(8,5),iflag,indexe,jface,istartset(*), + & iendset(*),ipkon(*),kon(*),iset,ialset(*), + & fidx +! + real*8 co(3,*),xl(3,20),shp(4,20),xs2(3,7),dvi,f(0:3), + & vkl(0:3,3),t(3,3),div, + & xl2(3,8),xsj2(3), + & shp2(7,8),xi,et,xsj,temp,xi3d,et3d,ze3d,weight, + & xlocal20(3,9,6),xlocal4(3,1,4),xlocal10(3,3,4),xlocal6(3,1,5), + & xlocal15(3,4,5),xlocal8(3,4,6),xlocal8r(3,1,6),pres, + & tf(0:3),tn,tt,dd,coords(3) +! + include "gauss.f" + include "xlocal.f" +! + data ifaceq /4,3,2,1,11,10,9,12, + & 5,6,7,8,13,14,15,16, + & 1,2,6,5,9,18,13,17, + & 2,3,7,6,10,19,14,18, + & 3,4,8,7,11,20,15,19, + & 4,1,5,8,12,17,16,20/ + data ifacet /1,3,2,7,6,5, + & 1,2,4,5,9,8, + & 2,3,4,6,10,9, + & 1,4,3,8,10,7/ + data ifacew /1,3,2,9,8,7,0,0, + & 4,5,6,10,11,12,0,0, + & 1,2,5,4,7,14,10,13, + & 2,3,6,5,8,15,11,14, + & 4,6,3,1,12,15,9,13/ + data iflag /3/ +! +! +! +! initialisierung of the flux +! + f(0)=0.d0 + +! index for the output array + fidx=1 + +! +! + do jj=istartset(iset),iendset(iset) +! + jface=ialset(jj) +! + nelem=int(jface/10.d0) + ig=jface-10*nelem + lakonl=lakon(nelem) + indexe=ipkon(nelem) +! + if(lakonl(4:4).eq.'2') then + nope=20 + nopes=8 + elseif(lakonl(4:4).eq.'8') then + nope=8 + nopes=4 + elseif(lakonl(4:5).eq.'10') then + nope=10 + nopes=6 + elseif(lakonl(4:4).eq.'4') then + nope=4 + nopes=3 + elseif(lakonl(4:5).eq.'15') then + nope=15 + elseif(lakonl(4:4).eq.'6') then + nope=6 + endif +! + if(lakonl(4:5).eq.'8R') then + mint2d=1 + elseif((lakonl(4:4).eq.'8').or.(lakonl(4:6).eq.'20R')) + & then + if((lakonl(7:7).eq.'A').or.(lakonl(7:7).eq.'S').or. + & (lakonl(7:7).eq.'E')) then + mint2d=2 + else + mint2d=4 + endif + elseif(lakonl(4:4).eq.'2') then + mint2d=9 + elseif(lakonl(4:5).eq.'10') then + mint2d=3 + elseif(lakonl(4:4).eq.'4') then + mint2d=1 + endif +! +! local topology +! + do i=1,nope + konl(i)=kon(indexe+i) + enddo +! +! computation of the coordinates of the local nodes +! + do i=1,nope + do j=1,3 + xl(j,i)=co(j,konl(i)) + enddo + enddo +! +! treatment of wedge faces +! + if(lakonl(4:4).eq.'6') then + mint2d=1 + if(ig.le.2) then + nopes=3 + else + nopes=4 + endif + endif + if(lakonl(4:5).eq.'15') then + if(ig.le.2) then + mint2d=3 + nopes=6 + else + mint2d=4 + nopes=8 + endif + endif +! + if((nope.eq.20).or.(nope.eq.8)) then + do i=1,nopes + do j=1,3 + xl2(j,i)=co(j,konl(ifaceq(i,ig))) + enddo + enddo + elseif((nope.eq.10).or.(nope.eq.4)) then + do i=1,nopes + do j=1,3 + xl2(j,i)=co(j,konl(ifacet(i,ig))) + enddo + enddo + else + do i=1,nopes + do j=1,3 + xl2(j,i)=co(j,konl(ifacew(i,ig))) + enddo + enddo + endif +! + + + do i=1,mint2d +! +! local coordinates of the surface integration +! point within the surface local coordinate system +! + if((lakonl(4:5).eq.'8R').or. + & ((lakonl(4:4).eq.'6').and.(nopes.eq.4))) then + xi=gauss2d1(1,i) + et=gauss2d1(2,i) + weight=weight2d1(i) + elseif((lakonl(4:4).eq.'8').or. + & (lakonl(4:6).eq.'20R').or. + & ((lakonl(4:5).eq.'15').and.(nopes.eq.8))) then + xi=gauss2d2(1,i) + et=gauss2d2(2,i) + weight=weight2d2(i) + elseif(lakonl(4:4).eq.'2') then + xi=gauss2d3(1,i) + et=gauss2d3(2,i) + weight=weight2d3(i) + elseif((lakonl(4:5).eq.'10').or. + & ((lakonl(4:5).eq.'15').and.(nopes.eq.6))) then + xi=gauss2d5(1,i) + et=gauss2d5(2,i) + weight=weight2d5(i) + elseif((lakonl(4:4).eq.'4').or. + & ((lakonl(4:4).eq.'6').and.(nopes.eq.3))) then + xi=gauss2d4(1,i) + et=gauss2d4(2,i) + weight=weight2d4(i) + endif +! +! local surface normal +! + if(nopes.eq.8) then + call shape8q(xi,et,xl2,xsj2,xs2,shp2,iflag) + elseif(nopes.eq.4) then + call shape4q(xi,et,xl2,xsj2,xs2,shp2,iflag) + elseif(nopes.eq.6) then + call shape6tri(xi,et,xl2,xsj2,xs2,shp2,iflag) + else + call shape3tri(xi,et,xl2,xsj2,xs2,shp2,iflag) + endif +! +! global coordinates of the integration point +! + do j1=1,3 + coords(j1)=0.d0 + do i1=1,nopes + coords(j1)=coords(j1)+shp2(4,i1)*xl2(j1,i1) + enddo + enddo + + print *, coords(1), coords(2), coords(3) + +! + enddo + + + enddo +! +! + return + end + + + From 49f880b36a97a0427594d5fe5e050a9008027a51 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 18 Nov 2024 16:24:52 +0100 Subject: [PATCH 33/55] Adding back functions which were deleted unintentionally --- adapter/CCXHelpers.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/adapter/CCXHelpers.h b/adapter/CCXHelpers.h index 99579e78..d4d13c9a 100644 --- a/adapter/CCXHelpers.h +++ b/adapter/CCXHelpers.h @@ -196,6 +196,18 @@ void getNodeDisplacementDeltas(ITG *nodes, ITG numNodes, int dim, double *v, dou */ void getTetraFaceCenters(ITG *elements, ITG *faces, ITG numElements, ITG *kon, ITG *ipkon, double *co, double *faceCenters); +/** + * @brief Computes the center of one of the faces of a hexahedral element + * @param elements: input list of hexahedral elements + * @param faces: input list of local face IDs + * @param numElements: number of input elements + * @param kon: CalculiX variable + * @param ipkon: CalculiX variable + * @param co: CalculiX array with the coordinates of all the nodes + * @param faceCenters: output array with the face centers of the input element faces + */ +void getHexaFaceCenters(ITG *elements, ITG *faces, ITG numElements, ITG *kon, ITG *ipkon, double *co, double *faceCenters); + /** * @brief Gets a list of node IDs from a list of input element faces * @param elements: list of element IDs @@ -292,6 +304,15 @@ void setFaceHeatTransferCoefficients(double *coefficients, ITG numFaces, int *xl */ void setFaceSinkTemperatures(double *sinkTemperatures, ITG numFaces, int *xloadIndices, double *xload); +/** + * @brief Calls setXload to update the pressure at the specified indices + * @param pressure: values for the pressure + * @param numFaces: number of faces + * @param xloadIndices: indices of the xload array where the values must be updated + * @param xload: CalculiX array for the loads + */ +void setFacePressure(double *pressure, int numFaces, int *xloadIndices, double *xload); + /** * @brief Modifies the values of the temperature boundary condition * @param temperatures: temperature values to apply @@ -439,6 +460,11 @@ void missingTemperatureBCError(); */ void missingForceError(); +/** + * @brief Terminate program if pressure faces are not defined (e.g. missing interface.dlo file) + */ +void missingPressureError(); + /** * @brief Terminate program if displacement Dirichlet BC are not defined for the interface in .inp file. (e.g. missing line under *BOUNDARY) */ @@ -459,4 +485,9 @@ void missingFilmBCError(); */ void unreachableError(); +/** + * @brief Terminate program if the CalculiX ELement Type is not supported for this type of analysis. + */ +void supportedElementError(); + #endif // CCXHELPERS_H From a5d92b855361e4e40dd9411f575e3691f24f3e60 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 18 Nov 2024 16:35:10 +0100 Subject: [PATCH 34/55] Revert more inadvertantly done changes --- adapter/CCXHelpers.c | 6 ++++++ adapter/CCXHelpers.h | 1 + adapter/PreciceInterface.c | 16 +++++----------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/adapter/CCXHelpers.c b/adapter/CCXHelpers.c index 1c6def34..fc36c679 100644 --- a/adapter/CCXHelpers.c +++ b/adapter/CCXHelpers.c @@ -293,6 +293,8 @@ void getXloadIndices(char const *loadType, ITG *elementIDs, ITG *faceIDs, ITG nu faceLabel[0] = (char) 'S'; } else if (strcmp(loadType, "FILM") == 0) { faceLabel[0] = (char) 'F'; + } else if (strcmp(loadType, "PRESSUREDLOAD") == 0) { + faceLabel[0] = (char) 'P'; } for (k = 0; k < numElements; k++) { @@ -315,6 +317,8 @@ void getXloadIndices(char const *loadType, ITG *elementIDs, ITG *faceIDs, ITG nu missingDfluxBCError(); } else if (!found && strcmp(loadType, "FILM") == 0) { missingFilmBCError(); + } else if (!found && strcmp(loadType, "PRESSUREDLOAD") == 0) { + missingPressureError(); } } } @@ -420,6 +424,8 @@ int getXloadIndexOffset(enum xloadVariable xloadVar) return 0; case FILM_T: return 1; + case PRESSUREDLOAD: + return 0; default: unreachableError(); return -1; diff --git a/adapter/CCXHelpers.h b/adapter/CCXHelpers.h index d4d13c9a..690031dc 100644 --- a/adapter/CCXHelpers.h +++ b/adapter/CCXHelpers.h @@ -47,6 +47,7 @@ enum CouplingDataType { TEMPERATURE, SINK_TEMPERATURE, HEAT_TRANSFER_COEFF, FORCES, + PRESSURE, DISPLACEMENTS, DISPLACEMENTDELTAS, VELOCITIES, diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index 1518c3a4..1cccbbd7 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -102,7 +102,6 @@ void Precice_AdjustSolverTimestep(SimulationData *sim) void Precice_Advance(SimulationData *sim) { printf("Adapter calling advance()...\n"); - fflush(stdout); precicec_advance(sim->solver_dt); @@ -145,10 +144,6 @@ void Precice_WriteIterationCheckpoint(SimulationData *sim, double *v) printf("Adapter writing checkpoint...\n"); fflush(stdout); - printf("*(sim->theta): %f\n", *(sim->theta)); - printf("*(sim->dtheta): %f\n", *(sim->dtheta)); - fflush(stdout); - // Save time sim->coupling_init_theta = *(sim->theta); @@ -196,8 +191,7 @@ void Precice_WriteIterationCheckpointModal(SimulationData *sim, const double *do void Precice_ReadCouplingData(SimulationData *sim) { - printf("Adapter reading coupling data....\n"); - // printf("precicec_isReadDataAvailable() %d \n,",precicec_isReadDataAvailable()); + printf("Adapter reading coupling data...\n"); fflush(stdout); PreciceInterface **interfaces = sim->preciceInterfaces; @@ -257,10 +251,10 @@ void Precice_ReadCouplingData(SimulationData *sim) printf("Reading FORCES coupling data.\n"); break; case PRESSURE: - // precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->pressure, interfaces[i]->numElements, interfaces[i]->preciceFaceCenterIDs, sim->solver_dt, interfaces[i]->faceCenterData); - // setFacePressure(interfaces[i]->faceCenterData, interfaces[i]->numElements, interfaces[i]->xloadIndices, sim->xload); - // printf("Reading PRESSURE coupling data.\n"); - // break; + precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->pressure, interfaces[i]->numElements, interfaces[i]->preciceFaceCenterIDs, sim->solver_dt, interfaces[i]->faceCenterData); + setFacePressure(interfaces[i]->faceCenterData, interfaces[i]->numElements, interfaces[i]->xloadIndices, sim->xload); + printf("Reading PRESSURE coupling data.\n"); + break; case DISPLACEMENTS: // Read and set displacements as single point constraints (Dirichlet BC) if (isQuasi2D3D(interfaces[i]->quasi2D3D)) { From 3784b38a273cf37519e6829510b39abcc02ab0f3 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 18 Nov 2024 16:40:53 +0100 Subject: [PATCH 35/55] Reverting some unnuecessary changes in the preCICE Interface functions --- adapter/PreciceInterface.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index 1cccbbd7..6bee4996 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -61,7 +61,7 @@ void Precice_Setup(char *configFilename, char *participantName, SimulationData * // Initialize coupling data printf("Initializing coupling data\n"); fflush(stdout); - // Precice_ReadCouplingData(sim); + Precice_ReadCouplingData(sim); } void Precice_AdjustSolverTimestep(SimulationData *sim) @@ -202,8 +202,6 @@ void Precice_ReadCouplingData(SimulationData *sim) for (j = 0; j < interfaces[i]->numReadData; j++) { - printf("Read data: %d\n", interfaces[i]->readData[j]); - switch (interfaces[i]->readData[j]) { case TEMPERATURE: // Read and set temperature BC @@ -484,7 +482,6 @@ void Precice_WriteCouplingData(SimulationData *sim) // Write data for (j = 0; j < interfaces[i]->numWriteData; j++) { - printf("Write data: %d\n", interfaces[i]->writeData[j]); switch (interfaces[i]->writeData[j]) { case TEMPERATURE: if (isQuasi2D3D(interfaces[i]->quasi2D3D)) { @@ -519,11 +516,13 @@ void Precice_WriteCouplingData(SimulationData *sim) break; case SINK_TEMPERATURE: // Not implemented: 2D-3D + precicec_writeData(interfaces[i]->couplingMeshName, interfaces[i]->kDeltaTemperatureWrite, interfaces[i]->numElements, interfaces[i]->preciceFaceCenterIDs, T); printf("Writing SINK_TEMPERATURE coupling data.\n"); break; case HEAT_TRANSFER_COEFF: // Not implemented: 2D-3D + precicec_writeData(interfaces[i]->couplingMeshName, interfaces[i]->kDeltaWrite, interfaces[i]->numElements, interfaces[i]->preciceFaceCenterIDs, KDelta); printf("Writing HEAT_TRANSFER_COEFF coupling data.\n"); break; @@ -622,6 +621,15 @@ void Precice_FreeData(SimulationData *sim) } free(sim->preciceInterfaces); + + // Clean up checkpointing buffers + if (sim->eigenDOFs != NULL) { + free(sim->eigenDOFs); + } + if (sim->eigenDOFsDerivatives != NULL) { + free(sim->eigenDOFsDerivatives); + } + precicec_finalize(); } @@ -629,7 +637,7 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I { // Deduce configured dimensions if (config->nodesMeshName == NULL && config->facesMeshName == NULL && config->elementsMeshName == NULL) { - printf("ERROR: You need to define a face mesh, nodes mesh or element mesh. Check the adapter configuration file.\n"); + printf("ERROR: You need to define either a face mesh, nodes mesh or an element mesh. Check the adapter configuration file.\n"); exit(EXIT_FAILURE); } if (config->nodesMeshName && config->facesMeshName) { From 6e405ea57b7fbd2a1d52da5b4f9d88c55cc1cda3 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Tue, 19 Nov 2024 08:12:14 +0100 Subject: [PATCH 36/55] Remove print statements for debugging --- Makefile | 4 +--- adapter/CCXHelpers.h | 1 - adapter/PreciceInterface.c | 14 ++------------ 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 344aa69c..2a85adde 100644 --- a/Makefile +++ b/Makefile @@ -74,9 +74,7 @@ SCCXMAIN = ccx_$(CCX_VERSION).c # Append additional sources SCCXC += nonlingeo_precice.c dyna_precice.c CCXHelpers.c PreciceInterface.c linstatic_precice.c -SCCXF += getflux.f getkdeltatemp.f getc3d8elementgausspointcoords.f getstrain.f multiscale_routines.f - - +SCCXF += getflux.f getkdeltatemp.f getc3d8elementgausspointcoords.f multiscale_routines.f # Source files in this folder and in the adapter directory $(OBJDIR)/%.o : %.c diff --git a/adapter/CCXHelpers.h b/adapter/CCXHelpers.h index 690031dc..2f656c10 100644 --- a/adapter/CCXHelpers.h +++ b/adapter/CCXHelpers.h @@ -52,7 +52,6 @@ enum CouplingDataType { TEMPERATURE, DISPLACEMENTDELTAS, VELOCITIES, POSITIONS, - PRESSURE, MACRO_IP_ID, RVE_ID, MOD_ID, diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index 6bee4996..9f1892cb 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -61,7 +61,7 @@ void Precice_Setup(char *configFilename, char *participantName, SimulationData * // Initialize coupling data printf("Initializing coupling data\n"); fflush(stdout); - Precice_ReadCouplingData(sim); + //Precice_ReadCouplingData(sim); } void Precice_AdjustSolverTimestep(SimulationData *sim) @@ -264,25 +264,14 @@ void Precice_ReadCouplingData(SimulationData *sim) } printf("Reading DISPLACEMENTS coupling data.\n"); break; - - // VOLUMETRIC COUPLING - MULTISCALE case CONV_FLAG: // READ CONVERGENCE FLAG precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->conv, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPScalarData); printf("Reading CONVERGENCE FLAG coupling data.\n"); break; - case CMAT1: // READ MATERIAL MATRIX COMPONENTS - C11, C12, C13 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent1Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - - printf("Reading MATERIAL TANGENT 1 coupling data.\n"); - - // for (int k = 0; k < interfaces[i]->numIPTotal; k++) { - // idx = k * 27 + 0; - // printf("idx: %d, read stiffness: %f, %f, %f\n", idx, interfaces[i]->elementIPVectorData[k * 3], interfaces[i]->elementIPVectorData[k * 3 + 1], interfaces[i]->elementIPVectorData[k * 3 + 2]); - // } - for (int k = 0; k < interfaces[i]->numIPTotal; k++) { idx = k * 27 + 0; sim->xstiff[idx] = interfaces[i]->elementIPVectorData[k * 3]; @@ -482,6 +471,7 @@ void Precice_WriteCouplingData(SimulationData *sim) // Write data for (j = 0; j < interfaces[i]->numWriteData; j++) { + switch (interfaces[i]->writeData[j]) { case TEMPERATURE: if (isQuasi2D3D(interfaces[i]->quasi2D3D)) { From 65cf38b54cc0bc8d866fe3cbc5c2776f8e23de11 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 17 Feb 2025 11:13:35 +0100 Subject: [PATCH 37/55] Revert changes to Makefile --- Makefile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 2a85adde..45ef3539 100644 --- a/Makefile +++ b/Makefile @@ -52,7 +52,7 @@ LIBS = \ #CFLAGS = -g -Wall -std=c++11 -O0 -fopenmp $(INCLUDES) -DARCH="Linux" -DSPOOLES -DARPACK -DMATRIXSTORAGE #FFLAGS = -g -Wall -O0 -fopenmp $(INCLUDES) -CFLAGS = -Wall -O0 -fopenmp $(INCLUDES) -DARCH="Linux" -DSPOOLES -DARPACK -DMATRIXSTORAGE -DUSE_MT -fbounds-check -g +CFLAGS = -Wall -O3 -fopenmp $(INCLUDES) -DARCH="Linux" -DSPOOLES -DARPACK -DMATRIXSTORAGE -DUSE_MT # OS-specific options UNAME_S := $(shell uname -s) @@ -62,7 +62,7 @@ else CC = mpicc endif -FFLAGS = -Wall -O0 -fopenmp $(INCLUDES) ${ADDITIONAL_FFLAGS} -fallow-argument-mismatch -fbounds-check -g +FFLAGS = -Wall -O3 -fopenmp $(INCLUDES) ${ADDITIONAL_FFLAGS} # Note for GCC 10 or newer: add -fallow-argument-mismatch in the above flags FC = mpifort # FC = mpif90 @@ -76,6 +76,8 @@ SCCXMAIN = ccx_$(CCX_VERSION).c SCCXC += nonlingeo_precice.c dyna_precice.c CCXHelpers.c PreciceInterface.c linstatic_precice.c SCCXF += getflux.f getkdeltatemp.f getc3d8elementgausspointcoords.f multiscale_routines.f + + # Source files in this folder and in the adapter directory $(OBJDIR)/%.o : %.c $(CC) $(CFLAGS) -c $< -o $@ @@ -102,7 +104,7 @@ OCCXC += $(OBJDIR)/ConfigReader.o $(OBJDIR)/2D3DCoupling.o $(OBJDIR)/OutputBuffe $(OBJDIR)/ccx_preCICE: $(OBJDIR) $(OCCXMAIN) $(OBJDIR)/ccx_$(CCX_VERSION).a - $(FC) -fopenmp -Wall -O0 -g -o $@ $(OCCXMAIN) $(OBJDIR)/ccx_$(CCX_VERSION).a $(LIBS) + $(FC) -fopenmp -Wall -O3 -o $@ $(OCCXMAIN) $(OBJDIR)/ccx_$(CCX_VERSION).a $(LIBS) $(OBJDIR)/ccx_$(CCX_VERSION).a: $(OCCXF) $(OCCXC) ar vr $@ $? From 8018a03a32a0b965e2b098f5dee71657e615e2c1 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 17 Feb 2025 11:48:16 +0100 Subject: [PATCH 38/55] Refactor and clean up functionality to get strains from CalculiX --- Makefile | 2 +- adapter/PreciceInterface.c | 26 ++++++------ getstrain.f | 2 +- multiscale_routines.f | 85 -------------------------------------- setstrain.f | 27 ++++++++++++ 5 files changed, 43 insertions(+), 99 deletions(-) delete mode 100644 multiscale_routines.f create mode 100644 setstrain.f diff --git a/Makefile b/Makefile index 45ef3539..04b4ab6c 100644 --- a/Makefile +++ b/Makefile @@ -74,7 +74,7 @@ SCCXMAIN = ccx_$(CCX_VERSION).c # Append additional sources SCCXC += nonlingeo_precice.c dyna_precice.c CCXHelpers.c PreciceInterface.c linstatic_precice.c -SCCXF += getflux.f getkdeltatemp.f getc3d8elementgausspointcoords.f multiscale_routines.f +SCCXF += getflux.f getkdeltatemp.f getc3d8elementgausspointcoords.f setstrain.f diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index 9f1892cb..43411903 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -357,11 +357,11 @@ void Precice_ReadCouplingData(SimulationData *sim) // READ STRESS COMPONENTS - S11, S22, S33 idx = 1; precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->stress1to3Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - FORTRAN(precice_multiscale_set_stx, (sim->mi, - &idx, - &interfaces[i]->numElements, - interfaces[i]->elementIPVectorData, - sim->stx)); + FORTRAN(setstrain, (sim->mi, + &idx, + &interfaces[i]->numElements, + interfaces[i]->elementIPVectorData, + sim->stx)); printf("Reading STRESS1TO3 coupling data.\n"); break; @@ -369,11 +369,11 @@ void Precice_ReadCouplingData(SimulationData *sim) // READ STRESS COMPONENTS - S23, S13, S12 idx = 4; precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->stress4to6Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - FORTRAN(precice_multiscale_set_stx, (sim->mi, - &idx, - &interfaces[i]->numElements, - interfaces[i]->elementIPVectorData, - sim->stx)); + FORTRAN(setstrain, (sim->mi, + &idx, + &interfaces[i]->numElements, + interfaces[i]->elementIPVectorData, + sim->stx)); printf("Reading STRESS4TO6 coupling data.\n"); break; @@ -665,6 +665,8 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I interface->xbounIndices = NULL; interface->xloadIndices = NULL; interface->xforcIndices = NULL; + interface->writeData = NULL; + interface->readData = NULL; // Initialize element data points as NULL interface->elementMeshName = NULL; @@ -726,6 +728,7 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I if (config->nodesMeshName) { interface->nodesMeshName = strdup(config->nodesMeshName); PreciceInterface_ConfigureNodesMesh(interface, sim); + interface->couplingMeshName = interface->nodesMeshName; } @@ -745,7 +748,6 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I interface->elementMeshName = NULL; if (config->elementsMeshName) { interface->elementMeshName = strdup(config->elementsMeshName); - // Configuring element mesh PreciceInterface_ConfigureElementsMesh(interface, sim); interface->couplingMeshName = interface->elementMeshName; } @@ -1049,7 +1051,7 @@ void PreciceInterface_ConfigureCouplingData(PreciceInterface *interface, Simulat interface->stress4to6Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); } else { - printf("ERROR: Read data '%s' does not exist!\n", config->readDataNames[i]); + printf("ERROR: Read data '%s' is not of a known type for the CalculiX-preCICE adapter. Check the adapter configuration file.\n", config->readDataNames[i]); exit(EXIT_FAILURE); } } diff --git a/getstrain.f b/getstrain.f index bc3d2501..12e804f9 100755 --- a/getstrain.f +++ b/getstrain.f @@ -60,7 +60,7 @@ subroutine getstrain(co,ntmat_,vold, & 4,6,3,1,12,15,9,13/ data iflag /3/ -! initialisierung of the flux +! initialization of the flux f(0)=0.d0 diff --git a/multiscale_routines.f b/multiscale_routines.f deleted file mode 100644 index 095c3e79..00000000 --- a/multiscale_routines.f +++ /dev/null @@ -1,85 +0,0 @@ - SUBROUTINE PRECICE_MULTISCALE_GET_STRAIN() - - - - END SUBROUTINE PRECICE_MULTISCALE_GET_STRAIN - - - - SUBROUTINE PRECICE_MULTISCALE_SET_STX(MI, - & INTPT, NUM_ELEM, PDATA, STX) - - IMPLICIT NONE - - ! IO VARIABLES - INTEGER :: MI(*) ! MAXIMUM VALUE OF INTEGRATION POINT PER ELEMENT (MI[0]) - INTEGER :: NUM_ELEM ! NUMBER OF ELEMENTS - INTEGER :: INTPT ! INTERCEPT ADDED TO STX - REAL(8) :: PDATA(*) ! DATA RECEIVED FROM PRECICE - REAL(8) :: STX(6, MI(1),*) ! STRESS VECTOR USED BY CALCULIX - - - ! LOCAL VARIABLES - INTEGER :: I, J, K, NGP_MAX, COUNT - - - NGP_MAX = MI(1) - - - COUNT= 1 - DO I = 1, NUM_ELEM - DO J = 1, NGP_MAX - STX(INTPT, J, I) = PDATA(COUNT) - STX(INTPT+1, J, I) = PDATA(COUNT+1) - STX(INTPT+2, J, I) = PDATA(COUNT+2) - COUNT = COUNT + 3 - ENDDO - ENDDO - - - END SUBROUTINE PRECICE_MULTISCALE_SET_STX - - - - SUBROUTINE PRECICE_MULTISCALE_SET_XSTIFF(MI, - & INTPT, NUM_ELEM, pdata, XSTIFF) - - IMPLICIT NONE - - ! IO VARIABLES - INTEGER :: MI(*) ! MAXIMUM VALUE OF INTEGRATION POINT PER ELEMENT (MI[0]) - INTEGER :: MAX_NGP ! MAXIMUM VALUE OF INTEGRATION POINT PER ELEMENT (MI[0]) - INTEGER :: NUM_ELEM ! NUMBER OF ELEMENTS - INTEGER :: INTPT ! INTERCEPT ADDED TO XSTIFF - REAL(8) :: PDATA(:) ! DATA RECEIVED FROM PRECICE - REAL(8) :: XSTIFF(:) ! MATERIAL STIFFNESS MATRIX USED BY CALCULIX - - - ! LOCAL VARIABLES - INTEGER :: I, J, K, NGP_MAX, COUNT - - - NGP_MAX = MI(1) - - COUNT= 1 - DO I = 1, NUM_ELEM - DO J = 1, NGP_MAX -! XSTIFF(INTPT, J, I) = PDATA(COUNT) -! XSTIFF(INTPT+1, J, I) = PDATA(COUNT+1) -! XSTIFF(INTPT+2, J, I) = PDATA(COUNT+2) - COUNT = COUNT + 3 - ENDDO - ENDDO - - ! IF(INTPT == 19) THEN - ! DO I = 1, NUM_ELEM - ! DO J = 1, NGP_MAX - ! write(*,*) XSTIFF(1:3, J, I) - ! ENDDO - ! ENDDO - ! ENDIF - - - - END SUBROUTINE PRECICE_MULTISCALE_SET_XSTIFF - diff --git a/setstrain.f b/setstrain.f new file mode 100644 index 00000000..cd99ac3c --- /dev/null +++ b/setstrain.f @@ -0,0 +1,27 @@ + subroutine setstrain(mi, intpt, num_elem, pdata, stx) + + implicit none + + ! io variables + integer :: mi(*) ! maximum value of integration point per element (mi[0]) + integer :: num_elem ! number of elements + integer :: intpt ! intercept added to stx + real(8) :: pdata(*) ! data received from preCICE + real(8) :: stx(6, mi(1),*) ! stress vector used by CalculiX + + ! local variables + integer :: i, j , k, ngp_max, count + + ngp_max = mi(1) + + count = 1 + do i = 1, num_elem + do j = 1, ngp_max + stx(intpt, j, i) = pdata(count) + stx(intpt+1, j, i) = pdata(count+1) + stx(intpt+2, j, i) = pdata(count+2) + count = count + 3 + end do + end do + + end subroutine setstrain From 1a46209c2a6b2a886439e5e649cec3742abc7e69 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 17 Feb 2025 11:59:27 +0100 Subject: [PATCH 39/55] Remove the file getstrain.f as the subroutine in it is not used --- getstrain.f | 325 ---------------------------------------------------- 1 file changed, 325 deletions(-) delete mode 100755 getstrain.f diff --git a/getstrain.f b/getstrain.f deleted file mode 100755 index 12e804f9..00000000 --- a/getstrain.f +++ /dev/null @@ -1,325 +0,0 @@ -! -! CalculiX - A 3-dimensional finite element program -! Copyright (C) 1998-2015 Guido Dhondt -! -! This program is free software; you can redistribute it and/or -! modify it under the terms of the GNU General Public License as -! published by the Free Software Foundation(version 2); -! -! -! This program is distributed in the hope that it will be useful, -! but WITHOUT ANY WARRANTY; without even the implied warranty of -! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -! GNU General Public License for more details. -! -! You should have received a copy of the GNU General Public License -! along with this program; if not, write to the Free Software -! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -! - subroutine getstrain(co,ntmat_,vold, - & cocon,ncocon,iset,istartset,iendset,ipkon,lakon,kon, - & ialset,ielmat,mi,kdelta,reftemp) -! returns the strain vector for given set of elements and corresponding gauss points. -! Each set consists of the following: [element_id, gp_id, mat_id, eps_11, eps_22, eps_33, eps_12, eps_13, eps_23] - implicit none - - character*8 lakonl,lakon(*) - - integer konl(20),ifaceq(8,6),nelem,ii,i,j,i1,i2,j1, - & ncocon(2,*),k1,jj,ig,ntmat_,nope,nopes,imat, - & mint2d,ifacet(6,4),ifacew(8,5),iflag,indexe,jface,istartset(*), - & iendset(*),ipkon(*),kon(*),iset,ialset(*),nset, - & mi(*),ielmat(mi(3),*),fidx - - real*8 co(3,*),xl(3,20),shp(4,20),xs2(3,7),dvi,f(0:3), - & vkl(0:3,3),t(3,3),div, - & voldl(0:mi(2),20),cocon(0:6,ntmat_,*),xl2(3,8),xsj2(3), - & shp2(7,8),vold(0:mi(2),*),xi,et,xsj,temp,xi3d,et3d,ze3d,weight, - & xlocal20(3,9,6),xlocal4(3,1,4),xlocal10(3,3,4),xlocal6(3,1,5), - & xlocal15(3,4,5),xlocal8(3,4,6),xlocal8r(3,1,6),pres, - & tf(0:3),tn,tt,dd,coords(3),cond, kdelta(*), reftemp(*), - & avgkdelta, avgreftemp - - include "gauss.f" - include "xlocal.f" - - data ifaceq /4,3,2,1,11,10,9,12, - & 5,6,7,8,13,14,15,16, - & 1,2,6,5,9,18,13,17, - & 2,3,7,6,10,19,14,18, - & 3,4,8,7,11,20,15,19, - & 4,1,5,8,12,17,16,20/ - data ifacet /1,3,2,7,6,5, - & 1,2,4,5,9,8, - & 2,3,4,6,10,9, - & 1,4,3,8,10,7/ - data ifacew /1,3,2,9,8,7,0,0, - & 4,5,6,10,11,12,0,0, - & 1,2,5,4,7,14,10,13, - & 2,3,6,5,8,15,11,14, - & 4,6,3,1,12,15,9,13/ - data iflag /3/ - -! initialization of the flux - - f(0)=0.d0 - -! index for the output array - fidx=1 - - do jj=istartset(iset),iendset(iset) - jface=ialset(jj) - - nelem=int(jface/10.d0) - ig=jface-10*nelem - lakonl=lakon(nelem) - indexe=ipkon(nelem) - imat=ielmat(1,nelem) ! what is this? - - if(lakonl(4:4).eq.'2') then - nope=20 - nopes=8 - elseif(lakonl(4:4).eq.'8') then - nope=8 - nopes=4 - elseif(lakonl(4:5).eq.'10') then - nope=10 - nopes=6 - elseif(lakonl(4:4).eq.'4') then - nope=4 - nopes=3 - elseif(lakonl(4:5).eq.'15') then - nope=15 - elseif(lakonl(4:4).eq.'6') then - nope=6 - endif - - if(lakonl(4:5).eq.'8R') then - mint2d=1 - elseif((lakonl(4:4).eq.'8').or.(lakonl(4:6).eq.'20R')) - & then - if((lakonl(7:7).eq.'A').or.(lakonl(7:7).eq.'S').or. - & (lakonl(7:7).eq.'E')) then - mint2d=2 - else - mint2d=4 - endif - elseif(lakonl(4:4).eq.'2') then - mint2d=9 - elseif(lakonl(4:5).eq.'10') then - mint2d=3 - elseif(lakonl(4:4).eq.'4') then - mint2d=1 - endif - ! - ! local topology - ! - do i=1,nope - konl(i)=kon(indexe+i) - enddo - ! - ! computation of the coordinates of the local nodes - ! - do i=1,nope - do j=1,3 - xl(j,i)=co(j,konl(i)) - enddo - enddo - ! - ! temperature, velocity and auxiliary variables - ! (rho*energy density, rho*velocity and rho) - ! - do i1=1,nope - do i2=0,mi(2) - voldl(i2,i1)=vold(i2,konl(i1)) - enddo - enddo - ! - ! treatment of wedge faces - ! - if(lakonl(4:4).eq.'6') then - mint2d=1 - if(ig.le.2) then - nopes=3 - else - nopes=4 - endif - endif - - if(lakonl(4:5).eq.'15') then - if(ig.le.2) then - mint2d=3 - nopes=6 - else - mint2d=4 - nopes=8 - endif - endif - - if((nope.eq.20).or.(nope.eq.8)) then - do i=1,nopes - do j=1,3 - xl2(j,i)=co(j,konl(ifaceq(i,ig))) - enddo - enddo - elseif((nope.eq.10).or.(nope.eq.4)) then - do i=1,nopes - do j=1,3 - xl2(j,i)=co(j,konl(ifacet(i,ig))) - enddo - enddo - else - do i=1,nopes - do j=1,3 - xl2(j,i)=co(j,konl(ifacew(i,ig))) - enddo - enddo - endif - - ! very simple averaging over the integration points!! - ! TODO: check whether this needs to be improved! - avgkdelta=0 - avgreftemp=0 - - do i=1,mint2d - ! - ! local coordinates of the surface integration - ! point within the surface local coordinate system - ! - if((lakonl(4:5).eq.'8R').or. - & ((lakonl(4:4).eq.'6').and.(nopes.eq.4))) then - xi=gauss2d1(1,i) - et=gauss2d1(2,i) - weight=weight2d1(i) - elseif((lakonl(4:4).eq.'8').or. - & (lakonl(4:6).eq.'20R').or. - & ((lakonl(4:5).eq.'15').and.(nopes.eq.8))) then - xi=gauss2d2(1,i) - et=gauss2d2(2,i) - weight=weight2d2(i) - elseif(lakonl(4:4).eq.'2') then - xi=gauss2d3(1,i) - et=gauss2d3(2,i) - weight=weight2d3(i) - elseif((lakonl(4:5).eq.'10').or. - & ((lakonl(4:5).eq.'15').and.(nopes.eq.6))) then - xi=gauss2d5(1,i) - et=gauss2d5(2,i) - weight=weight2d5(i) - elseif((lakonl(4:4).eq.'4').or. - & ((lakonl(4:4).eq.'6').and.(nopes.eq.3))) then - xi=gauss2d4(1,i) - et=gauss2d4(2,i) - weight=weight2d4(i) - endif - ! - ! local surface normal - ! - if(nopes.eq.8) then - call shape8q(xi,et,xl2,xsj2,xs2,shp2,iflag) - elseif(nopes.eq.4) then - call shape4q(xi,et,xl2,xsj2,xs2,shp2,iflag) - elseif(nopes.eq.6) then - call shape6tri(xi,et,xl2,xsj2,xs2,shp2,iflag) - else - call shape3tri(xi,et,xl2,xsj2,xs2,shp2,iflag) - endif - ! - ! global coordinates of the integration point - ! - do j1=1,3 - coords(j1)=0.d0 - do i1=1,nopes - coords(j1)=coords(j1)+shp2(4,i1)*xl2(j1,i1) - enddo - enddo - ! - ! local coordinates of the surface integration - ! point within the element local coordinate system - ! - if(lakonl(4:5).eq.'8R') then - xi3d=xlocal8r(1,i,ig) - et3d=xlocal8r(2,i,ig) - ze3d=xlocal8r(3,i,ig) - call shape8h(xi3d,et3d,ze3d,xl,xsj,shp,iflag) - elseif(lakonl(4:4).eq.'8') then - xi3d=xlocal8(1,i,ig) - et3d=xlocal8(2,i,ig) - ze3d=xlocal8(3,i,ig) - call shape8h(xi3d,et3d,ze3d,xl,xsj,shp,iflag) - elseif(lakonl(4:6).eq.'20R') then - xi3d=xlocal8(1,i,ig) - et3d=xlocal8(2,i,ig) - ze3d=xlocal8(3,i,ig) - call shape20h(xi3d,et3d,ze3d,xl,xsj,shp,iflag) - elseif(lakonl(4:4).eq.'2') then - xi3d=xlocal20(1,i,ig) - et3d=xlocal20(2,i,ig) - ze3d=xlocal20(3,i,ig) - call shape20h(xi3d,et3d,ze3d,xl,xsj,shp,iflag) - elseif(lakonl(4:5).eq.'10') then - xi3d=xlocal10(1,i,ig) - et3d=xlocal10(2,i,ig) - ze3d=xlocal10(3,i,ig) - call shape10tet(xi3d,et3d,ze3d,xl,xsj,shp,iflag) - elseif(lakonl(4:4).eq.'4') then - xi3d=xlocal4(1,i,ig) - et3d=xlocal4(2,i,ig) - ze3d=xlocal4(3,i,ig) - call shape4tet(xi3d,et3d,ze3d,xl,xsj,shp,iflag) - elseif(lakonl(4:5).eq.'15') then - xi3d=xlocal15(1,i,ig) - et3d=xlocal15(2,i,ig) - ze3d=xlocal15(3,i,ig) - call shape15w(xi3d,et3d,ze3d,xl,xsj,shp,iflag) - elseif(lakonl(4:4).eq.'6') then - xi3d=xlocal6(1,i,ig) - et3d=xlocal6(2,i,ig) - ze3d=xlocal6(3,i,ig) - call shape6w(xi3d,et3d,ze3d,xl,xsj,shp,iflag) - endif - ! - ! calculating of - ! the temperature temp - ! in the integration point - ! - temp=0.d0 - do j1=1,3 - vkl(0,j1)=0.d0 - enddo - do i1=1,nope - temp=temp+shp(4,i1)*voldl(0,i1) - do k1=1,3 - vkl(0,k1)=vkl(0,k1)+shp(k1,i1)*voldl(0,i1) - enddo - enddo - ! - ! material data (conductivity) - ! - call materialdata_cond(imat,ntmat_,temp,cocon,ncocon,cond) - ! - ! determining the stress - ! - dd=dsqrt(xsj2(1)*xsj2(1)+xsj2(2)*xsj2(2)+xsj2(3)*xsj2(3)) - ! - tf(0)=-cond*(vkl(0,1)*xsj2(1)+vkl(0,2)*xsj2(2)+ - & vkl(0,3)*xsj2(3)) - f(0)=f(0)+tf(0)*weight - tf(0)=tf(0)/dd - ! dd = .1; - ! print *, temp, tf(0), dd, temp+tf(0)/cond - avgreftemp = avgreftemp + (temp + tf(0) / cond * dd) - avgkdelta = avgkdelta + cond / dd - ! - ! print *, fidx, avgreftemp, avgkdelta, tf(0), cond - enddo - - reftemp(fidx) = avgreftemp / mint2d - kdelta(fidx) = avgkdelta / mint2d - - fidx=fidx+1 - - enddo -! - return - end From 8b9de3b7630cc09a16a9c1abcb7417645df336cb Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 17 Feb 2025 14:25:47 +0100 Subject: [PATCH 40/55] Remove duplicate helper function --- adapter/CCXHelpers.c | 19 ++++--------------- adapter/CCXHelpers.h | 8 -------- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/adapter/CCXHelpers.c b/adapter/CCXHelpers.c index 39aa5806..0d020fb5 100644 --- a/adapter/CCXHelpers.c +++ b/adapter/CCXHelpers.c @@ -276,7 +276,7 @@ void getXloadIndices(char const *loadType, ITG *elementIDs, ITG *faceIDs, ITG nu char faceLabel[] = {'x', 'x', '\0'}; /* Face number is prefixed with 'S' if it is DFLUX boundary condition - * and with 'F' if it is a FILM boundary condition */ + * and with 'F' if it is a FILM boundary condition */ if (strcmp(loadType, "DFLUX") == 0) { faceLabel[0] = (char) 'S'; } else if (strcmp(loadType, "FILM") == 0) { @@ -366,7 +366,7 @@ void getXforcIndices(ITG *nodes, ITG numNodes, int nforc, int *ikforc, int *ilfo ITG i; for (i = 0; i < numNodes; i++) { - //x-direction + // x-direction int idof = 8 * (nodes[i] - 1) + 1; // 1 for x force DOF int k; FORTRAN(nident, (ikforc, &idof, &nforc, &k)); @@ -374,14 +374,14 @@ void getXforcIndices(ITG *nodes, ITG numNodes, int nforc, int *ikforc, int *ilfo int m = ilforc[k] - 1; // Adjust because of FORTRAN indices xforcIndices[3 * i] = m; - //y-direction + // y-direction idof = 8 * (nodes[i] - 1) + 2; // 2 for y force DOF FORTRAN(nident, (ikforc, &idof, &nforc, &k)); k -= 1; // Adjust because of FORTRAN indices m = ilforc[k] - 1; // Adjust because of FORTRAN indices xforcIndices[3 * i + 1] = m; - //z-direction + // z-direction idof = 8 * (nodes[i] - 1) + 3; // 3 for z force DOF FORTRAN(nident, (ikforc, &idof, &nforc, &k)); k -= 1; // Adjust because of FORTRAN indices @@ -537,17 +537,6 @@ bool isQuasi2D3D(const int quasi2D3D) return quasi2D3D == 1; } -void setDoubleArrayZero(double *values, const int length, const int dim) -{ - ITG i, j; - - for (i = 0; i < length; i++) { - for (j = 0; j < dim; j++) { - values[i * dim + j] = 0.0; - } - } -} - /* Errors messages */ void nodeSetNotFoundError(char const *setName) diff --git a/adapter/CCXHelpers.h b/adapter/CCXHelpers.h index 0f6d0ed4..853abc62 100644 --- a/adapter/CCXHelpers.h +++ b/adapter/CCXHelpers.h @@ -384,14 +384,6 @@ bool isDoubleEqual(const double a, const double b); */ bool isQuasi2D3D(const int quasi2D3D); -/** - * @brief Set all values of an array to 0 - * @param values is the array carrying double values - * @param length is the number of elements in array - * @param dim is the dimension of the array data - */ -void setDoubleArrayZero(double *values, const int length, const int dim); - /* Error messages */ /** From ee111d7efd20eee347ab7c2091519a61fee34512 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 17 Feb 2025 16:45:01 +0100 Subject: [PATCH 41/55] Reinstate Elemtype --- adapter/CCXHelpers.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/adapter/CCXHelpers.h b/adapter/CCXHelpers.h index 853abc62..f00d1327 100644 --- a/adapter/CCXHelpers.h +++ b/adapter/CCXHelpers.h @@ -67,7 +67,17 @@ enum CouplingDataType { TEMPERATURE, CMAT4, CMAT5, CMAT6, - CMAT7, + CMAT7 }; + +/** + * @brief Type of element used for faces mesh, where we assume only one type of element is used. + * TETRAHEDRA - C3D4 or C3D10 element + * HEXAHEDRA - C3D8 or C3D20 elment + * INVALID_ELEMENT - Anything else + */ +enum ElemType { TETRAHEDRA, + HEXAHEDRA, + INVALID_ELEMENT, }; /** From cef7a0304be5931eea4e47e023c38786de834cec Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Thu, 20 Mar 2025 17:15:28 +0100 Subject: [PATCH 42/55] Remove NASMAT specific variable from the reading and writing functionality --- adapter/CCXHelpers.h | 5 --- adapter/PreciceInterface.c | 74 +------------------------------------- adapter/PreciceInterface.h | 4 --- 3 files changed, 1 insertion(+), 82 deletions(-) diff --git a/adapter/CCXHelpers.h b/adapter/CCXHelpers.h index f00d1327..2c2ed9b2 100644 --- a/adapter/CCXHelpers.h +++ b/adapter/CCXHelpers.h @@ -52,11 +52,6 @@ enum CouplingDataType { TEMPERATURE, DISPLACEMENTDELTAS, VELOCITIES, POSITIONS, - MACRO_IP_ID, - RVE_ID, - MOD_ID, - RUC_SIZE, - CONV_FLAG, STRAIN1TO3, STRAIN4TO6, STRESS1TO3, diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index 43411903..ed165cec 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -4,6 +4,7 @@ * Heat transfer adapter developed by Lucía Cheung with the support of SimScale GmbH * * * * Adapter extended to fluid-structure interaction by Alexander Rusch * + * Adapter extended to multiscale mechanics by Ibrahim Kaleel and Ishaan Desai * * * *********************************************************************************************/ @@ -264,11 +265,6 @@ void Precice_ReadCouplingData(SimulationData *sim) } printf("Reading DISPLACEMENTS coupling data.\n"); break; - case CONV_FLAG: - // READ CONVERGENCE FLAG - precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->conv, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPScalarData); - printf("Reading CONVERGENCE FLAG coupling data.\n"); - break; case CMAT1: // READ MATERIAL MATRIX COMPONENTS - C11, C12, C13 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent1Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); @@ -392,26 +388,6 @@ void Precice_ReadCouplingData(SimulationData *sim) fflush(stdout); exit(EXIT_FAILURE); break; - case MACRO_IP_ID: - printf("MACRO IP ID cannot be used as read data.\n"); - fflush(stdout); - exit(EXIT_FAILURE); - break; - case RVE_ID: - printf("RVE ID cannot be used as read data.\n"); - fflush(stdout); - exit(EXIT_FAILURE); - break; - case MOD_ID: - printf("MOD ID cannot be used as read data.\n"); - fflush(stdout); - exit(EXIT_FAILURE); - break; - case RUC_SIZE: - printf("RUC size cannot be used as read data.\n"); - fflush(stdout); - exit(EXIT_FAILURE); - break; case STRAIN1TO3: printf("Strain 1to3 cannot be used as read data.\n"); fflush(stdout); @@ -552,29 +528,6 @@ void Precice_WriteCouplingData(SimulationData *sim) printf("Writing FORCES coupling data.\n"); break; /* VOLUMETRIC COUPLING - MULTISCALE */ - case RVE_ID: - for (int k = 0; k < interfaces[i]->numIPTotal; k++) { - interfaces[i]->elementIPScalarData[k] = k; - }; - precicec_writeData(interfaces[i]->couplingMeshName, interfaces[i]->rveid, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, interfaces[i]->elementIPScalarData); - printf("Writing RVE ID coupling data.\n"); - break; - case MOD_ID: - /* Solve GMC 102 on all Gauss points */ - for (int k = 0; k < interfaces[i]->numIPTotal; k++) { - interfaces[i]->elementIPScalarData[k] = 102.0; - }; - precicec_writeData(interfaces[i]->couplingMeshName, interfaces[i]->modid, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, interfaces[i]->elementIPScalarData); - printf("Writing MOD ID coupling data.\n"); - break; - case RUC_SIZE: - /* Solve GMC problem with 4 sub cells in each axis */ - for (int k = 0; k < interfaces[i]->numIPTotal; k++) { - interfaces[i]->elementIPScalarData[k] = 5; - }; - precicec_writeData(interfaces[i]->couplingMeshName, interfaces[i]->rucsize, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, interfaces[i]->elementIPScalarData); - printf("Writing RUC_SIZE coupling data.\n"); - break; case STRAIN1TO3: idx = 0; getElementStrain(idx, sim->mi, interfaces[i]->numElements, sim->eei, interfaces[i]->elementIPVectorData); @@ -691,10 +644,6 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I interface->velocities = NULL; interface->forces = NULL; interface->pressure = NULL; - interface->rveid = NULL; - interface->modid = NULL; - interface->rucsize = NULL; - interface->conv = NULL; interface->strain1to3Data = NULL; interface->strain4to6Data = NULL; interface->stress1to3Data = NULL; @@ -1035,11 +984,6 @@ void PreciceInterface_ConfigureCouplingData(PreciceInterface *interface, Simulat interface->readData[i] = CMAT7; interface->materialTangent7Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); - } else if (startsWith(config->readDataNames[i], "conv")) { - PreciceInterface_EnsureValidRead(interface, CONV_FLAG); - interface->readData[i] = CONV_FLAG; - interface->conv = strdup(config->readDataNames[i]); - printf("Read data '%s' found.\n", config->readDataNames[i]); } else if (startsWith(config->readDataNames[i], "stresses1to3")) { PreciceInterface_EnsureValidRead(interface, STRESS1TO3); interface->readData[i] = STRESS1TO3; @@ -1099,18 +1043,6 @@ void PreciceInterface_ConfigureCouplingData(PreciceInterface *interface, Simulat interface->writeData[i] = FORCES; interface->forces = strdup(config->writeDataNames[i]); printf("Write data '%s' found.\n", interface->forces); - } else if (isEqual(config->writeDataNames[i], "rve_id")) { - interface->writeData[i] = RVE_ID; - interface->rveid = strdup(config->writeDataNames[i]); - printf("Write data '%s' found.\n", config->writeDataNames[i]); - } else if (isEqual(config->writeDataNames[i], "mod_id")) { - interface->writeData[i] = MOD_ID; - interface->modid = strdup(config->writeDataNames[i]); - printf("Write data '%s' found.\n", config->writeDataNames[i]); - } else if (isEqual(config->writeDataNames[i], "ruc_size")) { - interface->writeData[i] = RUC_SIZE; - interface->rucsize = strdup(config->writeDataNames[i]); - printf("Write data '%s' found.\n", config->writeDataNames[i]); } else if (isEqual(config->writeDataNames[i], "strains1to3")) { interface->writeData[i] = STRAIN1TO3; interface->strain1to3Data = strdup(config->writeDataNames[i]); @@ -1188,8 +1120,4 @@ void PreciceInterface_FreeData(PreciceInterface *preciceInterface) free(preciceInterface->materialTangent5Data); free(preciceInterface->materialTangent6Data); free(preciceInterface->materialTangent7Data); - free(preciceInterface->rveid); - free(preciceInterface->modid); - free(preciceInterface->rucsize); - free(preciceInterface->conv); } diff --git a/adapter/PreciceInterface.h b/adapter/PreciceInterface.h index 02082e46..e7cad598 100644 --- a/adapter/PreciceInterface.h +++ b/adapter/PreciceInterface.h @@ -81,10 +81,6 @@ typedef struct PreciceInterface { char *velocities; char *forces; char *pressure; - char *rveid; - char *modid; - char *rucsize; - char *conv; char *strain1to3Data; char *strain4to6Data; char *stress1to3Data; From e3ca91a5bb8cb1bca6fea3e7e63ade2c2898477a Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Thu, 20 Mar 2025 21:21:18 +0100 Subject: [PATCH 43/55] Reverting changes that are added inadvertently --- adapter/PreciceInterface.c | 62 +++++++++++--------------------------- adapter/PreciceInterface.h | 2 -- 2 files changed, 17 insertions(+), 47 deletions(-) diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index ed165cec..97981b17 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -62,7 +62,7 @@ void Precice_Setup(char *configFilename, char *participantName, SimulationData * // Initialize coupling data printf("Initializing coupling data\n"); fflush(stdout); - //Precice_ReadCouplingData(sim); + Precice_ReadCouplingData(sim); } void Precice_AdjustSolverTimestep(SimulationData *sim) @@ -74,9 +74,9 @@ void Precice_AdjustSolverTimestep(SimulationData *sim) fflush(stdout); // For steady-state simulations, we will always compute the converged steady-state solution in one coupling step - sim->theta = 0; - sim->tper = 1; - sim->dtheta = 1; + *sim->theta = 0; + *sim->tper = 1; + *sim->dtheta = 1; // Set the solver time step to be the same as the coupling time step sim->solver_dt = precice_dt; @@ -276,7 +276,6 @@ void Precice_ReadCouplingData(SimulationData *sim) } printf("Reading MATERIAL TANGENT 1 coupling data.\n"); break; - case CMAT2: // READ MATERIAL MATRIX COMPONENTS - C14, C15, C16 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent2Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); @@ -288,7 +287,6 @@ void Precice_ReadCouplingData(SimulationData *sim) } printf("Reading MATERIAL TANGENT 2 coupling data.\n"); break; - case CMAT3: // READ MATERIAL MATRIX COMPONENTS - C22, C23, C24 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent3Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); @@ -300,7 +298,6 @@ void Precice_ReadCouplingData(SimulationData *sim) } printf("Reading MATERIAL TANGENT 3 coupling data.\n"); break; - case CMAT4: // READ MATERIAL MATRIX COMPONENTS - C25, C26, C33 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent4Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); @@ -312,7 +309,6 @@ void Precice_ReadCouplingData(SimulationData *sim) } printf("Reading MATERIAL TANGENT 4 coupling data.\n"); break; - case CMAT5: // READ MATERIAL MATRIX COMPONENTS - C34, C35, C36 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent5Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); @@ -324,7 +320,6 @@ void Precice_ReadCouplingData(SimulationData *sim) } printf("Reading MATERIAL TANGENT 5 coupling data.\n"); break; - case CMAT6: // READ MATERIAL MATRIX COMPONENTS - C44, C45, C46 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent6Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); @@ -336,7 +331,6 @@ void Precice_ReadCouplingData(SimulationData *sim) } printf("Reading MATERIAL TANGENT 6 coupling data.\n"); break; - case CMAT7: // READ MATERIAL MATRIX COMPONENTS - C55, C56, C66 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent7Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); @@ -348,7 +342,6 @@ void Precice_ReadCouplingData(SimulationData *sim) } printf("Reading MATERIAL TANGENT 7 coupling data.\n"); break; - case STRESS1TO3: // READ STRESS COMPONENTS - S11, S22, S33 idx = 1; @@ -360,7 +353,6 @@ void Precice_ReadCouplingData(SimulationData *sim) sim->stx)); printf("Reading STRESS1TO3 coupling data.\n"); break; - case STRESS4TO6: // READ STRESS COMPONENTS - S23, S13, S12 idx = 4; @@ -372,7 +364,6 @@ void Precice_ReadCouplingData(SimulationData *sim) sim->stx)); printf("Reading STRESS4TO6 coupling data.\n"); break; - case DISPLACEMENTDELTAS: printf("DisplacementDeltas cannot be used as read data\n"); fflush(stdout); @@ -607,8 +598,6 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I interface->faceCenterCoordinates = NULL; interface->preciceFaceCenterIDs = NULL; interface->nodeCoordinates = NULL; - interface->node2DCoordinates = NULL; - interface->mapping2D3D = NULL; interface->preciceNodeIDs = NULL; interface->nodeScalarData = NULL; interface->node2DScalarData = NULL; @@ -795,27 +784,6 @@ void PreciceInterface_ConfigureNodesMesh(PreciceInterface *interface, Simulation // If 2D-3Q coupling is used (for a node mesh) delegate this to the specialized data structure. if (interface->nodesMeshName != NULL) { - int count = 0; - int dimCCX = interface->dimCCX; - for (int i = 0; i < interface->numNodes; i++) { - for (int ii = 0; ii < interface->numNodes; ii++) { - // Compare each node with every other node to find nodes with matching X and Y coordinates - if (isDoubleEqual(interface->nodeCoordinates[ii * dimCCX], interface->nodeCoordinates[i * dimCCX]) && - isDoubleEqual(interface->nodeCoordinates[ii * dimCCX + 1], interface->nodeCoordinates[i * dimCCX + 1]) && - !isDoubleEqual(interface->nodeCoordinates[ii * dimCCX + 2], interface->nodeCoordinates[i * dimCCX + 2])) { - if (!isDoubleEqual(interface->nodeCoordinates[i * dimCCX + 2], 0.0)) { - interface->mapping2D3D[i] = count; - interface->mapping2D3D[ii] = count; - count += 1; - } - } - } - } - } - - if (interface->nodesMeshName != NULL) { - // printf("nodesMeshName is not null \n"); - // interface->nodesMeshID = precicec_getMeshID(interface->nodesMeshName); if (isQuasi2D3D(interface->quasi2D3D)) { interface->mappingQuasi2D3D = createMapping(interface->nodeCoordinates, interface->numNodes, interface->nodesMeshName); } else { @@ -844,8 +812,17 @@ void PreciceInterface_NodeConnectivity(PreciceInterface *interface, SimulationDa PreciceInterface_ConfigureTetraFaces(interface, sim); } -void PreciceInterface_EnsureValidRead(PreciceInterface *interface, enum CouplingDataType type) +void PreciceInterface_EnsureValidRead(SimulationData *sim, PreciceInterface *interface, enum CouplingDataType type) { + // Forbidden read data in modal dynamic simulations + if (sim->isModalDynamic) { + if (type == TEMPERATURE || type == DISPLACEMENTS || type == DISPLACEMENTDELTAS || type == VELOCITIES || type == POSITIONS) { + printf("Error: in modal dynamic simulations, only loads (forces, pressures, heat fluxes) can be read.\n" + "Degrees of freedom (positions, velocities, temperatures) cannot be read from preCICE."); + fflush(stdout); + exit(EXIT_FAILURE); + } + } if (interface->elementMeshName == NULL) { printf("Element mesh not provided in YAML config file\n"); @@ -856,7 +833,7 @@ void PreciceInterface_EnsureValidRead(PreciceInterface *interface, enum Coupling void PreciceInterface_ConfigureTetraFaces(PreciceInterface *interface, SimulationData *sim) { - // int i; + int i; printf("Setting node connectivity for nearest projection mapping: \n"); if (interface->nodesMeshName != NULL) { int *triangles = malloc(interface->numElements * 3 * sizeof(ITG)); @@ -1068,7 +1045,6 @@ void PreciceInterface_FreeData(PreciceInterface *preciceInterface) free(preciceInterface->preciceFaceCenterIDs); free(preciceInterface->faceCenterCoordinates); free(preciceInterface->nodeCoordinates); - free(preciceInterface->node2DCoordinates); free(preciceInterface->preciceNodeIDs); free(preciceInterface->nodeScalarData); free(preciceInterface->node2DScalarData); @@ -1079,18 +1055,14 @@ void PreciceInterface_FreeData(PreciceInterface *preciceInterface) free(preciceInterface->xloadIndices); free(preciceInterface->xforcIndices); + freeMapping(preciceInterface->mappingQuasi2D3D); + // Volumteric element related data free(preciceInterface->elemIPCoordinates); free(preciceInterface->elemIPID); free(preciceInterface->elementIPScalarData); free(preciceInterface->elementIPVectorData); - // Quasi 2D-3D coupling - free(preciceInterface->mapping2D3D); - if (preciceInterface->quasi2D3D) { - freeMapping(preciceInterface->mappingQuasi2D3D); - } - // Mesh names free(preciceInterface->faceCentersMeshName); free(preciceInterface->nodesMeshName); diff --git a/adapter/PreciceInterface.h b/adapter/PreciceInterface.h index e7cad598..9ea401dd 100644 --- a/adapter/PreciceInterface.h +++ b/adapter/PreciceInterface.h @@ -29,10 +29,8 @@ typedef struct PreciceInterface { int numNodes; int num2DNodes; // Nodes in a single plane in case of quasi 2D-3D coupling int * nodeIDs; - int * mapping2D3D; // Node IDs to filter out 2D place in quasi 2D-3D coupling Mapping2D3D *mappingQuasi2D3D; double * nodeCoordinates; - double * node2DCoordinates; // 2D coordinates for quasi 2D-3D coupling int nodeSetID; int * preciceNodeIDs; int nodesMeshID; From 553183323aefa9a9ea7e110b6725b9befeb96246 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Fri, 21 Mar 2025 11:15:03 +0100 Subject: [PATCH 44/55] Reinstating some of the variables and functions which were inadvertently deleted --- adapter/CCXHelpers.c | 10 +++++----- adapter/PreciceInterface.c | 23 ++++++++++++++++++++++- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/adapter/CCXHelpers.c b/adapter/CCXHelpers.c index 0d020fb5..ae5a6e6f 100644 --- a/adapter/CCXHelpers.c +++ b/adapter/CCXHelpers.c @@ -400,11 +400,11 @@ void getXforcIndices(ITG *nodes, ITG numNodes, int nforc, int *ikforc, int *ilfo int getXloadIndexOffset(enum xloadVariable xloadVar) { /* - * xload is the CalculiX array where the DFLUX and FILM boundary conditions are stored - * the array has two components: - * - the first component corresponds to the flux value and the heat transfer coefficient - * - the second component corresponds to the sink temperature - * */ + * xload is the CalculiX array where the DFLUX and FILM boundary conditions are stored + * the array has two components: + * - the first component corresponds to the flux value and the heat transfer coefficient + * - the second component corresponds to the sink temperature + * */ switch (xloadVar) { case DFLUX: return 0; diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index 97981b17..da926d94 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -594,10 +594,11 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I // Initialize pointers as NULL interface->elementIDs = NULL; interface->faceIDs = NULL; - interface->nodeIDs = NULL; interface->faceCenterCoordinates = NULL; interface->preciceFaceCenterIDs = NULL; interface->nodeCoordinates = NULL; + interface->nodeIDs = NULL; + interface->mappingQuasi2D3D = NULL; interface->preciceNodeIDs = NULL; interface->nodeScalarData = NULL; interface->node2DScalarData = NULL; @@ -693,6 +694,25 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I PreciceInterface_ConfigureCouplingData(interface, sim, config); } +static enum ElemType findSimulationMeshType(SimulationData *sim) +{ + // Assuming only tetrahedra are used, or only hexaedral, for faces meshes. + // Return first non-zero mesh type. + // lakon tab takes 8 chars per element + + const char *lakon_ptr = sim->lakon; + for (int i = 0; i < sim->ne; ++i) { + if (startsWith(lakon_ptr, "C3D4") || startsWith(lakon_ptr, "C3D10")) { + return TETRAHEDRA; + } else if (startsWith(lakon_ptr, "C3D8") || startsWith(lakon_ptr, "C3D20")) { + return HEXAHEDRA; + } + lakon_ptr += 8; + } + + return INVALID_ELEMENT; +} + void PreciceInterface_ConfigureElementsMesh(PreciceInterface *interface, SimulationData *sim) { printf("Entering ConfigureElementsMesh \n"); @@ -726,6 +746,7 @@ void PreciceInterface_ConfigureElementsMesh(PreciceInterface *interface, Simulat interface->elemIPID, interface->elemIPCoordinates)); + // debugging TODO: remove for (int i = 0; i < interface->numIPTotal; i++) { printf("Gauss point coordinates: %f, %f, %f\n", interface->elemIPCoordinates[3 * i], interface->elemIPCoordinates[3 * i + 1], interface->elemIPCoordinates[3 * i + 2]); } From d5674d33bfc411025ccf3d89a8d66024ddb396fa Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Fri, 21 Mar 2025 11:25:19 +0100 Subject: [PATCH 45/55] Reverting unintended changes --- adapter/PreciceInterface.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index da926d94..be5cd3de 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -767,7 +767,18 @@ void PreciceInterface_ConfigureFaceCentersMesh(PreciceInterface *interface, Simu interface->faceCenterCoordinates = malloc(interface->numElements * 3 * sizeof(double)); interface->preciceFaceCenterIDs = malloc(interface->numElements * 3 * sizeof(int)); - getTetraFaceCenters(interface->elementIDs, interface->faceIDs, interface->numElements, sim->kon, sim->ipkon, sim->co, interface->faceCenterCoordinates); + + enum ElemType elemType = findSimulationMeshType(sim); + + if (elemType == TETRAHEDRA) { + printf("Configuring faces mesh with tetrahedra.\n"); + getTetraFaceCenters(interface->elementIDs, interface->faceIDs, interface->numElements, sim->kon, sim->ipkon, sim->co, interface->faceCenterCoordinates); + } else if (elemType == HEXAHEDRA) { + printf("Configuring faces mesh with hexahedra.\n"); + getHexaFaceCenters(interface->elementIDs, interface->faceIDs, interface->numElements, sim->kon, sim->ipkon, sim->co, interface->faceCenterCoordinates); + } else { + supportedElementError(); + } interface->preciceFaceCenterIDs = malloc(interface->numElements * sizeof(int)); From ef54706d053bb1393f07d72c0c86c3e9ad8c905d Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Fri, 21 Mar 2025 13:00:36 +0100 Subject: [PATCH 46/55] Revert more unnecessarily made changes --- adapter/PreciceInterface.c | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index be5cd3de..5c987f8c 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -881,30 +881,9 @@ void PreciceInterface_ConfigureCouplingData(PreciceInterface *interface, Simulat interface->nodeScalarData = malloc(interface->numNodes * sizeof(double)); interface->nodeVectorData = malloc(interface->numNodes * 3 * sizeof(double)); - if (isQuasi2D3D(interface->quasi2D3D)) { - interface->node2DScalarData = malloc(interface->num2DNodes * sizeof(double)); - interface->node2DVectorData = malloc(interface->num2DNodes * 2 * sizeof(double)); - - int dim = interface->dim; - for (int i = 0; i < interface->num2DNodes; i++) { - interface->node2DScalarData[i] = 0.0; - interface->node2DVectorData[i * dim] = 0.0; - interface->node2DVectorData[i * dim + 1] = 0.0; - } - } - interface->faceCenterData = malloc(interface->numElements * sizeof(double)); - /* Allocating and initilizing memory for multiscale coupling */ - interface->elementIPScalarData = malloc(interface->numIPTotal * sizeof(double)); - interface->elementIPVectorData = malloc(interface->numIPTotal * 3 * sizeof(double)); - for (int i = 0; i < interface->numIPTotal; i++) { - interface->elementIPScalarData[i] = 0.0; - interface->elementIPVectorData[i * 3] = 0.0; - interface->elementIPVectorData[i * 3 + 1] = 0.0; - interface->elementIPVectorData[i * 3 + 2] = 0.0; - } - + // Configure all the read data, then the write data int i; interface->numReadData = config->numReadData; if (config->numReadData > 0) @@ -952,9 +931,9 @@ void PreciceInterface_ConfigureCouplingData(PreciceInterface *interface, Simulat printf("Read data '%s' found.\n", interface->forces); } else if (startsWith(config->readDataNames[i], "Displacement")) { PreciceInterface_EnsureValidRead(interface, DISPLACEMENTS); - interface->readData[i] = DISPLACEMENTS; - interface->xbounIndices = malloc(interface->numNodes * 3 * sizeof(int)); - interface->displacementsData = strdup(config->readDataNames[i]); + interface->readData[i] = DISPLACEMENTS; + interface->xbounIndices = malloc(interface->numNodes * 3 * sizeof(int)); + interface->displacements = strdup(config->readDataNames[i]); getXbounIndices(interface->nodeIDs, interface->numNodes, sim->nboun, sim->ikboun, sim->ilboun, interface->xbounIndices, DISPLACEMENTS); printf("Read data '%s' found.\n", config->readDataNames[i]); /* MICROMANAGER COUPLING */ From 9277fe133995033fa02ff3e5f34d8442c196ffb0 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Fri, 21 Mar 2025 13:47:24 +0100 Subject: [PATCH 47/55] Reverting more changes --- adapter/PreciceInterface.c | 53 ++++++++++++++++---------------------- adapter/PreciceInterface.h | 20 +++++++------- 2 files changed, 32 insertions(+), 41 deletions(-) diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index 5c987f8c..2ee9b0cb 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -612,7 +612,6 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I interface->readData = NULL; // Initialize element data points as NULL - interface->elementMeshName = NULL; interface->elemIPID = NULL; interface->elemIPCoordinates = NULL; interface->elementIPScalarData = NULL; @@ -684,11 +683,11 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I } // Element mesh - interface->elementMeshName = NULL; + interface->elementsMeshName = NULL; if (config->elementsMeshName) { - interface->elementMeshName = strdup(config->elementsMeshName); + interface->elementsMeshName = strdup(config->elementsMeshName); PreciceInterface_ConfigureElementsMesh(interface, sim); - interface->couplingMeshName = interface->elementMeshName; + interface->couplingMeshName = interface->elementsMeshName; } PreciceInterface_ConfigureCouplingData(interface, sim, config); @@ -751,7 +750,7 @@ void PreciceInterface_ConfigureElementsMesh(PreciceInterface *interface, Simulat printf("Gauss point coordinates: %f, %f, %f\n", interface->elemIPCoordinates[3 * i], interface->elemIPCoordinates[3 * i + 1], interface->elemIPCoordinates[3 * i + 2]); } - precicec_setMeshVertices(interface->elementMeshName, interface->numIPTotal, interface->elemIPCoordinates, interface->elemIPID); + precicec_setMeshVertices(interface->elementsMeshName, interface->numIPTotal, interface->elemIPCoordinates, interface->elemIPID); } void PreciceInterface_ConfigureFaceCentersMesh(PreciceInterface *interface, SimulationData *sim) @@ -844,7 +843,7 @@ void PreciceInterface_NodeConnectivity(PreciceInterface *interface, SimulationDa PreciceInterface_ConfigureTetraFaces(interface, sim); } -void PreciceInterface_EnsureValidRead(SimulationData *sim, PreciceInterface *interface, enum CouplingDataType type) +void PreciceInterface_EnsureValidRead(SimulationData *sim, enum CouplingDataType type) { // Forbidden read data in modal dynamic simulations if (sim->isModalDynamic) { @@ -855,12 +854,6 @@ void PreciceInterface_EnsureValidRead(SimulationData *sim, PreciceInterface *int exit(EXIT_FAILURE); } } - - if (interface->elementMeshName == NULL) { - printf("Element mesh not provided in YAML config file\n"); - fflush(stdout); - exit(EXIT_FAILURE); - } } void PreciceInterface_ConfigureTetraFaces(PreciceInterface *interface, SimulationData *sim) @@ -880,7 +873,6 @@ void PreciceInterface_ConfigureCouplingData(PreciceInterface *interface, Simulat { interface->nodeScalarData = malloc(interface->numNodes * sizeof(double)); interface->nodeVectorData = malloc(interface->numNodes * 3 * sizeof(double)); - interface->faceCenterData = malloc(interface->numElements * sizeof(double)); // Configure all the read data, then the write data @@ -890,7 +882,7 @@ void PreciceInterface_ConfigureCouplingData(PreciceInterface *interface, Simulat interface->readData = malloc(config->numReadData * sizeof(int)); for (i = 0; i < config->numReadData; i++) { if (startsWith(config->readDataNames[i], "Temperature")) { - PreciceInterface_EnsureValidRead(interface, TEMPERATURE); + PreciceInterface_EnsureValidRead(sim, TEMPERATURE); interface->readData[i] = TEMPERATURE; interface->xbounIndices = malloc(interface->numNodes * sizeof(int)); interface->temperature = strdup(config->readDataNames[i]); @@ -900,85 +892,84 @@ void PreciceInterface_ConfigureCouplingData(PreciceInterface *interface, Simulat interface->readData[i] = HEAT_FLUX; interface->xloadIndices = malloc(interface->numElements * sizeof(int)); getXloadIndices("DFLUX", interface->elementIDs, interface->faceIDs, interface->numElements, sim->nload, sim->nelemload, sim->sideload, interface->xloadIndices); - PreciceInterface_EnsureValidRead(interface, HEAT_FLUX); + PreciceInterface_EnsureValidRead(sim, HEAT_FLUX); interface->flux = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", interface->flux); } else if (startsWith(config->readDataNames[i], "Sink-Temperature")) { interface->readData[i] = SINK_TEMPERATURE; interface->xloadIndices = malloc(interface->numElements * sizeof(int)); getXloadIndices("FILM", interface->elementIDs, interface->faceIDs, interface->numElements, sim->nload, sim->nelemload, sim->sideload, interface->xloadIndices); - PreciceInterface_EnsureValidRead(interface, SINK_TEMPERATURE); + PreciceInterface_EnsureValidRead(sim, SINK_TEMPERATURE); interface->kDeltaTemperatureRead = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", interface->kDeltaTemperatureRead); } else if (startsWith(config->readDataNames[i], "Heat-Transfer-Coefficient")) { interface->readData[i] = HEAT_TRANSFER_COEFF; - PreciceInterface_EnsureValidRead(interface, HEAT_TRANSFER_COEFF); + PreciceInterface_EnsureValidRead(sim, HEAT_TRANSFER_COEFF); interface->kDeltaRead = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", interface->kDeltaRead); } else if (startsWith(config->readDataNames[i], "Pressure")) { interface->readData[i] = PRESSURE; interface->xloadIndices = malloc(interface->numElements * sizeof(int)); - PreciceInterface_EnsureValidRead(interface, PRESSURE); + PreciceInterface_EnsureValidRead(sim, PRESSURE); getXloadIndices("PRESSUREDLOAD", interface->elementIDs, interface->faceIDs, interface->numElements, sim->nload, sim->nelemload, sim->sideload, interface->xloadIndices); interface->pressure = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", interface->pressure); } else if (startsWith(config->readDataNames[i], "Force")) { - PreciceInterface_EnsureValidRead(interface, FORCES); + PreciceInterface_EnsureValidRead(sim, FORCES); interface->readData[i] = FORCES; interface->xforcIndices = malloc(interface->numNodes * 3 * sizeof(int)); interface->forces = strdup(config->readDataNames[i]); getXforcIndices(interface->nodeIDs, interface->numNodes, sim->nforc, sim->ikforc, sim->ilforc, interface->xforcIndices); printf("Read data '%s' found.\n", interface->forces); } else if (startsWith(config->readDataNames[i], "Displacement")) { - PreciceInterface_EnsureValidRead(interface, DISPLACEMENTS); + PreciceInterface_EnsureValidRead(sim, DISPLACEMENTS); interface->readData[i] = DISPLACEMENTS; interface->xbounIndices = malloc(interface->numNodes * 3 * sizeof(int)); interface->displacements = strdup(config->readDataNames[i]); getXbounIndices(interface->nodeIDs, interface->numNodes, sim->nboun, sim->ikboun, sim->ilboun, interface->xbounIndices, DISPLACEMENTS); printf("Read data '%s' found.\n", config->readDataNames[i]); - /* MICROMANAGER COUPLING */ } else if (startsWith(config->readDataNames[i], "cmat1")) { - PreciceInterface_EnsureValidRead(interface, CMAT1); + PreciceInterface_EnsureValidRead(sim, CMAT1); interface->readData[i] = CMAT1; interface->materialTangent1Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); } else if (startsWith(config->readDataNames[i], "cmat2")) { - PreciceInterface_EnsureValidRead(interface, CMAT2); + PreciceInterface_EnsureValidRead(sim, CMAT2); interface->readData[i] = CMAT2; interface->materialTangent2Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); } else if (startsWith(config->readDataNames[i], "cmat3")) { - PreciceInterface_EnsureValidRead(interface, CMAT3); + PreciceInterface_EnsureValidRead(sim, CMAT3); interface->readData[i] = CMAT3; interface->materialTangent3Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); } else if (startsWith(config->readDataNames[i], "cmat4")) { - PreciceInterface_EnsureValidRead(interface, CMAT4); + PreciceInterface_EnsureValidRead(sim, CMAT4); interface->readData[i] = CMAT4; interface->materialTangent4Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); } else if (startsWith(config->readDataNames[i], "cmat5")) { - PreciceInterface_EnsureValidRead(interface, CMAT5); + PreciceInterface_EnsureValidRead(sim, CMAT5); interface->readData[i] = CMAT5; interface->materialTangent5Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); } else if (startsWith(config->readDataNames[i], "cmat6")) { - PreciceInterface_EnsureValidRead(interface, CMAT6); + PreciceInterface_EnsureValidRead(sim, CMAT6); interface->readData[i] = CMAT6; interface->materialTangent6Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); } else if (startsWith(config->readDataNames[i], "cmat7")) { - PreciceInterface_EnsureValidRead(interface, CMAT7); + PreciceInterface_EnsureValidRead(sim, CMAT7); interface->readData[i] = CMAT7; interface->materialTangent7Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); } else if (startsWith(config->readDataNames[i], "stresses1to3")) { - PreciceInterface_EnsureValidRead(interface, STRESS1TO3); + PreciceInterface_EnsureValidRead(sim, STRESS1TO3); interface->readData[i] = STRESS1TO3; interface->stress1to3Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); } else if (startsWith(config->readDataNames[i], "stresses4to6")) { - PreciceInterface_EnsureValidRead(interface, STRESS4TO6); + PreciceInterface_EnsureValidRead(sim, STRESS4TO6); interface->readData[i] = STRESS4TO6; interface->stress4to6Data = strdup(config->readDataNames[i]); printf("Read data '%s' found.\n", config->readDataNames[i]); @@ -1077,7 +1068,7 @@ void PreciceInterface_FreeData(PreciceInterface *preciceInterface) // Mesh names free(preciceInterface->faceCentersMeshName); free(preciceInterface->nodesMeshName); - free(preciceInterface->elementMeshName); + free(preciceInterface->elementsMeshName); // Data names free(preciceInterface->displacementDeltas); diff --git a/adapter/PreciceInterface.h b/adapter/PreciceInterface.h index 9ea401dd..a9182a50 100644 --- a/adapter/PreciceInterface.h +++ b/adapter/PreciceInterface.h @@ -47,7 +47,7 @@ typedef struct PreciceInterface { // Interface volumetric elements int elementMeshID; - char * elementMeshName; + char * elementsMeshName; int elementSetID; int numIPTotal; double *elemIPCoordinates; @@ -73,7 +73,6 @@ typedef struct PreciceInterface { char *kDeltaRead; char *kDeltaTemperatureRead; char *displacements; - char *displacementsData; char *displacementDeltas; char *positions; char *velocities; @@ -287,14 +286,8 @@ void Precice_FreeData(SimulationData *sim); void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, InterfaceConfig const *config); /** - * @brief Configures the elements mesh and calls setMeshVertices on preCICE - * @param interface - * @param sim - */ -void PreciceInterface_ConfigureElementsMesh(PreciceInterface *interface, SimulationData *sim); - -/** - * @brief Configures the face centers mesh and calls setMeshVertices on preCICE + * @brief * @brief Configures the face centers mesh and calls sendFaceCentersVertices, + * who is responsible for calling preCICE * @param interface * @param sim */ @@ -307,6 +300,13 @@ void PreciceInterface_ConfigureFaceCentersMesh(PreciceInterface *interface, Simu */ void PreciceInterface_ConfigureNodesMesh(PreciceInterface *interface, SimulationData *sim); +/** + * @brief Configures the elements mesh and calls setMeshVertices on preCICE + * @param interface + * @param sim + */ +void PreciceInterface_ConfigureElementsMesh(PreciceInterface *interface, SimulationData *sim); + /** * @brief Terminate execution if the nodes mesh ID is not valid * @param interface From 8842923bb6d5239122cb40795b70529e5d02d8b0 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Fri, 21 Mar 2025 13:53:08 +0100 Subject: [PATCH 48/55] Revert changes to fix function headers --- adapter/PreciceInterface.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/adapter/PreciceInterface.h b/adapter/PreciceInterface.h index a9182a50..7b302f0e 100644 --- a/adapter/PreciceInterface.h +++ b/adapter/PreciceInterface.h @@ -286,13 +286,20 @@ void Precice_FreeData(SimulationData *sim); void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, InterfaceConfig const *config); /** - * @brief * @brief Configures the face centers mesh and calls sendFaceCentersVertices, + * @brief Configures the face centers mesh and calls sendFaceCentersVertices, * who is responsible for calling preCICE * @param interface * @param sim */ void PreciceInterface_ConfigureFaceCentersMesh(PreciceInterface *interface, SimulationData *sim); +/** + * @brief Send the faces centers to preCICE. + * + * @param interface + */ +void sendFaceCentersVertices(PreciceInterface *interface); + /** * @brief Configures the nodes mesh * @param interface @@ -313,6 +320,19 @@ void PreciceInterface_ConfigureElementsMesh(PreciceInterface *interface, Simulat */ void PreciceInterface_EnsureValidNodesMeshID(PreciceInterface *interface); +/** + * @brief Terminate execution if the faces mesh ID is not valid + * @param type of data requiring mesh ID + */ +void PreciceInterface_EnsureValidFacesMeshID(PreciceInterface *interface, const char *type); + +/** + * @brief Terminate execution if this kind of data can't be read + * @param sim + * @param type of data to check + */ +void PreciceInterface_EnsureValidRead(SimulationData *sim, enum CouplingDataType type); + /** * @brief Configures the faces mesh (for tetrahedral elements only) * @param interface From d21da2881eb3d0040cbf87c04aa1a8e71228d0fc Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Fri, 21 Mar 2025 14:02:06 +0100 Subject: [PATCH 49/55] Removing variables that are not used --- adapter/PreciceInterface.c | 2 -- adapter/PreciceInterface.h | 8 +++----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index 2ee9b0cb..e10e503f 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -614,7 +614,6 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I // Initialize element data points as NULL interface->elemIPID = NULL; interface->elemIPCoordinates = NULL; - interface->elementIPScalarData = NULL; interface->elementIPVectorData = NULL; // Initialize preCICE mesh name as NULL @@ -1062,7 +1061,6 @@ void PreciceInterface_FreeData(PreciceInterface *preciceInterface) // Volumteric element related data free(preciceInterface->elemIPCoordinates); free(preciceInterface->elemIPID); - free(preciceInterface->elementIPScalarData); free(preciceInterface->elementIPVectorData); // Mesh names diff --git a/adapter/PreciceInterface.h b/adapter/PreciceInterface.h index 7b302f0e..6ebcfb32 100644 --- a/adapter/PreciceInterface.h +++ b/adapter/PreciceInterface.h @@ -27,13 +27,11 @@ typedef struct PreciceInterface { // Interface nodes int numNodes; - int num2DNodes; // Nodes in a single plane in case of quasi 2D-3D coupling int * nodeIDs; Mapping2D3D *mappingQuasi2D3D; double * nodeCoordinates; int nodeSetID; int * preciceNodeIDs; - int nodesMeshID; char * nodesMeshName; // Interface face elements @@ -46,7 +44,6 @@ typedef struct PreciceInterface { int * preciceFaceCenterIDs; // Interface volumetric elements - int elementMeshID; char * elementsMeshName; int elementSetID; int numIPTotal; @@ -59,7 +56,6 @@ typedef struct PreciceInterface { double *nodeVectorData; // Forces, displacements, velocities, positions and displacementDeltas are vector quantities double *node2DVectorData; // Vector quantities in 2D in case quasi 2D-3D coupling is done double *faceCenterData; - double *elementIPScalarData; // Scalar quantities at the integration points double *elementIPVectorData; // Vector quantities at the integration points // preCICE mesh name @@ -317,11 +313,13 @@ void PreciceInterface_ConfigureElementsMesh(PreciceInterface *interface, Simulat /** * @brief Terminate execution if the nodes mesh ID is not valid * @param interface + * @param type of data requiring mesh ID */ -void PreciceInterface_EnsureValidNodesMeshID(PreciceInterface *interface); +void PreciceInterface_EnsureValidNodesMeshID(PreciceInterface *interface, const char *type); /** * @brief Terminate execution if the faces mesh ID is not valid + * @param interface * @param type of data requiring mesh ID */ void PreciceInterface_EnsureValidFacesMeshID(PreciceInterface *interface, const char *type); From 5c2c66c6ee69b68c6b106c2fc49ddf18e0444b1b Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Fri, 21 Mar 2025 17:29:07 +0100 Subject: [PATCH 50/55] Use correct naming terminology for subroutine to set stress tensor --- adapter/PreciceInterface.c | 32 +++++++++++++++++++++----------- adapter/PreciceInterface.h | 11 +++++------ ccx_2.20.c | 5 ++--- setstrain.f => setstresstensor.f | 8 ++++++-- 4 files changed, 34 insertions(+), 22 deletions(-) rename setstrain.f => setstresstensor.f (74%) diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index a1287512..325a3c90 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -266,6 +266,7 @@ void Precice_ReadCouplingData(SimulationData *sim) printf("Reading DISPLACEMENTS coupling data.\n"); break; case CMAT1: + printf("Before reading MATERIAL TANGENT 1 coupling data.\n"); // READ MATERIAL MATRIX COMPONENTS - C11, C12, C13 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent1Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); for (int k = 0; k < interfaces[i]->numIPTotal; k++) { @@ -277,6 +278,7 @@ void Precice_ReadCouplingData(SimulationData *sim) printf("Reading MATERIAL TANGENT 1 coupling data.\n"); break; case CMAT2: + printf("Before reading MATERIAL TANGENT 2 coupling data.\n"); // READ MATERIAL MATRIX COMPONENTS - C14, C15, C16 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent2Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); for (int k = 0; k < interfaces[i]->numIPTotal; k++) { @@ -288,6 +290,7 @@ void Precice_ReadCouplingData(SimulationData *sim) printf("Reading MATERIAL TANGENT 2 coupling data.\n"); break; case CMAT3: + printf("Before reading MATERIAL TANGENT 3 coupling data.\n"); // READ MATERIAL MATRIX COMPONENTS - C22, C23, C24 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent3Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); for (int k = 0; k < interfaces[i]->numIPTotal; k++) { @@ -299,6 +302,7 @@ void Precice_ReadCouplingData(SimulationData *sim) printf("Reading MATERIAL TANGENT 3 coupling data.\n"); break; case CMAT4: + printf("Before reading MATERIAL TANGENT 4 coupling data.\n"); // READ MATERIAL MATRIX COMPONENTS - C25, C26, C33 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent4Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); for (int k = 0; k < interfaces[i]->numIPTotal; k++) { @@ -310,6 +314,7 @@ void Precice_ReadCouplingData(SimulationData *sim) printf("Reading MATERIAL TANGENT 4 coupling data.\n"); break; case CMAT5: + printf("Before reading MATERIAL TANGENT 5 coupling data.\n"); // READ MATERIAL MATRIX COMPONENTS - C34, C35, C36 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent5Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); for (int k = 0; k < interfaces[i]->numIPTotal; k++) { @@ -321,6 +326,7 @@ void Precice_ReadCouplingData(SimulationData *sim) printf("Reading MATERIAL TANGENT 5 coupling data.\n"); break; case CMAT6: + printf("Before reading MATERIAL TANGENT 6 coupling data.\n"); // READ MATERIAL MATRIX COMPONENTS - C44, C45, C46 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent6Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); for (int k = 0; k < interfaces[i]->numIPTotal; k++) { @@ -332,6 +338,7 @@ void Precice_ReadCouplingData(SimulationData *sim) printf("Reading MATERIAL TANGENT 6 coupling data.\n"); break; case CMAT7: + printf("Before reading MATERIAL TANGENT 7 coupling data.\n"); // READ MATERIAL MATRIX COMPONENTS - C55, C56, C66 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent7Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); for (int k = 0; k < interfaces[i]->numIPTotal; k++) { @@ -346,22 +353,24 @@ void Precice_ReadCouplingData(SimulationData *sim) // READ STRESS COMPONENTS - S11, S22, S33 idx = 1; precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->stress1to3Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - FORTRAN(setstrain, (sim->mi, - &idx, - &interfaces[i]->numElements, - interfaces[i]->elementIPVectorData, - sim->stx)); + printf("After preCICE read command: Reading STRESS1TO3 coupling data.\n"); + FORTRAN(setstresstensor, (sim->mi, + &idx, + &interfaces[i]->numElements, + interfaces[i]->elementIPVectorData, + sim->stx)); printf("Reading STRESS1TO3 coupling data.\n"); break; case STRESS4TO6: + printf("Before reading STRESS4TO6 coupling data.\n"); // READ STRESS COMPONENTS - S23, S13, S12 idx = 4; precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->stress4to6Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - FORTRAN(setstrain, (sim->mi, - &idx, - &interfaces[i]->numElements, - interfaces[i]->elementIPVectorData, - sim->stx)); + FORTRAN(setstresstensor, (sim->mi, + &idx, + &interfaces[i]->numElements, + interfaces[i]->elementIPVectorData, + sim->stx)); printf("Reading STRESS4TO6 coupling data.\n"); break; case DISPLACEMENTDELTAS: @@ -523,7 +532,6 @@ void Precice_WriteCouplingData(SimulationData *sim) precicec_writeData(interfaces[i]->couplingMeshName, interfaces[i]->forces, interfaces[i]->numNodes, interfaces[i]->preciceNodeIDs, interfaces[i]->nodeVectorData); printf("Writing FORCES coupling data.\n"); break; - /* VOLUMETRIC COUPLING - MULTISCALE */ case STRAIN1TO3: idx = 0; getElementStrain(idx, sim->mi, interfaces[i]->numElements, sim->eei, interfaces[i]->elementIPVectorData); @@ -879,6 +887,8 @@ void PreciceInterface_ConfigureCouplingData(PreciceInterface *interface, Simulat interface->nodeVectorData = malloc(interface->numNodes * 3 * sizeof(double)); interface->faceCenterData = malloc(interface->numElements * sizeof(double)); + interface->elementIPVectorData = malloc(interface->numIPTotal * 3 * sizeof(double)); + // Configure all the read data, then the write data int i; interface->numReadData = config->numReadData; diff --git a/adapter/PreciceInterface.h b/adapter/PreciceInterface.h index 6ebcfb32..bedec656 100644 --- a/adapter/PreciceInterface.h +++ b/adapter/PreciceInterface.h @@ -113,8 +113,7 @@ typedef struct PreciceInterface { typedef struct SimulationData { // CalculiX data - ITG *iset; - + ITG * iset; ITG * ialset; ITG * ielmat; ITG * istartset; @@ -135,7 +134,7 @@ typedef struct SimulationData { int nload; char * sideload; double nk; - double ne; // new variable added + double ne; ITG mt; double *theta; double *dtheta; @@ -153,9 +152,9 @@ typedef struct SimulationData { ITG * mi; ITG * nea; // element bounds in each thread - start ITG * neb; // element bounds in each thread - end - double *eei; // Strain values for multiscale - double *stx; // Stress values for multiscale - double *xstiff; // Strain values for multiscale + double *eei; // Strain tensor values + double *stx; // Stress tensor values + double *xstiff; // Stiffness matrix values // Interfaces int numPreciceInterfaces; diff --git a/ccx_2.20.c b/ccx_2.20.c index fa4b6856..74a02694 100644 --- a/ccx_2.20.c +++ b/ccx_2.20.c @@ -1308,7 +1308,7 @@ int main(int argc, char *argv[]) /* nmethod=15: Crack propagation */ /* nmethod=16: Feasible direction based on sensitivity information */ if (preciceUsed) { - int isStaticOrDynamic = ((nmethod == 1) || (nmethod == 4)); //&& (iperturb[0] > 1); + int isStaticOrDynamic = ((nmethod == 1) || (nmethod == 4)) ;//&& (iperturb[0] > 1); Necessary to trigger isStaticorDynamic int isDynamic = ((nmethod == 4) && (iperturb[0] > 1)); int isThermalAnalysis = ithermal[0] >= 2; int isModalDynamic = ((nmethod == 4) && (iperturb[0] < 2)); @@ -1428,7 +1428,6 @@ int main(int argc, char *argv[]) mpcfree = mpcinfo[1]; icascade = mpcinfo[2]; maxlenmpc = mpcinfo[3]; - } else { printf("ERROR: This simulation type is not available with preCICE"); exit(0); @@ -1449,7 +1448,7 @@ int main(int argc, char *argv[]) FORTRAN(stop, ()); } - printf("Starting Multiscale Linear Static Analysis via preCICE...\n"); + printf("Starting multiscale linear static analysis via preCICE...\n"); linstatic_precice(co, &nk, &kon, &ipkon, &lakon, &ne, nodeboun, ndirboun, xboun, &nboun, diff --git a/setstrain.f b/setstresstensor.f similarity index 74% rename from setstrain.f rename to setstresstensor.f index cd99ac3c..c7b2446a 100644 --- a/setstrain.f +++ b/setstresstensor.f @@ -1,4 +1,4 @@ - subroutine setstrain(mi, intpt, num_elem, pdata, stx) + subroutine setstresstensor(mi, intpt, num_elem, pdata, stx) implicit none @@ -12,6 +12,10 @@ subroutine setstrain(mi, intpt, num_elem, pdata, stx) ! local variables integer :: i, j , k, ngp_max, count + write(*,*) 'setstresstensor: num_elem = ', num_elem + write(*,*) 'setstresstensor: intpt = ', intpt + write(*,*) 'setstresstensor: mi(1) = ', mi(1) + ngp_max = mi(1) count = 1 @@ -24,4 +28,4 @@ subroutine setstrain(mi, intpt, num_elem, pdata, stx) end do end do - end subroutine setstrain + end subroutine setstresstensor From 1df50615908d3ad2ee73b2663f43188bbe014d09 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Sun, 23 Mar 2025 16:04:49 +0100 Subject: [PATCH 51/55] Move functionality to set stiffness matrix and stress tensor values into helper functions --- Makefile | 4 +- adapter/CCXHelpers.c | 40 ++++++++++---- adapter/CCXHelpers.h | 17 ++++-- adapter/PreciceInterface.c | 106 +++++++++++-------------------------- setstresstensor.f | 31 ----------- 5 files changed, 79 insertions(+), 119 deletions(-) delete mode 100644 setstresstensor.f diff --git a/Makefile b/Makefile index 04b4ab6c..514a31c5 100644 --- a/Makefile +++ b/Makefile @@ -62,7 +62,7 @@ else CC = mpicc endif -FFLAGS = -Wall -O3 -fopenmp $(INCLUDES) ${ADDITIONAL_FFLAGS} +FFLAGS = -Wall -O3 -fopenmp -fallow-argument-mismatch $(INCLUDES) ${ADDITIONAL_FFLAGS} # Note for GCC 10 or newer: add -fallow-argument-mismatch in the above flags FC = mpifort # FC = mpif90 @@ -74,7 +74,7 @@ SCCXMAIN = ccx_$(CCX_VERSION).c # Append additional sources SCCXC += nonlingeo_precice.c dyna_precice.c CCXHelpers.c PreciceInterface.c linstatic_precice.c -SCCXF += getflux.f getkdeltatemp.f getc3d8elementgausspointcoords.f setstrain.f +SCCXF += getflux.f getkdeltatemp.f getc3d8elementgausspointcoords.f diff --git a/adapter/CCXHelpers.c b/adapter/CCXHelpers.c index ae5a6e6f..2a9c41d3 100644 --- a/adapter/CCXHelpers.c +++ b/adapter/CCXHelpers.c @@ -420,17 +420,15 @@ int getXloadIndexOffset(enum xloadVariable xloadVar) } } -void getElementStrain(int strainIdx, int *mi, int nelem, double *eei, double *strainData) +void getElementStrain(int strainIdx, int numIPTotal, double *eei, double *strainData) { - int i, count, idx; + int i, idx; // Loop through all element and respective gauss points - count = 0; - for (i = 0; i < mi[0] * nelem; i++) { - idx = i * 6 + strainIdx; - strainData[count] = eei[idx]; - strainData[count + 1] = eei[idx + 1]; - strainData[count + 2] = eei[idx + 2]; - count = count + 3; + for (i = 0; i < numIPTotal; i++) { + idx = i * 6 + strainIdx; //TODO: Add explanation for 6 + strainData[i * 3] = eei[idx]; + strainData[i * 3 + 1] = eei[idx + 1]; + strainData[i * 3 + 2] = eei[idx + 2]; } } @@ -495,6 +493,30 @@ void setNodeDisplacements(double *displacements, ITG numNodes, int dim, int *xbo } } +void setElementsStiffness(int stiffnessIdx, int numIPTotal, double *stiffnessData, double *xstiff) +{ + int i, idx; + // Loop through all element and respective gauss points + for (i = 0; i < numIPTotal; i++) { + idx = i * 27 + stiffnessIdx; //TODO: Add explanation for 27 + xstiff[idx] = stiffnessData[i * 3]; + xstiff[idx + 1] = stiffnessData[i * 3 + 1]; + xstiff[idx + 2] = stiffnessData[i * 3 + 2]; + } +} + +void setElementsStress(int stressIdx, int numIPTotal, double *stressData, double *stx) +{ + int i, idx; + // Loop through all element and respective gauss points + for (i = 0; i < numIPTotal; i++) { + idx = i * 6 + stressIdx; //TODO: Add explanation for 6 + stx[idx] = stressData[i * 3]; + stx[idx + 1] = stressData[i * 3 + 1]; + stx[idx + 2] = stressData[i * 3 + 2]; + } +} + bool isSteadyStateSimulation(ITG *nmethod) { return *nmethod == 1; diff --git a/adapter/CCXHelpers.h b/adapter/CCXHelpers.h index 2c2ed9b2..f0f604f1 100644 --- a/adapter/CCXHelpers.h +++ b/adapter/CCXHelpers.h @@ -265,12 +265,11 @@ void getXforcIndices(ITG *nodes, ITG numNodes, int nforc, int *ikforc, int *ilfo /** * @brief Gets the strain values at each Gauss point of each element * @param strainIdx: CalculiX variable for the index of the strain values - * @param mi: CalculiX variable for the number of integration points - * @param nelem: CalculiX variable for the number of elements + * @param numIPTotal: CalculiX variable for the number of elements * @param eei: CalculiX array for the element integration information * @param strainData: CalculiX array for the strain values */ -void getElementStrain(int strainIdx, int *mi, int nelem, double *eei, double *strainData); +void getElementStrain(int strainIdx, int numIPTotal, double *eei, double *strainData); /** * @brief Modifies the values of a DFLUX or FILM boundary condition @@ -348,6 +347,18 @@ void setNodeForces(double *forces, ITG numNodes, int dim, int *xforcIndices, dou */ void setNodeDisplacements(double *displacements, ITG numNodes, int dim, int *xbounIndices, double *xboun); +/** + * @brief Modifies the values of stress of the elements at the interface + * @param TODO + */ +void setElementsStiffness(int stiffnessIdx, int numIPTotal, double *stiffnessData, double *xstiff); + +/** + * @brief Modifies the values of stress of the elements at the interface + * @param TODO + */ +void setElementsStress(int stressIdx, int numIPTotal, double *stressData, double *stx); + /** * @brief Returns whether it is a steady-state simulation based on the value of nmethod * @param nmethod: CalculiX variable with information regarding the type of analysis diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index 325a3c90..96be99f4 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -62,7 +62,7 @@ void Precice_Setup(char *configFilename, char *participantName, SimulationData * // Initialize coupling data printf("Initializing coupling data\n"); fflush(stdout); - Precice_ReadCouplingData(sim); + //Precice_ReadCouplingData(sim); } void Precice_AdjustSolverTimestep(SimulationData *sim) @@ -74,16 +74,18 @@ void Precice_AdjustSolverTimestep(SimulationData *sim) fflush(stdout); // For steady-state simulations, we will always compute the converged steady-state solution in one coupling step - *sim->theta = 0; - *sim->tper = 1; - *sim->dtheta = 1; + //*sim->theta = 0; + //*sim->tper = 1; + //*sim->dtheta = 1; + printf("Step 1\n"); // Set the solver time step to be the same as the coupling time step sim->solver_dt = precice_dt; } else { // Compute the time step size of CalculiX double solver_dt = (*sim->dtheta) * (*sim->tper); + printf("Step 2\n"); // Synchronize CalculiX time step with preCICE time window end double dt = fmin(precice_dt, solver_dt); @@ -197,7 +199,7 @@ void Precice_ReadCouplingData(SimulationData *sim) PreciceInterface **interfaces = sim->preciceInterfaces; int numInterfaces = sim->numPreciceInterfaces; - int i, j, idx; + int i, j; for (i = 0; i < numInterfaces; i++) { @@ -266,111 +268,71 @@ void Precice_ReadCouplingData(SimulationData *sim) printf("Reading DISPLACEMENTS coupling data.\n"); break; case CMAT1: - printf("Before reading MATERIAL TANGENT 1 coupling data.\n"); // READ MATERIAL MATRIX COMPONENTS - C11, C12, C13 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent1Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - for (int k = 0; k < interfaces[i]->numIPTotal; k++) { - idx = k * 27 + 0; - sim->xstiff[idx] = interfaces[i]->elementIPVectorData[k * 3]; - sim->xstiff[idx + 1] = interfaces[i]->elementIPVectorData[k * 3 + 1]; - sim->xstiff[idx + 2] = interfaces[i]->elementIPVectorData[k * 3 + 2]; - } + setElementsStiffness(0, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->xstiff); printf("Reading MATERIAL TANGENT 1 coupling data.\n"); break; case CMAT2: - printf("Before reading MATERIAL TANGENT 2 coupling data.\n"); // READ MATERIAL MATRIX COMPONENTS - C14, C15, C16 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent2Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - for (int k = 0; k < interfaces[i]->numIPTotal; k++) { - idx = k * 27 + 3; - sim->xstiff[idx] = interfaces[i]->elementIPVectorData[k * 3]; - sim->xstiff[idx + 1] = interfaces[i]->elementIPVectorData[k * 3 + 1]; - sim->xstiff[idx + 2] = interfaces[i]->elementIPVectorData[k * 3 + 2]; - } + setElementsStiffness(3, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->xstiff); printf("Reading MATERIAL TANGENT 2 coupling data.\n"); break; case CMAT3: - printf("Before reading MATERIAL TANGENT 3 coupling data.\n"); // READ MATERIAL MATRIX COMPONENTS - C22, C23, C24 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent3Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - for (int k = 0; k < interfaces[i]->numIPTotal; k++) { - idx = k * 27 + 6; - sim->xstiff[idx] = interfaces[i]->elementIPVectorData[k * 3]; - sim->xstiff[idx + 1] = interfaces[i]->elementIPVectorData[k * 3 + 1]; - sim->xstiff[idx + 2] = interfaces[i]->elementIPVectorData[k * 3 + 2]; - } + setElementsStiffness(6, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->xstiff); printf("Reading MATERIAL TANGENT 3 coupling data.\n"); break; case CMAT4: - printf("Before reading MATERIAL TANGENT 4 coupling data.\n"); // READ MATERIAL MATRIX COMPONENTS - C25, C26, C33 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent4Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - for (int k = 0; k < interfaces[i]->numIPTotal; k++) { - idx = k * 27 + 9; - sim->xstiff[idx] = interfaces[i]->elementIPVectorData[k * 3]; - sim->xstiff[idx + 1] = interfaces[i]->elementIPVectorData[k * 3 + 1]; - sim->xstiff[idx + 2] = interfaces[i]->elementIPVectorData[k * 3 + 2]; - } + setElementsStiffness(9, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->xstiff); printf("Reading MATERIAL TANGENT 4 coupling data.\n"); break; case CMAT5: - printf("Before reading MATERIAL TANGENT 5 coupling data.\n"); // READ MATERIAL MATRIX COMPONENTS - C34, C35, C36 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent5Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - for (int k = 0; k < interfaces[i]->numIPTotal; k++) { - idx = k * 27 + 12; - sim->xstiff[idx] = interfaces[i]->elementIPVectorData[k * 3]; - sim->xstiff[idx + 1] = interfaces[i]->elementIPVectorData[k * 3 + 1]; - sim->xstiff[idx + 2] = interfaces[i]->elementIPVectorData[k * 3 + 2]; - } + setElementsStiffness(12, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->xstiff); printf("Reading MATERIAL TANGENT 5 coupling data.\n"); break; case CMAT6: - printf("Before reading MATERIAL TANGENT 6 coupling data.\n"); // READ MATERIAL MATRIX COMPONENTS - C44, C45, C46 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent6Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - for (int k = 0; k < interfaces[i]->numIPTotal; k++) { - idx = k * 27 + 15; - sim->xstiff[idx] = interfaces[i]->elementIPVectorData[k * 3]; - sim->xstiff[idx + 1] = interfaces[i]->elementIPVectorData[k * 3 + 1]; - sim->xstiff[idx + 2] = interfaces[i]->elementIPVectorData[k * 3 + 2]; - } + setElementsStiffness(15, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->xstiff); printf("Reading MATERIAL TANGENT 6 coupling data.\n"); break; case CMAT7: - printf("Before reading MATERIAL TANGENT 7 coupling data.\n"); // READ MATERIAL MATRIX COMPONENTS - C55, C56, C66 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent7Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); for (int k = 0; k < interfaces[i]->numIPTotal; k++) { - idx = k * 27 + 18; - sim->xstiff[idx] = interfaces[i]->elementIPVectorData[k * 3]; - sim->xstiff[idx + 1] = interfaces[i]->elementIPVectorData[k * 3 + 1]; - sim->xstiff[idx + 2] = interfaces[i]->elementIPVectorData[k * 3 + 2]; + printf("CMAT7 read from preCICE: %f, %f, %f\n", interfaces[i]->elementIPVectorData[k * 3], interfaces[i]->elementIPVectorData[k * 3 + 1], interfaces[i]->elementIPVectorData[k * 3 + 2]); } + setElementsStiffness(18, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->xstiff); printf("Reading MATERIAL TANGENT 7 coupling data.\n"); break; case STRESS1TO3: // READ STRESS COMPONENTS - S11, S22, S33 - idx = 1; precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->stress1to3Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - printf("After preCICE read command: Reading STRESS1TO3 coupling data.\n"); - FORTRAN(setstresstensor, (sim->mi, - &idx, - &interfaces[i]->numElements, - interfaces[i]->elementIPVectorData, - sim->stx)); + for (int k = 0; k < interfaces[i]->numIPTotal; k++) { + printf("Stresses1to3 read from preCICE: %f, %f, %f\n", interfaces[i]->elementIPVectorData[k * 3], interfaces[i]->elementIPVectorData[k * 3 + 1], interfaces[i]->elementIPVectorData[k * 3 + 2]); + } + setElementsStress(0, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->stx); + int idxx; + for (int k = 0; k < interfaces[i]->numIPTotal; k++) { + idxx = k * 6; + printf("stx for %d = [%f,%f,%f]\n", idxx, sim->stx[idxx], sim->stx[idxx + 1], sim->stx[idxx + 2]); + } printf("Reading STRESS1TO3 coupling data.\n"); break; case STRESS4TO6: - printf("Before reading STRESS4TO6 coupling data.\n"); // READ STRESS COMPONENTS - S23, S13, S12 - idx = 4; precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->stress4to6Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - FORTRAN(setstresstensor, (sim->mi, - &idx, - &interfaces[i]->numElements, - interfaces[i]->elementIPVectorData, - sim->stx)); + for (int k = 0; k < interfaces[i]->numIPTotal; k++) { + printf("Stresses4to6 read from preCICE: %f, %f, %f\n", interfaces[i]->elementIPVectorData[k * 3], interfaces[i]->elementIPVectorData[k * 3 + 1], interfaces[i]->elementIPVectorData[k * 3 + 2]); + } + setElementsStress(3, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->stx); printf("Reading STRESS4TO6 coupling data.\n"); break; case DISPLACEMENTDELTAS: @@ -411,7 +373,7 @@ void Precice_WriteCouplingData(SimulationData *sim) PreciceInterface **interfaces = sim->preciceInterfaces; int numInterfaces = sim->numPreciceInterfaces; - int i, j, idx; + int i, j; int iset; for (i = 0; i < numInterfaces; i++) { @@ -533,16 +495,12 @@ void Precice_WriteCouplingData(SimulationData *sim) printf("Writing FORCES coupling data.\n"); break; case STRAIN1TO3: - idx = 0; - getElementStrain(idx, sim->mi, interfaces[i]->numElements, sim->eei, interfaces[i]->elementIPVectorData); - // printf("strain1to3 values: %d\n", interfaces[i]->elementIPVectorData[0]); + getElementStrain(0, interfaces[i]->numIPTotal, sim->eei, interfaces[i]->elementIPVectorData); precicec_writeData(interfaces[i]->couplingMeshName, interfaces[i]->strain1to3Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, interfaces[i]->elementIPVectorData); printf("Writing STRAIN1TO3 coupling data.\n"); break; case STRAIN4TO6: - idx = 3; - getElementStrain(idx, sim->mi, interfaces[i]->numElements, sim->eei, interfaces[i]->elementIPVectorData); - // printf("strain4to6 values: %d\n", interfaces[i]->elementIPVectorData[0]); + getElementStrain(3, interfaces[i]->numIPTotal, sim->eei, interfaces[i]->elementIPVectorData); precicec_writeData(interfaces[i]->couplingMeshName, interfaces[i]->strain4to6Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, interfaces[i]->elementIPVectorData); printf("Writing STRAIN4TO6 coupling data.\n"); break; @@ -735,7 +693,7 @@ void PreciceInterface_ConfigureElementsMesh(PreciceInterface *interface, Simulat getElementsIDs(interface->elementSetID, sim->ialset, sim->istartset, sim->iendset, interface->elementIDs); // Find guass point coordinates of the element -> Serves as mesh for data transfer - interface->numIPTotal = 8 * interface->numElements; // Gauss point mesh coordinate - each element 8 gauss points + interface->numIPTotal = sim->mi[0] * interface->numElements; // Number of Gauss points per element * number of elements interface->elemIPCoordinates = malloc(interface->numIPTotal * 3 * sizeof(double)); interface->elemIPID = malloc(interface->numIPTotal * sizeof(int)); diff --git a/setstresstensor.f b/setstresstensor.f deleted file mode 100644 index c7b2446a..00000000 --- a/setstresstensor.f +++ /dev/null @@ -1,31 +0,0 @@ - subroutine setstresstensor(mi, intpt, num_elem, pdata, stx) - - implicit none - - ! io variables - integer :: mi(*) ! maximum value of integration point per element (mi[0]) - integer :: num_elem ! number of elements - integer :: intpt ! intercept added to stx - real(8) :: pdata(*) ! data received from preCICE - real(8) :: stx(6, mi(1),*) ! stress vector used by CalculiX - - ! local variables - integer :: i, j , k, ngp_max, count - - write(*,*) 'setstresstensor: num_elem = ', num_elem - write(*,*) 'setstresstensor: intpt = ', intpt - write(*,*) 'setstresstensor: mi(1) = ', mi(1) - - ngp_max = mi(1) - - count = 1 - do i = 1, num_elem - do j = 1, ngp_max - stx(intpt, j, i) = pdata(count) - stx(intpt+1, j, i) = pdata(count+1) - stx(intpt+2, j, i) = pdata(count+2) - count = count + 3 - end do - end do - - end subroutine setstresstensor From 31d95524c367a91bfab811926e5cfca7be829a1a Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 24 Mar 2025 11:01:08 +0100 Subject: [PATCH 52/55] Use singular form for the word Element in function names, to make then consistent with Node or Face based functions --- adapter/CCXHelpers.c | 4 ++-- adapter/CCXHelpers.h | 4 ++-- adapter/PreciceInterface.c | 30 ++++++++++++++---------------- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/adapter/CCXHelpers.c b/adapter/CCXHelpers.c index 2a9c41d3..34858a88 100644 --- a/adapter/CCXHelpers.c +++ b/adapter/CCXHelpers.c @@ -493,7 +493,7 @@ void setNodeDisplacements(double *displacements, ITG numNodes, int dim, int *xbo } } -void setElementsStiffness(int stiffnessIdx, int numIPTotal, double *stiffnessData, double *xstiff) +void setElementStiffness(int stiffnessIdx, int numIPTotal, double *stiffnessData, double *xstiff) { int i, idx; // Loop through all element and respective gauss points @@ -505,7 +505,7 @@ void setElementsStiffness(int stiffnessIdx, int numIPTotal, double *stiffnessDat } } -void setElementsStress(int stressIdx, int numIPTotal, double *stressData, double *stx) +void setElementStress(int stressIdx, int numIPTotal, double *stressData, double *stx) { int i, idx; // Loop through all element and respective gauss points diff --git a/adapter/CCXHelpers.h b/adapter/CCXHelpers.h index f0f604f1..47e3550f 100644 --- a/adapter/CCXHelpers.h +++ b/adapter/CCXHelpers.h @@ -351,13 +351,13 @@ void setNodeDisplacements(double *displacements, ITG numNodes, int dim, int *xbo * @brief Modifies the values of stress of the elements at the interface * @param TODO */ -void setElementsStiffness(int stiffnessIdx, int numIPTotal, double *stiffnessData, double *xstiff); +void setElementStiffness(int stiffnessIdx, int numIPTotal, double *stiffnessData, double *xstiff); /** * @brief Modifies the values of stress of the elements at the interface * @param TODO */ -void setElementsStress(int stressIdx, int numIPTotal, double *stressData, double *stx); +void setElementStress(int stressIdx, int numIPTotal, double *stressData, double *stx); /** * @brief Returns whether it is a steady-state simulation based on the value of nmethod diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index 96be99f4..6003d631 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -78,14 +78,12 @@ void Precice_AdjustSolverTimestep(SimulationData *sim) //*sim->tper = 1; //*sim->dtheta = 1; - printf("Step 1\n"); // Set the solver time step to be the same as the coupling time step sim->solver_dt = precice_dt; } else { // Compute the time step size of CalculiX double solver_dt = (*sim->dtheta) * (*sim->tper); - printf("Step 2\n"); // Synchronize CalculiX time step with preCICE time window end double dt = fmin(precice_dt, solver_dt); @@ -309,30 +307,30 @@ void Precice_ReadCouplingData(SimulationData *sim) for (int k = 0; k < interfaces[i]->numIPTotal; k++) { printf("CMAT7 read from preCICE: %f, %f, %f\n", interfaces[i]->elementIPVectorData[k * 3], interfaces[i]->elementIPVectorData[k * 3 + 1], interfaces[i]->elementIPVectorData[k * 3 + 2]); } - setElementsStiffness(18, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->xstiff); + setElementStiffness(18, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->xstiff); printf("Reading MATERIAL TANGENT 7 coupling data.\n"); break; case STRESS1TO3: // READ STRESS COMPONENTS - S11, S22, S33 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->stress1to3Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - for (int k = 0; k < interfaces[i]->numIPTotal; k++) { - printf("Stresses1to3 read from preCICE: %f, %f, %f\n", interfaces[i]->elementIPVectorData[k * 3], interfaces[i]->elementIPVectorData[k * 3 + 1], interfaces[i]->elementIPVectorData[k * 3 + 2]); - } - setElementsStress(0, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->stx); - int idxx; - for (int k = 0; k < interfaces[i]->numIPTotal; k++) { - idxx = k * 6; - printf("stx for %d = [%f,%f,%f]\n", idxx, sim->stx[idxx], sim->stx[idxx + 1], sim->stx[idxx + 2]); - } + // for (int k = 0; k < interfaces[i]->numIPTotal; k++) { + // printf("Stresses1to3 read from preCICE: %f, %f, %f\n", interfaces[i]->elementIPVectorData[k * 3], interfaces[i]->elementIPVectorData[k * 3 + 1], interfaces[i]->elementIPVectorData[k * 3 + 2]); + // } + setElementStress(0, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->stx); + // int idxx; + // for (int k = 0; k < interfaces[i]->numIPTotal; k++) { + // idxx = k * 6; + // printf("stx for %d = [%f,%f,%f]\n", idxx, sim->stx[idxx], sim->stx[idxx + 1], sim->stx[idxx + 2]); + // } printf("Reading STRESS1TO3 coupling data.\n"); break; case STRESS4TO6: // READ STRESS COMPONENTS - S23, S13, S12 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->stress4to6Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - for (int k = 0; k < interfaces[i]->numIPTotal; k++) { - printf("Stresses4to6 read from preCICE: %f, %f, %f\n", interfaces[i]->elementIPVectorData[k * 3], interfaces[i]->elementIPVectorData[k * 3 + 1], interfaces[i]->elementIPVectorData[k * 3 + 2]); - } - setElementsStress(3, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->stx); + // for (int k = 0; k < interfaces[i]->numIPTotal; k++) { + // printf("Stresses4to6 read from preCICE: %f, %f, %f\n", interfaces[i]->elementIPVectorData[k * 3], interfaces[i]->elementIPVectorData[k * 3 + 1], interfaces[i]->elementIPVectorData[k * 3 + 2]); + // } + setElementStress(3, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->stx); printf("Reading STRESS4TO6 coupling data.\n"); break; case DISPLACEMENTDELTAS: From 2b679fed0c7748e234d160bc49ebb44640425845 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Tue, 25 Mar 2025 16:36:26 +0100 Subject: [PATCH 53/55] Use appropriate functionality to identify element type for element mesh definition --- Makefile | 2 +- adapter/PreciceInterface.c | 53 +++++++++++------- adapter/PreciceInterface.h | 4 +- getc3d4elementgausspointcoords.f | 95 ++++++++++++++++++++++++++++++++ getc3d8elementgausspointcoords.f | 9 ++- linstatic_precice.c | 2 +- 6 files changed, 135 insertions(+), 30 deletions(-) create mode 100755 getc3d4elementgausspointcoords.f diff --git a/Makefile b/Makefile index 514a31c5..b1bf7b6d 100644 --- a/Makefile +++ b/Makefile @@ -74,7 +74,7 @@ SCCXMAIN = ccx_$(CCX_VERSION).c # Append additional sources SCCXC += nonlingeo_precice.c dyna_precice.c CCXHelpers.c PreciceInterface.c linstatic_precice.c -SCCXF += getflux.f getkdeltatemp.f getc3d8elementgausspointcoords.f +SCCXF += getflux.f getkdeltatemp.f getc3d8elementgausspointcoords.f getc3d4elementgausspointcoords.f diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index 6003d631..b2952211 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -268,37 +268,37 @@ void Precice_ReadCouplingData(SimulationData *sim) case CMAT1: // READ MATERIAL MATRIX COMPONENTS - C11, C12, C13 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent1Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - setElementsStiffness(0, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->xstiff); + setElementStiffness(0, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->xstiff); printf("Reading MATERIAL TANGENT 1 coupling data.\n"); break; case CMAT2: // READ MATERIAL MATRIX COMPONENTS - C14, C15, C16 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent2Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - setElementsStiffness(3, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->xstiff); + setElementStiffness(3, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->xstiff); printf("Reading MATERIAL TANGENT 2 coupling data.\n"); break; case CMAT3: // READ MATERIAL MATRIX COMPONENTS - C22, C23, C24 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent3Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - setElementsStiffness(6, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->xstiff); + setElementStiffness(6, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->xstiff); printf("Reading MATERIAL TANGENT 3 coupling data.\n"); break; case CMAT4: // READ MATERIAL MATRIX COMPONENTS - C25, C26, C33 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent4Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - setElementsStiffness(9, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->xstiff); + setElementStiffness(9, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->xstiff); printf("Reading MATERIAL TANGENT 4 coupling data.\n"); break; case CMAT5: // READ MATERIAL MATRIX COMPONENTS - C34, C35, C36 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent5Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - setElementsStiffness(12, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->xstiff); + setElementStiffness(12, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->xstiff); printf("Reading MATERIAL TANGENT 5 coupling data.\n"); break; case CMAT6: // READ MATERIAL MATRIX COMPONENTS - C44, C45, C46 precicec_readData(interfaces[i]->couplingMeshName, interfaces[i]->materialTangent6Data, interfaces[i]->numIPTotal, interfaces[i]->elemIPID, sim->solver_dt, interfaces[i]->elementIPVectorData); - setElementsStiffness(15, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->xstiff); + setElementStiffness(15, interfaces[i]->numIPTotal, interfaces[i]->elementIPVectorData, sim->xstiff); printf("Reading MATERIAL TANGENT 6 coupling data.\n"); break; case CMAT7: @@ -663,12 +663,12 @@ void PreciceInterface_Create(PreciceInterface *interface, SimulationData *sim, I static enum ElemType findSimulationMeshType(SimulationData *sim) { - // Assuming only tetrahedra are used, or only hexaedral, for faces meshes. + // Assuming only tetrahedra or hexahedra are used. // Return first non-zero mesh type. // lakon tab takes 8 chars per element const char *lakon_ptr = sim->lakon; - for (int i = 0; i < sim->ne; ++i) { + for (int i = 0; i < sim->ne + 1; ++i) { // +1 because ne starts from zero if (startsWith(lakon_ptr, "C3D4") || startsWith(lakon_ptr, "C3D10")) { return TETRAHEDRA; } else if (startsWith(lakon_ptr, "C3D8") || startsWith(lakon_ptr, "C3D20")) { @@ -699,19 +699,30 @@ void PreciceInterface_ConfigureElementsMesh(PreciceInterface *interface, Simulat interface->elemIPID[j] = j; } - int numElements = interface->numElements; - int numIPTotal = interface->numIPTotal; - char **lakon = sim->lakon; - - FORTRAN(getc3d8elementgausspointcoords, (&numElements, - &numIPTotal, - interface->elementIDs, - sim->co, - &lakon, - sim->kon, - sim->ipkon, - interface->elemIPID, - interface->elemIPCoordinates)); + int numElements = interface->numElements; + int numIPTotal = interface->numIPTotal; + + enum ElemType elemType = findSimulationMeshType(sim); + + if (elemType == TETRAHEDRA) { + FORTRAN(getc3d4elementgausspointcoords, (&numElements, + interface->elementIDs, + sim->co, + sim->kon, + sim->ipkon, + interface->elemIPID, + interface->elemIPCoordinates)); + } else if (elemType == HEXAHEDRA) { + FORTRAN(getc3d8elementgausspointcoords, (&numElements, + interface->elementIDs, + sim->co, + sim->kon, + sim->ipkon, + interface->elemIPID, + interface->elemIPCoordinates)); + } else { + supportedElementError(); + } // debugging TODO: remove for (int i = 0; i < interface->numIPTotal; i++) { diff --git a/adapter/PreciceInterface.h b/adapter/PreciceInterface.h index bedec656..872b44b4 100644 --- a/adapter/PreciceInterface.h +++ b/adapter/PreciceInterface.h @@ -118,7 +118,7 @@ typedef struct SimulationData { ITG * ielmat; ITG * istartset; ITG * iendset; - char ** lakon; + char * lakon; ITG * kon; ITG * ipkon; ITG nset; @@ -134,7 +134,7 @@ typedef struct SimulationData { int nload; char * sideload; double nk; - double ne; + ITG ne; ITG mt; double *theta; double *dtheta; diff --git a/getc3d4elementgausspointcoords.f b/getc3d4elementgausspointcoords.f new file mode 100755 index 00000000..55f2f003 --- /dev/null +++ b/getc3d4elementgausspointcoords.f @@ -0,0 +1,95 @@ +! +! CalculiX - A 3-dimensional finite element program +! Copyright (C) 1998-2015 Guido Dhondt +! +! This program is free software; you can redistribute it and/or +! modify it under the terms of the GNU General Public License as +! published by the Free Software Foundation(version 2); +! +! +! This program is distributed in the hope that it will be useful, +! but WITHOUT ANY WARRANTY; without even the implied warranty of +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +! GNU General Public License for more details. +! +! You should have received a copy of the GNU General Public License +! along with this program; if not, write to the Free Software +! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +! +! This function is a copy of the function for calculation and printout of the lift and drag forces +! + subroutine getc3d4elementgausspointcoords(nelem, elem_ids, + & co, kon, ipkon, elem_gp_id, elem_gp_coord) + + implicit none + + !Input/Output variables + integer :: nelem ! Number of elements + integer :: elem_ids(*) ! Element IDs, need to be adjusted for Fortran + real(8) :: co(3,*) ! Nodal coordinates of all nodes + integer :: kon(*) + integer :: ipkon(*) + + integer :: elem_gp_id(*) ! Gauss point IDs + real(8) :: elem_gp_coord(*) ! Gauss point coords + + ! Internal variables + integer(4) :: iel, el_id, indexe, i, j, k, l + integer(4) :: iflag, idx, konl(4), gp_id + REAL(8) :: xl(3,4), xi, et, ze, xsj, shp(4,20) + + include "gauss.f" + + data iflag /1/ + + ! Initialize gauss point coordinates to zero + do l = 1, nelem*4*3 + elem_gp_coord(l) = 0.0 + end do + + do iel = 1, nelem + el_id = elem_ids(iel) + + indexe=ipkon(el_id) + + ! connectivity + do i = 1, 4 + konl(i)=kon(indexe+i) + end do + + ! Local nodal coordinates + do i = 1, 4 + do j = 1, 3 + xl(j,i)=co(j,konl(i)) + end do + end do + + ! Loop through gauss points of each element + do gp_id = 1, 4 + elem_gp_id((el_id - 1)*4 + gp_id) = + & (el_id - 1)*4 + gp_id - 1 + + ! gauss3d5: tet, 4 integration points + xi = gauss3d5(1,gp_id) + et = gauss3d5(2,gp_id) + ze = gauss3d5(3,gp_id) + + ! Get the shape function + call shape4tet(xi,et,ze,xl,xsj,shp,iflag) + + ! Calculate the Gauss point coordinates + do k = 1, 3 + do l = 1, 4 + idx = (el_id - 1)*24 + (gp_id - 1)*3 + k + elem_gp_coord(idx)=elem_gp_coord(idx) + & +xl(k,l)*shp(4,l) + end do + end do + + end do + + end do + + return + + end subroutine getc3d4elementgausspointcoords diff --git a/getc3d8elementgausspointcoords.f b/getc3d8elementgausspointcoords.f index 1273552b..3fcf3c2f 100755 --- a/getc3d8elementgausspointcoords.f +++ b/getc3d8elementgausspointcoords.f @@ -18,17 +18,15 @@ ! ! This function is a copy of the function for calculation and printout of the lift and drag forces ! - subroutine getc3d8elementgausspointcoords(nelem, ngp, elem_ids, - & co, lakon, kon, ipkon, elem_gp_id, elem_gp_coord) + subroutine getc3d8elementgausspointcoords(nelem, elem_ids, + & co, kon, ipkon, elem_gp_id, elem_gp_coord) implicit none !Input/Output variables integer :: nelem ! Number of elements - integer :: ngp ! Total number of elements (nelem * 8) integer :: elem_ids(*) ! Element IDs, need to be adjusted for Fortran real(8) :: co(3,*) ! Nodal coordinates of all nodes - character(8):: lakon(*) integer :: kon(*) integer :: ipkon(*) @@ -38,7 +36,7 @@ subroutine getc3d8elementgausspointcoords(nelem, ngp, elem_ids, ! Internal variables integer(4) :: iel, el_id, indexe, i, j, k, l integer(4) :: iflag, idx, konl(8), gp_id - REAL(8) :: xl(3,8), xi, et, ze, xsj, shp(4,20) + real(8) :: xl(3,8), xi, et, ze, xsj, shp(4,20) include "gauss.f" @@ -71,6 +69,7 @@ subroutine getc3d8elementgausspointcoords(nelem, ngp, elem_ids, elem_gp_id((el_id - 1)*8 + gp_id) = & (el_id - 1)*8 + gp_id - 1 + ! gauss3d2: hex, 2-point integration (8 integration points) xi = gauss3d2(1,gp_id) et = gauss3d2(2,gp_id) ze = gauss3d2(3,gp_id) diff --git a/linstatic_precice.c b/linstatic_precice.c index e0065359..6d02024f 100644 --- a/linstatic_precice.c +++ b/linstatic_precice.c @@ -153,7 +153,7 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak .iendset = iendset, .kon = kon, .ipkon = ipkon, - .lakon = &lakon, + .lakon = lakon, .co = co, .set = set, .nset = *nset, From 85a265fad5680ee63fdd1bbaa32bbef3f8d94f7f Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Wed, 26 Mar 2025 06:58:00 +0100 Subject: [PATCH 54/55] Rework Gauss points coord loop for C3D4 and C3D8 elements --- adapter/PreciceInterface.c | 1 - getc3d4elementgausspointcoords.f | 2 +- getc3d8elementgausspointcoords.f | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index b2952211..284ab3ba 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -690,7 +690,6 @@ void PreciceInterface_ConfigureElementsMesh(PreciceInterface *interface, Simulat interface->elementIDs = malloc(interface->numElements * sizeof(ITG)); getElementsIDs(interface->elementSetID, sim->ialset, sim->istartset, sim->iendset, interface->elementIDs); - // Find guass point coordinates of the element -> Serves as mesh for data transfer interface->numIPTotal = sim->mi[0] * interface->numElements; // Number of Gauss points per element * number of elements interface->elemIPCoordinates = malloc(interface->numIPTotal * 3 * sizeof(double)); interface->elemIPID = malloc(interface->numIPTotal * sizeof(int)); diff --git a/getc3d4elementgausspointcoords.f b/getc3d4elementgausspointcoords.f index 55f2f003..272f9269 100755 --- a/getc3d4elementgausspointcoords.f +++ b/getc3d4elementgausspointcoords.f @@ -79,8 +79,8 @@ subroutine getc3d4elementgausspointcoords(nelem, elem_ids, ! Calculate the Gauss point coordinates do k = 1, 3 + idx = (el_id - 1)*12 + (gp_id - 1)*3 + k do l = 1, 4 - idx = (el_id - 1)*24 + (gp_id - 1)*3 + k elem_gp_coord(idx)=elem_gp_coord(idx) & +xl(k,l)*shp(4,l) end do diff --git a/getc3d8elementgausspointcoords.f b/getc3d8elementgausspointcoords.f index 3fcf3c2f..a587a530 100755 --- a/getc3d8elementgausspointcoords.f +++ b/getc3d8elementgausspointcoords.f @@ -79,8 +79,8 @@ subroutine getc3d8elementgausspointcoords(nelem, elem_ids, ! Calculate the Gauss point coordinates do k = 1, 3 + idx = (el_id - 1)*24 + (gp_id - 1)*3 + k do l = 1, 8 - idx = (el_id - 1)*24 + (gp_id - 1)*3 + k elem_gp_coord(idx)=elem_gp_coord(idx) & +xl(k,l)*shp(4,l) end do From 3278c16990e2b917da842b4db4e311aa0c92b01c Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Fri, 28 Mar 2025 21:03:32 +0100 Subject: [PATCH 55/55] FIRST WORKING VERSION with C3D4 elements and a 3D notch geometry --- adapter/PreciceInterface.c | 10 ++----- getc3d4elementgausspointcoords.f | 49 +++++++++++++------------------- getc3d8elementgausspointcoords.f | 6 +--- linstatic_precice.c | 3 +- 4 files changed, 26 insertions(+), 42 deletions(-) diff --git a/adapter/PreciceInterface.c b/adapter/PreciceInterface.c index 284ab3ba..1590b057 100644 --- a/adapter/PreciceInterface.c +++ b/adapter/PreciceInterface.c @@ -668,7 +668,7 @@ static enum ElemType findSimulationMeshType(SimulationData *sim) // lakon tab takes 8 chars per element const char *lakon_ptr = sim->lakon; - for (int i = 0; i < sim->ne + 1; ++i) { // +1 because ne starts from zero + for (int i = 0; i < sim->ne; ++i) { if (startsWith(lakon_ptr, "C3D4") || startsWith(lakon_ptr, "C3D10")) { return TETRAHEDRA; } else if (startsWith(lakon_ptr, "C3D8") || startsWith(lakon_ptr, "C3D20")) { @@ -676,14 +676,13 @@ static enum ElemType findSimulationMeshType(SimulationData *sim) } lakon_ptr += 8; } - return INVALID_ELEMENT; } void PreciceInterface_ConfigureElementsMesh(PreciceInterface *interface, SimulationData *sim) { printf("Entering ConfigureElementsMesh \n"); - char *elementSetName = interface->name; // toFaceSetName(interface->name); + char *elementSetName = interface->name; interface->elementSetID = getSetID(elementSetName, sim->set, sim->nset); interface->numElements = getNumSetElements(interface->elementSetID, sim->istartset, sim->iendset); @@ -692,14 +691,13 @@ void PreciceInterface_ConfigureElementsMesh(PreciceInterface *interface, Simulat interface->numIPTotal = sim->mi[0] * interface->numElements; // Number of Gauss points per element * number of elements interface->elemIPCoordinates = malloc(interface->numIPTotal * 3 * sizeof(double)); - interface->elemIPID = malloc(interface->numIPTotal * sizeof(int)); + interface->elemIPID = malloc(interface->numIPTotal * sizeof(int)); for (int j = 0; j < interface->numIPTotal; j++) { interface->elemIPID[j] = j; } int numElements = interface->numElements; - int numIPTotal = interface->numIPTotal; enum ElemType elemType = findSimulationMeshType(sim); @@ -709,7 +707,6 @@ void PreciceInterface_ConfigureElementsMesh(PreciceInterface *interface, Simulat sim->co, sim->kon, sim->ipkon, - interface->elemIPID, interface->elemIPCoordinates)); } else if (elemType == HEXAHEDRA) { FORTRAN(getc3d8elementgausspointcoords, (&numElements, @@ -717,7 +714,6 @@ void PreciceInterface_ConfigureElementsMesh(PreciceInterface *interface, Simulat sim->co, sim->kon, sim->ipkon, - interface->elemIPID, interface->elemIPCoordinates)); } else { supportedElementError(); diff --git a/getc3d4elementgausspointcoords.f b/getc3d4elementgausspointcoords.f index 272f9269..bffc43fd 100755 --- a/getc3d4elementgausspointcoords.f +++ b/getc3d4elementgausspointcoords.f @@ -19,7 +19,7 @@ ! This function is a copy of the function for calculation and printout of the lift and drag forces ! subroutine getc3d4elementgausspointcoords(nelem, elem_ids, - & co, kon, ipkon, elem_gp_id, elem_gp_coord) + & co, kon, ipkon, elem_gp_coord) implicit none @@ -30,7 +30,6 @@ subroutine getc3d4elementgausspointcoords(nelem, elem_ids, integer :: kon(*) integer :: ipkon(*) - integer :: elem_gp_id(*) ! Gauss point IDs real(8) :: elem_gp_coord(*) ! Gauss point coords ! Internal variables @@ -43,7 +42,7 @@ subroutine getc3d4elementgausspointcoords(nelem, elem_ids, data iflag /1/ ! Initialize gauss point coordinates to zero - do l = 1, nelem*4*3 + do l = 1, nelem*3 elem_gp_coord(l) = 0.0 end do @@ -52,40 +51,32 @@ subroutine getc3d4elementgausspointcoords(nelem, elem_ids, indexe=ipkon(el_id) - ! connectivity - do i = 1, 4 - konl(i)=kon(indexe+i) - end do - ! Local nodal coordinates do i = 1, 4 + konl(i) = kon(indexe+i) do j = 1, 3 xl(j,i)=co(j,konl(i)) end do end do - ! Loop through gauss points of each element - do gp_id = 1, 4 - elem_gp_id((el_id - 1)*4 + gp_id) = - & (el_id - 1)*4 + gp_id - 1 - - ! gauss3d5: tet, 4 integration points - xi = gauss3d5(1,gp_id) - et = gauss3d5(2,gp_id) - ze = gauss3d5(3,gp_id) - - ! Get the shape function - call shape4tet(xi,et,ze,xl,xsj,shp,iflag) - - ! Calculate the Gauss point coordinates - do k = 1, 3 - idx = (el_id - 1)*12 + (gp_id - 1)*3 + k - do l = 1, 4 - elem_gp_coord(idx)=elem_gp_coord(idx) - & +xl(k,l)*shp(4,l) - end do - end do + ! One Gauss point per element + gp_id = 1 + ! gauss3d4: tet, 1 integration point + xi = gauss3d4(1,gp_id) + et = gauss3d4(2,gp_id) + ze = gauss3d4(3,gp_id) + + ! Get the shape function + call shape4tet(xi,et,ze,xl,xsj,shp,iflag) + + ! Calculate the Gauss point coordinates + do k = 1, 3 + idx = (iel - 1) * 3 + k + do l = 1, 4 + elem_gp_coord(idx)=elem_gp_coord(idx) + & +xl(k,l)*shp(4,l) + end do end do end do diff --git a/getc3d8elementgausspointcoords.f b/getc3d8elementgausspointcoords.f index a587a530..c36bb2b4 100755 --- a/getc3d8elementgausspointcoords.f +++ b/getc3d8elementgausspointcoords.f @@ -19,7 +19,7 @@ ! This function is a copy of the function for calculation and printout of the lift and drag forces ! subroutine getc3d8elementgausspointcoords(nelem, elem_ids, - & co, kon, ipkon, elem_gp_id, elem_gp_coord) + & co, kon, ipkon, elem_gp_coord) implicit none @@ -30,7 +30,6 @@ subroutine getc3d8elementgausspointcoords(nelem, elem_ids, integer :: kon(*) integer :: ipkon(*) - integer :: elem_gp_id(*) ! GP ID real(8) :: elem_gp_coord(*) ! GP coords ! Internal variables @@ -66,9 +65,6 @@ subroutine getc3d8elementgausspointcoords(nelem, elem_ids, ! Loop through gauss points of each element do gp_id = 1, 8 - elem_gp_id((el_id - 1)*8 + gp_id) = - & (el_id - 1)*8 + gp_id - 1 - ! gauss3d2: hex, 2-point integration (8 integration points) xi = gauss3d2(1,gp_id) et = gauss3d2(2,gp_id) diff --git a/linstatic_precice.c b/linstatic_precice.c index 6d02024f..57565041 100644 --- a/linstatic_precice.c +++ b/linstatic_precice.c @@ -181,7 +181,8 @@ void linstatic_precice(double *co, ITG *nk, ITG **konp, ITG **ipkonp, char **lak .fn = fn, .cocon = cocon, .ncocon = ncocon, - .mi = mi + .mi = mi, + .ne = *ne }; /* preCICE Adapter: Initialize */