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

Go to the source code of this file.

## Macros

#define min(a, b)   ((a) <= (b) ? (a) : (b))

#define max(a, b)   ((a) >= (b) ? (a) : (b))

## Functions

void frdselect (double *field1, double *field2, ITG *iset, ITG *nkcoords, ITG *inum, char *m1, ITG *istartset, ITG *iendset, ITG *ialset, ITG *ngraph, ITG *ncomp, ITG *ifield, ITG *icomp, ITG *nfield, ITG *iselect, char *m2, FILE *f1, char *output, char *m3)

## Macro Definition Documentation

 #define max ( a, b ) ((a) >= (b) ? (a) : (b))

Definition at line 25 of file frdselect.c.

 #define min ( a, b ) ((a) <= (b) ? (a) : (b))

Definition at line 24 of file frdselect.c.

## Function Documentation

 void frdselect ( double * field1, double * field2, ITG * iset, ITG * nkcoords, ITG * inum, char * m1, ITG * istartset, ITG * iendset, ITG * ialset, ITG * ngraph, ITG * ncomp, ITG * ifield, ITG * icomp, ITG * nfield, ITG * iselect, char * m2, FILE * f1, char * output, char * m3 )

Definition at line 27 of file frdselect.c.

30  {
31
32  /* storing scalars, components of vectors and tensors without additional
33  transformations */
34
35  /* number of components in field1: nfield[0]
36  number of components in field2: nfield[1]
37
38  number of entities to store: ncomp
39  for each entity i, 0<=i<ncomp:
40  - ifield[i]: 1=field1,2=field2
41  - icomp[i]: component: 0...,(nfield[0]-1 or nfield[1]-1) */
42
43  ITG i,j,k,l,m,n,nksegment;
44
45  int iw;
46
47  float ifl;
48
49  if(*iset==0){
50  for(i=0;i<*nkcoords;i++){
51
52  /* check whether output is requested for solid nodes or
53  network nodes */
54
55  if(*iselect==1){
56  if(inum[i]<=0) continue;
57  }else if(*iselect==-1){
58  if(inum[i]>=0) continue;
59  }else{
60  if(inum[i]==0) continue;
61  }
62
63  /* storing the entities */
64
65  for(n=1;n<=(ITG)((*ncomp+5)/6);n++){
66  if(n==1){
67  if(strcmp1(output,"asc")==0){
68  fprintf(f1,"%3s%10" ITGFORMAT "",m1,i+1);
69  }else{
70  iw=(int)(i+1);fwrite(&iw,sizeof(int),1,f1);
71  }
72  for(j=0;j<min(6,*ncomp);j++){
73  if(ifield[j]==1){
74  if(strcmp1(output,"asc")==0){
75  fprintf(f1,"%12.5E",(float)field1[i*nfield[0]+icomp[j]]);
76  }else{
77  ifl=(float)field1[i*nfield[0]+icomp[j]];
78  fwrite(&ifl,sizeof(float),1,f1);
79  }
80  }else{
81  if(strcmp1(output,"asc")==0){
82  fprintf(f1,"%12.5E",(float)field2[i*nfield[1]+icomp[j]]);
83  }else{
84  ifl=(float)field2[i*nfield[1]+icomp[j]];
85  fwrite(&ifl,sizeof(float),1,f1);
86  }
87  }
88  }
89  if(strcmp1(output,"asc")==0)fprintf(f1,"\n");
90  }else{
91  if(strcmp1(output,"asc")==0)fprintf(f1,"%3s ",m2);
92  for(j=(n-1)*6;j<min(n*6,*ncomp);j++){
93  if(ifield[j]==1){
94  if(strcmp1(output,"asc")==0){
95  fprintf(f1,"%12.5E",(float)field1[i*nfield[0]+icomp[j]]);
96  }else{
97  ifl=(float)field1[i*nfield[0]+icomp[j]];
98  fwrite(&ifl,sizeof(float),1,f1);
99  }
100  }else{
101  if(strcmp1(output,"asc")==0){
102  fprintf(f1,"%12.5E",(float)field2[i*nfield[1]+icomp[j]]);
103  }else{
104  ifl=(float)field2[i*nfield[1]+icomp[j]];
105  fwrite(&ifl,sizeof(float),1,f1);
106  }
107  }
108  }
109  if(strcmp1(output,"asc")==0)fprintf(f1,"\n");
110  }
111  }
112
113  }
114  }else{
115  nksegment=(*nkcoords)/(*ngraph);
116  for(k=istartset[*iset-1]-1;k<iendset[*iset-1];k++){
117  if(ialset[k]>0){
118  for(l=0;l<*ngraph;l++){
119  i=ialset[k]+l*nksegment-1;
120
121  /* check whether output is requested for solid nodes or
122  network nodes */
123
124  if(*iselect==1){
125  if(inum[i]<=0) continue;
126  }else if(*iselect==-1){
127  if(inum[i]>=0) continue;
128  }else{
129  if(inum[i]==0) continue;
130  }
131
132  /* storing the entities */
133
134  for(n=1;n<=(ITG)((*ncomp+5)/6);n++){
135  if(n==1){
136  if(strcmp1(output,"asc")==0){
137  fprintf(f1,"%3s%10" ITGFORMAT "",m1,i+1);
138  }else{
139  iw=(int)(i+1);fwrite(&iw,sizeof(int),1,f1);
140  }
141  for(j=0;j<min(6,*ncomp);j++){
142  if(ifield[j]==1){
143  if(strcmp1(output,"asc")==0){
144  fprintf(f1,"%12.5E",(float)field1[i*nfield[0]+icomp[j]]);
145  }else{
146  ifl=(float)field1[i*nfield[0]+icomp[j]];
147  fwrite(&ifl,sizeof(float),1,f1);
148  }
149  }else{
150  if(strcmp1(output,"asc")==0){
151  fprintf(f1,"%12.5E",(float)field2[i*nfield[1]+icomp[j]]);
152  }else{
153  ifl=(float)field2[i*nfield[1]+icomp[j]];
154  fwrite(&ifl,sizeof(float),1,f1);
155  }
156  }
157  }
158  if(strcmp1(output,"asc")==0)fprintf(f1,"\n");
159  }else{
160  if(strcmp1(output,"asc")==0)fprintf(f1,"%3s ",m2);
161  for(j=(n-1)*6;j<min(n*6,*ncomp);j++){
162  if(ifield[j]==1){
163  if(strcmp1(output,"asc")==0){
164  fprintf(f1,"%12.5E",(float)field1[i*nfield[0]+j]);
165  }else{
166  ifl=(float)field1[i*nfield[0]+icomp[j]];
167  fwrite(&ifl,sizeof(float),1,f1);
168  }
169  }else{
170  if(strcmp1(output,"asc")==0){
171  fprintf(f1,"%12.5E",(float)field2[i*nfield[1]+j]);
172  }else{
173  ifl=(float)field2[i*nfield[1]+icomp[j]];
174  fwrite(&ifl,sizeof(float),1,f1);
175  }
176  }
177  }
178  if(strcmp1(output,"asc")==0)fprintf(f1,"\n");
179  }
180  }
181
182  }
183  }else{
184  l=ialset[k-2];
185  do{
186  l-=ialset[k];
187  if(l>=ialset[k-1]) break;
188  for(m=0;m<*ngraph;m++){
189  i=l+m*nksegment-1;
190
191  /* check whether output is requested for solid nodes or
192  network nodes */
193
194  if(*iselect==1){
195  if(inum[i]<=0) continue;
196  }else if(*iselect==-1){
197  if(inum[i]>=0) continue;
198  }else{
199  if(inum[i]==0) continue;
200  }
201
202  /* storing the entities */
203
204  for(n=1;n<=(ITG)((*ncomp+5)/6);n++){
205  if(n==1){
206  if(strcmp1(output,"asc")==0){
207  fprintf(f1,"%3s%10" ITGFORMAT "",m1,i+1);
208  }else{
209  iw=(int)(i+1);fwrite(&iw,sizeof(int),1,f1);
210  }
211  for(j=0;j<min(6,*ncomp);j++){
212  if(ifield[j]==1){
213  if(strcmp1(output,"asc")==0){
214  fprintf(f1,"%12.5E",(float)field1[i*nfield[0]+icomp[j]]);
215  }else{
216  ifl=(float)field1[i*nfield[0]+icomp[j]];
217  fwrite(&ifl,sizeof(float),1,f1);
218  }
219  }else{
220  if(strcmp1(output,"asc")==0){
221  fprintf(f1,"%12.5E",(float)field2[i*nfield[1]+icomp[j]]);
222  }else{
223  ifl=(float)field2[i*nfield[1]+icomp[j]];
224  fwrite(&ifl,sizeof(float),1,f1);
225  }
226  }
227  }
228  if(strcmp1(output,"asc")==0)fprintf(f1,"\n");
229  }else{
230  if(strcmp1(output,"asc")==0)fprintf(f1,"%3s ",m2);
231  for(j=(n-1)*6;j<min(n*6,*ncomp);j++){
232  if(ifield[j]==1){
233  if(strcmp1(output,"asc")==0){
234  fprintf(f1,"%12.5E",(float)field1[i*nfield[0]+j]);
235  }else{
236  ifl=(float)field1[i*nfield[0]+icomp[j]];
237  fwrite(&ifl,sizeof(float),1,f1);
238  }
239  }else{
240  if(strcmp1(output,"asc")==0){
241  fprintf(f1,"%12.5E",(float)field2[i*nfield[1]+j]);
242  }else{
243  ifl=(float)field2[i*nfield[1]+icomp[j]];
244  fwrite(&ifl,sizeof(float),1,f1);
245  }
246  }
247  }
248  if(strcmp1(output,"asc")==0)fprintf(f1,"\n");
249  }
250  }
251
252  }
253  }while(1);
254  }
255  }
256  }
257
258  if(strcmp1(output,"asc")==0)fprintf(f1,"%3s\n",m3);
259
260  return;
261
262 }
#define ITGFORMAT
Definition: CalculiX.h:52
ITG strcmp1(const char *s1, const char *s2)
Definition: strcmp1.c:24
#define min(a, b)
Definition: frdselect.c:24
#define ITG
Definition: CalculiX.h:51
Hosted by OpenAircraft.com, (Michigan UAV, LLC)