Implementation of a Alifanov's regularization to solve inverse Laplacian problems. More...
#include <inverseLaplacianProblem_CG.H>
Public Member Functions | |
inverseLaplacianProblem_CG () | |
Null constructor. | |
inverseLaplacianProblem_CG (int argc, char *argv[]) | |
Construct with argc and argv. Reads the thermocouples dictionary. | |
virtual | ~inverseLaplacianProblem_CG () |
Destructor. | |
void | set_valueFraction () |
Set valueFraction list values for Robin condition. | |
void | assignAdjointBC () |
Set BC of the adjoint problem. | |
volScalarField | assignAdjointBCandSource () |
Assign the BC for the adjoint problem and returs the source field. | |
void | assignSensitivityBC () |
Set BC and IF of the sensitivity problem. | |
void | solveAdjoint () |
Solve adjoint problem. | |
void | solveSensitivity () |
Solve sensibility problem. | |
void | solve (const char *problemID) |
Solve for direct and sensitivity. | |
void | defineThermocouplesPlane () |
Identifies the plane defined by the thermocouples. | |
void | sensibilitySolAtThermocouplesLocations () |
Fill the Foam::vector containing the values of the sensitivity solution at the thermocouples locations. | |
int | conjugateGradient () |
Conjugate gradient method. | |
void | computeGradJ () |
Computes the gradient of cost function J and its L2 norm. | |
void | searchDirection () |
Computes the search direction P. | |
void | computeSearchStep () |
Compute the search step beta. | |
void | updateHeatFlux () |
Updates the heat flux in the conjugate gradient iterations. | |
int | conjugateGradientConvergenceCheck () |
Convergence cher for the conjugate gradient method. | |
int | isInPlane (double cx, double cy, double cz, Foam::vector thermocoupleCellDim) |
Checks if a cell crosses the interpolation plane. | |
void | writeFields (label folderNumber, const char *folder) |
Writes fields to file. | |
void | thermocouplesInterpolation () |
Interpolates the thermocouples measurements in the plane defined in readThermocouples() using radial basis functions. | |
void | thermocouplesInterpolation (DenseMatrix &RBFweights, DenseMatrix &RBFbasis) |
Interpolates the thermocouples measurements in the plane defined in readThermocouples() using Radial Basis Functions (RBF) Assumes thermocouples are all at the same y coordinate. | |
void | differenceBetweenDirectAndMeasure () |
Computes the difference between direct problem solution and measure. | |
void | restart (word fieldName="all") |
Restart fields. | |
Public Member Functions inherited from inverseLaplacianProblem | |
inverseLaplacianProblem () | |
Null constructor. | |
inverseLaplacianProblem (int argc, char *argv[]) | |
Construct with argc and argv. Reads the thermocouples dictionary. | |
virtual | ~inverseLaplacianProblem () |
Destructor. | |
void | set_g () |
Set the right g size and fills it with zeros. | |
volScalarField | list2Field (List< scalar > list, scalar innerField=0.0) |
Create a field with the hotSide boundary heat flux at the hotSide bounday cells for visualization. | |
void | set_valueFraction () |
Set valueFraction list values for Robin condition. | |
virtual void | solveTrue () |
Solve the direct problem with the true heat flux as boundary condition and fills the measured temeprature vector. | |
virtual void | assignDirectBC () |
Set boundary condition of the direct problem. | |
void | solveDirect () |
Solve direct problem. | |
void | solve (const char *problem) |
Solve Laplacian problem without source term. | |
virtual void | readThermocouples () |
Identifies in the mesh the cells corresponding to the termocouples locations. | |
Eigen::VectorXd | fieldValueAtThermocouples (volScalarField &field) |
Interpolates the field value at the thermocouples points. | |
void | differenceBetweenDirectAndMeasure () |
Computes the difference between direct problem solution and measures Saves the difference vector in Tdiff. | |
Foam::vector | cellDim (const faceList &ff, const pointField &pp, const cell &cc, labelList pLabels, pointField pLocal) |
Compute maximum cell dimension in x, y and z. | |
void | restart () |
Restart fields. | |
Public Member Functions inherited from laplacianProblem | |
laplacianProblem () | |
laplacianProblem (int argc, char *argv[]) | |
Construct with argc and argv. | |
~laplacianProblem () | |
void | truthSolve (List< scalar > mu_now, word folder="./ITHACAoutput/Offline/") |
Perform a truthsolve. | |
void | project (label Nmodes) |
Perform a projection onto the POD modes. | |
Public Member Functions inherited from reductionProblem | |
reductionProblem () | |
Construct Null. | |
~reductionProblem () | |
void | setParameters () |
Set Parameters Problems. | |
void | genRandPar () |
Generate Random Numbers. | |
void | genRandPar (label tsize) |
Generate Random Numbers given the dimension of the training set. | |
void | genEquiPar () |
Generate Equidistributed Numbers. | |
void | truthSolve () |
Perform a TruthSolve. | |
void | assignBC (volVectorField &s, label BC_ind, Vector< double > &value) |
Assign Boundary Condition to a volVectorField. | |
void | assignBC (volScalarField &s, label BC_ind, double &value) |
Assign Boundary Condition to a volScalarField. | |
void | reconstructFromMatrix (PtrList< volVectorField > &rec_field2, PtrList< volVectorField > &modes, label Nmodes, Eigen::MatrixXd coeff_matrix) |
Exact reconstruction using a certain number of modes for vector list of fields and the projection coefficients (volVectorField) | |
void | reconstructFromMatrix (PtrList< volScalarField > &rec_field2, PtrList< volScalarField > &modes, label Nmodes, Eigen::MatrixXd coeff_matrix) |
Exact reconstruction using a certain number of modes for vector list of fields and the projection coefficients (volScalarField) | |
template<typename T , typename G > | |
void | assignIF (T &s, G &value) |
Assign internal field condition. | |
template<typename T > | |
void | computeLift (T &Lfield, T &liftfield, T &omfield) |
Homogenize the snapshot matrix, it works with PtrList of volVectorField and volScalarField. | |
template<typename T > | |
void | computeLiftT (T &Lfield, T &liftfield, T &omfield) |
Virtual function to compute the lifting function. | |
void | liftSolve () |
Virtual function to compute the lifting function for scalar field. | |
void | liftSolveT () |
void | project () |
General projection operation. | |
void | writeMu (List< scalar > mu_now) |
Write out a list of scalar corresponding to the parameters used in the truthSolve. | |
std::vector< SPLINTER::RBFSpline > | getCoeffManifoldRBF (PtrList< volVectorField > snapshots, PtrList< volVectorField > &modes, word rbfBasis="GAUSSIAN") |
Constructs the parameters-coefficients manifold for vector fields, based on RBF-spline model. | |
std::vector< SPLINTER::RBFSpline > | getCoeffManifoldRBF (PtrList< volScalarField > snapshots, PtrList< volScalarField > &modes, word rbfBasis="GAUSSIAN") |
Constructs the parameters-coefficients manifold for scalar fields, based on RBF-spline model. | |
std::vector< SPLINTER::BSpline > | getCoeffManifoldSPL (PtrList< volVectorField > snapshots, PtrList< volVectorField > &modes, label splDeg=3) |
Constructs the parameters-coefficients manifold for vector fields, based on the B-spline model. | |
std::vector< SPLINTER::BSpline > | getCoeffManifoldSPL (PtrList< volScalarField > snapshots, PtrList< volScalarField > &modes, label splDeg=3) |
Constructs the parameters-coefficients manifold for scalar fields, based on the B-spline model. | |
Public Attributes | |
autoPtr< volScalarField > | _lambda |
Adjoint field. | |
autoPtr< volScalarField > | _deltaT |
Sensibility temperature field. | |
List< scalar > | valueFractionAdj |
Value fraction for the adjoint Robin BC. | |
PtrList< volScalarField > | Tfield |
List of temperature solutions. | |
PtrList< volScalarField > | lambdaField |
List of adjoint solutions. | |
PtrList< volScalarField > | deltaTfield |
List of sensitivity solutions. | |
bool | interpolation |
Flag for interpolation of the temperature measurements. | |
bool | interpolationPlaneDefined |
Flag for definition of interpolation plane. | |
int | cgIter |
Conjugate Gradient (CG) interations counter. | |
int | cgIterMax |
Maximum CG iterations. | |
bool | saveSolInLists = 0 |
Flag to save solutions in lists. | |
Eigen::MatrixXd | Jlist |
Vector to store the const function J. | |
double | gradJ_L2norm |
L2 norm of the gradient of J. | |
double | Jtol |
Absolute stopping criterion for the CG. | |
double | JtolRel |
Relative stopping criterion for the CG. | |
double | gamma |
Conjugate coefficient. | |
double | gamma_den |
Denoinator of the conjugate coefficient. | |
double | beta |
CG search step size. | |
List< scalar > | P |
Search direction. | |
List< scalar > | gradJ |
Gradient of the cost function. | |
Eigen::VectorXd | Tsens |
Vector of solutions of the sensitivity problem at the thermocouples points. | |
List< Eigen::MatrixXd > | ArbT |
Temperature reduced matrix. | |
List< Eigen::MatrixXd > | ArbLambda |
Adjoint reduced matrix. | |
List< Eigen::MatrixXd > | ArbDeltaT |
Sensitivity reduced matrix. | |
thermocouplesPlane | interpolationPlane |
Interpolation plane. | |
Eigen::VectorXd | cellsInPlane |
IDs of the cells in the interpolation plane. | |
Public Attributes inherited from inverseLaplacianProblem | |
ITHACAparameters * | para |
autoPtr< volScalarField > | _T |
Temperature field. | |
autoPtr< fvMesh > | _mesh |
Mesh. | |
autoPtr< simpleControl > | _simple |
simpleControl | |
autoPtr< fv::options > | _fvOptions |
fvOptions | |
autoPtr< Time > | _runTime |
Time. | |
dimensionedScalar | DT |
Dummy thermal conductivity with unitary value. | |
double | k |
Thermal diffusivity [W/(m K)]. | |
double | H |
Heat transfer coefficient [W/(m2 K)]. | |
bool | thermocouplesRead = 0 |
Flag to know if thermocouples file was read. | |
int | thermocouplesNum |
Number of thermocouples. | |
double | J |
Cost funtion [K^2]. | |
double | L2norm |
double | LinfNorm |
scalar | homogeneousBC = 0.0 |
Homogenerous BC. | |
List< scalar > | homogeneousBCcoldSide |
List of zeros of the size of coldSide patch. | |
List< scalar > | Tf |
Temperature at coldSide [K]. | |
List< scalar > | refGrad |
Reference gradient for the Robin BC. | |
List< scalar > | valueFraction |
Value fraction for the Robin BC. | |
label | hotSide_ind |
Index of the hotSide patch. | |
label | coldSide_ind |
Index of the coldSide patch. | |
List< scalar > | g |
Heat flux at hotSide [W/m2]. | |
List< List< scalar > > | gList |
List of boundary heat fluxes. | |
List< scalar > | gTrue |
True heat flux at hotSide [w/m2]. | |
List< scalar > | faceCellArea |
List of patch faces areas [m2]. | |
List< vector > | thermocouplesPos |
List containing the positions of the thermocouples. | |
List< int > | thermocouplesCellID |
List of cells indices containing a thermocouple. | |
List< int > | thermocouplesCellProc |
List of incedes of the processors contining each thermocouple. | |
Eigen::VectorXd | Tmeas |
Vector of measured temperatures at the thermocouples locations [K]. | |
Eigen::VectorXd | Tdirect |
Vector of computed temperatures at the thermocouples locations [K]. | |
Eigen::VectorXd | Tdiff |
Difference between computed and measured temperatures at the thermocouples. | |
label | nProcs |
Number of processors. | |
Public Attributes inherited from laplacianProblem | |
PtrList< volScalarField > | Tfield |
List of snapshots for the solution. | |
PtrList< volScalarField > | Tonline |
List of snapshots for the solution. | |
volScalarModes | Tmodes |
List of POD modes. | |
PtrList< fvScalarMatrix > | operator_list |
List of operators. | |
List< scalar > | theta |
Theta (coefficients of the affine expansion) | |
PtrList< volScalarField > | nu_list |
Nu (diffusivity) | |
label | NTmodes |
Number of modes reduced problem. | |
List< Eigen::MatrixXd > | A_matrices |
A matrices. | |
Eigen::MatrixXd | source |
Source vector. | |
autoPtr< volScalarField > | _T |
Temperature field. | |
autoPtr< volScalarField > | _S |
Source Term. | |
autoPtr< volScalarField > | _nu |
Diffusivity. | |
autoPtr< fvMesh > | _mesh |
Mesh. | |
autoPtr< Time > | _runTime |
Time. | |
Public Attributes inherited from reductionProblem | |
label | Pnumber |
Number of parameters. | |
label | Tnumber |
Dimension of the training set (used only when gerating parameters without input) | |
Eigen::MatrixXd | mu |
Row matrix of parameters. | |
Eigen::MatrixXd | mu_range |
Range of the parameter spaces. | |
Eigen::MatrixXd | mu_samples |
Matrix of parameters to be used for PODI, where each row corresponds to a sample point. In this matrix the time dimension is regarded as a parameter for unsteady problems. | |
double | mu_cur |
Current value of the parameter. | |
bool | podex |
Boolean variable, it is 1 if the POD has already been computed, else 0. | |
bool | offline |
Boolean variable, it is 1 if the Offline phase has already been computed, else 0. | |
IOdictionary * | ITHACAdict |
dictionary to store input output infos | |
autoPtr< argList > | _args |
argList | |
ITHACAparallel * | paral |
parallel handling | |
label | folderN = 1 |
Counter to save intermediate steps in the correct folder, for unsteady and some stationary cases. | |
label | counter = 1 |
Counter used for the output of the full order solutions. | |
Eigen::MatrixXi | inletIndex |
Matrix that contains informations about the inlet boundaries. | |
Eigen::MatrixXi | inletPatch |
Matrix that contains informations about the inlet boundaries without specifing the direction Rows = Number of parametrized boundary conditions Cols = 1 Example: example.inletIndex.resize(2, 1); example.inletIndex(0, 0) = 0; example.inletIndex(1, 0) = 1; Means that there are two parametrized boundary conditions of which the first row is of patch 0 and the second row of patch 1. | |
Eigen::MatrixXi | inletIndexT |
Implementation of a Alifanov's regularization to solve inverse Laplacian problems.
In this class, we implement the Alifanov's regularization for solving the inverse problem of estimating the boundary heat flux, given pointwise temperature measurements, in a Laplacian problem
Definition at line 59 of file inverseLaplacianProblem_CG.H.
inverseLaplacianProblem_CG::inverseLaplacianProblem_CG | ( | ) |
Null constructor.
Definition at line 40 of file inverseLaplacianProblem_CG.C.
inverseLaplacianProblem_CG::inverseLaplacianProblem_CG | ( | int | argc, |
char * | argv[] ) |
Construct with argc and argv. Reads the thermocouples dictionary.
Definition at line 42 of file inverseLaplacianProblem_CG.C.
|
inlinevirtual |
Destructor.
Definition at line 69 of file inverseLaplacianProblem_CG.H.
void inverseLaplacianProblem_CG::assignAdjointBC | ( | ) |
Set BC of the adjoint problem.
Definition at line 71 of file inverseLaplacianProblem_CG.C.
volScalarField inverseLaplacianProblem_CG::assignAdjointBCandSource | ( | ) |
Assign the BC for the adjoint problem and returs the source field.
Definition at line 95 of file inverseLaplacianProblem_CG.C.
void inverseLaplacianProblem_CG::assignSensitivityBC | ( | ) |
Set BC and IF of the sensitivity problem.
Definition at line 128 of file inverseLaplacianProblem_CG.C.
void inverseLaplacianProblem_CG::computeGradJ | ( | ) |
Computes the gradient of cost function J and its L2 norm.
Definition at line 377 of file inverseLaplacianProblem_CG.C.
void inverseLaplacianProblem_CG::computeSearchStep | ( | ) |
Compute the search step beta.
Definition at line 411 of file inverseLaplacianProblem_CG.C.
int inverseLaplacianProblem_CG::conjugateGradient | ( | ) |
Conjugate gradient method.
Definition at line 303 of file inverseLaplacianProblem_CG.C.
int inverseLaplacianProblem_CG::conjugateGradientConvergenceCheck | ( | ) |
Convergence cher for the conjugate gradient method.
Definition at line 451 of file inverseLaplacianProblem_CG.C.
void inverseLaplacianProblem_CG::defineThermocouplesPlane | ( | ) |
Identifies the plane defined by the thermocouples.
Definition at line 235 of file inverseLaplacianProblem_CG.C.
void inverseLaplacianProblem_CG::differenceBetweenDirectAndMeasure | ( | ) |
Computes the difference between direct problem solution and measure.
Definition at line 758 of file inverseLaplacianProblem_CG.C.
int inverseLaplacianProblem_CG::isInPlane | ( | double | cx, |
double | cy, | ||
double | cz, | ||
Foam::vector | thermocoupleCellDim ) |
Checks if a cell crosses the interpolation plane.
[in] | cx | X coordinate of the cell center |
[in] | cy | Y coordinate of the cell center |
[in] | cz | Z coordinate of the cell center |
[in] | thermocoupleCellDim | Dimension of the cell |
Definition at line 494 of file inverseLaplacianProblem_CG.C.
void inverseLaplacianProblem_CG::restart | ( | word | fieldName = "all" | ) |
Restart fields.
[in] | fieldName | Name of the field to restart. Options are (T, lambda and deltaT) |
Definition at line 779 of file inverseLaplacianProblem_CG.C.
void inverseLaplacianProblem_CG::searchDirection | ( | ) |
Computes the search direction P.
Definition at line 392 of file inverseLaplacianProblem_CG.C.
void inverseLaplacianProblem_CG::sensibilitySolAtThermocouplesLocations | ( | ) |
Fill the Foam::vector containing the values of the sensitivity solution at the thermocouples locations.
Definition at line 285 of file inverseLaplacianProblem_CG.C.
void inverseLaplacianProblem_CG::set_valueFraction | ( | ) |
Set valueFraction list values for Robin condition.
Definition at line 53 of file inverseLaplacianProblem_CG.C.
void inverseLaplacianProblem_CG::solve | ( | const char * | problemID | ) |
Solve for direct and sensitivity.
Definition at line 185 of file inverseLaplacianProblem_CG.C.
void inverseLaplacianProblem_CG::solveAdjoint | ( | ) |
Solve adjoint problem.
Definition at line 151 of file inverseLaplacianProblem_CG.C.
void inverseLaplacianProblem_CG::solveSensitivity | ( | ) |
Solve sensibility problem.
Definition at line 178 of file inverseLaplacianProblem_CG.C.
void inverseLaplacianProblem_CG::thermocouplesInterpolation | ( | ) |
Interpolates the thermocouples measurements in the plane defined in readThermocouples() using radial basis functions.
Assumes thermocouples are all at the same y coordinate. Assumes all cells have the same dimensions
Definition at line 540 of file inverseLaplacianProblem_CG.C.
void inverseLaplacianProblem_CG::thermocouplesInterpolation | ( | DenseMatrix & | RBFweights, |
DenseMatrix & | RBFbasis ) |
Interpolates the thermocouples measurements in the plane defined in readThermocouples() using Radial Basis Functions (RBF) Assumes thermocouples are all at the same y coordinate.
Assumes all cells have the same dimensions
[in] | RBFweights | Weights of the RBFs |
[in] | RBFbasis | Basis for the RBF interpolation |
Definition at line 649 of file inverseLaplacianProblem_CG.C.
void inverseLaplacianProblem_CG::updateHeatFlux | ( | ) |
Updates the heat flux in the conjugate gradient iterations.
Definition at line 445 of file inverseLaplacianProblem_CG.C.
void inverseLaplacianProblem_CG::writeFields | ( | label | folderNumber, |
const char * | folder ) |
Writes fields to file.
[in] | folder | Folder in which the fields are written |
[in] | folderNumber | Folder number |
Definition at line 506 of file inverseLaplacianProblem_CG.C.
autoPtr<volScalarField> inverseLaplacianProblem_CG::_deltaT |
Sensibility temperature field.
Definition at line 76 of file inverseLaplacianProblem_CG.H.
autoPtr<volScalarField> inverseLaplacianProblem_CG::_lambda |
Adjoint field.
Definition at line 73 of file inverseLaplacianProblem_CG.H.
List<Eigen::MatrixXd> inverseLaplacianProblem_CG::ArbDeltaT |
Sensitivity reduced matrix.
Definition at line 143 of file inverseLaplacianProblem_CG.H.
List<Eigen::MatrixXd> inverseLaplacianProblem_CG::ArbLambda |
Adjoint reduced matrix.
Definition at line 140 of file inverseLaplacianProblem_CG.H.
List<Eigen::MatrixXd> inverseLaplacianProblem_CG::ArbT |
Temperature reduced matrix.
Definition at line 137 of file inverseLaplacianProblem_CG.H.
double inverseLaplacianProblem_CG::beta |
CG search step size.
Definition at line 124 of file inverseLaplacianProblem_CG.H.
Eigen::VectorXd inverseLaplacianProblem_CG::cellsInPlane |
IDs of the cells in the interpolation plane.
Definition at line 149 of file inverseLaplacianProblem_CG.H.
int inverseLaplacianProblem_CG::cgIter |
Conjugate Gradient (CG) interations counter.
Definition at line 97 of file inverseLaplacianProblem_CG.H.
int inverseLaplacianProblem_CG::cgIterMax |
Maximum CG iterations.
Definition at line 100 of file inverseLaplacianProblem_CG.H.
PtrList<volScalarField> inverseLaplacianProblem_CG::deltaTfield |
List of sensitivity solutions.
Definition at line 88 of file inverseLaplacianProblem_CG.H.
double inverseLaplacianProblem_CG::gamma |
Conjugate coefficient.
Definition at line 118 of file inverseLaplacianProblem_CG.H.
double inverseLaplacianProblem_CG::gamma_den |
Denoinator of the conjugate coefficient.
Definition at line 121 of file inverseLaplacianProblem_CG.H.
List<scalar> inverseLaplacianProblem_CG::gradJ |
Gradient of the cost function.
Definition at line 131 of file inverseLaplacianProblem_CG.H.
double inverseLaplacianProblem_CG::gradJ_L2norm |
L2 norm of the gradient of J.
Definition at line 109 of file inverseLaplacianProblem_CG.H.
bool inverseLaplacianProblem_CG::interpolation |
Flag for interpolation of the temperature measurements.
Definition at line 91 of file inverseLaplacianProblem_CG.H.
thermocouplesPlane inverseLaplacianProblem_CG::interpolationPlane |
Interpolation plane.
Definition at line 146 of file inverseLaplacianProblem_CG.H.
bool inverseLaplacianProblem_CG::interpolationPlaneDefined |
Flag for definition of interpolation plane.
Definition at line 94 of file inverseLaplacianProblem_CG.H.
Eigen::MatrixXd inverseLaplacianProblem_CG::Jlist |
Vector to store the const function J.
Definition at line 106 of file inverseLaplacianProblem_CG.H.
double inverseLaplacianProblem_CG::Jtol |
Absolute stopping criterion for the CG.
Definition at line 112 of file inverseLaplacianProblem_CG.H.
double inverseLaplacianProblem_CG::JtolRel |
Relative stopping criterion for the CG.
Definition at line 115 of file inverseLaplacianProblem_CG.H.
PtrList<volScalarField> inverseLaplacianProblem_CG::lambdaField |
List of adjoint solutions.
Definition at line 85 of file inverseLaplacianProblem_CG.H.
List<scalar> inverseLaplacianProblem_CG::P |
Search direction.
Definition at line 128 of file inverseLaplacianProblem_CG.H.
bool inverseLaplacianProblem_CG::saveSolInLists = 0 |
Flag to save solutions in lists.
Definition at line 103 of file inverseLaplacianProblem_CG.H.
PtrList<volScalarField> inverseLaplacianProblem_CG::Tfield |
List of temperature solutions.
Definition at line 82 of file inverseLaplacianProblem_CG.H.
Eigen::VectorXd inverseLaplacianProblem_CG::Tsens |
Vector of solutions of the sensitivity problem at the thermocouples points.
Definition at line 134 of file inverseLaplacianProblem_CG.H.
List<scalar> inverseLaplacianProblem_CG::valueFractionAdj |
Value fraction for the adjoint Robin BC.
Definition at line 79 of file inverseLaplacianProblem_CG.H.