diff --git a/C++/basicClasses/libBasicClasses.cc b/C++/basicClasses/libBasicClasses.cc index 694eb32fbafae987ed820194bd307451a8d5b809..ccf617b9d7913cbc0136ff58eb04d842afed1264 100644 --- a/C++/basicClasses/libBasicClasses.cc +++ b/C++/basicClasses/libBasicClasses.cc @@ -221,36 +221,36 @@ void declare_vec_t(py::module &m) { // declaration in libMain.h -template<typename T, unsigned int DIM, typename CL_PARENT> +template<typename T, unsigned int DIM> void declare_ngData_class(py::module &m, std::string name, std::string suffix){ //Data Class std::string pyclass_name = std::string("ng") + name +std::string("_class") + std::to_string(DIM) + suffix; - py::class_<ngData_class<T, DIM, CL_PARENT>, shared_ptr<ngData_class<T, DIM, CL_PARENT>> , CoefficientFunction> + py::class_<ngData_class<T, DIM>, shared_ptr<ngData_class<T, DIM>> , CoefficientFunction> (m, pyclass_name.c_str()) .def(py::init( [](shared_ptr<MeshAccess>& mesh, IntegrationRule& intrule, const shared_ptr<CoefficientFunction>& ptrMask) { - return new ngData_class<T, DIM, CL_PARENT>(mesh, intrule, ptrMask); + return new ngData_class<T, DIM>(mesh, intrule, ptrMask); }), py::arg("mesh"), py::arg("intrule"), py::arg("mask")=nullptr) - .def("Save", &ngData_class<T, DIM, CL_PARENT>::Save, py::arg("filename"), py::arg("binary")=true, "save all values in the container to a file.") - .def("Load", &ngData_class<T, DIM, CL_PARENT>::Load, py::arg("filename"), py::arg("skipTest")=1, py::arg("binary")=true, "load the values for the container from a file. The arguments of the constructor have to fit. skipTest will make loading faster.") - .def("Set", overload_cast_<const shared_ptr<CoefficientFunction>&>()(&ngData_class<T, DIM, CL_PARENT>::Set), py::arg("CF"), "set the values according to a Coefficient function") - .def_property_readonly("numBytes", &ngData_class<T, DIM, CL_PARENT>::GetNumBytes, "approximation of the current memory demand") - .def("__str__", &ngData_class<T, DIM, CL_PARENT>::toString) - .def("__repr__", &ngData_class<T, DIM, CL_PARENT>::toString) - .def("__sum__", &ngData_class<T, DIM, CL_PARENT>::Sum) - .def("Sum", &ngData_class<T, DIM, CL_PARENT>::Sum) - .def("SerialElement", &ngData_class<T, DIM, CL_PARENT>::serialElement) - .def("GetData", &ngData_class<T, DIM, CL_PARENT>::getData) - .def("GetMips", &ngData_class<T, DIM, CL_PARENT>::getMips) - .def("GetMipsAsMatrix", &ngData_class<T, DIM, CL_PARENT>::getMipsAsMatrix) - .def("GetRotatedValues", &ngData_class<T, DIM, CL_PARENT>::GetRotatedValues, py::arg("angle"), py::arg("axis")=2, "rotate all values around the axis in the center") - .def_property("autoUpdate", &ngData_class<T, DIM, CL_PARENT>::GetAutoUpdate, &ngData_class<T, DIM, CL_PARENT>::SetAutoUpdate, "Set the additional field to mark the object to be updated") - .def_property("derivative", &ngData_class<T, DIM, CL_PARENT>::GetDerivative, &ngData_class<T, DIM, CL_PARENT>::SetDerivative, "Set the derivative used for AutoDiff") - .def("copy", &ngData_class<T, DIM, CL_PARENT>::copy) - .def_property_readonly("numEntries", &ngData_class<T, DIM, CL_PARENT>::GetNumEntries, "number of allocated objects of type T") - .def_property("vec", &ngData_class<T, DIM, CL_PARENT>::GetVec, &ngData_class<T, DIM, CL_PARENT>::SetVec , "vec") + .def("Save", &ngData_class<T, DIM>::Save, py::arg("filename"), py::arg("binary")=true, "save all values in the container to a file.") + .def("Load", &ngData_class<T, DIM>::Load, py::arg("filename"), py::arg("skipTest")=1, py::arg("binary")=true, "load the values for the container from a file. The arguments of the constructor have to fit. skipTest will make loading faster.") + .def("Set", overload_cast_<const shared_ptr<CoefficientFunction>&>()(&ngData_class<T, DIM>::Set), py::arg("CF"), "set the values according to a Coefficient function") + .def_property_readonly("numBytes", &ngData_class<T, DIM>::GetNumBytes, "approximation of the current memory demand") + .def("__str__", &ngData_class<T, DIM>::toString) + .def("__repr__", &ngData_class<T, DIM>::toString) + .def("__sum__", &ngData_class<T, DIM>::Sum) + .def("Sum", &ngData_class<T, DIM>::Sum) + .def("SerialElement", &ngData_class<T, DIM>::serialElement) + .def("GetData", &ngData_class<T, DIM>::getData) + .def("GetMips", &ngData_class<T, DIM>::getMips) + .def("GetMipsAsMatrix", &ngData_class<T, DIM>::getMipsAsMatrix) + .def("GetRotatedValues", &ngData_class<T, DIM>::GetRotatedValues, py::arg("angle"), py::arg("axis")=2, "rotate all values around the axis in the center") + .def_property("autoUpdate", &ngData_class<T, DIM>::GetAutoUpdate, &ngData_class<T, DIM>::SetAutoUpdate, "Set the additional field to mark the object to be updated") + .def_property("derivative", &ngData_class<T, DIM>::GetDerivative, &ngData_class<T, DIM>::SetDerivative, "Set the derivative used for AutoDiff") + .def("copy", &ngData_class<T, DIM>::copy) + .def_property_readonly("numEntries", &ngData_class<T, DIM>::GetNumEntries, "number of allocated objects of type T") + .def_property("vec", &ngData_class<T, DIM>::GetVec, &ngData_class<T, DIM>::SetVec , "vec") // destroys convergence // .def("__add__", [](ngData_class<T, DIM> *instance, const ngData_class<T, DIM>& o){return instance->operator+(o);}) @@ -376,15 +376,6 @@ void declare_PreisachVectorPilots_t(py::module &m){ } -template<typename T> -void declare_DummyPilot(py::module &m, std::string name){ - //return type of pV pilots - std::string pyclass_name = std::string("__dummyPilot_") + name + std::string("__"); - py::class_<dummyPilot<T>, shared_ptr<dummyPilot<T>>> - (m, pyclass_name.c_str()) - ; -} - void ExportReclibBasicClasses(py::module &main_m){ py::module_ m = main_m.def_submodule("basicClasses", "This is a submodule with all basicClasses and types."); @@ -395,18 +386,13 @@ void ExportReclibBasicClasses(py::module &main_m){ // declare_vvector_t<double>(m, ""); // declare_vvector_t<std::complex<double>>(m, "complex"); - declare_DummyPilot<double>(m, "double"); - + declare_ngData_class<scal_t<double>, 1>(m, "Scalar"); declare_ngData_class<scal_t<double>, 2>(m, "Scalar"); declare_ngData_class<scal_t<double>, 3>(m, "Scalar"); declare_ngData_class<scal_t<std::complex<double>>, 3>(m, "ScalarComplex"); - declare_ngData_class<vec_t<double, 1>, 1, ngPreisachScalar<1> >(m, "Vector", "PreisachScalar"); - declare_ngData_class<vec_t<double, 1>, 2, ngPreisachScalar<2> >(m, "Vector", "PreisachScalar"); - declare_ngData_class<vec_t<double, 1>, 3, ngPreisachScalar<3> >(m, "Vector", "PreisachScalar"); - // declare_ngData_class<vec_t<double, 1>, 1>(m, "Vector"); //same as <scal_t<double>, 1> diff --git a/C++/basicClasses/ngData_class.cc b/C++/basicClasses/ngData_class.cc index 810f1a64a9d18852cefc17b53982b96f6d5562c2..38f90d8875894fba9ab91096a60a651d5d601010 100644 --- a/C++/basicClasses/ngData_class.cc +++ b/C++/basicClasses/ngData_class.cc @@ -1,15 +1,14 @@ #include "ngData_class.h" #include "../preisach/ngPreisachScalar.h" -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -ngData_class<T, DIM_MESH, CL_PARENT>::ngData_class():CoefficientFunction( T::Nr * T::Nc, basicDataTypes::is_complex<typename T::value_type>{}){ +template<typename T, unsigned int DIM_MESH> +ngData_class<T, DIM_MESH>::ngData_class():CoefficientFunction( T::Nr * T::Nc, basicDataTypes::is_complex<typename T::value_type>{}){ } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -ngData_class<T, DIM_MESH, CL_PARENT>::ngData_class(shared_ptr<MeshAccess> mesh_in, IntegrationRule intrule_in, const vector<vector<MappedIntegrationPoint<DIM_MESH, DIM_MESH>> >& mips_in, - CL_PARENT * parent, typename T::value_type (CL_PARENT::*pilot) (const BaseMappedIntegrationPoint& mip, const typename T::value_type) const): - CoefficientFunction( T::Nr * T::Nc, basicDataTypes::is_complex<typename T::value_type>{}), mips{mips_in}, mesh{mesh_in}, intrule{intrule_in}, parent{parent}, pilot{pilot}{ +template<typename T, unsigned int DIM_MESH> +ngData_class<T, DIM_MESH>::ngData_class(shared_ptr<MeshAccess> mesh_in, IntegrationRule intrule_in, const vector<vector<MappedIntegrationPoint<DIM_MESH, DIM_MESH>> >& mips_in): + CoefficientFunction( T::Nr * T::Nc, basicDataTypes::is_complex<typename T::value_type>{}), mips{mips_in}, mesh{mesh_in}, intrule{intrule_in}{ // cout << __PRETTY_FUNCTION__ << endl; if constexpr(T::Nc > 1){ @@ -43,10 +42,9 @@ ngData_class<T, DIM_MESH, CL_PARENT>::ngData_class(shared_ptr<MeshAccess> mesh_i }; -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -ngData_class<T, DIM_MESH, CL_PARENT>::ngData_class(shared_ptr<MeshAccess>& mesh, IntegrationRule& intrule, const shared_ptr<CoefficientFunction>& ptrMask, - CL_PARENT * parent, typename T::value_type (CL_PARENT::*pilot) (const BaseMappedIntegrationPoint& mip, const typename T::value_type) const): - CoefficientFunction( T::Nr * T::Nc, basicDataTypes::is_complex<typename T::value_type>{}), mesh{mesh}, intrule{intrule}, parent{parent}, pilot{pilot}{ +template<typename T, unsigned int DIM_MESH> +ngData_class<T, DIM_MESH>::ngData_class(shared_ptr<MeshAccess>& mesh, IntegrationRule& intrule, const shared_ptr<CoefficientFunction>& ptrMask): + CoefficientFunction( T::Nr * T::Nc, basicDataTypes::is_complex<typename T::value_type>{}), mesh{mesh}, intrule{intrule}{ // cout << __PRETTY_FUNCTION__ << endl; @@ -65,10 +63,10 @@ ngData_class<T, DIM_MESH, CL_PARENT>::ngData_class(shared_ptr<MeshAccess>& mesh, } // copy const -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -ngData_class<T, DIM_MESH, CL_PARENT>::ngData_class(const ngData_class& o): +template<typename T, unsigned int DIM_MESH> +ngData_class<T, DIM_MESH>::ngData_class(const ngData_class& o): CoefficientFunction( T::Nr * T::Nc, basicDataTypes::is_complex<typename T::value_type>{}), - mips{o.mips}, mesh{o.mesh}, intrule{o.intrule}, data{o.data}, num{o.num}, autoUpdate{o.autoUpdate}, parent{parent}, pilot{pilot}{ // cout << __PRETTY_FUNCTION__ << endl; + mips{o.mips}, mesh{o.mesh}, intrule{o.intrule}, data{o.data}, num{o.num}, autoUpdate{o.autoUpdate}{ // cout << __PRETTY_FUNCTION__ << endl; if constexpr(T::Nc > 1){ // Set CF dimensions Array<int> dims(2, global_alloc); @@ -79,8 +77,8 @@ ngData_class<T, DIM_MESH, CL_PARENT>::ngData_class(const ngData_class& o): } // copy assignment -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -ngData_class<T, DIM_MESH, CL_PARENT> ngData_class<T, DIM_MESH, CL_PARENT>::operator =(const ngData_class& o){ +template<typename T, unsigned int DIM_MESH> +ngData_class<T, DIM_MESH> ngData_class<T, DIM_MESH>::operator =(const ngData_class& o){ // cout << __PRETTY_FUNCTION__ << endl; @@ -102,13 +100,13 @@ ngData_class<T, DIM_MESH, CL_PARENT> ngData_class<T, DIM_MESH, CL_PARENT>::opera return *this; } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -ngData_class<T, DIM_MESH, CL_PARENT> ngData_class<T, DIM_MESH, CL_PARENT>::copy() const{ +template<typename T, unsigned int DIM_MESH> +ngData_class<T, DIM_MESH> ngData_class<T, DIM_MESH>::copy() const{ return *this; } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -void ngData_class<T, DIM_MESH, CL_PARENT>::generateMipsFromMesh(const shared_ptr<CoefficientFunction> ptrMask){ +template<typename T, unsigned int DIM_MESH> +void ngData_class<T, DIM_MESH>::generateMipsFromMesh(const shared_ptr<CoefficientFunction> ptrMask){ if(mesh == nullptr){ throw std::runtime_error("mesh has to be set first"); } @@ -150,8 +148,8 @@ void ngData_class<T, DIM_MESH, CL_PARENT>::generateMipsFromMesh(const shared_ptr } // operators -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -ngData_class<T, DIM_MESH, CL_PARENT>& ngData_class<T, DIM_MESH, CL_PARENT>::operator +=(const ngData_class& o){ +template<typename T, unsigned int DIM_MESH> +ngData_class<T, DIM_MESH>& ngData_class<T, DIM_MESH>::operator +=(const ngData_class& o){ unsigned int el, ip; for(el = 0; el != o.mips.size(); ++el){ for (ip = 0;ip < o.mips[el].size(); ip++) { @@ -162,8 +160,8 @@ ngData_class<T, DIM_MESH, CL_PARENT>& ngData_class<T, DIM_MESH, CL_PARENT>::oper return *this; } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -ngData_class<T, DIM_MESH, CL_PARENT>& ngData_class<T, DIM_MESH, CL_PARENT>::operator -=(const ngData_class& o){ +template<typename T, unsigned int DIM_MESH> +ngData_class<T, DIM_MESH>& ngData_class<T, DIM_MESH>::operator -=(const ngData_class& o){ unsigned int el, ip; for(el = 0; el != o.mips.size(); ++el){ for (ip = 0;ip < o.mips[el].size(); ip++) { @@ -173,15 +171,15 @@ ngData_class<T, DIM_MESH, CL_PARENT>& ngData_class<T, DIM_MESH, CL_PARENT>::oper return *this; } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -ngData_class<T, DIM_MESH, CL_PARENT> ngData_class<T, DIM_MESH, CL_PARENT>::operator +(const ngData_class& o) const{ +template<typename T, unsigned int DIM_MESH> +ngData_class<T, DIM_MESH> ngData_class<T, DIM_MESH>::operator +(const ngData_class& o) const{ ngData_class ret(*this); ret += o; return ret; } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -ngData_class<T, DIM_MESH, CL_PARENT> ngData_class<T, DIM_MESH, CL_PARENT>::operator -(const ngData_class& o) const{ +template<typename T, unsigned int DIM_MESH> +ngData_class<T, DIM_MESH> ngData_class<T, DIM_MESH>::operator -(const ngData_class& o) const{ ngData_class ret(*this); ret -= o; return ret; @@ -204,35 +202,35 @@ ngData_class<T, DIM_MESH, CL_PARENT> ngData_class<T, DIM_MESH, CL_PARENT>::opera // } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -std::map<std::pair<const unsigned int, const unsigned int>, T>& ngData_class<T, DIM_MESH, CL_PARENT>::getData(){ +template<typename T, unsigned int DIM_MESH> +std::map<std::pair<const unsigned int, const unsigned int>, T>& ngData_class<T, DIM_MESH>::getData(){ return data; } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -std::map<std::pair<const unsigned int, const unsigned int>, T> ngData_class<T, DIM_MESH, CL_PARENT>::getDataConst() const{ +template<typename T, unsigned int DIM_MESH> +std::map<std::pair<const unsigned int, const unsigned int>, T> ngData_class<T, DIM_MESH>::getDataConst() const{ return data; } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -vector<vector<MappedIntegrationPoint<DIM_MESH, DIM_MESH>> >& ngData_class<T, DIM_MESH, CL_PARENT>::getMips(){ +template<typename T, unsigned int DIM_MESH> +vector<vector<MappedIntegrationPoint<DIM_MESH, DIM_MESH>> >& ngData_class<T, DIM_MESH>::getMips(){ return mips; } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -shared_ptr<MeshAccess>& ngData_class<T, DIM_MESH, CL_PARENT>::getMesh(){ +template<typename T, unsigned int DIM_MESH> +shared_ptr<MeshAccess>& ngData_class<T, DIM_MESH>::getMesh(){ return mesh; } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -IntegrationRule& ngData_class<T, DIM_MESH, CL_PARENT>::getIntrule(){ +template<typename T, unsigned int DIM_MESH> +IntegrationRule& ngData_class<T, DIM_MESH>::getIntrule(){ return intrule; } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -vector<vector<double>> ngData_class<T, DIM_MESH, CL_PARENT>::getMipsAsMatrix(){ +template<typename T, unsigned int DIM_MESH> +vector<vector<double>> ngData_class<T, DIM_MESH>::getMipsAsMatrix(){ vector<vector<double>> tmp; unsigned int el, ip; @@ -258,8 +256,8 @@ vector<vector<double>> ngData_class<T, DIM_MESH, CL_PARENT>::getMipsAsMatrix(){ } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -auto ngData_class<T, DIM_MESH, CL_PARENT>::getState() const{ +template<typename T, unsigned int DIM_MESH> +auto ngData_class<T, DIM_MESH>::getState() const{ throw std::runtime_error("not implemented"); // return std::make_tuple(, instance->getPtrMask(), instance->getNum()); return std::make_tuple(data, mesh); @@ -267,16 +265,16 @@ auto ngData_class<T, DIM_MESH, CL_PARENT>::getState() const{ } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -T& ngData_class<T, DIM_MESH, CL_PARENT>::serialElement(const unsigned int ind){ +template<typename T, unsigned int DIM_MESH> +T& ngData_class<T, DIM_MESH>::serialElement(const unsigned int ind){ // data per element = T::Nc * T::Nr auto it = data.begin(); std::advance(it, ind); return it->second; } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -const T ngData_class<T, DIM_MESH, CL_PARENT>::Get(const unsigned int el, const unsigned int ip) const{ +template<typename T, unsigned int DIM_MESH> +const T ngData_class<T, DIM_MESH>::Get(const unsigned int el, const unsigned int ip) const{ if( el < mips.size() && ip < mips[el].size() ){ return data.at(std::make_pair(el, ip)); } @@ -286,8 +284,8 @@ const T ngData_class<T, DIM_MESH, CL_PARENT>::Get(const unsigned int el, const u } } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -void ngData_class<T, DIM_MESH, CL_PARENT>::Set(const unsigned int el, const unsigned int ip, const T& val){ +template<typename T, unsigned int DIM_MESH> +void ngData_class<T, DIM_MESH>::Set(const unsigned int el, const unsigned int ip, const T& val){ if( el < mips.size() && ip < mips[el].size() ){ data[std::make_pair(el, ip)] = val; } @@ -297,8 +295,8 @@ void ngData_class<T, DIM_MESH, CL_PARENT>::Set(const unsigned int el, const unsi } // special case for double -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -void ngData_class<T, DIM_MESH, CL_PARENT>::Set(const unsigned int el, const unsigned int ip, const double& val){ +template<typename T, unsigned int DIM_MESH> +void ngData_class<T, DIM_MESH>::Set(const unsigned int el, const unsigned int ip, const double& val){ if( el < mips.size() && ip < mips[el].size() ){ data[std::make_pair(el, ip)][0][0] = val; } @@ -307,8 +305,8 @@ void ngData_class<T, DIM_MESH, CL_PARENT>::Set(const unsigned int el, const unsi } } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -void ngData_class<T, DIM_MESH, CL_PARENT>::Set(const shared_ptr<CoefficientFunction>& ptrIn){ +template<typename T, unsigned int DIM_MESH> +void ngData_class<T, DIM_MESH>::Set(const shared_ptr<CoefficientFunction>& ptrIn){ parFor(mips.size(), [&](int el) { unsigned int ip, i, l; typename T::value_type tmp[T::Nr * T::Nc]; @@ -350,13 +348,13 @@ void ngData_class<T, DIM_MESH, CL_PARENT>::Set(const shared_ptr<CoefficientFunct } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -void ngData_class<T, DIM_MESH, CL_PARENT>::Set(const ngData_class<T, DIM_MESH, CL_PARENT>& ptrIn){ +template<typename T, unsigned int DIM_MESH> +void ngData_class<T, DIM_MESH>::Set(const ngData_class<T, DIM_MESH>& ptrIn){ this->operator=(ptrIn); } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -std::string ngData_class<T, DIM_MESH, CL_PARENT>::toString() const{ +template<typename T, unsigned int DIM_MESH> +std::string ngData_class<T, DIM_MESH>::toString() const{ std::stringstream s; s << *this; @@ -364,8 +362,8 @@ std::string ngData_class<T, DIM_MESH, CL_PARENT>::toString() const{ return s.str(); } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -unsigned int ngData_class<T, DIM_MESH, CL_PARENT>::GetNumBytes() const{ +template<typename T, unsigned int DIM_MESH> +unsigned int ngData_class<T, DIM_MESH>::GetNumBytes() const{ if constexpr(!basicDataTypes::is_vvector_t<T>{}){ return num * sizeof(typename T::value_type) * T::Nr * T::Nc; @@ -378,18 +376,18 @@ unsigned int ngData_class<T, DIM_MESH, CL_PARENT>::GetNumBytes() const{ } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -unsigned int ngData_class<T, DIM_MESH, CL_PARENT>::GetNumEntries() const{ +template<typename T, unsigned int DIM_MESH> +unsigned int ngData_class<T, DIM_MESH>::GetNumEntries() const{ return num; } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -void ngData_class<T, DIM_MESH, CL_PARENT>::SetNumEntries(unsigned int o){ +template<typename T, unsigned int DIM_MESH> +void ngData_class<T, DIM_MESH>::SetNumEntries(unsigned int o){ num = o; } // for now, just around xyz-axis -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -std::shared_ptr<ngData_class<T, DIM_MESH, CL_PARENT>> ngData_class<T, DIM_MESH, CL_PARENT>::GetRotatedValues(const double phi, unsigned int axis){ +template<typename T, unsigned int DIM_MESH> +std::shared_ptr<ngData_class<T, DIM_MESH>> ngData_class<T, DIM_MESH>::GetRotatedValues(const double phi, unsigned int axis){ // if constexpr(basicDataTypes::is_complex<typename T::value_type>{}){ // throw std::runtime_error("not implemented for complex values yet"); @@ -415,7 +413,7 @@ std::shared_ptr<ngData_class<T, DIM_MESH, CL_PARENT>> ngData_class<T, DIM_MESH, R = mat_t<double, DIM_MESH, DIM_MESH>{1}; } - std::shared_ptr<ngData_class<T, DIM_MESH, CL_PARENT>> data_ret = std::make_shared<ngData_class<T, DIM_MESH, CL_PARENT>>(mesh, intrule, mips); + std::shared_ptr<ngData_class<T, DIM_MESH>> data_ret = std::make_shared<ngData_class<T, DIM_MESH>>(mesh, intrule, mips); @@ -483,30 +481,30 @@ std::shared_ptr<ngData_class<T, DIM_MESH, CL_PARENT>> ngData_class<T, DIM_MESH, } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -bool ngData_class<T, DIM_MESH, CL_PARENT>::GetAutoUpdate() const{ +template<typename T, unsigned int DIM_MESH> +bool ngData_class<T, DIM_MESH>::GetAutoUpdate() const{ return autoUpdate; } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -void ngData_class<T, DIM_MESH, CL_PARENT>::SetAutoUpdate(const bool val){ +template<typename T, unsigned int DIM_MESH> +void ngData_class<T, DIM_MESH>::SetAutoUpdate(const bool val){ autoUpdate = val; } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -shared_ptr<ngData_class<T, DIM_MESH, CL_PARENT>> ngData_class<T, DIM_MESH, CL_PARENT>::GetDerivative() const{ +template<typename T, unsigned int DIM_MESH> +shared_ptr<ngData_class<T, DIM_MESH>> ngData_class<T, DIM_MESH>::GetDerivative() const{ return derivative; } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -void ngData_class<T, DIM_MESH, CL_PARENT>::SetDerivative(const shared_ptr<ngData_class<T, DIM_MESH, CL_PARENT>> val){ +template<typename T, unsigned int DIM_MESH> +void ngData_class<T, DIM_MESH>::SetDerivative(const shared_ptr<ngData_class<T, DIM_MESH>> val){ derivative = val; } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -void ngData_class<T, DIM_MESH, CL_PARENT>::Evaluate(const BaseMappedIntegrationPoint& ip, FlatVector<Complex> result) const{ +template<typename T, unsigned int DIM_MESH> +void ngData_class<T, DIM_MESH>::Evaluate(const BaseMappedIntegrationPoint& ip, FlatVector<Complex> result) const{ if constexpr(basicDataTypes::is_complex<typename T::value_type>{}){ double tmp[2 * (T::Nc * T::Nr)]; @@ -535,8 +533,8 @@ void ngData_class<T, DIM_MESH, CL_PARENT>::Evaluate(const BaseMappedIntegrationP -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -void ngData_class<T, DIM_MESH, CL_PARENT>::Evaluate(const BaseMappedIntegrationPoint& mip, FlatVector<> result) const{ +template<typename T, unsigned int DIM_MESH> +void ngData_class<T, DIM_MESH>::Evaluate(const BaseMappedIntegrationPoint& mip, FlatVector<> result) const{ // cout << __PRETTY_FUNCTION__ << " enter" << endl; if constexpr(!basicDataTypes::is_vvector_t<T>{}){ @@ -582,10 +580,12 @@ void ngData_class<T, DIM_MESH, CL_PARENT>::Evaluate(const BaseMappedIntegrationP } } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -void ngData_class<T, DIM_MESH, CL_PARENT>::Evaluate (const BaseMappedIntegrationRule & ir, +template<typename T, unsigned int DIM_MESH> +void ngData_class<T, DIM_MESH>::Evaluate (const BaseMappedIntegrationRule & ir, BareSliceMatrix<AutoDiff<1,double>> values) const{ + cout << __PRETTY_FUNCTION__ << endl; + throw std::runtime_error("not implemented"); // typename T::value_type tmp[this->Dimension()] = {}; // FlatVector<typename T::value_type> result(this->Dimension(), tmp); @@ -615,12 +615,12 @@ void ngData_class<T, DIM_MESH, CL_PARENT>::Evaluate (const BaseMappedIntegration // double eps = 1e-5; double val=0; - if (parent && pilot){ + // if (parent && pilot){ - // cout << values(i, j).Value() << " " << values(i, j).DValue(0) << endl; - val = (parent->*pilot)(ir[i], values(i, j).Value() + values(i, j).DValue(0)); - // this->Evaluate(ir[i]); - } + // // cout << values(i, j).Value() << " " << values(i, j).DValue(0) << endl; + // val = (parent->*pilot)(ir[i], values(i, j).Value() + values(i, j).DValue(0)); + // // this->Evaluate(ir[i]); + // } double dval2=0; @@ -646,8 +646,8 @@ void ngData_class<T, DIM_MESH, CL_PARENT>::Evaluate (const BaseMappedIntegration } } } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -double ngData_class<T, DIM_MESH, CL_PARENT>::Evaluate(const BaseMappedIntegrationPoint& mip) const{ +template<typename T, unsigned int DIM_MESH> +double ngData_class<T, DIM_MESH>::Evaluate(const BaseMappedIntegrationPoint& mip) const{ // cout << __PRETTY_FUNCTION__ << " enter" << endl; if constexpr(!basicDataTypes::is_vvector_t<T>{}){ @@ -661,8 +661,8 @@ double ngData_class<T, DIM_MESH, CL_PARENT>::Evaluate(const BaseMappedIntegratio } } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -typename T::value_type ngData_class<T, DIM_MESH, CL_PARENT>::Sum() const{ +template<typename T, unsigned int DIM_MESH> +typename T::value_type ngData_class<T, DIM_MESH>::Sum() const{ typename T::value_type sum{}; for (int el = 0; el < mips.size(); el++) { // create a container for every integration point @@ -682,8 +682,8 @@ typename T::value_type ngData_class<T, DIM_MESH, CL_PARENT>::Sum() const{ return sum; } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -std::vector<typename T::value_type> ngData_class<T, DIM_MESH, CL_PARENT>::GetVec() const{ +template<typename T, unsigned int DIM_MESH> +std::vector<typename T::value_type> ngData_class<T, DIM_MESH>::GetVec() const{ std::vector<typename T::value_type> ret{}; for (int el = 0; el < mips.size(); el++) { // create a container for every integration point @@ -708,8 +708,8 @@ std::vector<typename T::value_type> ngData_class<T, DIM_MESH, CL_PARENT>::GetVe return ret; } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -void ngData_class<T, DIM_MESH, CL_PARENT>::SetVec(const std::vector<typename T::value_type>& val){ +template<typename T, unsigned int DIM_MESH> +void ngData_class<T, DIM_MESH>::SetVec(const std::vector<typename T::value_type>& val){ int n = 0; for (int el = 0; el < mips.size(); el++) { @@ -736,15 +736,15 @@ void ngData_class<T, DIM_MESH, CL_PARENT>::SetVec(const std::vector<typename T: } } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -void ngData_class<T, DIM_MESH, CL_PARENT>::setData(std::map<std::pair<const unsigned int, const unsigned int>, T> o){ +template<typename T, unsigned int DIM_MESH> +void ngData_class<T, DIM_MESH>::setData(std::map<std::pair<const unsigned int, const unsigned int>, T> o){ data = o; } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -void ngData_class<T, DIM_MESH, CL_PARENT>::Save(std::string fileName, bool binary) const{ +template<typename T, unsigned int DIM_MESH> +void ngData_class<T, DIM_MESH>::Save(std::string fileName, bool binary) const{ std::ofstream file(fileName, std::ios::out | std::ios::binary) ; if (file.is_open()){ @@ -781,8 +781,8 @@ void ngData_class<T, DIM_MESH, CL_PARENT>::Save(std::string fileName, bool binar } } -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -void ngData_class<T, DIM_MESH, CL_PARENT>::Load(std::string filename, const unsigned int iSkip, bool binary){ +template<typename T, unsigned int DIM_MESH> +void ngData_class<T, DIM_MESH>::Load(std::string filename, const unsigned int iSkip, bool binary){ if(!binary){ size_t pos = 0; @@ -967,8 +967,8 @@ void ngData_class<T, DIM_MESH, CL_PARENT>::Load(std::string filename, const unsi -template<typename T, unsigned int DIM_MESH, typename CL_PARENT> -std::ostream& operator << (std::ostream& o, const ngData_class<T, DIM_MESH, CL_PARENT>& m){ +template<typename T, unsigned int DIM_MESH> +std::ostream& operator << (std::ostream& o, const ngData_class<T, DIM_MESH>& m){ unsigned int el, ip, i, l; @@ -1018,10 +1018,6 @@ template class ngData_class<basicDataTypes::vec_t<double, 2>, 2>; template class ngData_class<basicDataTypes::vec_t<double, 2>, 1>; // 2D VPM for 1D Mesh template class ngData_class<basicDataTypes::vec_t<double, 3>, 3>; template class ngData_class<basicDataTypes::vec_t<double, 2>, 3>; // 2D VPM for 3D Mesh -// new -template class ngData_class<vec_t<double, 1>, 1, ngPreisachScalar<1> >; -template class ngData_class<vec_t<double, 1>, 2, ngPreisachScalar<2> >; -template class ngData_class<vec_t<double, 1>, 3, ngPreisachScalar<3> >; // template class ngData_class<vec_t<double, 1>, 3, ngPreisachScalar<3> >; diff --git a/C++/basicClasses/ngData_class.h b/C++/basicClasses/ngData_class.h index 17a358a06f26c4d9759993b0acf905cd64b53c6a..89fd5baa37d4b7c319f9caad6fd04818c05ff60a 100644 --- a/C++/basicClasses/ngData_class.h +++ b/C++/basicClasses/ngData_class.h @@ -30,17 +30,8 @@ using basicDataTypes::vec_t; using basicDataTypes::vvector_t; using basicDataTypes::scal_t; -template<typename T> -class dummyPilot{ - public: - dummyPilot(){}; - T pilot(const BaseMappedIntegrationPoint& mip, const T){ - return T{}; - } -}; - -template<typename T, unsigned int DIM_MESH, typename CL_PARENT=dummyPilot<typename T::value_type>> +template<typename T, unsigned int DIM_MESH> class ngData_class : public CoefficientFunction{ protected: // data @@ -58,20 +49,15 @@ class ngData_class : public CoefficientFunction{ std::map<std::pair<const unsigned int, const unsigned int>, T> data; unsigned int num = 0; - shared_ptr<ngData_class<T, DIM_MESH, CL_PARENT>> derivative = nullptr; + shared_ptr<ngData_class<T, DIM_MESH>> derivative = nullptr; - CL_PARENT* parent = nullptr; - typename T::value_type (CL_PARENT::*pilot) (const BaseMappedIntegrationPoint& mip, const typename T::value_type) const= nullptr; - + public: ngData_class(); - ngData_class(shared_ptr<MeshAccess> mesh_in, IntegrationRule intrule_in, const vector<vector<MappedIntegrationPoint<DIM_MESH, DIM_MESH>> >& mips_in, - CL_PARENT * parent = nullptr, typename T::value_type (CL_PARENT::*pilot) (const BaseMappedIntegrationPoint& mip, const typename T::value_type) const = nullptr); - - ngData_class(shared_ptr<MeshAccess>& mesh, IntegrationRule& intrule, const shared_ptr<CoefficientFunction>& ptrMask=nullptr, - CL_PARENT * parent = nullptr, typename T::value_type (CL_PARENT::*pilot) (const BaseMappedIntegrationPoint& mip, const typename T::value_type) const = nullptr); + ngData_class(shared_ptr<MeshAccess> mesh_in, IntegrationRule intrule_in, const vector<vector<MappedIntegrationPoint<DIM_MESH, DIM_MESH>> >& mips_in); + ngData_class(shared_ptr<MeshAccess>& mesh, IntegrationRule& intrule, const shared_ptr<CoefficientFunction>& ptrMask=nullptr); // copy const ngData_class(const ngData_class& o); @@ -147,17 +133,17 @@ class ngData_class : public CoefficientFunction{ void SetNumEntries(unsigned int o); // for now, just around xyz-axis - std::shared_ptr<ngData_class<T, DIM_MESH, CL_PARENT>> GetRotatedValues(const double phi, unsigned int axis=2); + std::shared_ptr<ngData_class<T, DIM_MESH>> GetRotatedValues(const double phi, unsigned int axis=2); [[nodiscard]] bool GetAutoUpdate() const; void SetAutoUpdate(const bool val); - [[nodiscard]] shared_ptr<ngData_class<T, DIM_MESH, CL_PARENT>> GetDerivative() const; - void SetDerivative(const shared_ptr<ngData_class<T, DIM_MESH, CL_PARENT>> val); + [[nodiscard]] shared_ptr<ngData_class<T, DIM_MESH>> GetDerivative() const; + void SetDerivative(const shared_ptr<ngData_class<T, DIM_MESH>> val); - template<typename iT, unsigned int iDIM_MESH, typename iCL_PARENT> - friend std::ostream& operator << (std::ostream& o, const ngData_class<iT, iDIM_MESH, iCL_PARENT>& m); + template<typename iT, unsigned int iDIM_MESH> + friend std::ostream& operator << (std::ostream& o, const ngData_class<iT, iDIM_MESH>& m); virtual void Evaluate(const BaseMappedIntegrationPoint& ip, FlatVector<Complex> result) const; @@ -185,12 +171,12 @@ class ngData_class : public CoefficientFunction{ -template<typename T, unsigned int DIM_MESH, typename CL_PARENT=dummyPilot<T>> -using ngScalar_class = ngData_class<scal_t<T>, DIM_MESH, CL_PARENT>; -template<typename T, unsigned int DIM_MESH, typename CL_PARENT=dummyPilot<T>> -using ngVector_class = ngData_class<vec_t<T, DIM_MESH>, DIM_MESH, CL_PARENT>; -template<typename T, unsigned int DIM_MESH, typename CL_PARENT=dummyPilot<T>> -using ngMat_class = ngData_class<mat_t<T, DIM_MESH, DIM_MESH>, DIM_MESH, CL_PARENT>; +template<typename T, unsigned int DIM_MESH> +using ngScalar_class = ngData_class<scal_t<T>, DIM_MESH>; +template<typename T, unsigned int DIM_MESH> +using ngVector_class = ngData_class<vec_t<T, DIM_MESH>, DIM_MESH>; +template<typename T, unsigned int DIM_MESH> +using ngMat_class = ngData_class<mat_t<T, DIM_MESH, DIM_MESH>, DIM_MESH>; diff --git a/C++/libMain.h b/C++/libMain.h index a93ced5cd274d1c842a222a19179b95936938e74..68ec0c241dc71b4bdb1ecb118e15116cf74657cc 100644 --- a/C++/libMain.h +++ b/C++/libMain.h @@ -37,7 +37,7 @@ void ExportReclibPhiFunctions(py::module &m); #ifdef CMAKE_BASICCLASSES void ExportReclibBasicClasses(py::module &m); -template<typename T, unsigned int DIM, typename CL_PARENT=dummyPilot<typename T::value_type>> +template<typename T, unsigned int DIM> void declare_ngData_class(py::module &m, std::string name, std::string suffix=""); #endif diff --git a/C++/preisach/ngPreisachScalar.cc b/C++/preisach/ngPreisachScalar.cc index 7dacb7b720d1017a800e417ee1ae28d729dfef3c..49bbdf8d30130d805309e20b5838c1c1da0b4000 100644 --- a/C++/preisach/ngPreisachScalar.cc +++ b/C++/preisach/ngPreisachScalar.cc @@ -740,11 +740,11 @@ const shared_ptr<ngScalar_class<double, DIM>> ngPreisachScalar<DIM>::GetReactive } template <unsigned int DIM> -const shared_ptr<ngScalar_class<double, DIM, ngPreisachScalar<DIM>>> ngPreisachScalar<DIM>::GetB(const bool autoupdate){ +const shared_ptr<ngScalar_class<double, DIM>> ngPreisachScalar<DIM>::GetB(const bool autoupdate){ //----------- MEMORY DEMANDING --------------- // flux density if(ptrFluxDens == nullptr){ - ptrFluxDens = std::make_shared<ngScalar_class<double, DIM, ngPreisachScalar<DIM>>>(mesh, intrule, mips, this, &ngPreisachScalar<DIM>::pilotForward<TYPES_PILOT::OUTPUT>); + ptrFluxDens = std::make_shared<ngScalar_class<double, DIM>>(mesh, intrule, mips); ptrFluxDens->SetAutoUpdate(autoupdate); Update(); } @@ -752,30 +752,30 @@ const shared_ptr<ngScalar_class<double, DIM, ngPreisachScalar<DIM>>> ngPreisachS } template <unsigned int DIM> -const shared_ptr<ngScalar_class<double, DIM, ngPreisachScalar<DIM>>> ngPreisachScalar<DIM>::GetH(const bool autoupdate){ +const shared_ptr<ngScalar_class<double, DIM>> ngPreisachScalar<DIM>::GetH(const bool autoupdate){ // field strength if(ptrFieldStrength == nullptr){ - ptrFieldStrength = std::make_shared<ngScalar_class<double, DIM, ngPreisachScalar<DIM>>>(mesh, intrule, mips, this, &ngPreisachScalar<DIM>::pilotForward<TYPES_PILOT::INPUT>); + ptrFieldStrength = std::make_shared<ngScalar_class<double, DIM>>(mesh, intrule, mips); ptrFieldStrength->SetAutoUpdate(autoupdate); Update(); } return ptrFieldStrength; } template <unsigned int DIM> -const shared_ptr<ngScalar_class<double, DIM, ngPreisachScalar<DIM>>> ngPreisachScalar<DIM>::GetMu(const bool autoupdate){ +const shared_ptr<ngScalar_class<double, DIM>> ngPreisachScalar<DIM>::GetMu(const bool autoupdate){ // diff_mu if(ptrMu == nullptr){ - ptrMu = std::make_shared<ngScalar_class<double, DIM, ngPreisachScalar<DIM>>>(mesh, intrule, mips, this, &ngPreisachScalar<DIM>::pilotForward<TYPES_PILOT::MAT>); + ptrMu = std::make_shared<ngScalar_class<double, DIM>>(mesh, intrule, mips); ptrMu->SetAutoUpdate(autoupdate); Update(); } return ptrMu; } template <unsigned int DIM> -const shared_ptr<ngScalar_class<double, DIM, ngPreisachScalar<DIM>>> ngPreisachScalar<DIM>::GetMuDiff(const bool autoupdate){ +const shared_ptr<ngScalar_class<double, DIM>> ngPreisachScalar<DIM>::GetMuDiff(const bool autoupdate){ // diff_mu if(ptrMuDiff == nullptr){ - ptrMuDiff = std::make_shared<ngScalar_class<double, DIM, ngPreisachScalar<DIM>>>(mesh, intrule, mips, this, &ngPreisachScalar<DIM>::pilotForward<TYPES_PILOT::MAT_DIFF>); + ptrMuDiff = std::make_shared<ngScalar_class<double, DIM>>(mesh, intrule, mips); ptrMuDiff->SetAutoUpdate(autoupdate); Update(); } @@ -783,10 +783,10 @@ const shared_ptr<ngScalar_class<double, DIM, ngPreisachScalar<DIM>>> ngPreisachS } template <unsigned int DIM> -const shared_ptr<ngScalar_class<double, DIM, ngPreisachScalar<DIM>>> ngPreisachScalar<DIM>::GetMatDiffDiff(const bool autoupdate){ +const shared_ptr<ngScalar_class<double, DIM>> ngPreisachScalar<DIM>::GetMatDiffDiff(const bool autoupdate){ // diffdiff_mu if(ptrMatDiffDiff == nullptr){ - ptrMatDiffDiff = std::make_shared<ngScalar_class<double, DIM, ngPreisachScalar<DIM>>>(mesh, intrule, mips, this, &ngPreisachScalar<DIM>::pilotForward<TYPES_PILOT::MAT_DIFFDIFF>); + ptrMatDiffDiff = std::make_shared<ngScalar_class<double, DIM>>(mesh, intrule, mips); ptrMatDiffDiff->SetAutoUpdate(true); Update(); diff --git a/C++/preisach/ngPreisachScalar.h b/C++/preisach/ngPreisachScalar.h index ce0e8e070ba2524519a5a25aafff4cbd7c2dbc49..9d86928106df6d61ced9c554d190ddc535977e31 100644 --- a/C++/preisach/ngPreisachScalar.h +++ b/C++/preisach/ngPreisachScalar.h @@ -58,11 +58,11 @@ class ngPreisachScalar:public CoefficientFunction ~ngPreisachScalar() = default; - const shared_ptr<ngScalar_class<double, DIM, ngPreisachScalar<DIM>>> GetB(const bool autoupdate=true); - const shared_ptr<ngScalar_class<double, DIM, ngPreisachScalar<DIM>>> GetH(const bool autoupdate=true); - const shared_ptr<ngScalar_class<double, DIM, ngPreisachScalar<DIM>>> GetMu(const bool autoupdate=true); - const shared_ptr<ngScalar_class<double, DIM, ngPreisachScalar<DIM>>> GetMuDiff(const bool autoupdate=true); - const shared_ptr<ngScalar_class<double, DIM, ngPreisachScalar<DIM>>> GetMatDiffDiff(const bool autoupdate=true); + const shared_ptr<ngScalar_class<double, DIM>> GetB(const bool autoupdate=true); + const shared_ptr<ngScalar_class<double, DIM>> GetH(const bool autoupdate=true); + const shared_ptr<ngScalar_class<double, DIM>> GetMu(const bool autoupdate=true); + const shared_ptr<ngScalar_class<double, DIM>> GetMuDiff(const bool autoupdate=true); + const shared_ptr<ngScalar_class<double, DIM>> GetMatDiffDiff(const bool autoupdate=true); const shared_ptr<ngScalar_class<double, DIM>> GetNu(const bool autoupdate=true); const shared_ptr<ngScalar_class<double, DIM>> GetNuDiff(const bool autoupdate=true); const shared_ptr<ngScalar_class<double, DIM>> GetEnergyDensity(const bool autoupdate=false); @@ -170,11 +170,11 @@ class ngPreisachScalar:public CoefficientFunction std::unordered_map<shared_ptr<preisach>, std::pair<unsigned int, unsigned int> > elIpResponsibleForUpdatingPreisach; shared_ptr<EverettMatrix> ptrEverettMatrix; - shared_ptr<ngScalar_class<double, DIM, ngPreisachScalar<DIM>>> ptrFluxDens; - shared_ptr<ngScalar_class<double, DIM, ngPreisachScalar<DIM>>> ptrFieldStrength; - shared_ptr<ngScalar_class<double, DIM, ngPreisachScalar<DIM>>> ptrMu; - shared_ptr<ngScalar_class<double, DIM, ngPreisachScalar<DIM>>> ptrMuDiff; - shared_ptr<ngScalar_class<double, DIM, ngPreisachScalar<DIM>>> ptrMatDiffDiff; + shared_ptr<ngScalar_class<double, DIM>> ptrFluxDens; + shared_ptr<ngScalar_class<double, DIM>> ptrFieldStrength; + shared_ptr<ngScalar_class<double, DIM>> ptrMu; + shared_ptr<ngScalar_class<double, DIM>> ptrMuDiff; + shared_ptr<ngScalar_class<double, DIM>> ptrMatDiffDiff; shared_ptr<ngScalar_class<double, DIM>> ptrNu; shared_ptr<ngScalar_class<double, DIM>> ptrNuDiff; shared_ptr<ngScalar_class<double, DIM>> ptrEnergyDens;