@@ -126,7 +126,7 @@ namespace GridKit
126126 /* *
127127 * @brief Get the absolute tolerance for each variable in the model
128128 *
129- * @return a view of the absolute tolerance vector.
129+ * @return the absolute tolerance vector.
130130 *
131131 * @pre `setAbsoluteTolerance` must have been called first.
132132 */
@@ -138,7 +138,7 @@ namespace GridKit
138138 /* *
139139 * @brief Get the absolute tolerance for each variable in the model
140140 *
141- * @return a const view of the absolute tolerance vector.
141+ * @return the absolute tolerance vector.
142142 *
143143 * @pre `setAbsoluteTolerance` must have been called first.
144144 */
@@ -225,26 +225,27 @@ namespace GridKit
225225 virtual void bind (VectorT& y, VectorT& yp, VectorT& f, VectorT& tag, VectorT& abs_tol, IdxT offset)
226226 {
227227 const IdxT n = size ();
228- assert (static_cast <std::size_t >(offset) + static_cast <std::size_t >(n) <= y.size ());
229- assert (static_cast <std::size_t >(offset) + static_cast <std::size_t >(n) <= yp.size ());
230- assert (static_cast <std::size_t >(offset) + static_cast <std::size_t >(n) <= f.size ());
231- assert (static_cast <std::size_t >(offset) + static_cast <std::size_t >(n) <= tag.size ());
232- assert (static_cast <std::size_t >(offset) + static_cast <std::size_t >(n) <= abs_tol.size ());
228+ assert (!allocated_);
229+ assert (offset + n <= y.getSize ());
230+ assert (offset + n <= yp.getSize ());
231+ assert (offset + n <= f.getSize ());
232+ assert (offset + n <= tag.getSize ());
233+ assert (offset + n <= abs_tol.getSize ());
233234
234- y_ = VectorT (n);
235- y_.setData (y.data ( ) + offset);
235+ y_. resize (n);
236+ y_.setData (y.getData (memory:: HOST ) + offset);
236237
237- yp_ = VectorT (n);
238- yp_.setData (yp.data ( ) + offset);
238+ yp_. resize (n);
239+ yp_.setData (yp.getData (memory:: HOST ) + offset);
239240
240- f_ = VectorT (n);
241- f_.setData (f.data ( ) + offset);
241+ f_. resize (n);
242+ f_.setData (f.getData (memory:: HOST ) + offset);
242243
243- tag_ = VectorT (n);
244- tag_.setData (tag.data ( ) + offset);
244+ tag_. resize (n);
245+ tag_.setData (tag.getData (memory:: HOST ) + offset);
245246
246- abs_tol_ = VectorT (n);
247- abs_tol_.setData (abs_tol.data ( ) + offset);
247+ abs_tol_. resize (n);
248+ abs_tol_.setData (abs_tol.getData (memory:: HOST ) + offset);
248249
249250 offset_ = offset;
250251 allocated_ = true ;
@@ -256,25 +257,25 @@ namespace GridKit
256257 */
257258 void allocateVectors (IdxT n)
258259 {
259- y_ = VectorT (n);
260+ y_. resize (n);
260261 y_.allocate (memory::HOST );
261- y_.setDataUpdated (memory::HOST );
262+ y_.setToZero (memory::HOST );
262263
263- yp_ = VectorT (n);
264+ yp_. resize (n);
264265 yp_.allocate (memory::HOST );
265- yp_.setDataUpdated (memory::HOST );
266+ yp_.setToZero (memory::HOST );
266267
267- f_ = VectorT (n);
268+ f_. resize (n);
268269 f_.allocate (memory::HOST );
269- f_.setDataUpdated (memory::HOST );
270+ f_.setToZero (memory::HOST );
270271
271- tag_ = VectorT (n);
272+ tag_. resize (n);
272273 tag_.allocate (memory::HOST );
273- tag_.setDataUpdated (memory::HOST );
274+ tag_.setToZero (memory::HOST );
274275
275- abs_tol_ = VectorT (n);
276+ abs_tol_. resize (n);
276277 abs_tol_.allocate (memory::HOST );
277- abs_tol_.setDataUpdated (memory::HOST );
278+ abs_tol_.setToZero (memory::HOST );
278279
279280 offset_ = 0 ;
280281 allocated_ = true ;
0 commit comments