CalculiX  2.13
A Free Software Three-Dimensional Structural Finite Element Program
thicknessmain.c File Reference
#include <unistd.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <pthread.h>
#include "CalculiX.h"
Include dependency graph for thicknessmain.c:

Go to the source code of this file.

Functions

void thicknessmain (double *co, double *dgdx, ITG *nobject, ITG *nk, ITG *nodedesi, ITG *ndesi, char *objectset, ITG *ipkon, ITG *kon, char *lakon, char *set, ITG *nset, ITG *istartset, ITG *iendset, ITG *ialset, ITG *iobject, ITG *nodedesiinv, double *dgdxglob)
 
void * thicknessmt (ITG *i)
 

Variables

static char * objectset1
 
static ITGnobject1
 
static ITGnodedesiboun1
 
static ITG ndesiboun1
 
static ITGnx1
 
static ITGny1
 
static ITGnz1
 
static ITG num_cpus
 
static ITG ifree1
 
static ITGiobject1
 
static ITGndesi1
 
static ITGnk1
 
static double * dgdx1
 
static double * xo1
 
static double * yo1
 
static double * zo1
 
static double * x1
 
static double * yy1
 
static double * z1
 
static double * co1
 
static double * dgdxglob1
 

Function Documentation

◆ thicknessmain()

