Loading...
Searching...
No Matches
Ptot_time.C
Go to the documentation of this file.
1#include "Ptot_time.H"
2
4
5Ptot_time::Ptot_time(int argc, char* argv[], label Nsampled)
6{
7 Npoints = Nsampled;
8 modelOutput.resize(Npoints);
9 modelOutput.setZero();
10 name = {"Ptot_time"};
11#include "setRootCase.H"
12#include "createTime.H"
13#include "createMesh.H"
14#include "createpowerDens.H"
15}
16
17void Ptot_time::buildMO(std::string dir, label t)
18{
19 Time& runTime = _runTime();
20 fvMesh& mesh = _mesh();
21 volScalarField& powerDens = _powerDens();
22 std::string folder = dir;
23
24 if (ITHACAutilities::check_folder(folder) == true)
25 {
26 for (label j = 0; j < Npoints; j++)
27 {
28 folder.append(std::to_string(j));
29 folder.append("/");
31
32 for (label i = 0; i < ptrfield.size(); i++)
33 {
34 if (i == t)
35 {
36 modelOutput(j) = fvc::domainIntegrate(ptrfield[i]).value();
37 }
38 }
39
40 folder = dir;
41 ptrfield.clear();
42 }
43
44 MObuilt = true;
45 }
46 else
47 {
48 std::cout << "Outputs of the model are not computed yet, programm aborted" <<
49 std::endl;
50 }
51}
Foam::fvMesh & mesh
Definition createMesh.H:47
Foam::Time & runTime
Definition createTime.H:33
label Npoints
Number of points for which simulation is run.
Definition FofM.H:57
std::string name
Name of the figure of merit.
Definition FofM.H:59
Eigen::VectorXd modelOutput
Vector to store the desired output of the model, i.e. the figure of merit.
Definition FofM.H:49
bool MObuilt
boolean variable to check if the model output is computed (true) or not (false)
Definition FofM.H:61
autoPtr< Time > _runTime
Definition FofM.H:52
PtrList< volScalarField > ptrfield
list of pointers to scalar and vector field
Definition FofM.H:54
autoPtr< fvMesh > _mesh
dummy variables to transform FofM into a class
Definition FofM.H:51
Ptot_time()
Definition Ptot_time.C:3
autoPtr< volScalarField > _powerDens
List of pointers to power density field.
Definition Ptot_time.H:51
void buildMO(std::string dir, label t)
Method that computes the total power for the snapshot number t (starting from 0), output are sought i...
Definition Ptot_time.C:17
volScalarField & powerDens
void read_fields(PtrList< GeometricField< Type, PatchField, GeoMesh > > &Lfield, word Name, fileName casename, int first_snap, int n_snap)
Function to read a list of fields from the name of the field and casename.
bool check_folder(word folder)
Checks if a folder exists.
label i
Definition pEqn.H:46