#include "source.hpp"

Pump::Pump(){
  amplitude_init=1.e-4;
  left_init=0.45;
  right_init=0.55;
  bottom_init=0.45;
  top_init=0.55;
  delta_left_init=0.05;
  delta_right_init=0.05;
  delta_top_init=0.05;
  delta_bottom_init=0.05;
  amplitude_final=1.e-4;
  left_final=0.45;
  right_final=0.55;
  bottom_final=0.45;
  top_final=0.55;
  delta_left_final=0.05;
  delta_right_final=0.05;
  delta_top_final=0.05;
  delta_bottom_final=0.05;
}


double
Pump::get_amplitude(double t){
  return (1-t)*amplitude_init+t*amplitude_final;
}

double
Pump::get_left(double t){
  return (1-t)*left_init+t*left_final;
}

double
Pump::get_right(double t){
  return (1-t)*right_init+t*right_final;
}

double
Pump::get_top(double t){
  return (1-t)*top_init+t*top_final;
}

double
Pump::get_bottom(double t){
  return (1-t)*bottom_init+t*bottom_final;
}

double
Pump::get_left_delta(double t){
  return (1-t)*delta_left_init+t*delta_left_final;
}

double
Pump::get_right_delta(double t){
  return (1-t)*delta_right_init+t*delta_right_final;
}

double
Pump::get_top_delta(double t){
  return (1-t)*delta_top_init+t*delta_top_final;
}

double
Pump::get_bottom_delta(double t){
  return (1-t)*delta_bottom_init+t*delta_bottom_final;
}

Cloud::Cloud(){
  amplitude_init=1.e-4;
  left_init=0.45;
  right_init=0.55;
  delta_left_init=0.05;
  delta_right_init=0.05;
  amplitude_final=1.e-4;
  left_final=0.45;
  right_final=0.55;
  delta_left_final=0.05;
  delta_right_final=0.05;
}

double
Cloud::get_amplitude(double t){
  return (1-t)*amplitude_init+t*amplitude_final;
}

double
Cloud::get_amplitude_max(){
  return max(amplitude_init,amplitude_final);
}

double
Cloud::get_left(double t){
  return (1-t)*left_init+t*left_final;
}

double
Cloud::get_right(double t){
  return (1-t)*right_init+t*right_final;
}

double
Cloud::get_left_delta(double t){
  return (1-t)*delta_left_init+t*delta_left_final;
}

double
Cloud::get_right_delta(double t){
  return (1-t)*delta_right_init+t*delta_right_final;
}


Pump*
Source::addPump(){
  Pump* pump=new Pump;
  pumps.push_back(pump);
  return pump;
}

void
Source::removePump(Pump* pump){
  for(auto it=pumps.begin();it!=pumps.end();++it){
    if(*it==pump){
      delete *it;
      pumps.erase(it);
      return;
    }
  }
}

Cloud*
Source::addCloud(){
  Cloud* cloud=new Cloud;
  clouds.push_back(cloud);
  return cloud;
}

void
Source::removeCloud(Cloud* cloud){
  for(auto it=clouds.begin();it!=clouds.end();++it){
    if(*it==cloud){
      delete *it;
      clouds.erase(it);
      return;
    }
  }
}
