Program Listing for File AdvectionField.h

Return to documentation for file (include/crpropa/advectionField/AdvectionField.h)

#ifndef CRPROPA_ADVECTIONFIELD_H
#define CRPROPA_ADVECTIONFIELD_H


#include <string>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <sstream>

#include "crpropa/Vector3.h"
#include "crpropa/Referenced.h"
#include "crpropa/Units.h"

namespace crpropa {

class AdvectionField: public Referenced {
public:
        virtual ~AdvectionField() {
        }
        virtual Vector3d getField(const Vector3d &position) const = 0;
        virtual double getDivergence(const Vector3d &position) const = 0;
};


class AdvectionFieldList: public AdvectionField {
        std::vector<ref_ptr<AdvectionField> > fields;
public:
        void addField(ref_ptr<AdvectionField> field);
        Vector3d getField(const Vector3d &position) const;
        double getDivergence(const Vector3d &position) const;
};


class UniformAdvectionField: public AdvectionField {
        Vector3d value;
public:
        UniformAdvectionField(const Vector3d &value);
        Vector3d getField(const Vector3d &position) const;
        double getDivergence(const Vector3d &position) const;

        std::string getDescription() const;
};


class ConstantSphericalAdvectionField: public AdvectionField {
        Vector3d origin; //origin of the advection sphere
        double vWind; // wind velocity
public:
        ConstantSphericalAdvectionField(const Vector3d origin, double vWind);
        Vector3d getField(const Vector3d &position) const;
        double getDivergence(const Vector3d &position) const;

        void setOrigin(const Vector3d origin);
        void setVWind(double vMax);

        Vector3d getOrigin() const;
        double getVWind() const;

        std::string getDescription() const;


};

class SphericalAdvectionField: public AdvectionField {
        Vector3d origin; //origin of the advection sphere
        double radius; //radius of the advection sphere
        double vMax; // maximum wind velocity
        double tau; // transition distance
        double alpha; //tuning parameter
public:
        SphericalAdvectionField(const Vector3d origin, double radius, double vMax, double tau, double alpha);
        Vector3d getField(const Vector3d &position) const;
        double getDivergence(const Vector3d &position) const;

        double getV(const double &r) const;

        void setOrigin(const Vector3d origin);
        void setRadius(double radius);
        void setVMax(double vMax);
        void setTau(double tau);
        void setAlpha(double alpha);

        Vector3d getOrigin() const;
        double getRadius() const;
        double getVMax() const;
        double getTau() const;
        double getAlpha() const;

        std::string getDescription() const;
};

class OneDimensionalCartesianShock: public AdvectionField {
        double compressionRatio; //compression ratio of shock
        double vUp; //upstream velocity
        double lShock; //shock width
public:
        OneDimensionalCartesianShock(double compressionRatio, double vUp, double lShock);
        Vector3d getField(const Vector3d &position) const;
        double getDivergence(const Vector3d &position) const;

        void setComp(double compressionRatio);
        void setVup(double vUp);
        void setShockwidth(double lShock);

        double getComp() const;
        double getVup() const;
        double getShockwidth() const;

        std::string getDescription() const;
};

class OneDimensionalSphericalShock: public AdvectionField {
        double compressionRatio;        //compression ratio of shock
        double vUp;     //upstream velocity
        double lShock;  //shock width
        double rShock;  //shock radius
        bool coolUpstream;      //flag for upstream cooling
public:
        OneDimensionalSphericalShock(double rShock, double vUp, double compressionRatio, double lShock, bool coolUpstream);
        Vector3d getField(const Vector3d &position) const;
        double getDivergence(const Vector3d &position) const;

        void setComp(double compressionRatio);
        void setVup(double vUp);
        void setShockwidth(double lShock);
        void setShockRadius(double rShock);
        void setCooling(bool coolUpstream);

        double getComp() const;
        double getVup() const;
        double getShockwidth() const;
        double getShockRadius() const;
        bool getCooling() const;

        std::string getDescription() const;
};

class ObliqueAdvectionShock: public AdvectionField {
        double compressionRatio; //compression ratio of shock
        double vXUp; //upstream velocity x-component
        double vY; //constant velocity y-component
        double lShock; //shock width

public:
        ObliqueAdvectionShock(double compressionRatio, double vXUp, double vY, double lShock);
        Vector3d getField(const Vector3d &position) const;
        double getDivergence(const Vector3d &position) const;

        void setComp(double compressionRatio);
        void setVup(double vXUp);
        void setVy(double vY);
        void setShockwidth(double lShock);

        double getComp() const;
        double getVup() const;
        double getVy() const;
        double getShockwidth() const;

        std::string getDescription() const;
};

class SphericalAdvectionShock: public AdvectionField {
        Vector3d origin; // origin of the advection sphere
        double r_0; // position of the shock
        double v_0; // constant velocity
        double lambda; //transition width
        double r_rot; // normalization radius for rotation speed
        double v_phi; // rotation speed at r_rot

public:
        SphericalAdvectionShock(const Vector3d origin, double r_0, double v_0, double lambda);

        Vector3d getField(const Vector3d &position) const;
        double getDivergence(const Vector3d &position) const;

        double g(double R) const;
        double g_prime(double R) const;

        void setOrigin(const Vector3d Origin);
        void setR0(double r);
        void setV0(double v);
        void setLambda(double l);
        void setRRot(double r);
        void setAzimuthalSpeed(double vPhi);

        Vector3d getOrigin() const;
        double getR0() const;
        double getV0() const;
        double getLambda() const;
        double getRRot() const;
        double getAzimuthalSpeed() const;

        std::string getDescription() const;
};

} // namespace crpropa

#endif // CRPROPA_ADVECTIONFIELD_H