43 int argc,
char* argv[])
73 Info <<
"Iteration " <<
cgIter + 1 << endl;
83 volScalarField&
T =
_T();
85 "./ITHACAoutput/CGtest/",
T.name());
99 volScalarField& lambda =
_lambda();
101 "./ITHACAoutput/CGtest/", lambda.name());
105 volScalarField& deltaT =
_deltaT();
107 "./ITHACAoutput/CGtest/", deltaT.name());
114 volScalarField&
T =
_T();
115 volScalarField& lambda =
_lambda();
116 volScalarField& deltaT =
_deltaT();
133 volScalarField& lambda =
_lambda();
154 Info <<
"beta = " <<
beta << endl;
163 Info <<
"J = " <<
J << endl;
167 Info <<
"Convergence reached in " <<
cgIter <<
" iterations" << endl;
170 else if (Foam::mag((Jold -
J) /
J) <=
JtolRel)
172 Info <<
"Relative tolerance criteria meet in " <<
cgIter <<
" iterations" <<
174 Info <<
"|Jold - J| / |J| = " << Foam::mag((Jold -
J) /
J) << endl;
forAll(example_CG.gList, solutionI)
#define M_Assert(Expr, Msg)
int conjugateGradientConvergenceCheck()
Convergence cher for the conjugate gradient method.
inverseLaplacianProblemTotalHeatMeasure_CG()
int conjugateGradient()
Conjugate gradient method.
void computeSearchStep()
Compute the search step beta.
void computeGradJ()
Computes the gradient of cost function J and its L2 norm.
Implementation of a Alifanov's regularization to solve inverse Laplacian problems.
int cgIterMax
Maximum CG iterations.
Eigen::VectorXd Tsens
Vector of solutions of the sensitivity problem at the thermocouples points.
Eigen::MatrixXd Jlist
Vector to store the const function J.
void set_valueFraction()
Set valueFraction list values for Robin condition.
PtrList< volScalarField > lambdaField
List of adjoint solutions.
double gamma
Conjugate coefficient.
bool saveSolInLists
Flag to save solutions in lists.
double Jtol
Absolute stopping criterion for the CG.
int cgIter
Conjugate Gradient (CG) interations counter.
double gamma_den
Denoinator of the conjugate coefficient.
void sensibilitySolAtThermocouplesLocations()
Fill the Foam::vector containing the values of the sensitivity solution at the thermocouples location...
double beta
CG search step size.
void updateHeatFlux()
Updates the heat flux in the conjugate gradient iterations.
List< scalar > gradJ
Gradient of the cost function.
bool interpolation
Flag for interpolation of the temperature measurements.
List< scalar > P
Search direction.
void solveSensitivity()
Solve sensibility problem.
double gradJ_L2norm
L2 norm of the gradient of J.
PtrList< volScalarField > Tfield
List of temperature solutions.
double JtolRel
Relative stopping criterion for the CG.
autoPtr< volScalarField > _deltaT
Sensibility temperature field.
void solveAdjoint()
Solve adjoint problem.
PtrList< volScalarField > deltaTfield
List of sensitivity solutions.
autoPtr< volScalarField > _lambda
Adjoint field.
void searchDirection()
Computes the search direction P.
void differenceBetweenDirectAndMeasure()
Computes the difference between direct problem solution and measure.
Eigen::VectorXd Tdiff
Difference between computed and measured temperatures at the thermocouples.
label hotSide_ind
Index of the hotSide patch.
List< scalar > g
Heat flux at hotSide [W/m2].
double J
Cost funtion [K^2].
void restart()
Restart fields.
List< List< scalar > > gList
List of boundary heat fluxes.
void set_g()
Set the right g size and fills it with zeros.
autoPtr< fvMesh > _mesh
Mesh.
void solveDirect()
Solve direct problem.
autoPtr< volScalarField > _T
Temperature field.
Header file of the inverseLaplacianProblemTotalHeatMeasure_CG 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.
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 ...
double integralOnPatch(fvMesh &mesh, volScalarField &field, word patch)
Evaluate the integral on a patch.