32 if ((*body) != NULL) {
34 fprintf(stderr,
"Error in IBReadBodySTL(): pointer to immersed body not NULL.\n");
44 in = fopen(filename,
"r");
46 fprintf(stderr,
"Error in IBReadBodySTL(): file %s not found or cannot be opened.\n",
55 ierr = fscanf(in,
"%s",word);
56 if (!strcmp(word,
"solid")) {
58 while (strcmp(word,
"endsolid")) {
59 ierr = fscanf(in,
"%s",word);
60 if (!strcmp(word,
"facet")) nfacets++;
67 (*body)->nfacets = nfacets;
71 in = fopen(filename,
"r");
72 ierr = fscanf(in,
"%s",word);
74 while (strcmp(word,
"endsolid")) {
76 ierr = fscanf(in,
"%s",word);
77 if (!strcmp(word,
"facet")) {
78 ierr = fscanf(in,
"%s",word);
79 if (strcmp(word,
"normal")) {
80 fprintf(stderr,
"Error in IBReadBodySTL(): Illegal keyword read in %s.\n",filename);
82 ierr = fscanf(in,
"%lf",&t1);
83 ierr = fscanf(in,
"%lf",&t2);
84 ierr = fscanf(in,
"%lf",&t3);
85 (*body)->surface[n].nx = t1;
86 (*body)->surface[n].ny = t2;
87 (*body)->surface[n].nz = t3;
89 ierr = fscanf(in,
"%s",word);
90 if (strcmp(word,
"outer")) {
91 fprintf(stderr,
"Error in IBReadBodySTL(): Illegal keyword read in %s.\n",filename);
94 ierr = fscanf(in,
"%s",word);
95 if (strcmp(word,
"loop")) {
96 fprintf(stderr,
"Error in IBReadBodySTL(): Illegal keyword read in %s.\n",filename);
99 ierr = fscanf(in,
"%s",word);
100 if (strcmp(word,
"vertex")) {
101 fprintf(stderr,
"Error in IBReadBodySTL(): Illegal keyword read in %s.\n",filename);
104 ierr = fscanf(in,
"%lf",&t1);
105 ierr = fscanf(in,
"%lf",&t2);
106 ierr = fscanf(in,
"%lf",&t3);
107 (*body)->surface[n].x1 = t1;
108 (*body)->surface[n].y1 = t2;
109 (*body)->surface[n].z1 = t3;
111 ierr = fscanf(in,
"%s",word);
112 if (strcmp(word,
"vertex")) {
113 fprintf(stderr,
"Error in IBReadBodySTL(): Illegal keyword read in %s.\n",filename);
116 ierr = fscanf(in,
"%lf",&t1);
117 ierr = fscanf(in,
"%lf",&t2);
118 ierr = fscanf(in,
"%lf",&t3);
119 (*body)->surface[n].x2 = t1;
120 (*body)->surface[n].y2 = t2;
121 (*body)->surface[n].z2 = t3;
123 ierr = fscanf(in,
"%s",word);
124 if (strcmp(word,
"vertex")) {
125 fprintf(stderr,
"Error in IBReadBodySTL(): Illegal keyword read in %s.\n",filename);
128 ierr = fscanf(in,
"%lf",&t1);
129 ierr = fscanf(in,
"%lf",&t2);
130 ierr = fscanf(in,
"%lf",&t3);
131 (*body)->surface[n].x3 = t1;
132 (*body)->surface[n].y3 = t2;
133 (*body)->surface[n].z3 = t3;
143 fprintf(stderr,
"Error in IBReadBodySTL(): Inconsistency in number of facets read.\n");
144 free((*body)->surface);
149 fprintf(stderr,
"Error in IBReadBodySTL(): nfacets = 0!!\n");
157 if ((*stat))
return(0);
161 if (!mpi->
rank) nfacets = (*body)->nfacets;
166 (*body)->nfacets = nfacets;
171 double *buffer = (
double*) calloc (bufdim*nfacets,
sizeof(
double));
173 for (n=0; n<nfacets; n++) {
174 buffer[n*bufdim+ 0] = (*body)->surface[n].x1;
175 buffer[n*bufdim+ 1] = (*body)->surface[n].x2;
176 buffer[n*bufdim+ 2] = (*body)->surface[n].x3;
177 buffer[n*bufdim+ 3] = (*body)->surface[n].y1;
178 buffer[n*bufdim+ 4] = (*body)->surface[n].y2;
179 buffer[n*bufdim+ 5] = (*body)->surface[n].y3;
180 buffer[n*bufdim+ 6] = (*body)->surface[n].z1;
181 buffer[n*bufdim+ 7] = (*body)->surface[n].z2;
182 buffer[n*bufdim+ 8] = (*body)->surface[n].z3;
183 buffer[n*bufdim+ 9] = (*body)->surface[n].nx;
184 buffer[n*bufdim+10] = (*body)->surface[n].ny;
185 buffer[n*bufdim+11] = (*body)->surface[n].nz;
190 for (n=0; n<nfacets; n++) {
191 (*body)->surface[n].x1 = buffer[n*bufdim+ 0];
192 (*body)->surface[n].x2 = buffer[n*bufdim+ 1];
193 (*body)->surface[n].x3 = buffer[n*bufdim+ 2];
194 (*body)->surface[n].y1 = buffer[n*bufdim+ 3];
195 (*body)->surface[n].y2 = buffer[n*bufdim+ 4];
196 (*body)->surface[n].y3 = buffer[n*bufdim+ 5];
197 (*body)->surface[n].z1 = buffer[n*bufdim+ 6];
198 (*body)->surface[n].z2 = buffer[n*bufdim+ 7];
199 (*body)->surface[n].z3 = buffer[n*bufdim+ 8];
200 (*body)->surface[n].nx = buffer[n*bufdim+ 9];
201 (*body)->surface[n].ny = buffer[n*bufdim+10];
202 (*body)->surface[n].nz = buffer[n*bufdim+11];
Structure defining a facet.
Structure defining a body.
MPI related function definitions.
int MPIBroadcast_integer(int *, int, int, void *)
Some basic definitions and macros.
int MPIBroadcast_double(double *, int, int, void *)
#define _MAX_STRING_SIZE_
Structures and function definitions for immersed boundaries.
int IBReadBodySTL(Body3D **body, char *filename, void *m, int *stat)
Structure of MPI-related variables.