32#include "interpolation.H"
35#include "simpleControl.H"
43#define _USE_MATH_DEFINES
46#include "mixedFvPatchFields.H"
47#include "cellDistFuncs.H"
52int main(
int argc,
char* argv[])
54 solverPerformance::debug = 1;
62 example_paramBC.
a = a;
63 example_paramBC.
b = b;
64 example_paramBC.
c = c;
65 example_paramBC.
d = d;
73 label CGtest = para->
ITHACAdict->lookupOrDefault<
int>(
"CGtest", 0);
74 label CGnoiseTest = para->
ITHACAdict->lookupOrDefault<
int>(
"CGnoiseTest", 0);
75 label CGnoiseLevelTest =
76 para->
ITHACAdict->lookupOrDefault<
int>(
"CGnoiseLevelTest", 0);
77 label parameterizedBCtest =
78 para->
ITHACAdict->lookupOrDefault<
int>(
"parameterizedBCtest", 0);
79 label parameterizedBCtest_RBFwidth =
80 para->
ITHACAdict->lookupOrDefault<
int>(
"parameterizedBCtest_RBFwidth", 0);
81 label thermocouplesLocationTest_CG =
82 para->
ITHACAdict->lookupOrDefault<
int>(
"thermocouplesLocationTest_CG", 0);
83 label thermocouplesLocationTest_paramBC =
84 para->
ITHACAdict->lookupOrDefault<
int>(
"thermocouplesLocationTest_paramBC", 0);
85 label thermocouplesNumberTest_CG =
86 para->
ITHACAdict->lookupOrDefault<
int>(
"thermocouplesNumberTest_CG", 0);
87 label thermocouplesNumberTest_paramBC =
88 para->
ITHACAdict->lookupOrDefault<
int>(
"thermocouplesNumberTest_paramBC", 0);
91 example_CG.
Jtol = para->
ITHACAdict->lookupOrDefault<
double>(
"Jtolerance",
94 para->
ITHACAdict->lookupOrDefault<
double>(
"JrelativeTolerance",
96 double rbfShapePar = para->
ITHACAdict->lookupOrDefault<
double>(
"rbfShapePar",
98 M_Assert(rbfShapePar > 0,
"rbfShapePar not specified");
100 para->
ITHACAdict->lookupOrDefault<
double>(
"thermalConductivity", 0);
101 M_Assert(example_paramBC.
k > 0,
"thermalConductivity, k, not specified");
103 para->
ITHACAdict->lookupOrDefault<
double>(
"heatTranferCoeff", 0);
104 M_Assert(example_paramBC.
H > 0,
"Heat transfer coeff, H, not specified");
105 example_CG.
k = example_paramBC.
k;
106 example_CG.
H = example_paramBC.
H;
107 int rbfWidthTest_size =
108 para->
ITHACAdict->lookupOrDefault<
int>(
"rbfWidthTest_size", 0);
110 volScalarField T_true(example_paramBC.
_T());
112 for (label
i = 0;
i < T_true.internalField().size();
i++)
114 auto cx = T_true.mesh().C()[
i].component(vector::X);
115 auto cy = T_true.mesh().C()[
i].component(vector::Y);
116 auto cz = T_true.mesh().C()[
i].component(vector::Z);
117 T_true.ref()[
i] = a * cx * cx + b * cx * cy + c * cy - a * cz * cz + c;
122 example_paramBC.
hotSide_ind =
mesh.boundaryMesh().findPatchID(
"hotSide");
123 label hotSideSize = T_true.boundaryField()[example_paramBC.
hotSide_ind].size();
124 example_paramBC.
g.resize(hotSideSize);
125 example_paramBC.
gTrue.resize(hotSideSize);
126 forAll(example_paramBC.
g, faceI)
129 mesh.boundaryMesh()[example_paramBC.
hotSide_ind].faceCentres()[faceI].x();
130 example_paramBC.
g[faceI] = example_paramBC.
k * (b * faceX + c) ;
132 example_paramBC.
gTrue = example_paramBC.
g;
134 example_CG.
g = example_paramBC.
g;
135 example_CG.
gTrue = example_paramBC.
g;
137 volScalarField&
T(example_paramBC.
_T());
138 Info <<
"Exporting analytical solution" << endl;
141 volScalarField error = (T_true -
T).ref();
145 Info <<
"Linf norm of the relative error = " <<
166 if (parameterizedBCtest)
172 if (parameterizedBCtest_RBFwidth)
178 if (thermocouplesLocationTest_CG)
184 if (thermocouplesLocationTest_paramBC)
190 if (thermocouplesNumberTest_CG)
196 if (thermocouplesNumberTest_paramBC)
forAll(example_CG.gList, solutionI)
Header file of the Foam2Eigen class.
int main(int argc, char *argv[])
Header file of the ITHACAPOD class.
#define M_Assert(Expr, Msg)
Header file of the ITHACAutilities namespace.
Class where the first inverse heat transfer problem tutorial is solved using Alifanov's regularizatio...
double a
Constant to define boundary conditions.
double b
Constant to define boundary conditions.
double d
Constant to define boundary conditions.
double c
Constant to define boundary conditions.
void solveTrue()
Perform a solution of the direct problem with the correct boundary conditions.
Class where the first inverse heat transfer problem tutorial is solved using the Parameterization of ...
double a
Constant to define boundary conditions.
double c
Constant to define boundary conditions.
void solveTrue()
Perform a solution of the direct problem with the correct boundary conditions.
double d
Constant to define boundary conditions.
double b
Constant to define boundary conditions.
Class for the definition of some general parameters, the parameters must be defined from the file ITH...
IOdictionary * ITHACAdict
Dictionary for input objects from file.
static ITHACAparameters * getInstance()
Gets an instance of ITHACAparameters, to be used if the instance is already existing.
int cgIterMax
Maximum CG iterations.
double Jtol
Absolute stopping criterion for the CG.
double JtolRel
Relative stopping criterion for the CG.
label hotSide_ind
Index of the hotSide patch.
double H
Heat transfer coefficient [W/(m2 K)].
List< scalar > g
Heat flux at hotSide [W/m2].
autoPtr< Time > _runTime
Time.
Eigen::VectorXd Tmeas
Vector of measured temperatures at the thermocouples locations [K].
autoPtr< fvMesh > _mesh
Mesh.
Eigen::VectorXd fieldValueAtThermocouples(volScalarField &field)
Interpolates the field value at the thermocouples points.
List< scalar > gTrue
True heat flux at hotSide [w/m2].
virtual void readThermocouples()
Identifies in the mesh the cells corresponding to the termocouples locations.
double k
Thermal diffusivity [W/(m K)].
autoPtr< volScalarField > _T
Temperature field.
Header file of the inverseLaplacianProblem_CG class.
Header file of the inverseLaplacianProblem_paramBC class.
void exportSolution(GeometricField< Type, PatchField, GeoMesh > &s, fileName subfolder, fileName folder, word fieldName)
Export a field to file in a certain folder and subfolder.
double LinfNorm(GeometricField< scalar, fvPatchField, volMesh > &field)
double errorLinfRel(GeometricField< T, fvPatchField, volMesh > &field1, GeometricField< T, fvPatchField, volMesh > &field2, List< label > *labels)
Computes the relative error between two geometric Fields in Linf norm.
double L2Norm(GeometricField< scalar, fvPatchField, volMesh > &field)
double errorL2Rel(GeometricField< T, fvPatchField, volMesh > &field1, GeometricField< T, fvPatchField, volMesh > &field2, List< label > *labels)
Computes the relative error between two geometric Fields in L2 norm.
double errorL2Abs(GeometricField< vector, fvPatchField, volMesh > &field1, GeometricField< vector, fvPatchField, volMesh > &field2, volScalarField &Volumes)