Loading...
Searching...
No Matches
thermocouplesNumberTest_paramBC.H
Go to the documentation of this file.
1Info << endl;
2Info << "*********************************************************" << endl;
3Info << "Performing test for the paramBC inverse solver" << endl;
4Info << "Changing the position of the thermocouples on y" << endl;
5Info << endl;
6word outputFolder = "./ITHACAoutput/thermocouplesNumberTest_paramBC/";
7word outputFolder_bestFit =
8 "./ITHACAoutput/thermocouplesNumberTest_paramBC_bestFit/";
9word outputFolder_bestInt =
10 "./ITHACAoutput/thermocouplesNumberTest_paramBC_bestInt/";
11volScalarField gTrueField = example_paramBC.list2Field(example_paramBC.gTrue);
13 "1", outputFolder,
14 "gTrue");
15
16int testSize = 40;
17
18Eigen::VectorXi numberTCperAxis = Eigen::VectorXi::LinSpaced(testSize, 1,
19 testSize + 1);
20ITHACAstream::exportMatrix(numberTCperAxis, "numberTCperAxis", "eigen",
21 outputFolder);
22
23for (int i = 0; i < testSize; i++)
24{
25 Info << "\n**************************************************** " << endl;
26 Info << "\nTest " << i << endl;
27 Info << "\n**************************************************** " << endl;
28 Eigen::VectorXd TCcoord_temp = Eigen::VectorXd::LinSpaced(numberTCperAxis(
29 i) + 2, 0.0, 1.0);
30 Eigen::VectorXd TCcoord = TCcoord_temp.segment(1, numberTCperAxis(i));
31 example_paramBC.thermocouplesPos.resize(numberTCperAxis(i) * numberTCperAxis(
32 i));
33 double TCyCoord = 0.2;
34 int TCi = 0;
35
36 for (int Zi = 0; Zi < numberTCperAxis(i); Zi++)
37 {
38 for (int Xi = 0; Xi < numberTCperAxis(i); Xi++)
39 {
40 example_paramBC.thermocouplesPos[TCi][0] = TCcoord(Xi);
41 example_paramBC.thermocouplesPos[TCi][1] = TCyCoord;
42 example_paramBC.thermocouplesPos[TCi][2] = TCcoord(Zi);
43 Info << "thermocouplesPos[" << TCi << "] = " <<
44 example_paramBC.thermocouplesPos[TCi] << endl;
45 TCi++;
46 }
47 }
48
50 if ( remove( "./thermocouplesCellsID_mat.txt" ) != 0 )
51 {
52 perror( "\nError deleting thermocouples file\n" );
53 }
54 else
55 {
56 puts( "\nThermocouples file successfully deleted\n" );
57 }
58
59 volScalarField Ttrue(example_paramBC._T());
60
61 for (label i = 0; i < Ttrue.internalField().size(); i++)
62 {
63 auto cx = Ttrue.mesh().C()[i].component(vector::X);
64 auto cy = Ttrue.mesh().C()[i].component(vector::Y);
65 auto cz = Ttrue.mesh().C()[i].component(vector::Z);
66 Ttrue.ref()[i] = a * cx * cx + b * cx * cy + c * cy - a * cz * cz + c;
67 }
68
69 example_paramBC.thermocouplesRead = 0;
70 example_paramBC.readThermocouples();
71 example_paramBC.Tmeas = Eigen::VectorXd::Zero(numberTCperAxis(
72 i) * numberTCperAxis(i));
73 example_paramBC.Tmeas = example_paramBC.fieldValueAtThermocouples(Ttrue);
74 example_paramBC.set_gParametrized("rbf", rbfShapePar);
75 example_paramBC.parameterizedBCoffline(1);
76 example_paramBC.parameterizedBC("fullPivLU");
77 volScalarField gParametrizedField = example_paramBC.list2Field(
78 example_paramBC.g);
79 ITHACAstream::exportSolution(gParametrizedField,
80 std::to_string(i + 1),
81 outputFolder,
82 "g");
83 volScalarField& T(example_paramBC._T());
85 std::to_string(i + 1),
86 outputFolder,
87 "T");
88 // Best fit
89 example_paramBC.parameterizedBCpostProcess(example_paramBC.bestApproximator());
90 gParametrizedField = example_paramBC.list2Field(
91 example_paramBC.g);
92 ITHACAstream::exportSolution(gParametrizedField,
93 std::to_string(i + 1),
94 outputFolder_bestFit,
95 "g");
96 volScalarField& T2(example_paramBC._T());
98 std::to_string(i + 1),
99 outputFolder_bestFit,
100 "T");
101 // Interpolation
102 example_paramBC.parameterizedBCpostProcess(example_paramBC.bestInterpolation());
103 gParametrizedField = example_paramBC.list2Field(
104 example_paramBC.g);
105 ITHACAstream::exportSolution(gParametrizedField,
106 std::to_string(i + 1),
107 outputFolder_bestInt,
108 "g");
109 volScalarField& T3(example_paramBC._T());
111 std::to_string(i + 1),
112 outputFolder_bestInt,
113 "T");
114}
115
116example_paramBC.postProcess(outputFolder, "g");
117example_paramBC.postProcess(outputFolder_bestFit, "g");
118example_paramBC.postProcess(outputFolder_bestInt, "g");
119
121if ( remove( "./thermocouplesCellsID_mat.txt" ) != 0 )
122{
123 perror( "\nError deleting thermocouples file\n" );
124}
125else
126{
127 puts( "\nThermocouples file successfully deleted\n" );
128}
129
volScalarField & T
Definition createT.H:46
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