proteus  1.8.1
C/C++/Fortran libraries
ModelFactory.h
Go to the documentation of this file.
1 #ifndef MODELFACTORY_H
2 #define MODELFACTORY_H
3 #include <iostream>
4 
5 #define NO_INSTANCE std::cout<<"Constructing model object from template class:"<<std::endl \
6  <<"return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<" \
7  <<nSpaceIn<<"," \
8  <<nDOF_mesh_trial_elementIn<<"," \
9  <<nDOF_trial_elementIn<<"," \
10  <<nDOF_test_elementIn<<">," \
11  <<nSpaceIn<<"," \
12  <<nQuadraturePoints_elementIn<<"," \
13  <<nDOF_mesh_trial_elementIn<<"," \
14  <<nDOF_trial_elementIn<<"," \
15  <<nDOF_test_elementIn<<"," \
16  <<nQuadraturePoints_elementBoundaryIn<<">());" \
17  <<std::endl<<std::flush
18 
19 namespace proteus
20 {
21  template<class Model_Base,
22  template<class CompKernelType,
23  int nSpace,
24  int nQuadraturePoints_element,
25  int nDOF_mesh_trial_element,
26  int nDOF_trial_element,
27  int nDOF_test_element,
28  int nQuadraturePoints_elementBoundary>
29  class ModelTemplate,
30  template<int nSpace,
31  int nDOF_mesh_trial_element,
32  int nDOF_trial_element,
33  int nDOF_test_element>
34  class CompKernelTemplate>
35  Model_Base* chooseAndAllocateDiscretization(int nSpaceIn,
36  int nQuadraturePoints_elementIn,
37  int nDOF_mesh_trial_elementIn,
38  int nDOF_trial_elementIn,
39  int nDOF_test_elementIn,
40  int nQuadraturePoints_elementBoundaryIn,
41  int CompKernelFlag)//0=Parametric
42  {
43  if (CompKernelFlag == 0)
44  {
45  if (nSpaceIn == 3) // 3D
46  {
47  if (nDOF_mesh_trial_elementIn == nDOF_trial_elementIn)//iso-parametric
48  {
49  if (nDOF_mesh_trial_elementIn == 4) // P1 FE-space. Default nquad=5
50  {
51  if (nQuadraturePoints_elementIn == 5)
52  return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<3,4,4,4>,3,5,4,4,4,4>());
53  else if (nQuadraturePoints_elementIn == 4)
54  return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<3,4,4,4>,3,4,4,4,4,3>());
55  else if (nQuadraturePoints_elementIn == 15 && nQuadraturePoints_elementBoundaryIn == 7)
56  return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<3,4,4,4>,3,15,4,4,4,7>());
57  else if (nQuadraturePoints_elementIn == 24 && nQuadraturePoints_elementBoundaryIn == 12)
58  return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<3,4,4,4>,3,24,4,4,4,12>());
59  else
60  {
62  abort();
63  }
64  }
65  else if (nDOF_mesh_trial_elementIn == 8) // Q1 FE-space. Default nquad=27
66  {
67  if (nQuadraturePoints_elementIn == 8)
68  {
69  if ( nQuadraturePoints_elementBoundaryIn == 4)
70  return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<3,8,8,8>,3,8,8,8,8,4>());
71  /* else if ( nQuadraturePoints_elementBoundaryIn == 9) */
72  /* return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<3,8,8,8>,3,8,8,8,8,9>()); */
73  else
74  {
76  abort();
77  }
78  }
79  /* else if (nQuadraturePoints_elementIn == 27) */
80  /* { */
81  /* if ( nQuadraturePoints_elementBoundaryIn == 4) */
82  /* return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<3,8,8,8>,3,27,8,8,8,4>()); */
83  /* /\* else if ( nQuadraturePoints_elementBoundaryIn == 9) *\/ */
84  /* /\* return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<3,8,8,8>,3,27,8,8,8,9>()); *\/ */
85  /* else */
86  /* { */
87  /* NO_INSTANCE; */
88  /* abort(); */
89  /* } */
90  /* } */
91  else
92  {
94  abort();
95  }
96  }
97  /* else if (nDOF_mesh_trial_elementIn == 10) // P2 FE space. Default nquad=15 */
98  /* { */
99  /* if (nQuadraturePoints_elementIn == 15) */
100  /* return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<3,10,10,10>,3,15,10,10,10,7>()); */
101  /* else */
102  /* { */
103  /* NO_INSTANCE; */
104  /* abort(); */
105  /* } */
106  /* } */
107  /* else if (nDOF_mesh_trial_elementIn == 27) // Q2 FE space. Default nquad=27 */
108  /* { */
109  /* if (nQuadraturePoints_elementIn == 8) */
110  /* { */
111  /* if ( nQuadraturePoints_elementBoundaryIn == 4) */
112  /* return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<3,27,27,27>,3,8,27,27,27,4>()); */
113  /* /\* else if ( nQuadraturePoints_elementBoundaryIn == 9) *\/ */
114  /* /\* return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<3,27,27,27>,3,8,27,27,27,9>()); *\/ */
115  /* else */
116  /* { */
117  /* NO_INSTANCE; */
118  /* abort(); */
119  /* } */
120  /* } */
121  /* else if (nQuadraturePoints_elementIn == 27) */
122  /* { */
123  /* if ( nQuadraturePoints_elementBoundaryIn == 4) */
124  /* return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<3,27,27,27>,3,27,27,27,27,4>()); */
125  /* /\* else if ( nQuadraturePoints_elementBoundaryIn == 9) *\/ */
126  /* /\* return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<3,27,27,27>,3,27,27,27,27,9>()); *\/ */
127  /* else */
128  /* { */
129  /* NO_INSTANCE; */
130  /* abort(); */
131  /* } */
132  /* } */
133  else
134  {
135  NO_INSTANCE;
136  abort();
137  }
138  }
139  else if (nDOF_mesh_trial_elementIn == 4)//sub-parametric tets
140  {
141  if (nDOF_trial_elementIn == 10)
142  {
143  if (nQuadraturePoints_elementIn == 4 && nQuadraturePoints_elementBoundaryIn == 3)
144  {
145  return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<3,4,10,10>,3,4,4,10,10,3>());
146  }
147  /* else if (nQuadraturePoints_elementIn == 5 && nQuadraturePoints_elementBoundaryIn == 4) */
148  /* { */
149  /* return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<3,4,10,10>,3,5,4,10,10,4>()); */
150  /* } */
151  /* else if (nQuadraturePoints_elementIn == 14 && nQuadraturePoints_elementBoundaryIn == 6) */
152  /* { */
153  /* return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<3,4,10,10>,3,14,4,10,10,6>()); */
154  /* } */
155  else if (nQuadraturePoints_elementIn == 15 && nQuadraturePoints_elementBoundaryIn == 7)
156  {
157  return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<3,4,10,10>,3,15,4,10,10,7>());
158  }
159  else if (nQuadraturePoints_elementIn == 24 && nQuadraturePoints_elementBoundaryIn == 12)
160  {
161  return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<3,4,10,10>,3,24,4,10,10,12>());
162  }
163  /* else if (nQuadraturePoints_elementIn == 31 && nQuadraturePoints_elementBoundaryIn == 12) */
164  /* { */
165  /* return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<3,4,10,10>,3,31,4,10,10,12>()); */
166  /* } */
167  else
168  {
169  NO_INSTANCE;
170  abort();
171  }
172  }
173  else
174  {
175  NO_INSTANCE;
176  abort();
177  }
178  }
179  else if (nDOF_mesh_trial_elementIn == 8)//sub-parametric hexes
180  {
181  if (nDOF_trial_elementIn == 27)
182  {
183  if (nQuadraturePoints_elementIn == 125)
184  return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<3,8,27,27>,3,125,8,27,27,25>());
185  }
186  else
187  {
188  NO_INSTANCE;
189  abort();
190  }
191  }
192  else
193  {
194  NO_INSTANCE;
195  abort();
196  }
197  }
198  else
199  {
200  NO_INSTANCE;
201  abort();
202  }
203  }
204  else
205  {
206  NO_INSTANCE;
207  abort();
208  }
209  return NULL;
210  }
211  template<class Model_Base,
212  template<class CompKernelType,
213  int nSpace,
214  int nQuadraturePoints_element,
215  int nDOF_mesh_trial_element,
216  int nDOF_trial_element,
217  int nDOF_test_element,
218  int nQuadraturePoints_elementBoundary>
219  class ModelTemplate,
220  template<int nSpace,
221  int nDOF_mesh_trial_element,
222  int nDOF_trial_element,
223  int nDOF_test_element>
224  class CompKernelTemplate>
225  Model_Base* chooseAndAllocateDiscretization2D(int nSpaceIn,
226  int nQuadraturePoints_elementIn,
227  int nDOF_mesh_trial_elementIn,
228  int nDOF_trial_elementIn,
229  int nDOF_test_elementIn,
230  int nQuadraturePoints_elementBoundaryIn,
231  int CompKernelFlag)//0=Parametric
232  {
233  if (CompKernelFlag == 0)
234  {
235  if (nSpaceIn == 2) // 2D
236  {
237  if (nDOF_mesh_trial_elementIn == nDOF_trial_elementIn)//iso-parametric
238  {
239  if (nDOF_mesh_trial_elementIn == 3) // P1 FE-space. Default nquad=4
240  {
241  if (nQuadraturePoints_elementIn == 1)
242  {
243  if (nQuadraturePoints_elementBoundaryIn == 1)
244  return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<2,3,3,3>,2,1,3,3,3,1>());
245  else
246  {
247  NO_INSTANCE;
248  abort();
249  }
250  }
251  else if (nQuadraturePoints_elementIn == 3)
252  {
253  if (nQuadraturePoints_elementBoundaryIn == 2)
254  return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<2,3,3,3>,2,3,3,3,3,2>());
255  else
256  {
257  NO_INSTANCE;
258  abort();
259  }
260  }
261  else if (nQuadraturePoints_elementIn == 4)
262  {
263  if (nQuadraturePoints_elementBoundaryIn == 3)
264  return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<2,3,3,3>,2,4,3,3,3,3>());
265  else
266  {
267  NO_INSTANCE;
268  abort();
269  }
270  }
271  else if (nQuadraturePoints_elementIn == 6)
272  {
273  if (nQuadraturePoints_elementBoundaryIn == 4)
274  return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<2,3,3,3>,2,6,3,3,3,4>());
275  else
276  {
277  NO_INSTANCE;
278  abort();
279  }
280  }
281  else if (nQuadraturePoints_elementIn == 7)
282  {
283  if (nQuadraturePoints_elementBoundaryIn == 5)
284  return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<2,3,3,3>,2,7,3,3,3,5>());
285  else
286  {
287  NO_INSTANCE;
288  abort();
289  }
290  }
291  else if (nQuadraturePoints_elementIn == 12)
292  {
293  if (nQuadraturePoints_elementBoundaryIn == 6)
294  return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<2,3,3,3>,2,12,3,3,3,6>());
295  else
296  {
297  NO_INSTANCE;
298  abort();
299  }
300  }
301  /* else if (nQuadraturePoints_elementIn == 112)//hk=0.25 */
302  /* { */
303  /* if (nQuadraturePoints_elementBoundaryIn == 5) */
304  /* { */
305  /* return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<2,3,3,3>,2,112,3,3,3,5>()); */
306  /* } */
307  /* else */
308  /* { */
309  /* NO_INSTANCE; */
310  /* abort(); */
311  /* } */
312  /* } */
313  /* else if (nQuadraturePoints_elementIn == 16)//hk=0.5 */
314  /* { */
315  /* if (nQuadraturePoints_elementBoundaryIn == 3) */
316  /* { */
317  /* return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<2,3,3,3>,2,16,3,3,3,3>()); */
318  /* } */
319  /* else */
320  /* { */
321  /* NO_INSTANCE; */
322  /* abort(); */
323  /* } */
324  /* } */
325  /* else if (nQuadraturePoints_elementIn == 36)//hk=0.3 */
326  /* { */
327  /* if (nQuadraturePoints_elementBoundaryIn == 3) */
328  /* { */
329  /* return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<2,3,3,3>,2,36,3,3,3,3>()); */
330  /* } */
331  /* else */
332  /* { */
333  /* NO_INSTANCE; */
334  /* abort(); */
335  /* } */
336  /* } */
337  /* else if (nQuadraturePoints_elementIn == 100)//hk=0.2 */
338  /* { */
339  /* if (nQuadraturePoints_elementBoundaryIn == 3) */
340  /* { */
341  /* return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<2,3,3,3>,2,100,3,3,3,3>()); */
342  /* } */
343  /* else */
344  /* { */
345  /* NO_INSTANCE; */
346  /* abort(); */
347  /* } */
348  /* } */
349  else
350  {
351  NO_INSTANCE;
352  abort();
353  }
354  }
355  else if(nDOF_mesh_trial_elementIn == 4)
356  {
357  if (nQuadraturePoints_elementIn == 4) // Q1 FE-space
358  {
359  if (nQuadraturePoints_elementBoundaryIn == 2)
360  return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<2,4,4,4>,2,4,4,4,4,2>());
361  else
362  {
363  NO_INSTANCE;
364  abort();
365  }
366  }
367  else
368  {
369  NO_INSTANCE;
370  abort();
371  }
372  }
373  else
374  {
375  NO_INSTANCE;
376  abort();
377  }
378  }
379  else if (nDOF_mesh_trial_elementIn == 3)
380  {
381  if (nDOF_trial_elementIn == 6) // P2 FE-space. Default nquad=7
382  {
383  if (nQuadraturePoints_elementIn == 1)
384  {
385  if (nQuadraturePoints_elementBoundaryIn == 1)
386  return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<2,3,6,6>,2,1,3,6,6,1>());
387  else
388  {
389  NO_INSTANCE;
390  abort();
391  }
392  }
393  /* else if (nQuadraturePoints_elementIn == 3) */
394  /* { */
395  /* if (nQuadraturePoints_elementBoundaryIn == 2) */
396  /* return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<2,3,6,6>,2,3,3,6,6,2>()); */
397  /* else */
398  /* { */
399  /* NO_INSTANCE; */
400  /* abort(); */
401  /* } */
402  /* } */
403  /* else if (nQuadraturePoints_elementIn == 4) */
404  /* { */
405  /* if (nQuadraturePoints_elementBoundaryIn == 3) */
406  /* return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<2,3,6,6>,2,4,3,6,6,3>()); */
407  /* else */
408  /* { */
409  /* NO_INSTANCE; */
410  /* abort(); */
411  /* } */
412  /* } */
413  /* else if (nQuadraturePoints_elementIn == 6) */
414  /* { */
415  /* if (nQuadraturePoints_elementBoundaryIn == 4) */
416  /* return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<2,3,6,6>,2,6,3,6,6,4>()); */
417  /* else */
418  /* { */
419  /* NO_INSTANCE; */
420  /* abort(); */
421  /* } */
422  /* } */
423  else if (nQuadraturePoints_elementIn == 7)
424  {
425  if (nQuadraturePoints_elementBoundaryIn == 5)
426  {
427  return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<2,3,6,6>,2,7,3,6,6,5>());
428  }
429  else
430  {
431  NO_INSTANCE;
432  abort();
433  }
434  }
435  else if (nQuadraturePoints_elementIn == 12)
436  {
437  if (nQuadraturePoints_elementBoundaryIn == 6)
438  {
439  return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<2,3,6,6>,2,12,3,6,6,6>());
440  }
441  else
442  {
443  NO_INSTANCE;
444  abort();
445  }
446  }
447  /* else if (nQuadraturePoints_elementIn == 112) */
448  /* { */
449  /* if (nQuadraturePoints_elementBoundaryIn == 5) */
450  /* { */
451  /* return static_cast<Model_Base*>(new ModelTemplate<CompKernelTemplate<2,3,6,6>,2,112,3,6,6,5>()); */
452  /* } */
453  /* else */
454  /* { */
455  /* NO_INSTANCE; */
456  /* abort(); */
457  /* } */
458  /* } */
459  else
460  {
461  NO_INSTANCE;
462  abort();
463  }
464 
465  }
466  else
467  {
468  NO_INSTANCE;
469  abort();
470  }
471  }
472  else
473  {
474  NO_INSTANCE;
475  abort();
476  }
477  }
478  }
479  else
480  {
481  NO_INSTANCE;
482  abort();
483  }
484  return NULL;
485  }
486 }
487 #endif
proteus::chooseAndAllocateDiscretization2D
Model_Base * chooseAndAllocateDiscretization2D(int nSpaceIn, int nQuadraturePoints_elementIn, int nDOF_mesh_trial_elementIn, int nDOF_trial_elementIn, int nDOF_test_elementIn, int nDOF_v_trial_elementIn, int nDOF_v_test_elementIn, int nQuadraturePoints_elementBoundaryIn, int CompKernelFlag)
Definition: MixedModelFactory.h:309
proteus::chooseAndAllocateDiscretization
Model_Base * chooseAndAllocateDiscretization(int nSpaceIn, int nQuadraturePoints_elementIn, int nDOF_mesh_trial_elementIn, int nDOF_trial_elementIn, int nDOF_test_elementIn, int nDOF_v_trial_elementIn, int nDOF_v_test_elementIn, int nQuadraturePoints_elementBoundaryIn, int CompKernelFlag)
Definition: MixedModelFactory.h:48
proteus
Definition: ADR.h:17
NO_INSTANCE
#define NO_INSTANCE
Definition: ModelFactory.h:5