|
Phyth v0.1.0
A dimensional safe C++ header-only mechanics and electromagnetics simulation library.
|
Magnetic field composed of multiple magnetic sources. More...
#include <MagneticField.hpp>


Public Member Functions | |
| MagneticField ()=default | |
| void | AddSource (std::shared_ptr< MagneticSource > source) |
| Add a single magnetic source to the field. | |
| template<typename... Args> | |
| void | AddSources (Args &&... args) |
| Add multiple magnetic sources. | |
| Vector3< Quantity< Tesla > > | GetValueAt (const Vector3< Quantity< Meter > > &point) const override |
| Compute the total magnetic field at a point. | |
| template<typename T , typename = std::enable_if<is_magnetic_source_v<T> >> | |
| std::unordered_set< std::shared_ptr< T > > | GetMagneticSources () const |
| Get all sources of a specific type. | |
| void | Clear () |
| Remove all sources from the field. | |
| void | RemoveSource (const std::shared_ptr< MagneticSource > &source) |
| Remove a specific source from the field. | |
| template<typename... Args> | |
| void | RemoveSources (Args &&... args) |
| Remove multiple sources. | |
| std::unordered_set< std::shared_ptr< MagneticSource > > | GetSources () const |
| Get all sources currently in the field. | |
Public Member Functions inherited from Phyth::Field< Vector3< Quantity< Tesla > > > | |
| virtual | ~Field ()=default |
| virtual void | Update () |
| Update the field state (for time-varying fields) | |
Private Attributes | |
| std::unordered_set< std::shared_ptr< MagneticSource > > | sources_ |
Additional Inherited Members | |
Public Types inherited from Phyth::Field< Vector3< Quantity< Tesla > > > | |
| using | value_type = Vector3< Quantity< Tesla > > |
Magnetic field composed of multiple magnetic sources.
MagneticField aggregates multiple MagneticSource objects and computes the total magnetic field at any point by summing their contributions.
This class implements the Field interface, returning a Vector3 of Tesla quantities (magnetic flux density B).
Example: MagneticField field;
auto dipole = std::make_shared<MagneticDipole>(...); field.AddSource(dipole);
auto point = Vector3<Quantity<Meter>>(1.0_m, 0_m, 0_m); auto B = field.GetValueAt(point); // Total B-field at that point
Definition at line 29 of file MagneticField.hpp.
|
default |
|
inline |
Add a single magnetic source to the field.
| source | Shared pointer to the source to add |
Duplicate sources are automatically handled by the unordered_set. Null pointers are silently ignored.
Definition at line 41 of file MagneticField.hpp.
|
inline |
Add multiple magnetic sources.
| Args | Parameter pack of shared_ptr<MagneticSource> |
| args | The sources to add |
Example: field.AddSources(dipole1, dipole2, coil);
Definition at line 57 of file MagneticField.hpp.
|
inline |
Remove all sources from the field.
Definition at line 102 of file MagneticField.hpp.
|
inline |
Get all sources of a specific type.
| T | The magnetic source type to filter by (must satisfy is_magnetic_source_v) |
Example: auto dipoles = field.GetMagneticSources<MagneticDipole>(); // Only returns sources that are MagneticDipole instances
Definition at line 91 of file MagneticField.hpp.
|
inline |
Get all sources currently in the field.
Definition at line 131 of file MagneticField.hpp.
|
inlineoverridevirtual |
Compute the total magnetic field at a point.
Sums the magnetic field contribution from all sources.
| point | Position in 3D space (meters) |
Implements Phyth::Field< Vector3< Quantity< Tesla > > >.
Definition at line 70 of file MagneticField.hpp.
|
inline |
Remove a specific source from the field.
| source | Shared pointer to the source to remove |
If the source is not present, this function does nothing.
Definition at line 113 of file MagneticField.hpp.
|
inline |
Remove multiple sources.
| Args | Parameter pack of shared_ptr<MagneticSource> |
| args | The sources to remove |
Definition at line 126 of file MagneticField.hpp.
|
private |
Definition at line 136 of file MagneticField.hpp.