Fixed: Avoid memory corruption when multi-threaded CGL2 and -principal.
Also handle patch index out-of-range in SIMgeneric::evalPoint.
This commit is contained in:
		@@ -2354,7 +2354,9 @@ bool SIMbase::project (Matrix& ssol, const Vector& psol,
 | 
			
		||||
    if (myModel[i]->empty()) continue; // skip empty patches
 | 
			
		||||
 | 
			
		||||
    // Extract the primary solution control point values for this patch
 | 
			
		||||
    extractPatchSolution(myProblem,Vectors(1,psol),i);
 | 
			
		||||
    myProblem->initResultPoints(time.t);
 | 
			
		||||
    if (!this->extractPatchSolution(myProblem,Vectors(1,psol),i))
 | 
			
		||||
      return false;
 | 
			
		||||
 | 
			
		||||
    // Initialize material properties for this patch in case of multiple regions
 | 
			
		||||
    const_cast<SIMbase*>(this)->setPatchMaterial(i+1);
 | 
			
		||||
 
 | 
			
		||||
@@ -47,13 +47,14 @@ Vector SIMgeneric::getSolution (const Vector& psol, const double* par,
 | 
			
		||||
  return tmpVal.getColumn(1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SIMgeneric::evalPoint(const double* xi, Vec3& X, double* param, int patch) const
 | 
			
		||||
{
 | 
			
		||||
  ASMbase *pch = getPatch(patch-1);
 | 
			
		||||
 | 
			
		||||
  double dummy[2];
 | 
			
		||||
  if(param == nullptr)
 | 
			
		||||
    return pch->evalPoint(xi, dummy, X);
 | 
			
		||||
  else
 | 
			
		||||
    return pch->evalPoint(xi, param, X);
 | 
			
		||||
int SIMgeneric::evalPoint (const double* xi, Vec3& X, double* param,
 | 
			
		||||
                           int patch) const
 | 
			
		||||
{
 | 
			
		||||
  patch = this->getLocalPatchIndex(patch);
 | 
			
		||||
  if (patch < 1 || (size_t)patch > myModel.size())
 | 
			
		||||
    return -1;
 | 
			
		||||
 | 
			
		||||
  double dummy[3];
 | 
			
		||||
  return myModel[patch-1]->evalPoint(xi, param ? param : dummy, X);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -50,8 +50,8 @@ public:
 | 
			
		||||
  //! \param[in] xi Dimensionless parameters in range [0,1] of the point
 | 
			
		||||
  //! \param[out] X The Cartesian coordinates of the point
 | 
			
		||||
  //! \param[out] param The parameters of the point in the knot-span domain
 | 
			
		||||
  //! \param[in] patch The patch to evaluate
 | 
			
		||||
  //! \return 0 if the evaluation went good
 | 
			
		||||
  //! \param[in] patch 1-based patch index contining the evaluation point
 | 
			
		||||
  //! \return Local node number within the patch that matches the point
 | 
			
		||||
  int evalPoint(const double* xi, Vec3& X,
 | 
			
		||||
                double* param = nullptr, int patch = 1) const;
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user