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 unit_segment.cpp
19 \author N. Kielbasiewicz
20 \since 5 nov 2012
21 \date 18 dec 2012
22
23 Low level tests of refSegment class.
24 */
25
26 #include "xlife++-libs.h"
27 #include "testUtils.hpp"
28
29 #include <iostream>
30 #include <sstream>
31
32 using namespace xlifepp;
33
34 namespace unit_segment {
35
unit_segment(bool check)36 String unit_segment(bool check)
37 {
38 String rootname = "unit_segment";
39 trace_p->push(rootname);
40 std::stringstream oss;
41 oss.precision(testPrec);
42
43 Interpolation* p1 = findInterpolation(_Lagrange, _standard, 1, H1);
44 Interpolation* p2 = findInterpolation(_Lagrange, _standard, 2, H1);
45 Interpolation* p3 = findInterpolation(_Lagrange, _standard, 3, H1);
46 Interpolation* p4 = findInterpolation(_Lagrange, _standard, 4, H1);
47 Interpolation* p5 = findInterpolation(_Lagrange, _standard, 5, H1);
48 RefElement* segmentP1 = findRefElement(_segment, p1);
49 RefElement* segmentP2 = findRefElement(_segment, p2);
50 RefElement* segmentP3 = findRefElement(_segment, p3);
51 RefElement* segmentP4 = findRefElement(_segment, p4);
52 RefElement* segmentP5 = findRefElement(_segment, p5);
53
54 verboseLevel(10);
55 oss << *(segmentP1) << std::endl;
56 oss << *(segmentP2) << std::endl;
57 oss << *(segmentP3) << std::endl;
58 oss << *(segmentP4) << std::endl;
59 oss << *(segmentP5) << std::endl;
60
61 //test polynomials representation
62 oss<<"===================== with polynomials representation ========================"<<eol;
63 segmentP1->computeShapeFunctions();oss << *(segmentP1) << std::endl;
64 segmentP2->computeShapeFunctions();oss << *(segmentP2) << std::endl;
65 segmentP3->computeShapeFunctions();oss << *(segmentP3) << std::endl;
66 segmentP4->computeShapeFunctions();oss << *(segmentP4) << std::endl;
67 segmentP5->computeShapeFunctions();oss << *(segmentP5) << std::endl;
68
69 //------------------------------------------------------------------------------------
70 // save results in a file or compare results with some references value in a file
71 //------------------------------------------------------------------------------------
72 trace_p->pop();
73 if (check) { return diffResFile(oss, rootname); }
74 else { return saveResToFile(oss, rootname); }
75 }
76
77 }
78