@@ -66,7 +66,7 @@ GenerateStreamLinesAlgo::GenerateStreamLinesAlgo()
6666 addParameter (Parameters::StreamlineMaxSteps, 2000 );
6767 addOption (Parameters::StreamlineDirection, " Both" , " Negative|Both|Positive" );
6868 addOption (Parameters::StreamlineValue, " Seed index" , " Seed value|Seed index|Integration index|Integration step|Distance from seed|Streamline length" );
69- addParameter (Parameters::RemoveColinearPoints, false );
69+ addParameter (Parameters::RemoveColinearPoints, true );
7070 addOption (Parameters::StreamlineMethod, " RungeKuttaFehlberg" , " AdamsBashforth|Heun|RungeKutta|RungeKuttaFehlberg|CellWalk" );
7171 // Estimate step size and tolerance automatically based on average edge length
7272 addParameter (Parameters::AutoParameters,false );
@@ -383,7 +383,7 @@ void GenerateStreamLinesAlgoP::parallel(int proc_num)
383383 if (success_[q] == false ) return ;
384384
385385 const index_type start_gd = (global_dimension_ * proc_num)/numprocessors_+1 ;
386- const index_type end_gd = (global_dimension_ * (proc_num+1 ))/numprocessors_+ 1 ;
386+ const index_type end_gd = (global_dimension_ * (proc_num+1 ))/numprocessors_;
387387
388388 outputs_[proc_num]=StreamLinesForCertainSeeds (start_gd, end_gd, proc_num);
389389}
@@ -401,16 +401,15 @@ bool GenerateStreamLinesAlgoP::run(FieldHandle input,
401401 omesh_ = output->vmesh ();
402402 tolerance_ = algo_->get (Parameters::StreamlineTolerance).toDouble ();
403403 step_size_ = algo_->get (Parameters::StreamlineStepSize).toDouble ();
404- max_steps_ = algo_->get (Parameters::StreamlineMaxSteps).toInt ();
404+ max_steps_ = algo_->get (Parameters::StreamlineMaxSteps).toInt ();
405405 direction_ = convertDirectionOption (algo_->getOption (Parameters::StreamlineDirection));
406406 value_ = convertValue (algo_->getOption (Parameters::StreamlineValue));
407407 remove_colinear_pts_ = algo_->get (Parameters::RemoveColinearPoints).toBool ();
408408 method_ = method;
409409 input_=input;
410-
411- global_dimension_=seed_mesh_->num_nodes ()-1 ;
412- if (global_dimension_<numprocessors_) numprocessors_=1 ;
413- if (numprocessors_>16 ) numprocessors_=16 ;
410+ global_dimension_=seed_mesh_->num_nodes ();
411+ if (global_dimension_<numprocessors_ || numprocessors_<1 ) numprocessors_=1 ;
412+ if (numprocessors_>16 ) numprocessors_=16 ; // request from Dan White to limit the number of threads
414413 success_.resize (numprocessors_,true );
415414 outputs_.resize (numprocessors_, nullptr );
416415
@@ -470,14 +469,11 @@ class GenerateStreamLinesAccAlgo {
470469void GenerateStreamLinesAccAlgo::parallel (int proc_num)
471470{
472471 success_[proc_num] = true ;
473-
474472 for (int q=0 ; q<numprocessors_;q++)
475- if (success_[q] == false ) return ;
476-
477- const index_type start_gd = (global_dimension_ * proc_num)/numprocessors_+1 ;
478- const index_type end_gd = (global_dimension_ * (proc_num+1 ))/numprocessors_+1 ;
479-
480- outputs_[proc_num]=StreamLinesForCertainSeeds (start_gd, end_gd, proc_num);
473+ if (success_[q] == false ) return ;
474+ const index_type start_gd = (global_dimension_ * proc_num)/numprocessors_;
475+ const index_type end_gd = (global_dimension_ * (proc_num+1 ))/numprocessors_;
476+ outputs_[proc_num]=StreamLinesForCertainSeeds (start_gd, end_gd, proc_num);
481477}
482478
483479
@@ -488,25 +484,21 @@ FieldHandle GenerateStreamLinesAccAlgo::StreamLinesForCertainSeeds(VMesh::Node::
488484 fi.make_lineardata ();
489485 fi.make_linearmesh ();
490486 fi.make_double ();
491- FieldHandle out = CreateField (fi);
487+ FieldHandle out; // = CreateField(fi);
492488 try
493489 {
494490 out = CreateField (fi);
495491 VField* ofield=out->vfield ();
496492 VMesh* omesh=out->vmesh ();
497-
498493 Point seed;
499-
500494 VMesh::Elem::index_type elem;
501495 std::vector<Point> nodes;
502496 nodes.reserve (max_steps_);
503-
504497 std::vector<Point>::iterator node_iter;
505498 VMesh::Node::index_type n1, n2;
506499 VMesh::Node::array_type newnodes (2 );
507500
508501 // Try to find the streamline for each seed point.
509-
510502 for (VMesh::Node::index_type idx=from; idx<to; ++idx)
511503 {
512504 seed_mesh_->get_center (seed, idx);
@@ -655,15 +647,17 @@ bool GenerateStreamLinesAccAlgo::run(const AlgorithmBase* algo, FieldHandle inpu
655647{
656648 seed_field_ = seeds->vfield ();
657649 seed_mesh_ = seeds->vmesh ();
650+ input_=input;
658651 field_ = input->vfield ();
659652 mesh_ = input->vmesh ();
660653 algo_=algo;
661654 max_steps_ = algo_->get (Parameters::StreamlineMaxSteps).toInt ();
662655 direction_ = convertDirectionOption (algo_->getOption (Parameters::StreamlineDirection));
663656 value_ = convertValue (algo_->getOption (Parameters::StreamlineValue));
664657 remove_colinear_pts_ = algo_->get (Parameters::RemoveColinearPoints).toBool ();
665- global_dimension_=seed_mesh_->num_nodes ()- 1 ;
658+ global_dimension_=seed_mesh_->num_nodes ();
666659 if (global_dimension_<numprocessors_) numprocessors_=1 ;
660+ if (numprocessors_>16 ) numprocessors_=16 ;
667661 success_.resize (numprocessors_,true );
668662 outputs_.resize (numprocessors_, nullptr );
669663 Parallel::RunTasks ([this ](int i) { parallel (i); }, numprocessors_);
@@ -673,6 +667,7 @@ bool GenerateStreamLinesAccAlgo::run(const AlgorithmBase* algo, FieldHandle inpu
673667 if (outputs_[j] == nullptr ) return false ;
674668 }
675669 JoinFieldsAlgo JFalgo;
670+ JFalgo.set (JoinFieldsAlgo::Tolerance,1e-8 );
676671 JFalgo.set (JoinFieldsAlgo::MergeNodes,false );
677672 JFalgo.runImpl (outputs_, output);
678673
0 commit comments