Loading...
Searching...
No Matches
thermocouplesNumberTest_CG.H
Go to the documentation of this file.
1Info << endl;
2Info << "*********************************************************" << endl;
3Info << "Performing test for the CG inverse solver" << endl;
4Info << "Changint the position of the thermocouples on y" << endl;
5Info << endl;
6word outputFolder = "./ITHACAoutput/thermocouplesNumberTest_CG/";
7volScalarField gTrueField = example_CG.list2Field(example_paramBC.gTrue);
9 "1", outputFolder,
10 "gTrue");
11example_CG.saveSolInLists = 1;
12
13int testSize = 10;
14
15Eigen::VectorXi numberTCperAxis = Eigen::VectorXi::LinSpaced(testSize, 1,
16 testSize);
17ITHACAstream::exportMatrix(numberTCperAxis, "numberTCperAxis", "eigen",
18 outputFolder);
19
20for (int i = 0; i < testSize; i++)
21{
22 Info << "\n**************************************************** " << endl;
23 Info << "\nTest " << i << endl;
24 Info << "\n**************************************************** " << endl;
25 Eigen::VectorXd TCcoord_temp = Eigen::VectorXd::LinSpaced(numberTCperAxis(
26 i) + 2, 0.0, 1.0);
27 Eigen::VectorXd TCcoord = TCcoord_temp.segment(1, numberTCperAxis(i));
28 example_CG.thermocouplesPos.resize(numberTCperAxis(i) * numberTCperAxis(i));
29 double TCyCoord = 0.2;
30 int TCi = 0;
31
32 for (int Xi = 0; Xi < numberTCperAxis(i); Xi++)
33 {
34 for (int Zi = 0; Zi < numberTCperAxis(i); Zi++)
35 {
36 example_CG.thermocouplesPos[TCi][0] = TCcoord(Xi);
37 example_CG.thermocouplesPos[TCi][1] = TCyCoord;
38 example_CG.thermocouplesPos[TCi][2] = TCcoord(Zi);
39 Info << "thermocouplesPos[" << TCi << "] = " << example_CG.thermocouplesPos[TCi]
40 << endl;
41 TCi++;
42 }
43 }
44
46 if ( remove( "./thermocouplesCellsID_mat.txt" ) != 0 )
47 {
48 perror( "\nError deleting thermocouples file\n" );
49 }
50 else
51 {
52 puts( "\nThermocouples file successfully deleted\n" );
53 }
54
55 example_CG.thermocouplesRead = 0;
56 example_CG.readThermocouples();
57 example_CG.Tmeas = example_CG.fieldValueAtThermocouples(T_true);
58
59 if (example_CG.conjugateGradient())
60 {
61 Info << "\nCG converged" << endl;
62 volScalarField heatFluxField = example_CG.list2Field(
63 example_CG.gList[example_CG.gList.size() - 1]);
65 std::to_string(i + 1), outputFolder,
66 "g");
67 Info << "************************************" << endl;
68 Info << endl << endl;
69 }
70 else
71 {
72 Info << "CG did not converged" << endl;
73 Info << "************************************" << endl;
74 Info << endl << endl;
75 }
76}
77
78example_CG.postProcess(outputFolder, "g");
79
81if ( remove( "./thermocouplesCellsID_mat.txt" ) != 0 )
82{
83 perror( "\nError deleting thermocouples file\n" );
84}
85else
86{
87 puts( "\nThermocouples file successfully deleted\n" );
88}
std::cout<< "Duration = "<< duration<< " seconds"<< std::endl;Info<< "CG converged"<< endl;PtrList< volScalarField > heatFluxField
Definition CGtest.H:20
void exportSolution(GeometricField< Type, PatchField, GeoMesh > &s, fileName subfolder, fileName folder, word fieldName)
Export a field to file in a certain folder and subfolder.
void exportMatrix(Eigen::Matrix< T, -1, dim > &matrix, word Name, word type, word folder)
Export the reduced matrices in numpy (type=python), matlab (type=matlab) and txt (type=eigen) format ...
label i
Definition pEqn.H:46