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];
128 Eigen::VectorXd faceCellDist =
132 scalar faceDist = faceCellDist(faceI);
144 volScalarField&
T =
_T();
148 if (patchI ==
mesh.boundaryMesh().findPatchID(
"coldSide"))
152 else if (patchI ==
mesh.boundaryMesh().findPatchID(
"hotSide"))
172 volScalarField&
T =
_T();
176 if (strcmp( problemID,
"direct") == 0)
182 Info <<
"Problem name should be direct or sensitivity" << endl;
186#if defined(OFVER) && (OFVER == 6)
193 while (
simple.correctNonOrthogonal())
195 if (strcmp( problemID,
"direct") == 0)
199 fvm::laplacian(
DT,
T)
211 word fileName =
"./thermocouplesCellsID";
215 Info <<
"Reading thermocouples cells from file" << endl;
222 Info <<
"Defining positions of thermocouples" << endl;
224 volScalarField&
T =
_T();
231 volScalarField thermocouplesField(
T);
239 "thermocouplesField,");
251 WarningInFunction <<
"readThermocouples function called twice." << endl;
252 WarningInFunction <<
"I am not doing the second reading." << endl;
257 volScalarField& field)
265 dictionary interpolationDict =
266 mesh.solutionDict().subDict(
"interpolationSchemes");
267 autoPtr<Foam::interpolation<scalar >> fieldInterp =
268 Foam::interpolation<scalar>::New(interpolationDict, field);
269 Eigen::VectorXd fieldInt;
282 volScalarField&
T =
_T();
289 const pointField& pp,
290 const cell& cc, labelList pLabels, pointField pLocal)
293 pLocal[pointi] = pp[pLabels[pointi]];
294 double xDim = Foam::max(pLocal & Foam::vector(1, 0, 0))
295 - Foam::min(pLocal & Foam::vector(1, 0, 0));
296 double yDim = Foam::max(pLocal & Foam::vector(0, 1, 0))
297 - Foam::min(pLocal & Foam::vector(0, 1, 0));
298 double zDim = Foam::max(pLocal & Foam::vector(0, 0, 1))
299 - Foam::min(pLocal & Foam::vector(0, 0, 1));
300 Foam::vector dim (xDim, yDim, zDim);
309 argList& args =
_args();
312 instantList Times =
runTime.times();
315 _simple = autoPtr<simpleControl>
322 _T = autoPtr<volScalarField>
337 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)