Skip to content

Commit

Permalink
clean observation method
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiangyu-Hu committed Jun 22, 2024
1 parent 09e2c6d commit 0bb9fde
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,26 +112,9 @@ class ObservingAQuantity : public InteractionDynamics<BaseInterpolation<DataType
explicit ObservingAQuantity(BaseContactRelation &contact_relation, const std::string &variable_name)
: InteractionDynamics<BaseInterpolation<DataType>>(contact_relation, variable_name)
{
this->interpolated_quantities_ = registerObservedQuantity(variable_name);
this->interpolated_quantities_ = this->particles_->template registerSharedVariable<DataType>(variable_name);
};
virtual ~ObservingAQuantity(){};

protected:
StdLargeVec<DataType> *observed_quantities_;

/** Register the observed variable if the variable name is new.
* If the variable is registered already, the registered variable will be returned. */
StdLargeVec<DataType> *registerObservedQuantity(const std::string &variable_name)
{
BaseParticles *particles = this->particles_;
DiscreteVariable<DataType> *variable = findVariableByName<DataType>(particles->AllDiscreteVariables(), variable_name);
if (variable == nullptr)
{
observed_quantities_ = particles->registerSharedVariable<DataType>(variable_name, ZeroData<DataType>::value);
return observed_quantities_;
}
return particles->getVariableByName<DataType>(variable_name);
};
};

/**
Expand Down
1 change: 0 additions & 1 deletion src/shared/particles/base_particles.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ class BaseParticles
StdLargeVec<DataType> *registerSharedVariableFrom(const std::string &new_name, const std::string &old_name);
template <typename DataType>
StdLargeVec<DataType> *getVariableByName(const std::string &variable_name);
ParticleVariables &AllDiscreteVariables() { return all_discrete_variables_; };

template <typename DataType>
DataType *registerSingleVariable(const std::string &variable_name,
Expand Down

0 comments on commit 0bb9fde

Please sign in to comment.