1 /*
2 XLiFE++ is an extended library of finite elements written in C++
3     Copyright (C) 2014  Lunéville, Eric; Kielbasiewicz, Nicolas; Lafranche, Yvon; Nguyen, Manh-Ha; Chambeyron, Colin
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 3 of the License, or
8     (at your option) any later version.
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13     You should have received a copy of the GNU General Public License
14     along with this program.  If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 /*!
18   \file RefSegment.cpp
19   \authors D. Martin, N. Kielbasiewicz
20   \since 15 dec 2002
21   \date 6 aug 2012
22 
23   \brief Implementation of xlifepp::RefSegment class members and related functions
24  */
25 
26 #include "RefSegment.hpp"
27 #include "LagrangeSegment.hpp"
28 #include "HermiteSegment.hpp"
29 
30 #include "../Interpolation.hpp"
31 #include "utils.h"
32 
33 namespace xlifepp
34 {
35 
36 //! segment construction of a 1D Reference Element by interpolation type and interpolation subtype
selectRefSegment(const Interpolation * interp_p)37 RefElement* selectRefSegment(const Interpolation* interp_p)
38 {
39   switch (interp_p->type)
40   {
41     case _Lagrange:
42       switch (interp_p->subtype)
43       {
44         case _standard: return new LagrangeStdSegment(interp_p); break;
45         case _GaussLobatto:
46           switch (interp_p->numtype)
47           {
48             case 0: interp_p->badDegree(_segment); break;
49             default: return new LagrangeGLSegment(interp_p); break;
50           }
51           break;
52         default: interp_p->badSubType(_segment); break;
53       }
54     case _Hermite:
55       switch (interp_p->subtype)
56       {
57         case standard:
58           switch (interp_p->numtype)
59           {
60             case 3: return new HermiteStdSegment<P3>(interp_p); break;
61             default: interp_p->badDegree(_segment); break;
62           }
63         default: interp_p->badSubType(_segment); break;
64       }
65       break;
66     default: break;
67   }
68 
69   // Throw error messages
70   trace_p->push("selectRefSegment");
71   interp_p->badType(_segment);
72   trace_p->pop();
73   return 0;
74 }
75 
76 } // end of namespace xlifepp
77