Salome HOME
initial project version
[tools/solverlab.git] / CoreFlows / examples / SinglePhase_3DSphericalExplosion_unstructured.cxx
1 #include "SinglePhase.hxx"
2
3 using namespace std;
4
5
6 int main(int argc, char** argv)
7 {
8         // preprocessing: mesh and group creation
9         cout << "Loading unstructured mesh for test SinglePhase_3DSphericalExplosion_unstructured()" << endl;
10         string inputfile="resources/meshCube.med";
11
12         double xinf=0;
13         double xsup=1;
14         double yinf=0;
15         double ysup=1;
16         double zinf=0;
17         double zsup=1;
18         Mesh M(inputfile);
19         double eps=1.E-6;
20         M.setGroupAtPlan(xinf,0,eps,"GAUCHE");
21         M.setGroupAtPlan(xsup,0,eps,"DROITE");
22         M.setGroupAtPlan(yinf,1,eps,"ARRIERE");
23         M.setGroupAtPlan(ysup,1,eps,"AVANT");
24         M.setGroupAtPlan(zinf,2,eps,"BAS");
25         M.setGroupAtPlan(zsup,2,eps,"HAUT");
26
27         /* Initial field data */
28         int spaceDim = 3;
29         int nVar=2+spaceDim;
30         double radius=0.5;
31         Vector Center(3);//default value is (0,0,0)
32         Vector Vout(nVar), Vin(nVar);
33         Vin[0]=1.1;
34         Vin[1]=0;
35         Vin[2]=0;
36         Vin[3]=0;
37         Vin[4]=300;
38         Vout[0]=1;
39         Vout[1]=0;
40         Vout[2]=0;
41         Vout[3]=0;
42         Vout[4]=300;
43
44
45         SinglePhase  myProblem(Gas,around1bar300K,spaceDim);
46
47         /*Setting mesh and Initial */
48         cout << "Setting initial data " << endl;
49         myProblem.setInitialFieldSphericalStepFunction( M, Vout, Vin, radius, Center);
50
51         //set the boundary conditions
52         double wallVelocityX=0;
53         double wallVelocityY=0;
54         double wallVelocityZ=0;
55         double wallTemperature=563;
56         myProblem.setWallBoundaryCondition("GAUCHE", wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
57         myProblem.setWallBoundaryCondition("DROITE", wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
58         myProblem.setWallBoundaryCondition("HAUT", wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
59         myProblem.setWallBoundaryCondition("BAS" , wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
60         myProblem.setWallBoundaryCondition("AVANT", wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
61         myProblem.setWallBoundaryCondition("ARRIERE" , wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
62
63         // set the numerical method
64         myProblem.setNumericalScheme(upwind, Explicit);
65
66         // name file save
67         string fileName = "3DSphericalExplosion_unstructured";
68
69         // parameters calculation
70         unsigned MaxNbOfTimeStep = 3 ;
71         int freqSave = 1;
72         double cfl = 0.3;
73         double maxTime = 5;
74         double precision = 1e-6;
75
76         myProblem.setCFL(cfl);
77         myProblem.setPrecision(precision);
78         myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
79         myProblem.setTimeMax(maxTime);
80         myProblem.setFreqSave(freqSave);
81         myProblem.setFileName(fileName);
82         myProblem.setNewtonSolver(precision,20);
83         myProblem.saveVelocity();
84
85         // evolution
86         myProblem.initialize();
87
88         bool ok = myProblem.run();
89         if (ok)
90                 cout << "Simulation "<<fileName<<" is successful !" << endl;
91         else
92                 cout << "Simulation "<<fileName<<"  failed ! " << endl;
93
94         cout << "------------ End of calculation !!! -----------" << endl;
95         myProblem.terminate();
96
97         return EXIT_SUCCESS;
98 }