Skip to content

Instantly share code, notes, and snippets.

@ejjunju
Last active December 4, 2017 16:48
Show Gist options
  • Save ejjunju/76e5189908b6e60dfe64dcdae27ee02c to your computer and use it in GitHub Desktop.
Save ejjunju/76e5189908b6e60dfe64dcdae27ee02c to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
using namespace std;
class Div{//Module Divison or Spillway
public:
int id;
int ds; //Downstream module
float H[10];//elevation curve (moh)
float Q[10];//Outflow Curve (m3/s) Q[10][]
};
class obj{//Module
public:
int Type;// 1 dam, tunnel etc Route 0 =
int id;//Id of object
int nds;//Number of dowsntream components or spillways for a dam
int *ds;//Array of downstrean components that receive flow
int nt; //Number of timesteps
float *Qin; //Inflow
float *Qout;//Outflow
float **QoutDS; //Outflow dividd into difefrent downstream components
float H[10];//elevation curve (moh)
float **Q;//Outflow Curve (m3/s) Q[10][]
float **S;//Storage curve (Mm3)
Div *Spillway; // Spillways in the module
obj(){};//Default constructor
void makeobj(int,int,int); //add data to object
void Ruting(); //Ruting of Inflow through an object
void DivideQout2DS(); //Divides Outflow among the different components
};
void obj::makeobj(int id,int nt,int nds){
this->id=id;
this->ds=new int [nds];
this->nt=nt;
this->Qin=new float [nt];
this->Qout=new float [nt];
}
int main(int argc, const char * argv[])
{
cout << "Starting" << endl;
string s;
//Inpect arguments
//argc holds the number of elements in argv
for(int i = 0; i < argc; i++){
printf("Argument %i = %s\n", i, argv[i]);
}
//Number of timesteps
int nt;cin>>s>>nt;//LINE 01
cout<<s<<" = "<<nt<<"\n";
//Create Modules
int nmod; cin>>s>>nmod;//LINE 02
cout<<s<<" = "<<nmod<<"\n";
obj *Module; Module = new obj[nmod];
//Populate Modules with data
//The first Module is run first
for (int i=0;i<nmod;i++){
cout<<"--------------------------------------------------\n";
//Module number
int id;cin>>s>>id;//LINE 03
Module[i].id=id;
cout<<s<<"="<<Module[i].id<<"\n";
//Module Divisions
int nds;cin>>s>>nds;//LINE 04
Module[i].nds=nds;
cout<<s<<"="<<Module[i].nds<<"\n";
Module[i].Spillway= new Div[nds];
//HQ Curves
//HS curves
string h,q;
//Spillways
for(int j=0;j<nds;j++){
cout<<".................................................\n";
Module[i].Spillway[j].id=j;
cout<<"Spillway "<<j+1<<"\n";
cin>>s>>Module[i].Spillway[j].ds;//LINE 05
cout<<s<<"|"<<Module[i].Spillway[j].ds<<"\n";
cin>>h>>q;//LINE 06
cout<<h<<"|"<<q<<"\n";
for(int k=0;k<10;k++){
//cin>>h>>q;
cin>>Module[i].Spillway[j].H[k]>>Module[i].Spillway[j].Q[k];//LINE 07 (n=10)
cout<<Module[i].Spillway[j].H[k]<<"|"<<Module[i].Spillway[j].H[k]<<"\n";
}
}
cout<<"--------------------------------------------------\n";
}
return(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment