diff --git a/common/wave/element.cpp b/common/wave/element.cpp index 45d183cf60c14454eb6884822ffe0a9da57794b1..55393ced1ba75501d2d5207cfe6448c3d94f5c9f 100644 --- a/common/wave/element.cpp +++ b/common/wave/element.cpp @@ -47,13 +47,18 @@ void WaveMultiField<T_Physic>::write(std::string name) const template<Physic T_Physic> void WaveAuxilaryField<T_Physic>::assignValues(const std::vector< std::complex<double> > &values) { - unsigned int i = 0; - for(auto it = _wmf->_field.begin(); it != _wmf->_field.end(); it++) - { - if(it->first->type() == gmshfem::dofs::Type::Unknown) - { - _wmf->_dofValues[_index][i++] = values[it->first->numDof() - 1]; - } + if(_systemValuesToDofValues.size() == 0) { + _systemValuesToDofValues.reserve(values.size()); + for(auto it = _wmf->_field.begin(); it != _wmf->_field.end(); it++) + { + if(it->first->type() == gmshfem::dofs::Type::Unknown) + { + _systemValuesToDofValues.push_back(it->first->numDof() - 1); + } + } + } + for(unsigned int i = 0; i < values.size(); ++i) { + _wmf->_dofValues[_index][i] = values[_systemValuesToDofValues[i]]; } } diff --git a/common/wave/element.h b/common/wave/element.h index bd5f2fc03f47bf62401049cc65428a2db5dfb180..bb344f7ae54e4d178e798dba233a395d79aa15a0 100644 --- a/common/wave/element.h +++ b/common/wave/element.h @@ -47,8 +47,9 @@ class WaveAuxilaryField : public WaveField<T_Physic> private: WaveMultiField<T_Physic>* _wmf; unsigned int _index; + std::vector< unsigned int > _systemValuesToDofValues; public: - WaveAuxilaryField(std::string name, gmshfem::domain::Domain domain, std::string gmodel, const wave::Discretization<T_Physic>& w_discret): WaveField<T_Physic>(name,domain,gmodel,w_discret), _wmf(nullptr), _index(0) {}; + WaveAuxilaryField(std::string name, gmshfem::domain::Domain domain, std::string gmodel, const wave::Discretization<T_Physic>& w_discret): WaveField<T_Physic>(name,domain,gmodel,w_discret), _wmf(nullptr), _index(0), _systemValuesToDofValues() {}; void setField(WaveMultiField<T_Physic>* wmf){_wmf=wmf;}; void setIndex(unsigned int index){_index=index;}; virtual void assignValues(const std::vector< std::complex<double> > &values) override; diff --git a/specific/todata.cpp b/specific/todata.cpp index 950c55b494e7c1b6eba5dda4d7628a121f5c2869..eb44c5dc2592454989a850df123829ed7a89fd67 100644 --- a/specific/todata.cpp +++ b/specific/todata.cpp @@ -19,7 +19,7 @@ Data<Physic::acoustic> wave_to_data(const ConfigurationInterface* const config, { for (unsigned int r = 0; r < config->nr(s); r++) { - PointData<Physic::acoustic> buffer(integrate(1.0*w[s],config->receiver(s,r),"Gauss1")); + PointData<Physic::acoustic> buffer(integrate(ScalarFunction< std::complex< double > >(w[s]),config->receiver(s,r),"Gauss1")); v.value(s,r,buffer); } }