1 /*     CalculiX - A 3-dimensional finite element program                 */
2 /*              Copyright (C) 1998-2021 Guido Dhondt                          */
3 
4 /*     This program is free software; you can redistribute it and/or     */
5 /*     modify it under the terms of the GNU General Public License as    */
6 /*     published by the Free Software Foundation(version 2);    */
7 /*                    */
8 
9 /*     This program is distributed in the hope that it will be useful,   */
10 /*     but WITHOUT ANY WARRANTY; without even the implied warranty of    */
11 /*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the      */
12 /*     GNU General Public License for more details.                      */
13 
14 /*     You should have received a copy of the GNU General Public License */
15 /*     along with this program; if not, write to the Free Software       */
16 /*     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.         */
17 
18 #include <unistd.h>
19 #include <stdio.h>
20 #include <math.h>
21 #include <stdlib.h>
22 #include <pthread.h>
23 #include "CalculiX.h"
24 
25 static ITG *nface1,*ielfa1,*icyclic1,*ifatie1,*nef1,*num_cpus1,*ncfd1;
26 
27 static double *xrlfa1,*adv1,*advfa1,*hfa1,*c1,*vel1,*volume1;
28 
extrapolate_d_v_simplemain(ITG * nface,ITG * ielfa,double * xrlfa,double * adv,double * advfa,double * hfa,ITG * icyclic,double * c,ITG * ifatie,double * vel,ITG * nef,double * volume,ITG * num_cpus,ITG * ncfd)29 void extrapolate_d_v_simplemain(ITG *nface,ITG *ielfa,double *xrlfa,double *adv,
30 				double *advfa,double *hfa,ITG *icyclic,
31 				double *c,ITG *ifatie,double *vel,ITG *nef,
32 				double *volume,ITG *num_cpus,ITG *ncfd){
33 
34     ITG i;
35 
36     /* variables for multithreading procedure */
37 
38     ITG *ithread=NULL;;
39 
40     pthread_t tid[*num_cpus];
41 
42     /* calculation of the density at the cell centers */
43 
44     ielfa1=ielfa,xrlfa1=xrlfa;adv1=adv;advfa1=advfa;hfa1=hfa;
45     icyclic1=icyclic;c1=c;ifatie1=ifatie;vel1=vel;nef1=nef;
46     volume1=volume;num_cpus1=num_cpus;nface1=nface;ncfd1=ncfd;
47 
48     /* create threads and wait */
49 
50     NNEW(ithread,ITG,*num_cpus);
51     for(i=0; i<*num_cpus; i++)  {
52 	ithread[i]=i;
53 	pthread_create(&tid[i], NULL, (void *)extrapolate_d_v_simple1mt, (void *)&ithread[i]);
54     }
55     for(i=0; i<*num_cpus; i++)  pthread_join(tid[i], NULL);
56 
57     SFREE(ithread);
58 
59   return;
60 
61 }
62 
63 /* subroutine for multithreading of calcgammav1 */
64 
extrapolate_d_v_simple1mt(ITG * i)65 void *extrapolate_d_v_simple1mt(ITG *i){
66 
67     ITG nfacea,nfaceb,nfacedelta;
68 
69     nfacedelta=(ITG)floor(*nface1/(double)(*num_cpus1));
70     nfacea=*i*nfacedelta+1;
71     nfaceb=(*i+1)*nfacedelta;
72     if((*i==*num_cpus1-1)&&(nfaceb<*nface1)) nfaceb=*nface1;
73 
74     FORTRAN(extrapolate_d_v_simple,(ielfa1,xrlfa1,adv1,advfa1,hfa1,
75 				    icyclic1,c1,ifatie1,vel1,nef1,volume1,
76          			    &nfacea,&nfaceb,ncfd1));
77 
78     return NULL;
79 }
80