<commit_before>#ifndef CHC_LCPITERATIVESOLVERGPU_H
#define CHC_LCPITERATIVESOLVERGPU_H

//////////////////////////////////////////////////
//
//   ChIterativeGPU.h
//
//   GPU LCP Solver
//
//   HEADER file for CHRONO,
//   Multibody dynamics engine
//
// ------------------------------------------------
//   Copyright:<NAME> / DeltaKnowledge
//             www.deltaknowledge.com
// ------------------------------------------------
///////////////////////////////////////////////////

#include "lcp/ChLcpIterativeSolver.h"

#include "chrono_parallel/ChParallelDefines.h"
#include "chrono_parallel/ChDataManager.h"
#include "chrono_parallel/ChIntegratorParallel.h"
#include "chrono_parallel/solver/ChSolverParallel.h"
#include "chrono_parallel/constraints/ChConstraintRigidRigid.h"
#include "chrono_parallel/constraints/ChConstraintBilateral.h"
#include "chrono_parallel/math/ChParallelMath.h"

namespace chrono {

class CH_PARALLEL_API ChLcpSolverParallel : public ChLcpIterativeSolver {
 public:
  ChLcpSolverParallel() {
    tolerance = 1e-7;

    max_iter_bilateral = 100;
    record_violation_history = true;
    warm_start = false;
  }

  virtual ~ChLcpSolverParallel() {
  }

  virtual double Solve(ChLcpSystemDescriptor &sysd) {
    return 0;
  }
  void host_addForces(bool* active, real *mass, real3 *inertia, real3 *forces, real3 *torques, real3 *vel, real3 *omega);

  void host_ComputeGyro(real3 *omega, real3 *inertia, real3 *gyro, real3 *torque);

  void host_Integrate_Timestep(bool *active, real3 *acc, real4 *rot, real3 *vel, real3 *omega, real3 *pos, real3 *lim);

  virtual void RunTimeStep(real step) = 0;
  void Preprocess();

  void SetTolerance(real tol) {
    tolerance = tol;
  }

  void SetMaxIterationBilateral(uint max_iter) {
    max_iter_bilateral = max_iter;
  }
  real GetResidual() {
    return residual;
  }
  void Dump_Rhs(std::vector<double> &temp) {
    for (int i = 0; i < rhs.size(); i++) {
      temp.push_back(rhs[i]);
    }
  }
  void Dump_Shur(std::vector<double> &temp) {
    for (int i = 0; i < debug.size(); i++) {
      temp.push_back(debug[i]);
    }
  }
  void Dump_Lambda(std::vector<double> &temp) {
    for (int i = 0; i < lambda.size(); i++) {
      temp.push_back(lambda[i]);
    }
  }

  ChParallelDataManager *data_container;
  int3 num_bins_per_axis;
  real3 origin;
  real3 bin_size_vec;

 protected:
  real tolerance;

  uint max_iter_bilateral;

  real residual;

  cudaEvent_t start, stop;

  custom_vector<real> rhs, debug, lambda;

  ChConstraintBilateral bilateral;
};

class CH_PARALLEL_API ChLcpSolverParallelDVI : public ChLcpSolverParallel {
 public:
  ChLcpSolverParallelDVI() {
    alpha = .2;
    contact_recovery_speed = .6;
    solver_type = ACCELERATED_PROJECTED_GRADIENT_DESCENT;
    do_stab = false;
    collision_inside = false;

    max_iteration = 1000;
    max_iter_normal = max_iter_sliding = max_iter_spinning = 100;
  }

  virtual void RunTimeStep(real step);
  void RunWarmStartPostProcess();
  void RunWarmStartPreprocess();

