hips
Loading...
Searching...
No Matches
ex_3.cc
Go to the documentation of this file.
1
18
20
21#include <iostream>
22#include <vector>
23#include <memory>
24#include "hips.h"
25
26using namespace std;
27
29int main() {
30
31 double C_param = 0.5; // Eddy turnover rate multiplier
32 int forceTurb = 2; // Forcing parameter to impose turbulent profile
33 int nVar = 1; // Number of scalar fields
34 vector<double> ScHips = {1.0}; // Schmidt numbers for low and high diffusivity
35 bool performReaction = false;
36
37 hips HiPS(C_param, forceTurb, nVar, ScHips, performReaction);
38
39 //--------- initialize pseudo CFD variable
40
41 int nCFD = 4; // number of CFD grid cells
42
43 vector<vector<double>> var(nCFD); // var[iCell][iParticle]
44 var[0] = vector<double>(20, 0.0); // 20 particles in cell 0
45 var[1] = vector<double>(40, 0.0); // 40 particles in cell 1
46 var[2] = vector<double>(60, 0.0); // 60 particles in cell 2
47 var[3] = vector<double>(80, 0.0); // 80 particles in cell 3
48
49 vector<vector<double>> w(nCFD);
50 w[0] = vector<double>(20, 1.0/20); // uniform particle weights in cell 0
51 w[1] = vector<double>(40, 1.0/40); // uniform particle weights in cell 1
52 w[2] = vector<double>(60, 1.0/60); // uniform particle weights in cell 2
53 w[3] = vector<double>(80, 1.0/80); // uniform particle weights in cell 3
54
55 for(int i=0; i<nCFD; i++) // initialize variable values
56 for(int k=var[i].size()/2; k<var[i].size(); k++)
57 var[i][k] = 1.0;
58
60
62
63 for(int iCell=0; iCell<nCFD; iCell++) {
64
65 cout << endl << "running HiPS in cell " << iCell << endl;
66
67 //---------- reset tree
68
69 double tau0 = 1.0; // time scale for the largest eddies
70 int nLevels = 9; // Number of levels
71 double domainLength = 1.0; // domain length scale
72
73 HiPS.set_tree(nLevels, domainLength, tau0);
74
75 //---------- set variables (CFD particles to HiPS parcels)
76
77 HiPS.set_varData(var[iCell], w[iCell], "mixf");
78
79 //---------- advance hips
80
81 double tRun = 300.0;
82 HiPS.calculateSolution(tRun);
83
84 //---------- get variables (HiPS parcels to CFD particles)
85
86 var[iCell] = HiPS.get_varData()[0];
87 }
88
90
91 return 0;
92}
Definition hips.h:16
void set_tree(int nLevels_, double domainLength_, double tau0_)
Sets up the HiPS tree using explicitly specified tree parameters.
Definition hips.cc:124
std::vector< std::vector< double > > get_varData()
Retrieves the final data from the simulation.
Definition hips.cc:1420
void calculateSolution(const double tRun, bool shouldWriteData=false)
Runs the HiPS simulation, advancing the solution using eddy events.
Definition hips.cc:649
void set_varData(std::vector< double > &v, std::vector< double > &w, const std::string &varN)
Assigns variables, their corresponding weights, and names to the parcels in the HiPS tree.
Definition hips.cc:343
int main()
Definition ex_3.cc:29