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