@@ -270,13 +270,13 @@ template <typename SpSpace_> class BsFunction : public ScalarFieldBase<SpSpace_:
270270 if (e_id == -1 ) return std::numeric_limits<Scalar>::quiet_NaN (); // return NaN if point lies outside domain
271271 // map p to reference interval [-1, 1]
272272 double a = sp_space_->triangulation ().range ()[0 ], b = sp_space_->triangulation ().range ()[1 ];
273- double ref_p ;
273+ double p_ ;
274274 if constexpr (internals::is_subscriptable<InputType, int >) {
275- ref_p = p[0 ];
275+ p_ = p[0 ];
276276 } else {
277- ref_p = p;
277+ p_ = p;
278278 }
279- ref_p = (ref_p - (b - a) / 2 ) * 2 / (b + a);
279+ double ref_p = 2 * (p_ - a) / (b - a) - 1 ;
280280 // get active dofs
281281 typename DofHandlerType::CellType cell = sp_space_->dof_handler ().cell (e_id);
282282 std::vector<int > active_dofs = cell.dofs ();
@@ -327,7 +327,6 @@ template <typename Derived_> struct SpMap : public ScalarFieldBase<Derived_::Sta
327327 private:
328328 using OutputType = decltype (std::declval<Derived_>().operator ()(std::declval<typename Derived_::InputType>()));
329329 using Derived = std::decay_t <Derived_>;
330- using MatrixType = Eigen::Matrix<double , Dynamic, Dynamic>;
331330 public:
332331 using InputType = internals::sp_assembler_packet<Derived::StaticInputSize>;
333332 using Scalar = double ;
@@ -340,32 +339,25 @@ template <typename Derived_> struct SpMap : public ScalarFieldBase<Derived_::Sta
340339 static constexpr int Cols = 1 ;
341340
342341 constexpr SpMap () = default;
343- constexpr SpMap (const Derived_& xpr) : xpr_(& xpr) { }
342+ constexpr SpMap (const Derived_& xpr) : xpr_(xpr) { }
344343 template <typename CellIterator>
345344 void init (
346- std::unordered_map< const void *, MatrixType>& buff, const MatrixType & nodes, [[maybe_unused]] CellIterator begin,
345+ const Eigen::Matrix< double , Dynamic, Dynamic> & nodes, [[maybe_unused]] CellIterator begin,
347346 [[maybe_unused]] CellIterator end) const {
348- const void * ptr = reinterpret_cast <const void *>(xpr_);
349- if (buff.find (ptr) == buff.end ()) {
350- Eigen::Matrix<double , Dynamic, Dynamic> mapped (nodes.rows (), Rows * Cols);
351- for (int i = 0 , n = nodes.rows (); i < n; ++i) { mapped (i, 0 ) = xpr_->operator ()(nodes.row (i)); }
352- buff[ptr] = mapped;
353- map_ = &buff[ptr];
354- } else {
355- map_ = &buff[ptr];
356- }
347+ map_.resize (nodes.rows (), Rows * Cols);
348+ for (int i = 0 , n = nodes.rows (); i < n; ++i) { map_ (i, 0 ) = xpr_ (nodes.row (i)); }
357349 }
358350 // bs assembler evaluation
359351 constexpr OutputType operator ()(const InputType& sp_packet) const {
360- return map_-> operator () (sp_packet.quad_node_id , 0 );
352+ return map_ (sp_packet.quad_node_id , 0 );
361353 }
362354 constexpr const Derived& derived () const { return xpr_; }
363355 constexpr int input_size () const { return StaticInputSize; }
364356 constexpr int rows () const { return Rows; }
365357 constexpr int cols () const { return Cols; }
366358 private:
367- const Derived* xpr_;
368- mutable const MatrixType* map_;
359+ Derived xpr_;
360+ mutable Eigen::Matrix< double , Dynamic, Dynamic> map_;
369361};
370362
371363} // namespace fdapde
0 commit comments