void thicknessmain ( double *  co,
double *  dgdx,
ITG nobject,
ITG nk,
ITG nodedesi,
ITG ndesi,
char *  objectset,
ITG ipkon,
ITG kon,
char *  lakon,
char *  set,
ITG nset,
ITG istartset,
ITG iendset,
ITG ialset,
ITG iobject,
ITG nodedesiinv,
double *  dgdxglob 
)
54  {
55 
56  /* calculation of distance between nodes */
57 
58  ITG *nx=NULL,*ny=NULL,*nz=NULL,ifree,i,*ithread=NULL,ndesiboun,
59  *nodedesiboun=NULL;
60 
61  double *xo=NULL,*yo=NULL,*zo=NULL,*x=NULL,*y=NULL,*z=NULL;
62 
63  /* prepare for near3d */
64 
65  NNEW(xo,double,*nk);
66  NNEW(yo,double,*nk);
67  NNEW(zo,double,*nk);
68  NNEW(x,double,*nk);
69  NNEW(y,double,*nk);
70  NNEW(z,double,*nk);
71  NNEW(nx,ITG,*nk);
72  NNEW(ny,ITG,*nk);
73  NNEW(nz,ITG,*nk);
74  NNEW(nodedesiboun,ITG,*ndesi);
75 
76  FORTRAN(prethickness,(co,xo,yo,zo,x,y,z,nx,ny,nz,&ifree,nodedesiinv,
77  &ndesiboun,nodedesiboun,set,nset,objectset,
78  iobject,istartset,iendset,ialset));
79 
80  RENEW(nodedesiboun,ITG,ndesiboun);
81 
82  /* variables for multithreading procedure */
83 
84  ITG sys_cpus;
85  char *env,*envloc,*envsys;
86 
87  num_cpus = 0;
88  sys_cpus=0;
89 
90  /* explicit user declaration prevails */
91 
92  envsys=getenv("NUMBER_OF_CPUS");
93  if(envsys){
94  sys_cpus=atoi(envsys);
95  if(sys_cpus<0) sys_cpus=0;
96  }
97 
98  /* automatic detection of available number of processors */
99 
100  if(sys_cpus==0){
101  sys_cpus = getSystemCPUs();
102  if(sys_cpus<1) sys_cpus=1;
103  }
104 
105  /* local declaration prevails, if strictly positive */
106 
107  envloc = getenv("CCX_NPROC_FILTER");
108  if(envloc){
109  num_cpus=atoi(envloc);
110  if(num_cpus<0){
111  num_cpus=0;
112  }else if(num_cpus>sys_cpus){
113  num_cpus=sys_cpus;
114  }
115 
116  }
117 
118  /* else global declaration, if any, applies */
119 
120  env = getenv("OMP_NUM_THREADS");
121  if(num_cpus==0){
122  if (env)
123  num_cpus = atoi(env);
124  if (num_cpus < 1) {
125  num_cpus=1;
126  }else if(num_cpus>sys_cpus){
127  num_cpus=sys_cpus;
128  }
129  }
130 
131  /* check that the number of cpus does not supercede the number
132  of design variables in nodedesiboun */
133 
134  if(ndesiboun<num_cpus) num_cpus=ndesiboun;
135 
136  pthread_t tid[num_cpus];
137 
138  dgdx1=dgdx;nobject1=nobject;nodedesiboun1=nodedesiboun;
139  ndesiboun1=ndesiboun;objectset1=objectset;xo1=xo;yo1=yo;zo1=zo;
140  x1=x;yy1=y;z1=z;nx1=nx;ny1=ny;nz1=nz;ifree1=ifree;co1=co;
141  iobject1=iobject;ndesi1=ndesi;dgdxglob1=dgdxglob;nk1=nk;
142 
143  /* assessment of actual wallthickness */
144  /* create threads and wait */
145 
146  NNEW(ithread,ITG,num_cpus);
147  for(i=0; i<num_cpus; i++) {
148  ithread[i]=i;
149  pthread_create(&tid[i], NULL, (void *)thicknessmt, (void *)&ithread[i]);
150  }
151  for(i=0; i<num_cpus; i++) pthread_join(tid[i], NULL);
152 
153  SFREE(xo);SFREE(yo);SFREE(zo);
154  SFREE(x);SFREE(y);SFREE(z);SFREE(nx);SFREE(ny);SFREE(nz);
155  SFREE(ithread);SFREE(nodedesiboun);
156 
157  return;
158 
159 }
int pthread_create(pthread_t *thread_id, const pthread_attr_t *attributes, void *(*thread_function)(void *), void *arguments)
static ITG * iobject1
Definition: thicknessmain.c:39
static double * x1
Definition: thicknessmain.c:47
static ITG * nk1
Definition: thicknessmain.c:39
void FORTRAN(actideacti,(char *set, ITG *nset, ITG *istartset, ITG *iendset, ITG *ialset, char *objectset, ITG *ipkon, ITG *ibject, ITG *ne))
static double * co1
Definition: thicknessmain.c:47
ITG getSystemCPUs()
Definition: getSystemCPUs.c:40
void * thicknessmt(ITG *i)
Definition: thicknessmain.c:163
static double * xo1
Definition: thicknessmain.c:47
static ITG * nobject1
Definition: thicknessmain.c:39
static ITG * nz1
Definition: thicknessmain.c:39
static double * yo1
Definition: thicknessmain.c:47
#define RENEW(a, b, c)
Definition: CalculiX.h:40
static char * objectset1
Definition: thicknessmain.c:37
#define SFREE(a)
Definition: CalculiX.h:41
static ITG * nx1
Definition: thicknessmain.c:39
static double * yy1
Definition: thicknessmain.c:47
static ITG * nodedesiboun1
Definition: thicknessmain.c:39
static double * dgdx1
Definition: thicknessmain.c:47
static double * dgdxglob1
Definition: thicknessmain.c:47
static double * z1
Definition: thicknessmain.c:47
int pthread_join(pthread_t thread, void **status_ptr)
static double * zo1
Definition: thicknessmain.c:47
static ITG ndesiboun1
Definition: thicknessmain.c:39
static ITG num_cpus
Definition: thicknessmain.c:39
#define ITG
Definition: CalculiX.h:51
static ITG * ny1
Definition: thicknessmain.c:39
subroutine prethickness(co, xo, yo, zo, x, y, z, nx, ny, nz, ifree, nodedesiinv, ndesiboun, nodedesiboun, set, nset, objectset, iobject, istartset, iendset, ialset)
Definition: prethickness.f:22
#define NNEW(a, b, c)
Definition: CalculiX.h:39
static ITG ifree1
Definition: thicknessmain.c:39
static ITG * ndesi1
Definition: thicknessmain.c:39

