@@ -204,7 +204,7 @@ def test_manysweepsequalmatrix(self):
204204 #
205205 # Make sure that update function for K sweeps computed from K-sweep matrix gives same result as K sweeps in node-to-node form plus compute_end_point
206206 #
207- def test_maysweepupdate (self ):
207+ def test_manysweepupdate (self ):
208208
209209 step , level , problem , nnodes = self .setupLevelStepProblem ()
210210 step .levels [0 ].sweep .predict ()
@@ -229,3 +229,48 @@ def test_maysweepupdate(self):
229229 # Multiply u0 by value of update function to get end value directly
230230 uend_matrix = update * self .pparams ['u0' ]
231231 assert abs (uend_matrix - uend_sweep )< 1e-14 , "Node-to-node sweep plus update yields different result than update function computed through K-sweep matrix"
232+
233+ #
234+ # Make sure that creating a sweeper object with a collocation object with right_is_node=False and do_coll_update=False throws an exception
235+ #
236+ def test_norightnode_collupdate_fails (self ):
237+ self .swparams ['collocation_class' ] = collclass .CollGaussLegendre
238+ self .swparams ['do_coll_update' ] = False
239+ # Has to throw an exception
240+ with self .assertRaises (AssertionError ):
241+ step , level , problem , nnodes = self .setupLevelStepProblem ()
242+
243+ #
244+ # Make sure the update with do_coll_update=False reproduces last stage
245+ #
246+ def test_update_nocollupdate_laststage (self ):
247+ self .swparams ['do_coll_update' ] = False
248+ step , level , problem , nnodes = self .setupLevelStepProblem ()
249+ level .sweep .predict ()
250+ ulaststage = np .random .rand ()
251+ level .u [nnodes ].values = ulaststage
252+ level .sweep .compute_end_point ()
253+ uend = level .uend .values
254+ assert abs (uend - ulaststage )< 1e-14 , "compute_end_point with do_coll_update=False did not reproduce last stage value"
255+
256+ #
257+ # Make sure that update with do_coll_update=False is identical to update formula with q=(0,...,0,1)
258+ #
259+ def test_updateformula_no_coll_update (self ):
260+ self .swparams ['do_coll_update' ] = False
261+ step , level , problem , nnodes = self .setupLevelStepProblem ()
262+ level .sweep .predict ()
263+ u0full = np .array ([ level .u [l ].values .flatten () for l in range (1 ,nnodes + 1 ) ])
264+
265+ # Perform update step in sweeper
266+ level .sweep .update_nodes ()
267+ ustages = np .array ([ level .u [l ].values .flatten () for l in range (1 ,nnodes + 1 ) ])
268+
269+ # Compute end value through provided function
270+ level .sweep .compute_end_point ()
271+ uend_sweep = level .uend .values
272+ # Compute end value from matrix formulation
273+ q = np .zeros (nnodes )
274+ q [nnodes - 1 ] = 1.0
275+ uend_mat = q .dot (ustages )
276+ assert np .linalg .norm (uend_sweep - uend_mat , np .infty )< 1e-14 , "For do_coll_update=False, update formula in sweeper gives different result than matrix update formula with q=(0,..,0,1)"
0 commit comments