Phyth v0.1.0
A dimensional safe C++ header-only mechanics and electromagnetics simulation library.
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
Phyth::Field< T > Class Template Referenceabstract

Base class for physical fields (scalar or vector) More...

#include <Field.hpp>

Public Types

using value_type = T
 

Public Member Functions

virtual ~Field ()=default
 
virtual T GetValueAt (const Vector3< Quantity< Meter > > &point) const =0
 Get the field value at a specific point in space.
 
virtual void Update ()
 Update the field state (for time-varying fields)
 

Detailed Description

template<typename T>
class Phyth::Field< T >

Base class for physical fields (scalar or vector)

Field is an abstract interface for any physical quantity that varies over space, such as:

Template Parameters
TThe value type returned by the field (e.g., Quantity<Voltage> for scalar potential, or Vector3<Quantity<ElectricFieldIntensity>> for vector fields)

Example: class ElectricField : public Field<Vector3<Quantity<ElectricFieldIntensity>>> { [[nodiscard]] value_type GetValueAt(const Vector3<Quantity<Meter>>& point) const override { // Compute E-field at the given position return {0_V/m, 0_V/m, -1.0_V/m}; // uniform field for demo } };

class TemperatureField : public Field<Quantity<Kelvin>> { [[nodiscard]] value_type GetValueAt(const Vector3<Quantity<Meter>>& point) const override { return 300.0_K; // uniform temperature } };

Definition at line 38 of file Field.hpp.

Member Typedef Documentation

◆ value_type

template<typename T >
using Phyth::Field< T >::value_type = T

Definition at line 40 of file Field.hpp.

Constructor & Destructor Documentation

◆ ~Field()

template<typename T >
virtual Phyth::Field< T >::~Field ( )
virtualdefault

Member Function Documentation

◆ GetValueAt()

template<typename T >
virtual T Phyth::Field< T >::GetValueAt ( const Vector3< Quantity< Meter > > &  point) const
pure virtual

Get the field value at a specific point in space.

Parameters
pointPosition in 3D space (Meters)
Returns
The field value at that point

This is the core method of any field. Implementations must handle coordinate bounds and interpolation as needed.

Implemented in Phyth::Electromagnetics::ElectricField, and Phyth::Electromagnetics::MagneticField.

◆ Update()

template<typename T >
virtual void Phyth::Field< T >::Update ( )
inlinevirtual

Update the field state (for time-varying fields)

This method can be overridden to advance time-dependent fields (e.g., electromagnetic waves, changing boundary conditions). The default implementation does nothing.

Definition at line 62 of file Field.hpp.


The documentation for this class was generated from the following file: