Dynamic Neural Field Composer 0.0.0
A C++20 library and interactive application for building and simulating Dynamic Neural Field (DNF) architectures.
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Attributes | List of all members
dnf_composer::element::Element Class Referenceabstract

Abstract base class for all simulation elements. More...

#include <element.h>

Inheritance diagram for dnf_composer::element::Element:
Collaboration diagram for dnf_composer::element::Element:

Public Member Functions

virtual void addInput (const std::shared_ptr< Element > &inputElement, const std::string &inputComponent="output")
 Register inputElement as an upstream source for this element.
 
void buildInputCache ()
 Cache raw pointers to input component data. Call after all element init()s complete.
 
virtual void changeDimensions (const ElementDimensions &newDimensions)
 Resize all components to newDimensions and re-initialize.
 
virtual std::shared_ptr< Elementclone () const =0
 
void close ()
 
 Element (const ElementCommonParameters &parameters)
 Construct an element with the given common parameters.
 
std::vector< double > getComponent (const std::string &componentName)
 Return a copy of the named component vector.
 
std::vector< std::string > getComponentList () const
 
std::vector< double > * getComponentPtr (const std::string &componentName)
 
const std::unordered_map< std::string, std::vector< double > > * getComponents () const
 Return a read-only pointer to the full components map.
 
ElementCommonParameters getElementCommonParameters () const
 
std::vector< std::shared_ptr< Element > > getInputs ()
 
std::unordered_map< std::shared_ptr< Element >, std::string > getInputsAndComponents ()
 Return all inputs mapped to the component name they expose.
 
ElementLabel getLabel () const
 
int getMaxSpatialDimension () const
 
std::vector< std::shared_ptr< Element > > getOutputs ()
 
int getSize () const
 Return the number of spatial samples (size = round(x_max / d_x)).
 
double getStepSize () const
 Return the spatial resolution (d_x).
 
int getUniqueIdentifier () const
 
std::string getUniqueName () const
 
bool hasInput () const
 
bool hasInput (const std::string &inputElementName, const std::string &inputComponent)
 
bool hasInput (int inputElementId, const std::string &inputComponent)
 
bool hasOutput () const
 
bool hasOutput (const std::string &outputElementName, const std::string &outputComponent)
 
bool hasOutput (int outputElementId, const std::string &outputComponent)
 
virtual void init ()=0
 Initialize the element (called once before the simulation loop).
 
void print () const
 
void removeInput (const std::string &inputElementId)
 
void removeInput (int uniqueId)
 
void removeInputs ()
 
void removeOutput (const std::string &outputElementId)
 Deregister this element as an input of outputElementId.
 
void removeOutput (int uniqueId)
 Deregister this element as an input of the element with uniqueId.
 
void removeOutputs ()
 
void setUniqueName (const std::string &name)
 
virtual void step (double t, double deltaT)=0
 Advance the element by one time step.
 
virtual std::string toString () const =0
 
void updateInput ()
 Pull data from all registered input elements into this element's components.
 
virtual ~Element ()=default
 

Protected Attributes

ElementCommonParameters commonParameters
 Name, label, and spatial dimensions.
 
std::unordered_map< std::string, std::vector< double > > components
 Named data arrays (e.g. "output").
 
std::unordered_map< std::shared_ptr< Element >, std::string > inputs
 Upstream elements and the component they expose.
 
std::unordered_map< std::shared_ptr< Element >, std::string > outputs
 Downstream elements that read this element's output.
 

Detailed Description

Abstract base class for all simulation elements.

Every element owns a set of named data components (e.g. "activation", "output"), a list of input elements, and a list of output elements. Concrete subclasses implement the init / step lifecycle and exchange data via addInput().

Constructor & Destructor Documentation

◆ Element()

dnf_composer::element::Element::Element ( const ElementCommonParameters parameters)
explicit

Construct an element with the given common parameters.

Parameters
parametersName, label, and spatial dimensions.

◆ ~Element()

virtual dnf_composer::element::Element::~Element ( )
virtualdefault

Member Function Documentation

◆ addInput()

void dnf_composer::element::Element::addInput ( const std::shared_ptr< Element > &  inputElement,
const std::string &  inputComponent = "output" 
)
virtual

Register inputElement as an upstream source for this element.

Parameters
inputElementThe element whose output will be read.
inputComponentWhich component of inputElement to read (default: "output").

Reimplemented in dnf_composer::element::Collapse, dnf_composer::element::Expand, dnf_composer::element::FieldCoupling, dnf_composer::element::Resize, and dnf_composer::element::Resize2D.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ buildInputCache()

void dnf_composer::element::Element::buildInputCache ( )

Cache raw pointers to input component data. Call after all element init()s complete.

Here is the caller graph for this function:

◆ changeDimensions()

void dnf_composer::element::Element::changeDimensions ( const ElementDimensions newDimensions)
virtual

Resize all components to newDimensions and re-initialize.

Note
Does not remove connections — call Simulation::changeDimensions to disconnect neighbours before resizing.
Parameters
newDimensionsNew spatial discretization.

Reimplemented in dnf_composer::element::FieldCoupling, and dnf_composer::element::GaussFieldCoupling.

Here is the call graph for this function:

◆ clone()

virtual std::shared_ptr< Element > dnf_composer::element::Element::clone ( ) const
pure virtual

◆ close()

void dnf_composer::element::Element::close ( )

◆ getComponent()

std::vector< double > dnf_composer::element::Element::getComponent ( const std::string &  componentName)

Return a copy of the named component vector.

Parameters
componentNameE.g. "activation", "output", "input".

◆ getComponentList()

std::vector< std::string > dnf_composer::element::Element::getComponentList ( ) const

◆ getComponentPtr()

std::vector< double > * dnf_composer::element::Element::getComponentPtr ( const std::string &  componentName)

◆ getComponents()

const std::unordered_map< std::string, std::vector< double > > * dnf_composer::element::Element::getComponents ( ) const

Return a read-only pointer to the full components map.

◆ getElementCommonParameters()

ElementCommonParameters dnf_composer::element::Element::getElementCommonParameters ( ) const

◆ getInputs()

std::vector< std::shared_ptr< Element > > dnf_composer::element::Element::getInputs ( )

◆ getInputsAndComponents()

std::unordered_map< std::shared_ptr< Element >, std::string > dnf_composer::element::Element::getInputsAndComponents ( )

Return all inputs mapped to the component name they expose.

◆ getLabel()

ElementLabel dnf_composer::element::Element::getLabel ( ) const

◆ getMaxSpatialDimension()

int dnf_composer::element::Element::getMaxSpatialDimension ( ) const

◆ getOutputs()

std::vector< std::shared_ptr< Element > > dnf_composer::element::Element::getOutputs ( )

◆ getSize()

int dnf_composer::element::Element::getSize ( ) const

Return the number of spatial samples (size = round(x_max / d_x)).

◆ getStepSize()

double dnf_composer::element::Element::getStepSize ( ) const

Return the spatial resolution (d_x).

◆ getUniqueIdentifier()

int dnf_composer::element::Element::getUniqueIdentifier ( ) const

◆ getUniqueName()

std::string dnf_composer::element::Element::getUniqueName ( ) const
Here is the caller graph for this function:

◆ hasInput() [1/3]

bool dnf_composer::element::Element::hasInput ( ) const

◆ hasInput() [2/3]

bool dnf_composer::element::Element::hasInput ( const std::string &  inputElementName,
const std::string &  inputComponent 
)

◆ hasInput() [3/3]

bool dnf_composer::element::Element::hasInput ( int  inputElementId,
const std::string &  inputComponent 
)

◆ hasOutput() [1/3]

bool dnf_composer::element::Element::hasOutput ( ) const

◆ hasOutput() [2/3]

bool dnf_composer::element::Element::hasOutput ( const std::string &  outputElementName,
const std::string &  outputComponent 
)

◆ hasOutput() [3/3]

bool dnf_composer::element::Element::hasOutput ( int  outputElementId,
const std::string &  outputComponent 
)

◆ init()

virtual void dnf_composer::element::Element::init ( )
pure virtual

◆ print()

void dnf_composer::element::Element::print ( ) const
Here is the call graph for this function:

◆ removeInput() [1/2]

void dnf_composer::element::Element::removeInput ( const std::string &  inputElementId)
Here is the call graph for this function:

◆ removeInput() [2/2]

void dnf_composer::element::Element::removeInput ( int  uniqueId)
Here is the call graph for this function:

◆ removeInputs()

void dnf_composer::element::Element::removeInputs ( )
Here is the caller graph for this function:

◆ removeOutput() [1/2]

void dnf_composer::element::Element::removeOutput ( const std::string &  outputElementId)

Deregister this element as an input of outputElementId.

Here is the call graph for this function:

◆ removeOutput() [2/2]

void dnf_composer::element::Element::removeOutput ( int  uniqueId)

Deregister this element as an input of the element with uniqueId.

Here is the call graph for this function:

◆ removeOutputs()

void dnf_composer::element::Element::removeOutputs ( )
Here is the caller graph for this function:

◆ setUniqueName()

void dnf_composer::element::Element::setUniqueName ( const std::string &  name)

◆ step()

virtual void dnf_composer::element::Element::step ( double  t,
double  deltaT 
)
pure virtual

◆ toString()

virtual std::string dnf_composer::element::Element::toString ( ) const
pure virtual

◆ updateInput()

void dnf_composer::element::Element::updateInput ( )

Pull data from all registered input elements into this element's components.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ commonParameters

ElementCommonParameters dnf_composer::element::Element::commonParameters
protected

Name, label, and spatial dimensions.

◆ components

std::unordered_map<std::string, std::vector<double> > dnf_composer::element::Element::components
protected

Named data arrays (e.g. "output").

◆ inputs

std::unordered_map<std::shared_ptr<Element>, std::string> dnf_composer::element::Element::inputs
protected

Upstream elements and the component they expose.

◆ outputs

std::unordered_map<std::shared_ptr<Element>, std::string> dnf_composer::element::Element::outputs
protected

Downstream elements that read this element's output.


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