Salome HOME
update CoreFlows
[tools/solverlab.git] / CoreFlows / examples / C / SinglePhase_2DHeatDrivenCavity_unstructured.cxx
1 #include "SinglePhase.hxx"
2
3 using namespace std;
4
5 int main(int argc, char** argv)
6 {
7         /*Preprocessing: mesh and group creation*/
8         double xinf=0;
9         double xsup=1;
10         double yinf=0;
11         double ysup=1;
12         cout << "Loading unstuctured mesh for test SinglePhase_2DHeatDrivenCavity_unstructured" << endl;
13         Mesh M("resources/BoxWithMeshWithTriangularCells.med");
14         double eps=1.E-6;
15         M.setGroupAtPlan(xinf,0,eps,"coldWall");
16         M.setGroupAtPlan(xsup,0,eps,"hotWall");
17         M.setGroupAtPlan(yinf,1,eps,"coldWall");
18         M.setGroupAtPlan(ysup,1,eps,"hotWall");
19         int spaceDim = M.getSpaceDimension();
20
21         // physical constants
22         vector<double> viscosite(1), conductivite(1);
23         viscosite[0]= 8.85e-5;
24         conductivite[0]=1000;//transfert de chaleur du à l'ébullition en paroi.
25         vector<double> gravite(spaceDim,0.) ;
26         gravite[1]=-10;
27         gravite[0]=0;
28
29         // set the limit field for each boundary
30         LimitField limitColdWall, limitHotWall;
31         map<string, LimitField> boundaryFields;
32         limitColdWall.bcType=Wall;
33         limitColdWall.T = 590;//Temperature de la parois froide
34         limitColdWall.v_x = vector<double>(1,0);
35         limitColdWall.v_y = vector<double>(1,0);
36         boundaryFields["coldWall"]= limitColdWall;
37
38         limitHotWall.bcType=Wall;
39         limitHotWall.T = 560;//Temperature des parois chauffantes
40         limitHotWall.v_x = vector<double>(1,0);
41         limitHotWall.v_y = vector<double>(1,0);
42         boundaryFields["hotWall"]= limitHotWall;
43
44         SinglePhase  myProblem(Liquid,around155bars600K,spaceDim);
45         int nVar = myProblem.getNumberOfVariables();
46
47         //Initial field creation
48         cout << "Construction de la condition initiale" << endl;
49         /* First case constant initial data */
50         Vector VV_Constant(nVar);
51         // constant vector
52         VV_Constant(0) = 155e5;
53         VV_Constant(1) = 0;
54         VV_Constant(2) = 0;
55         VV_Constant(3) = 573;
56
57         myProblem.setInitialFieldConstant(M,VV_Constant);
58
59         //set the boundary conditions
60         myProblem.setBoundaryFields(boundaryFields);
61
62         // physical parameters
63         myProblem.setViscosity(viscosite);
64         myProblem.setConductivity(conductivite);
65         myProblem.setGravity(gravite);
66
67         // set the numerical method
68         myProblem.setNumericalScheme(upwind, Implicit);
69
70         // set the Petsc resolution
71         myProblem.setLinearSolver(GMRES,ILU,true);
72
73         // name result file
74         string fileName = "2DHeatDrivenCavity_unstructured";
75
76         // parameters calculation
77         unsigned MaxNbOfTimeStep = 3;
78         int freqSave = 1;
79         double cfl = 1;
80         double maxTime = 50;
81         double precision = 1e-7;
82
83         myProblem.setCFL(cfl);
84         myProblem.setPrecision(precision);
85         myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
86         myProblem.setTimeMax(maxTime);
87         myProblem.setFreqSave(freqSave);
88         myProblem.setFileName(fileName);
89         myProblem.setNewtonSolver(precision,50);
90         myProblem.saveVelocity();
91
92         // evolution
93         myProblem.initialize();
94         bool ok = myProblem.run();
95         if (ok)
96                 cout << "Simulation "<<fileName<<" is successful !" << endl;
97         else
98                 cout << "Simulation "<<fileName<<"  failed ! " << endl;
99
100         cout << "------------ End of calculation !!! -----------" << endl;
101
102         myProblem.terminate();
103
104         return EXIT_SUCCESS;
105 }