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


Public Member Functions | |
| ElectricField ()=default | |
| void | AddSource (std::shared_ptr< ChargeSource > source) |
| Add a single charge source to the field. | |
| template<typename... Args> | |
| void | AddSources (Args &&... args) |
| Add multiple charge sources. | |
| Vector3< Quantity< NewtonPerCoulomb > > | GetValueAt (const Vector3< Quantity< Meter > > &point) const override |
| Compute the total electric field at a point. | |
| Quantity< Volt > | GetElectricPotential (const Vector3< Quantity< Meter > > &point) const |
| Compute the total electric potential at a point. | |
| Quantity< CoulombPerCubicMeter > | GetChargeDensityAt (const Vector3< Quantity< Meter > > &point) const |
| Compute the total charge density at a point. | |
| template<typename T , typename = std::enable_if<is_charge_source_v<T> >> | |
| std::unordered_set< std::shared_ptr< T > > | GetChargeSources () const |
| Get all sources of a specific charge source type. | |
| Quantity< Coulomb > | GetTotalChargeValue () const |
| Get the total charge of all sources combined. | |
| void | Clear () |
| Remove all sources from the field. | |
| void | RemoveSource (const std::shared_ptr< ChargeSource > &source) |
| Remove a specific source from the field. | |
| template<typename... Args> | |
| void | RemoveSources (Args &&... args) |
| Remove multiple sources. | |
| std::unordered_set< std::shared_ptr< ChargeSource > > | GetSources () const |
| Get all sources currently in the field. | |
| std::string | toString () const |
| Convert the field to a string representation. | |
Public Member Functions inherited from Phyth::Field< Vector3< Quantity< NewtonPerCoulomb > > > | |
| virtual | ~Field ()=default |
| virtual void | Update () |
| Update the field state (for time-varying fields) | |
Private Attributes | |
| std::unordered_set< std::shared_ptr< ChargeSource > > | sources_ |
Additional Inherited Members | |
Public Types inherited from Phyth::Field< Vector3< Quantity< NewtonPerCoulomb > > > | |
| using | value_type = Vector3< Quantity< NewtonPerCoulomb > > |
Electric field composed of multiple charge sources.
ElectricField aggregates multiple ChargeSource objects and computes the total electric field, potential, and charge density at any point by summing their contributions.
This class implements the Field interface, returning a Vector3 of NewtonPerCoulomb quantities (electric field intensity E).
Example: ElectricField field;
auto point_charge = std::make_shared<PointCharge>(1.0_C, Vector3{0_m, 0_m, 0_m}); field.AddSource(point_charge);
auto point = Vector3<Quantity<Meter>>(1.0_m, 0_m, 0_m); auto E = field.GetValueAt(point); // Total E-field auto V = field.GetElectricPotential(point); // Total potential
Definition at line 31 of file ElectricField.hpp.
|
default |
|
inline |
Add a single charge 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 43 of file ElectricField.hpp.
|
inline |
Add multiple charge sources.
| Args | Parameter pack of shared_ptr<ChargeSource> |
| args | The sources to add |
Example: field.AddSources(charge1, charge2, dipole);
Definition at line 59 of file ElectricField.hpp.
|
inline |
Remove all sources from the field.
Definition at line 152 of file ElectricField.hpp.
|
inline |
Compute the total charge density at a point.
Sums the charge density contribution from all sources.
| point | Position in 3D space (meters) |
Definition at line 106 of file ElectricField.hpp.
|
inline |
Get all sources of a specific charge source type.
| T | The charge source type to filter by (must satisfy is_charge_source_v) |
Example: auto point_charges = field.GetChargeSources<PointCharge>(); // Only returns sources that are PointCharge instances
Definition at line 126 of file ElectricField.hpp.
|
inline |
Compute the total electric potential at a point.
Sums the electric potential contribution from all sources.
| point | Position in 3D space (meters) |
Definition at line 89 of file ElectricField.hpp.
|
inline |
Get all sources currently in the field.
Definition at line 181 of file ElectricField.hpp.
Get the total charge of all sources combined.
Sums the total charge value from each source.
Definition at line 143 of file ElectricField.hpp.
|
inlineoverridevirtual |
Compute the total electric field at a point.
Sums the electric field contribution from all sources.
| point | Position in 3D space (meters) |
Implements Phyth::Field< Vector3< Quantity< NewtonPerCoulomb > > >.
Definition at line 72 of file ElectricField.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 163 of file ElectricField.hpp.
|
inline |
Remove multiple sources.
| Args | Parameter pack of shared_ptr<ChargeSource> |
| args | The sources to remove |
Definition at line 176 of file ElectricField.hpp.
|
inline |
Convert the field to a string representation.
Definition at line 190 of file ElectricField.hpp.
|
private |
Definition at line 197 of file ElectricField.hpp.