1 /*
2     copyright (c) 1998  dennis roddeman
3     email: dennis.roddeman@feat.nl
4 
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9 
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14 
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software Foundation
17     59 Temple Place, Suite 330, Boston, MA, 02111-1307, USA
18 */
19 
20 #include "tochnog.h"
21 
print_giddata(long int task)22 void print_giddata( long int task )
23 
24 {
25   long int imat=0, idat=0, ndat=0, igen=0, intv=0;
26   char defaul[MCHAR];
27 
28   ofstream outprb( "tochnog.prb" );
29   ofstream outind( "tochnog.ind" );
30   ofstream outmat( "tochnog.mat" );
31   ofstream outfirstbas( "tochnog.firstbas" );
32   ofstream outcmd( "tochnog.cmd" );
33 
34     // bas file
35   outfirstbas << "echo *GenData(1)\n";
36   outfirstbas << "number_of_space_dimensions *ndime\n";
37 
38   task = labs(task);
39 
40     // problem data and bas file
41   if      ( task==ALL )
42     outprb << "21\n";
43   else if ( task==GROUND )
44     outprb << "6\n";
45   else if ( task==MAXFRE )
46     outprb << "4\n";
47   else if ( task==MAXTIM )
48     outprb << "4\n";
49   else if ( task==STRESS )
50     outprb << "18\n";
51   else if ( task==THERMAL )
52     outprb << "5\n";
53   else if ( task==WAVE )
54     outprb << "6\n";
55   outprb << "echo#CB#(-yes,-no) -yes\n";
56   igen = 1;
57   outprb << "number_of_space_dimensions#CB#(1,2,3) 2\n";
58   igen++;
59   if ( task!=MAXFRE && task!=MAXTIM ) {
60     outprb << "derivatives#CB#(Off,On) Off\n";
61     igen++;
62     outfirstbas << "*if(strcmp(GenData(" << igen << "),"
63       << '"' << "Off" << '"' << ")!=0)" << "\n";
64     outfirstbas << "derivatives" << "\n";
65     outfirstbas << "*endif\n";
66   }
67   if ( condif_temperature ) {
68     if ( task==THERMAL )
69       strcpy( defaul, "On" );
70     else
71       strcpy( defaul, "Off" );
72     outprb << "condif_temperature#CB#(Off,On) ";
73     outprb << defaul << "\n";
74     igen++;
75     outfirstbas << "*if(strcmp(GenData(" << igen << "),"
76       << '"' << "Off" << '"' << ")!=0)" << "\n";
77     outfirstbas << "condif_temperature" << "\n";
78     outfirstbas << "*endif\n";
79   }
80   if ( groundflow_pressure ) {
81     if ( task==GROUND )
82       strcpy( defaul, "On" );
83     else
84       strcpy( defaul, "Off" );
85     outprb << "groundflow_velocity#CB#(Off,On) ";
86     outprb << defaul << "\n";
87     igen++;
88     outfirstbas << "*if(strcmp(GenData(" << igen << "),"
89       << '"' << "Off" << '"' << ")!=0)" << "\n";
90     outfirstbas << "groundflow_velocity" << "\n";
91     outfirstbas << "*endif\n";
92     outprb << "groundflow_pressure#CB#(Off,On) ";
93     outprb << defaul << "\n";
94     igen++;
95     outfirstbas << "*if(strcmp(GenData(" << igen << "),"
96       << '"' << "Off" << '"' << ")!=0)" << "\n";
97     outfirstbas << "groundflow_pressure" << "\n";
98     outfirstbas << "*endif\n";
99   }
100   if ( materi_velocity ) {
101     if ( task==STRESS )
102       strcpy( defaul, "On" );
103     else
104       strcpy( defaul, "Off" );
105     outprb << "materi_damage#CB#(Off,On) Off\n";
106     igen++;
107     outfirstbas << "*if(strcmp(GenData(" << igen << "),"
108       << '"' << "Off" << '"' << ")!=0)" << "\n";
109     outfirstbas << "materi_damage" << "\n";
110     outfirstbas << "*endif\n";
111     outprb << "materi_density#CB#(Off,On) Off\n";
112     igen++;
113     outfirstbas << "*if(strcmp(GenData(" << igen << "),"
114       << '"' << "Off" << '"' << ")!=0)" << "\n";
115     outfirstbas << "materi_density" << "\n";
116     outfirstbas << "*endif\n";
117     outprb << "materi_displacement#CB#(Off,On) Off\n";
118     igen++;
119     outfirstbas << "*if(strcmp(GenData(" << igen << "),"
120       << '"' << "Off" << '"' << ")!=0)" << "\n";
121     outfirstbas << "materi_displacement" << "\n";
122     outfirstbas << "*endif\n";
123     outprb << "materi_history_variables#CB#(0,1,2,3,4,5,6,7,8,9,10,11,12) 0\n";
124     igen++;
125     outfirstbas << "*if(strcmp(GenData(" << igen << "),"
126       << '"' << "0" << '"' << ")!=0)" << "\n";
127     outfirstbas << "materi_history_variables" << "\n";
128     outfirstbas << "*endif\n";
129     outprb << "materi_maxwell_stress#CB#(0,1,2,3,4,5,6,7,8,9,10,11,12) 0\n";
130     igen++;
131     outfirstbas << "*if(strcmp(GenData(" << igen << "),"
132       << '"' << "0" << '"' << ")!=0)" << "\n";
133     outfirstbas << "materi_maxwell_stress" << "\n";
134     outfirstbas << "*endif\n";
135     outprb << "materi_plasti_kappa#CB#(Off,On) Off\n";
136     igen++;
137     outfirstbas << "*if(strcmp(GenData(" << igen << "),"
138       << '"' << "Off" << '"' << ")!=0)" << "\n";
139     outfirstbas << "materi_maxwell_stress" << "\n";
140     outfirstbas << "*endif\n";
141     outprb << "materi_plasti_rho#CB#(Off,On) Off\n";
142     igen++;
143     outfirstbas << "*if(strcmp(GenData(" << igen << "),"
144       << '"' << "Off" << '"' << ")!=0)" << "\n";
145     outfirstbas << "materi_plasti_rho" << "\n";
146     outfirstbas << "*endif\n";
147     outprb << "materi_strain_elasti#CB#(Off,On) Off\n";
148     igen++;
149     outfirstbas << "*if(strcmp(GenData(" << igen << "),"
150       << '"' << "Off" << '"' << ")!=0)" << "\n";
151     outfirstbas << "materi_strain_elasti" << "\n";
152     outfirstbas << "*endif\n";
153     outprb << "materi_strain_plasti#CB#(Off,On) Off\n";
154     igen++;
155     outfirstbas << "*if(strcmp(GenData(" << igen << "),"
156       << '"' << "Off" << '"' << ")!=0)" << "\n";
157     outfirstbas << "materi_strain_plasti" << "\n";
158     outfirstbas << "*endif\n";
159     outprb << "materi_strain_total#CB#(Off,On) ";
160     outprb << defaul << "\n";
161     igen++;
162     outfirstbas << "*if(strcmp(GenData(" << igen << "),"
163       << '"' << "Off" << '"' << ")!=0)" << "\n";
164     outfirstbas << "materi_strain_total" << "\n";
165     outfirstbas << "*endif\n";
166     outprb << "materi_stress#CB#(Off,On) ";
167     outprb << defaul << "\n";
168     igen++;
169     outfirstbas << "*if(strcmp(GenData(" << igen << "),"
170       << '"' << "Off" << '"' << ")!=0)" << "\n";
171     outfirstbas << "materi_stress" << "\n";
172     outfirstbas << "*endif\n";
173     outprb << "materi_velocity#CB#(Off,On) ";
174     outprb << defaul << "\n";
175     igen++;
176     outfirstbas << "*if(strcmp(GenData(" << igen << "),"
177       << '"' << "Off" << '"' << ")!=0)" << "\n";
178     outfirstbas << "materi_velocity" << "\n";
179     outfirstbas << "*endif\n";
180     outprb << "materi_void_fraction#CB#(Off,On) Off\n";
181     igen++;
182     outfirstbas << "*if(strcmp(GenData(" << igen << "),"
183       << '"' << "Off" << '"' << ")!=0)" << "\n";
184     outfirstbas << "materi_void_fraction" << "\n";
185     outfirstbas << "*endif\n";
186     outprb << "materi_work#CB#(Off,On) Off\n";
187     igen++;
188     outfirstbas << "*if(strcmp(GenData(" << igen << "),"
189       << '"' << "Off" << '"' << ")!=0)" << "\n";
190     outfirstbas << "materi_work" << "\n";
191     outfirstbas << "*endif\n";
192   }
193   if ( maxwell_er ) {
194     if ( task==MAXFRE )
195       strcpy( defaul, "On" );
196     else
197       strcpy( defaul, "Off" );
198     outprb << "maxwell_er#CB#(Off,On) ";
199     outprb << defaul << "\n";
200     igen++;
201     outfirstbas << "*if(strcmp(GenData(" << igen << "),"
202       << '"' << "Off" << '"' << ")!=0)" << "\n";
203     outfirstbas << "maxwell_er" << "\n";
204     outfirstbas << "*endif\n";
205     outprb << "maxwell_ei#CB#(Off,On) ";
206     outprb << defaul << "\n";
207     igen++;
208     outfirstbas << "*if(strcmp(GenData(" << igen << "),"
209       << '"' << "Off" << '"' << ")!=0)" << "\n";
210     outfirstbas << "maxwell_ei" << "\n";
211     outfirstbas << "*endif\n";
212   }
213   if ( maxwell_e ) {
214     if ( task==MAXTIM )
215       strcpy( defaul, "On" );
216     else
217       strcpy( defaul, "Off" );
218     outprb << "maxwell_e#CB#(Off,On) ";
219     outprb << defaul << "\n";
220     igen++;
221     outfirstbas << "*if(strcmp(GenData(" << igen << "),"
222       << '"' << "Off" << '"' << ")!=0)" << "\n";
223     outfirstbas << "maxwell_e" << "\n";
224     outfirstbas << "*endif\n";
225     outprb << "maxwell_fe#CB#(Off,On) ";
226     outprb << defaul << "\n";
227     igen++;
228     outfirstbas << "*if(strcmp(GenData(" << igen << "),"
229       << '"' << "Off" << '"' << ")!=0)" << "\n";
230     outfirstbas << "maxwell_fe" << "\n";
231     outfirstbas << "*endif\n";
232   }
233   if ( wave_scalar ) {
234     if ( task==WAVE )
235       strcpy( defaul, "On" );
236     else
237       strcpy( defaul, "Off" );
238     outprb << "wave_scalar#CB#(Off,On) ";
239     outprb << defaul << "\n";
240     igen++;
241     outfirstbas << "*if(strcmp(GenData(" << igen << "),"
242       << '"' << "Off" << '"' << ")!=0)" << "\n";
243     outfirstbas << "wave_scalar" << "\n";
244     outfirstbas << "*endif\n";
245     outprb << "wave_fscalar#CB#(Off,On) ";
246     outprb << defaul << "\n";
247     igen++;
248     outfirstbas << "*if(strcmp(GenData(" << igen << "),"
249       << '"' << "Off" << '"' << ")!=0)" << "\n";
250     outfirstbas << "wave_fscalar" << "\n";
251     outfirstbas << "*endif\n";
252   }
253   if ( task!=MAXFRE && task!=MAXTIM ) {
254     outprb << "residue#CB#(Off,On) Off\n";
255     igen++;
256     outfirstbas << "*if(strcmp(GenData(" << igen << "),"
257       << '"' << "Off" << '"' << ")!=0)" << "\n";
258     outfirstbas << "residue" << "\n";
259     outfirstbas << "*endif\n";
260   }
261 
262   for ( idat=0; idat<MDAT; idat++ ) {
263     if ( db_partialname( idat, "control" ) && db_external( idat ) &&
264         check( idat, CHECK_USAGE ) ) {
265       ndat++;
266     }
267   }
268   outprb << "1\n";
269   outprb << ndat << "\n";
270   for ( idat=0; idat<MDAT; idat++ ) {
271     if ( db_partialname( idat, "control" ) && db_external( idat ) &&
272         check( idat, CHECK_USAGE ) ) {
273       if      ( idat==CONTROL_TIMESTEP )
274         outprb << db_name(idat) << " 1,1\n";
275       else if ( idat==CONTROL_TIMESTEP_ITERATIONS && task==MAXFRE )
276         outprb << db_name(idat) << " 1\n";
277       else if ( idat==CONTROL_TIMESTEP_ITERATIONS && task==MAXTIM )
278         outprb << db_name(idat) << " 1\n";
279       else if ( idat==CONTROL_TIMESTEP_ITERATIONS && task==THERMAL )
280         outprb << db_name(idat) << " 1\n";
281       else if ( idat==CONTROL_PRINT )
282         outprb << db_name(idat) << " -node_dof\n";
283       else
284         outprb << db_name(idat) << " -\n";
285     }
286   }
287   outfirstbas << "end_initia\n";
288 
289   outfirstbas << "*loop intervals\n";
290   for ( idat=0; idat<MDAT; idat++ ) {
291     if ( db_partialname( idat, "control_" ) && db_external( idat ) &&
292         check( idat, CHECK_USAGE ) ) {
293       intv++;
294       outfirstbas << "*if(strcmp(IntvData(" << intv << "),"
295         << '"' << "-" << '"' << ")!=0)" << "\n";
296       outfirstbas << db_name(idat) << " *LoopVar" << " *IntvData(" << intv << ")" << "\n";
297       outfirstbas << "*endif\n";
298     }
299   }
300   outfirstbas << "*end intervals\n";
301 
302     // material file and bas file
303 
304   outmat << "NUMBER: 1 MATERIAL: GROUP0\n";
305   outfirstbas << "*loop materials\n";
306   outfirstbas << "*Set var material=0\n";
307   outfirstbas << "*Set var condif=0\n";
308   outfirstbas << "*Set var groundflow=0\n";
309   outfirstbas << "*Set var maxwell_frequency=0\n";
310   outfirstbas << "*Set var maxwell_time=0\n";
311   outfirstbas << "*Set var wave=0\n";
312   outfirstbas << "*Set var group=LoopVar-1\n";
313   if ( materi_velocity ) {
314     for ( idat=0; idat<MDAT; idat++ ) {
315       if ( db_partialname( idat, "group_materi" ) && db_external( idat ) ) {
316         imat++;
317         outmat << "QUESTION: " << db_name(idat) << "\n";
318         outmat << "VALUE: -\n";
319         outfirstbas << "*if(strcmp(MatProp(" << imat << "),"
320           << '"' << "-" << '"' << ")!=0)" << "\n";
321         outfirstbas << db_name(idat) << " *group" << " *MatProp(" << imat << ")" << "\n";
322         outfirstbas << "*Set var material=1\n";
323         outfirstbas << "*endif\n";
324       }
325     }
326   }
327   if ( condif_temperature ) {
328     for ( idat=0; idat<MDAT; idat++ ) {
329       if ( db_partialname( idat, "group_condif" ) && db_external( idat ) ) {
330         imat++;
331         outmat << "QUESTION: " << db_name(idat) << "\n";
332         outmat << "VALUE: -\n";
333         outfirstbas << "*if(strcmp(MatProp(" << imat << "),"
334           << '"' << "-" << '"' << ")!=0)" << "\n";
335         outfirstbas << db_name(idat) << " *group" << " *MatProp(" << imat << ")" << "\n";
336         outfirstbas << "*Set var condif=1\n";
337         outfirstbas << "*endif\n";
338       }
339     }
340   }
341   if ( groundflow_pressure ) {
342     for ( idat=0; idat<MDAT; idat++ ) {
343       if ( db_partialname( idat, "group_groundflow" ) && db_external( idat ) ) {
344         imat++;
345         outmat << "QUESTION: " << db_name(idat) << "\n";
346         outmat << "VALUE: -\n";
347         outfirstbas << "*if(strcmp(MatProp(" << imat << "),"
348           << '"' << "-" << '"' << ")!=0)" << "\n";
349         outfirstbas << db_name(idat) << " *group" << " *MatProp(" << imat << ")" << "\n";
350         outfirstbas << "*Set var groundflow=1\n";
351         outfirstbas << "*endif\n";
352       }
353     }
354   }
355   if ( maxwell_er ) {
356     for ( idat=0; idat<MDAT; idat++ ) {
357       if ( db_partialname( idat, "group_maxwell_frequency" ) && db_external( idat ) ) {
358         imat++;
359         outmat << "QUESTION: " << db_name(idat) << "\n";
360         outmat << "VALUE: -\n";
361         outfirstbas << "*if(strcmp(MatProp(" << imat << "),"
362           << '"' << "-" << '"' << ")!=0)" << "\n";
363         outfirstbas << db_name(idat) << " *group" << " *MatProp(" << imat << ")" << "\n";
364         outfirstbas << "*Set var maxwell_frequency=1\n";
365         outfirstbas << "*endif\n";
366       }
367     }
368   }
369   if ( maxwell_e ) {
370     for ( idat=0; idat<MDAT; idat++ ) {
371       if ( db_partialname( idat, "group_maxwell_time" ) && db_external( idat ) ) {
372         imat++;
373         outmat << "QUESTION: " << db_name(idat) << "\n";
374         outmat << "VALUE: -\n";
375         outfirstbas << "*if(strcmp(MatProp(" << imat << "),"
376           << '"' << "-" << '"' << ")!=0)" << "\n";
377         outfirstbas << db_name(idat) << " *group" << " *MatProp(" << imat << ")" << "\n";
378         outfirstbas << "*Set var maxwell_time=1\n";
379         outfirstbas << "*endif\n";
380       }
381     }
382   }
383   if ( wave_scalar ) {
384     for ( idat=0; idat<MDAT; idat++ ) {
385       if ( db_partialname( idat, "group_wave" ) && db_external( idat ) ) {
386         imat++;
387         outmat << "QUESTION: " << db_name(idat) << "\n";
388         outmat << "VALUE: -\n";
389         outfirstbas << "*if(strcmp(MatProp(" << imat << "),"
390           << '"' << "-" << '"' << ")!=0)" << "\n";
391         outfirstbas << db_name(idat) << " *group" << " *MatProp(" << imat << ")" << "\n";
392         outfirstbas << "*Set var wave=1\n";
393         outfirstbas << "*endif\n";
394       }
395     }
396   }
397   outmat << "QUESTION: group_integration_points\n";
398   outmat << "VALUE: -\n";
399   outmat << "END MATERIAL\n";
400   outfirstbas << "*Set var group=LoopVar-1\n";
401   outfirstbas << "group_type *group\n";
402   outfirstbas << "*if(material==1&&groundflow==1&&condif==1)\n-materi -groundflow -condif\n";
403   outfirstbas << "*elseif(material==1&&groundflow==1)\n-materi -groundflow\n";
404   outfirstbas << "*elseif(material==1&&condif==1)\n-materi -condif\n";
405   outfirstbas << "*elseif(groundflow==1&&condif==1)\n-groundflow -condif\n";
406   outfirstbas << "*elseif(material==1)\n-materi\n";
407   outfirstbas << "*elseif(groundflow==1)\n-groundflow\n";
408   outfirstbas << "*elseif(condif==1)\n-condif\n";
409   outfirstbas << "*elseif(maxwell_frequency==1)\n-maxwell_frequency\n";
410   outfirstbas << "*elseif(maxwell_time==1)\n-maxwell_time\n";
411   outfirstbas << "*elseif(wave==1)\n-wave\n";
412   outfirstbas << "*else\n-none\n*endif\n";
413   outfirstbas << "*end materials\n";
414 
415     // write data part commands
416   for ( idat=0; idat<MDAT; idat++ ) {
417     if ( db_external( idat ) && !db_print_only(idat) &&
418          check( idat, CHECK_USAGE ) &&
419          ( db_type(idat)==INTEGER || db_type(idat)==DOUBLE_PRECISION ) ) {
420       outcmd << db_name(idat) << "\n";
421     }
422   }
423 
424     // write data part commands index info
425   for ( idat=0; idat<MDAT; idat++ ) {
426     if ( db_external( idat ) && !db_print_only(idat) &&
427          check( idat, CHECK_USAGE ) &&
428          ( db_type(idat)==INTEGER || db_type(idat)==DOUBLE_PRECISION ) ) {
429        if ( db_no_index(idat) )
430           outind << "0\n";
431        else
432           outind << "1\n";
433     }
434   }
435 
436   outprb.close();
437   outind.close();
438   outfirstbas.close();
439   outcmd.close();
440   outmat.close();
441 }
442