Program Listing for File MagneticField.h

Return to documentation for file (include/crpropa/magneticField/MagneticField.h)

#ifndef CRPROPA_MAGNETICFIELD_H
#define CRPROPA_MAGNETICFIELD_H

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

#ifdef CRPROPA_HAVE_MUPARSER
#include "muParser.h"
#endif

namespace crpropa {
class MagneticField: public Referenced {
public:
        virtual ~MagneticField() {
        }
        virtual Vector3d getField(const Vector3d &position) const {
                return Vector3d(0,0,0);
        };
        virtual Vector3d getField(const Vector3d &position, double z) const {
                return getField(position);
        };
};

class PeriodicMagneticField: public MagneticField {
        ref_ptr<MagneticField> field;
        Vector3d origin, extends;
        bool reflective;
public:
        PeriodicMagneticField(ref_ptr<MagneticField> field,
                        const Vector3d &extends);
        PeriodicMagneticField(ref_ptr<MagneticField> field, const Vector3d &extends,
                        const Vector3d &origin, bool reflective);
        Vector3d &getOrigin();
        void setOrigin(const Vector3d &origin);
        Vector3d &getExtends();
        void setExtends(const Vector3d &origin);
        bool isReflective();
        void setReflective(bool reflective);
        Vector3d getField(const Vector3d &position) const;
};

class MagneticFieldList: public MagneticField {
        std::vector<ref_ptr<MagneticField> > fields;
public:
        void addField(ref_ptr<MagneticField> field);
        Vector3d getField(const Vector3d &position) const;
};

class MagneticFieldEvolution: public MagneticField {
        ref_ptr<MagneticField> field;
        double m;
public:
        MagneticFieldEvolution(ref_ptr<MagneticField> field, double m);
        Vector3d getField(const Vector3d &position, double z = 0) const;
};

class UniformMagneticField: public MagneticField {
        Vector3d value;
public:
        UniformMagneticField(const Vector3d &value) :
                        value(value) {
        }
        Vector3d getField(const Vector3d &position) const {
                return value;
        }
};

class MagneticDipoleField: public MagneticField {
        Vector3d origin;
        Vector3d moment;
        double radius;
public:
        MagneticDipoleField(const Vector3d &origin, const Vector3d &moment, const double radius) :
                        origin(origin), moment(moment), radius(radius) {
        }
        Vector3d getField(const Vector3d &position) const;
};

#ifdef CRPROPA_HAVE_MUPARSER
class RenormalizeMagneticField: public MagneticField {
        ref_ptr<MagneticField> field;
        std::string expression;
        mu::Parser *p;
        double Bmag;
public:
        RenormalizeMagneticField(ref_ptr<MagneticField> field, std::string expression);
        ~RenormalizeMagneticField() { delete p; }
        Vector3d getField(const Vector3d &position);
};
#endif

} // namespace crpropa

#endif // CRPROPA_MAGNETICFIELD_H