◆ thicknessmt()

void* thicknessmt ( ITG i)
163  {
164 
165  ITG indexr,ndesia,ndesib,ndesidelta;
166 
167  indexr=*i*ifree1;
168 
169  ndesidelta=(ITG)ceil(ndesiboun1/(double)num_cpus);
170  ndesia=*i*ndesidelta+1;
171  ndesib=(*i+1)*ndesidelta;
172  if(ndesib>ndesiboun1) ndesib=ndesiboun1;
173 
174  //printf("indexr=%" ITGFORMAT","ndesia=%" ITGFORMAT",ndesib=%" ITGFORMAT"\n",indexr,ndesia,ndesib);
175 
177  xo1,yo1,zo1,x1,yy1,z1,nx1,ny1,nz1,co1,&ifree1,
178  &ndesia,&ndesib,iobject1,ndesi1,dgdxglob1,nk1));
179 
180  return NULL;
181 }
static ITG * iobject1
Definition: thicknessmain.c:39
static double * x1
Definition: thicknessmain.c:47
static ITG * nk1
Definition: thicknessmain.c:39
void FORTRAN(actideacti,(char *set, ITG *nset, ITG *istartset, ITG *iendset, ITG *ialset, char *objectset, ITG *ipkon, ITG *ibject, ITG *ne))
static double * co1
Definition: thicknessmain.c:47
static double * xo1
Definition: thicknessmain.c:47
static ITG * nobject1
Definition: thicknessmain.c:39
static ITG * nz1
Definition: thicknessmain.c:39
static double * yo1
Definition: thicknessmain.c:47
static char * objectset1
Definition: thicknessmain.c:37
static ITG * nx1
Definition: thicknessmain.c:39
static double * yy1
Definition: thicknessmain.c:47
static ITG * nodedesiboun1
Definition: thicknessmain.c:39
static double * dgdx1
Definition: thicknessmain.c:47
static double * dgdxglob1
Definition: thicknessmain.c:47
static double * z1
Definition: thicknessmain.c:47
static double * zo1
Definition: thicknessmain.c:47
static ITG ndesiboun1
Definition: thicknessmain.c:39
static ITG num_cpus
Definition: thicknessmain.c:39
#define ITG
Definition: CalculiX.h:51
static ITG * ny1
Definition: thicknessmain.c:39
subroutine thickness(dgdx, nobject, nodedesiboun, ndesiboun, objectset, xo, yo, zo, x, y, z, nx, ny, nz, co, ifree, ndesia, ndesib, iobject, ndesi, dgdxglob, nk)
Definition: thickness.f:22
static ITG ifree1
Definition: thicknessmain.c:39
static ITG * ndesi1
Definition: thicknessmain.c:39

Variable Documentation

◆ co1

double * co1
static

◆ dgdx1

double* dgdx1
static

◆ dgdxglob1

double * dgdxglob1
static

◆ ifree1

ITG ifree1
static

◆ iobject1

ITG * iobject1
static

◆ ndesi1

ITG * ndesi1
static

◆ ndesiboun1

ITG ndesiboun1
static

◆ nk1

ITG * nk1
static

◆ nobject1

ITG* nobject1
static

◆ nodedesiboun1

ITG * nodedesiboun1
static

◆ num_cpus

ITG num_cpus
static

◆ nx1

ITG * nx1
static

◆ ny1

ITG * ny1
static

◆ nz1

ITG * nz1
static

◆ objectset1

char* objectset1
static

◆ x1

double * x1
static

◆ xo1

double * xo1
static

◆ yo1

double * yo1
static

◆ yy1

double * yy1
static

◆ z1

double * z1
static

◆ zo1

double * zo1
static
Hosted by OpenAircraft.com, (Michigan UAV, LLC)