  void SetCompliance(real a) {
    data_container->alpha = a;
  }
  void SetSolverType(GPUSOLVERTYPE type) {<commit_msg>Cleanup.<commit_after>#ifndef CHC_LCPITERATIVESOLVERGPU_H
#define CHC_LCPITERATIVESOLVERGPU_H

//////////////////////////////////////////////////
//
//   ChIterativeGPU.h
//
//   GPU LCP Solver
//
//   HEADER file for CHRONO,
//   Multibody dynamics engine
//
// ------------------------------------------------
//   Copyright:<NAME> / DeltaKnowledge
//             www.deltaknowledge.com
// ------------------------------------------------
///////////////////////////////////////////////////

#include "lcp/ChLcpIterativeSolver.h"

#include "chrono_parallel/ChParallelDefines.h"
#include "chrono_parallel/ChDataManager.h"
#include "chrono_parallel/ChIntegratorParallel.h"
#include "chrono_parallel/solver/ChSolverParallel.h"
#include "chrono_parallel/constraints/ChConstraintRigidRigid.h"
#include "chrono_parallel/constraints/ChConstraintBilateral.h"
#include "chrono_parallel/math/ChParallelMath.h"

namespace chrono {

class CH_PARALLEL_API ChLcpSolverParallel : public ChLcpIterativeSolver {
 public:
  ChLcpSolverParallel() {
    tolerance = 1e-7;

    max_iter_bilateral = 100;
    record_violation_history = true;
    warm_start = false;
  }

  virtual ~ChLcpSolverParallel() {
  }

  virtual double Solve(ChLcpSystemDescriptor &sysd) {
    return 0;
  }
  void host_addForces(bool* active, real *mass, real3 *inertia, real3 *forces, real3 *torques, real3 *vel, real3 *omega);

  void host_ComputeGyro(real3 *omega, real3 *inertia, real3 *gyro, real3 *torque);

  void host_Integrate_Timestep(bool *active, real3 *acc, real4 *rot, real3 *vel, real3 *omega, real3 *pos, real3 *lim);

  virtual void RunTimeStep(real step) = 0;
  void Preprocess();

  void SetTolerance(real tol) {
    tolerance = tol;
  }

  void SetMaxIterationBilateral(uint max_iter) {
    max_iter_bilateral = max_iter;
  }
  real GetResidual() {
    return residual;
  }
  void Dump_Rhs(std::vector<double> &temp) {
    for (int i = 0; i < rhs.size(); i++) {
      temp.push_back(rhs[i]);
    }
  }
  void Dump_Shur(std::vector<double> &temp) {
    for (int i = 0; i < debug.size(); i++) {
      temp.push_back(debug[i]);
    }
  }
  void Dump_Lambda(std::vector<double> &temp) {
    for (int i = 0; i < lambda.size(); i++) {
      temp.push_back(lambda[i]);
    }
  }

  ChParallelDataManager *data_container;
  int3 num_bins_per_axis;
  real3 origin;
  real3 bin_size_vec;

 protected:
  real tolerance;

  uint max_iter_bilateral;

  real residual;

  custom_vector<real> rhs, debug, lambda;

  ChConstraintBilateral bilateral;
};

class CH_PARALLEL_API ChLcpSolverParallelDVI : public ChLcpSolverParallel {
 public:
  ChLcpSolverParallelDVI() {
    alpha = .2;
    contact_recovery_speed = .6;
    solver_type = ACCELERATED_PROJECTED_GRADIENT_DESCENT;
    do_stab = false;
    collision_inside = false;

    max_iteration = 1000;
    max_iter_normal = max_iter_sliding = max_iter_spinning = 100;
  }

  virtual void RunTimeStep(real step);
  void RunWarmStartPostProcess();
  void RunWarmStartPreprocess();

  void SetCompliance(real a) {
    data_container->alpha = a;
  }
  void SetSolverType(GPUSOLVERTYPE type) {
{'fraction_non_alphanumeric': 0.1667469106082491, 'fraction_numerical': 0.011876103354196758, 'mean_word_length': 3.0, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6268363', 'n_tokens_mistral': 2242, 'n_tokens_neox': 2170, 'n_words': 427}