44 DT(
"DT", dimensionSet(1, 1, -3, -1, 0, 0, 0), 1.0)
46 _args = autoPtr<argList>
48 new argList(argc, argv)
51 if (!
_args->checkRootCase())
53 Foam::FatalError.exit();
56 argList& args =
_args();
59 _simple = autoPtr<simpleControl>
85 nProcs = Pstream::nProcs();
92 volScalarField&
T =
_T();
103 volScalarField&
T =
_T();
105 volScalarField field(
T);
110 const labelUList& faceCells = cPatch.faceCells();
111 M_Assert(faceCells.size() == list.size(),
"Inpust list has the wrong size.");
115 label faceOwner = faceCells[faceI] ;
116 field[faceOwner] = list[faceI];
127 Eigen::VectorXd faceCellDist =
131 scalar faceDist = faceCellDist(faceI);
142 volScalarField&
T =
_T();
146 if (patchI ==
mesh.boundaryMesh().findPatchID(
"coldSide"))
150 else if (patchI ==
mesh.boundaryMesh().findPatchID(
"hotSide"))
170 volScalarField&
T =
_T();
174 if (strcmp( problemID,
"direct") == 0)
180 Info <<
"Problem name should be direct or sensitivity" << endl;
184#if defined(OFVER) && (OFVER == 6)
191 while (
simple.correctNonOrthogonal())
193 if (strcmp( problemID,
"direct") == 0)
197 fvm::laplacian(
DT,
T)
209 word fileName =
"./thermocouplesCellsID";
213 Info <<
"Reading thermocouples cells from file" << endl;
220 Info <<
"Defining positions of thermocouples" << endl;
222 volScalarField&
T =
_T();
228 volScalarField thermocouplesField(
T);
235 "thermocouplesField,");
247 WarningInFunction <<
"readThermocouples function called twice." << endl;
248 WarningInFunction <<
"I am not doing the second reading." << endl;
253 volScalarField& field)
261 dictionary interpolationDict =
262 mesh.solutionDict().subDict(
"interpolationSchemes");
263 autoPtr<Foam::interpolation<scalar>> fieldInterp =
264 Foam::interpolation<scalar>::New(interpolationDict, field);
265 Eigen::VectorXd fieldInt;
277 volScalarField&
T =
_T();
284 const pointField& pp,
285 const cell& cc, labelList pLabels, pointField pLocal)
288 pLocal[pointi] = pp[pLabels[pointi]];
289 double xDim = Foam::max(pLocal & Foam::vector(1, 0, 0))
290 - Foam::min(pLocal & Foam::vector(1, 0, 0));
291 double yDim = Foam::max(pLocal & Foam::vector(0, 1, 0))
292 - Foam::min(pLocal & Foam::vector(0, 1, 0));
293 double zDim = Foam::max(pLocal & Foam::vector(0, 0, 1))
294 - Foam::min(pLocal & Foam::vector(0, 0, 1));
295 Foam::vector dim (xDim, yDim, zDim);
304 argList& args =
_args();
307 instantList Times =
runTime.times();
310 _simple = autoPtr<simpleControl>
317 _T = autoPtr<volScalarField>
332 Info <<
"Ready for new computation" << endl;
forAll(example_CG.gList, solutionI)
#define M_Assert(Expr, Msg)
static Eigen::Matrix< type_matrix, Eigen::Dynamic, Eigen::Dynamic > List2EigenMatrix(List< type_matrix > list)
Convert a Foam List into an Eigen matrix with one column.
static List< type_matrix > EigenMatrix2List(Eigen::Matrix< type_matrix, Eigen::Dynamic, Eigen::Dynamic > matrix)
Convert an Eigen matrix with one column into a Foam List.
static ITHACAparameters * getInstance()
Gets an instance of ITHACAparameters, to be used if the instance is already existing.
Eigen::VectorXd Tdiff
Difference between computed and measured temperatures at the thermocouples.
label hotSide_ind
Index of the hotSide patch.
dimensionedScalar DT
Dummy thermal conductivity with unitary value.
List< vector > thermocouplesPos
List containing the positions of the thermocouples.
double H
Heat transfer coefficient [W/(m2 K)].
List< scalar > Tf
Temperature at coldSide [K].
autoPtr< simpleControl > _simple
simpleControl
List< scalar > g
Heat flux at hotSide [W/m2].
bool thermocouplesRead
Flag to know if thermocouples file was read.
Eigen::VectorXd Tdirect
Vector of computed temperatures at the thermocouples locations [K].
void restart()
Restart fields.
List< scalar > homogeneousBCcoldSide
List of zeros of the size of coldSide patch.
List< scalar > valueFraction
Value fraction for the Robin BC.
autoPtr< Time > _runTime
Time.
scalar homogeneousBC
Homogenerous BC.
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.
Eigen::VectorXd Tmeas
Vector of measured temperatures at the thermocouples locations [K].
virtual void assignDirectBC()
Set boundary condition of the direct problem.
void set_valueFraction()
Set valueFraction list values for Robin condition.
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 set_g()
Set the right g size and fills it with zeros.
label coldSide_ind
Index of the coldSide patch.
autoPtr< fvMesh > _mesh
Mesh.
Eigen::VectorXd fieldValueAtThermocouples(volScalarField &field)
Interpolates the field value at the thermocouples points.
List< scalar > refGrad
Reference gradient for the Robin BC.
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.
inverseLaplacianProblem()
Null constructor.
void differenceBetweenDirectAndMeasure()
Computes the difference between direct problem solution and measures Saves the difference vector in T...
int thermocouplesNum
Number of thermocouples.
double k
Thermal diffusivity [W/(m K)].
void solveDirect()
Solve direct problem.
label nProcs
Number of processors.
autoPtr< volScalarField > _T
Temperature field.
List< int > thermocouplesCellID
List of cells indices containing a thermocouple.
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
bool podex
Boolean variable, it is 1 if the POD has already been computed, else 0.
List< vector > TCpos(thermocouplesPosition.lookup("positions"))
Header file of the inverseLaplacianProblem 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 ...
List< Eigen::MatrixXd > readMatrix(word folder, word mat_name)
Read a three dimensional matrix from a txt file in Eigen format.
void assignMixedBC(GeometricField< Type, fvPatchField, volMesh > &field, label BC_ind, List< Type > &value, List< Type > &grad, List< scalar > &valueFrac)
Assign value of a boundary condition of type "mixed".
void assignIF(GeometricField< Type, fvPatchField, volMesh > &s, Type value)
Assign internal field.
bool check_pod()
Check if the POD data folder "./ITHACAoutput/POD" exists.
bool check_off()
Check if the offline data folder "./ITHACAoutput/Offline" exists.
void assignBC(GeometricField< scalar, fvPatchField, volMesh > &s, label BC_ind, double value)
Assign uniform Boundary Condition to a volScalarField.
bool check_file(std::string fileName)
Function that returns true if a file exists.
Eigen::VectorXd boudaryFaceToCellDistance(fvMesh &mesh, label BC_ind)
Compute the distance between the boundary face center and the boundary cell center.
simpleControl simple(mesh)