Phyth v0.1.0
A dimensional safe C++ header-only mechanics and electromagnetics simulation library.
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
Phyth::CombineField< FieldT > Class Template Reference

Combine multiple fields of the same type. More...

#include <Field.hpp>

Inheritance diagram for Phyth::CombineField< FieldT >:
Inheritance graph
[legend]
Collaboration diagram for Phyth::CombineField< FieldT >:
Collaboration graph
[legend]

Public Member Functions

void AddField (std::shared_ptr< FieldT > field)
 Add a field to the combination.
 
- Public Member Functions inherited from Phyth::Field< FieldT::value_type >
virtual ~Field ()=default
 
virtual FieldT::value_type 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)
 

Protected Attributes

std::unordered_set< std::shared_ptr< FieldT > > fields_
 

Additional Inherited Members

- Public Types inherited from Phyth::Field< FieldT::value_type >
using value_type = FieldT::value_type
 

Detailed Description

template<typename FieldT>
class Phyth::CombineField< FieldT >

Combine multiple fields of the same type.

CombineField aggregates multiple Field objects and presents them as a single field. The combined behavior is determined by subclasses that override GetValueAt.

Template Parameters
FieldTThe field type to combine (must inherit from Field)

Example: class CombinedElectricField : public CombineField<ElectricField> { [[nodiscard]] value_type GetValueAt(const Vector3<Quantity<Meter>>& point) const override { value_type total = 0_V/m; for (const auto& field : fields_) { total += field->GetValueAt(point); } return total; } }; CombinedElectricField combined; combined.AddField(pointChargeField); combined.AddField(uniformField);

Definition at line 123 of file Field.hpp.

Member Function Documentation

◆ AddField()

template<typename FieldT >
void Phyth::CombineField< FieldT >::AddField ( std::shared_ptr< FieldT >  field)
inline

Add a field to the combination.

Parameters
fieldShared pointer to the field to add

Fields are stored in an unordered_set, so duplicates are prevented and ownership is shared.

Definition at line 135 of file Field.hpp.

Member Data Documentation

◆ fields_

template<typename FieldT >
std::unordered_set<std::shared_ptr<FieldT> > Phyth::CombineField< FieldT >::fields_
protected

Definition at line 140 of file Field.hpp.


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