diff --git a/common/wave/element.cpp b/common/wave/element.cpp index fda4158851d5b4cad66517290087865cfbb54cbb..45d183cf60c14454eb6884822ffe0a9da57794b1 100644 --- a/common/wave/element.cpp +++ b/common/wave/element.cpp @@ -18,8 +18,12 @@ void WaveMultiField<T_Physic>::initializeField(const WaveField<T_Physic>& field) template<Physic T_Physic> const WaveField<T_Physic>& WaveMultiField<T_Physic>::operator[](const unsigned int index) const { - _field.setAllVector(_dofValues[index], gmshfem::dofs::RawOrder::Hash); - return _field; + if(index!=_index) + { + _field.setAllVector(_dofValues[index], gmshfem::dofs::RawOrder::Hash); + _index=index; + } + return _field; } template<Physic T_Physic> diff --git a/common/wave/element.h b/common/wave/element.h index 26a82957d5d2c274077efa7f7d2dab7a1427d59a..bd5f2fc03f47bf62401049cc65428a2db5dfb180 100644 --- a/common/wave/element.h +++ b/common/wave/element.h @@ -19,8 +19,9 @@ private: mutable WaveField<T_Physic> _field; bool _isInitialized; std::vector< gmshfem::algebra::Vector< std::complex< double > > > _dofValues; + mutable unsigned int _index; public: - WaveMultiField(unsigned int n, const std::string& name = "") : _field(), _isInitialized(false), _dofValues(n) {_field.name(name);}; + WaveMultiField(unsigned int n, const std::string& name = "") : _field(), _isInitialized(false), _dofValues(n), _index(n+1) {_field.name(name);}; void initializeField(const WaveField<T_Physic>& field); bool isInitialized() const {return _isInitialized;};