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 sys_Laplace_var.cpp
19   \author E. Lun�ville
20   \since 14 nov 2013
21   \date 14 nov 2013
22 
23 */
24 #include "xlife++-libs.h"
25 #include "testUtils.hpp"
26 
27 using namespace xlifepp;
28 
29 namespace sys_Laplace_var
30 {
31 
M(const Point & P,Parameters & pa=defaultParameters)32 Matrix<Real> M(const Point& P, Parameters& pa = defaultParameters)
33 {
34  Real x=P(1) , y=P(2);
35  Real r=sqrt(x*x+y*y);
36  Matrix<Real> rM(2,_idMatrix);
37  if((1<r)&&(r<=2))
38   {
39    rM(1,1)=((r-1)*(r-1)/(r*r));
40    rM(2,2)=2;
41   }
42   return rM;
43 }
44 
sys_Laplace_var(bool check)45 String sys_Laplace_var(bool check)
46 {
47    String rootname = "sys_Laplace_var";
48    trace_p->push(rootname);
49    std::stringstream out;
50    out.precision(testPrec);
51    verboseLevel(30);
52 
53   //create mesh of square
54   Strings sidenames("y=0","y=1","x=0","x=1");
55   Mesh mesh2d(Rectangle(_xmin=0,_xmax=1,_ymin=0,_ymax=1,_nnodes=11),_triangle,1,_structured);
56   mesh2d.printInfo();
57   Domain omega=mesh2d.domain("Omega");
58 //  Domain sigmaM=mesh2d.domain("x=0"),  sigmaP=mesh2d.domain("x=1");
59 
60   // create interpolation
61   Space V(omega, P1,"V",true);
62   Unknown u(V,"u");  TestFunction v(u,"v");
63 
64   // create bilinear form, linear form and their algebraic representation
65   BilinearForm auv=intg(omega,(M*grad(u))|grad(v));
66   TermMatrix A(auv, "A");
67 //  EssentialConditions ecs= (u|sigmaM = 1) & (u|sigmaP = 1);
68 //  TermMatrix A(auv, ecs, "A");
69 
70   //------------------------------------------------------------------------------------
71   // save results in a file or compare results with some references value in a file
72   //------------------------------------------------------------------------------------
73    trace_p->pop();
74    if (check) { return diffResFile(out, rootname); }
75    else { return saveResToFile(out, rootname); }
76 }
77 
78 }
79