<commit_before>//
// PROJECT CHRONO - http://projectchrono.org
//
// Copyright (c) 2013 Project Chrono
// All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be 
// found in the LICENSE file at the top level of the distribution
// and at http://projectchrono.org/license-chrono.txt.
//

#ifndef CHTIMESTEPPER_H
#define CHTIMESTEPPER_H

#include <stdlib.h>
#include "core/ChApiCE.h"
#include "core/ChMath.h"
#include "core/ChShared.h"
#include "core/ChVectorDynamic.h"
#include "timestepper/ChState.h"
#include "timestepper/ChIntegrable.h"


namespace chrono 
{



/// Base class for timesteppers, that is
/// a time integrator which can advance a system state.
/// It operates on systems inherited from ChIntegrable.

class ChTimestepper : public ChShared
{
protected:
	ChIntegrable* integrable;
	double T;

	//ChVectorDynamic<>* mL;
public:
					/// Constructor
	ChTimestepper(ChIntegrable& mintegrable) 
				{
					integrable = &mintegrable;
					T = 0;
					//mL    = new ChVectorDynamic<>(1);
				};
	
					/// Destructor
	virtual ~ChTimestepper()
				{
					//delete mL;
				};

					/// Performs an integration timestep
	virtual void Advance(
				const double dt				///< timestep to advance
				) =0;


					/// Access the lagrangian multipliers, if any
	//virtual ChVectorDynamic<>& L() { return *mL; }

					/// Get the integrable object 
	ChIntegrable* GetIntegrable() { return integrable;}
					
					/// Get the current time 
	virtual double GetTime() { return T;}

					/// Set the current time 
	virtual void SetTime(double mt) { T = mt;}
};



/// Base class for 1st order timesteppers, that is
/// a time integrator for whatever ChIntegrable.

class ChTimestepperIorder : public ChTimestepper
{
protected:
	ChState* mY;
	ChStateDelta* mdYdt;
public:

	/// Constructor
	ChTimestepperIorder(ChIntegrable& mintegrable) 
		: ChTimestepper(mintegrable)
	{
		mY = new ChState(&mintegrable);
		mdYdt = new ChStateDelta(&mintegrable);
	};

	/// Destructor
	virtual ~ChTimestepperIorder()
	{
		delete mY;
		delete mdYdt;
	};

	/// Access the state at current time
	virtual ChState& Y() { return *mY; }

	/// Access the derivative of state at current time
	virtual ChStateDelta& dYdt() { return *mdYdt; }
};


/// Base class for 2nd order timesteppers, that is
/// a time integrator for whatever ChIntegrableIIorder
/// (special sub lass of integrable objects that have a state 
/// made with position and velocity y={x,v}, and dy/dt={v,a} 
/// with a=acceleration)

class ChTimestepperIIorder : public ChTimestepper
{
protected:
	ChState* mX;
	ChStateDelta* mV;
	ChStateDelta* mA;
public:

	/// Constructor
	ChTimestepperIIorder(ChIntegrableIIorder& mintegrable)
		: ChTimestepper(mintegrable)
	{
		mX = new ChState(&mintegrable);
		mV = new ChStateDelta(&mintegrable);
		mA = new ChStateDelta(&mintegrable);
	};

	/// Destructor
	virtual ~ChTimestepperIIorder()
	{
		delete mX;
		delete mV;
		delete mA;
	};

	/// Access the state, position part, at current time
	virtual ChState& X() { return *mX; }

	/// Access the state, speed part, at current time
	virtual ChStateDelta& V() { return *mV; }

	/// Access the acceleration, at current time
	virtual ChStateDelta& A() { return *mA; }
};



/// Base properties for implicit solvers (double inheritance)
class ChImplicitTimestepper 
{
private:
	int maxiters;
	double tolerance;

public:
					/// Constructors 
	ChImplicitTimestepper() :
		maxiters(20),
		tolerance(1e-10)
	{}

		/// Set the max number of iterations using the Newton Raphson procedure
	void   SetMaxiters(int miters) { maxiters = miters; }
		/// Get the max number of iterations using the Newton Raphson procedure
	double GetMaxiters() { return maxiters;}
	
		/// Set the tolerance for terminating the Newton Raphson procedure
	void   SetTolerance(double mtol) { tolerance = mtol; }
		/// Get the tolerance for terminating the Newton Raphson procedure
	double GetTolerance() { return tolerance; }
};
<commit_msg>Smaller default limit on max NR iterations for implicit solvers<commit_after>//
// PROJECT CHRONO - http://projectchrono.org
//
// Copyright (c) 2013 Project Chrono
// All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be 
// found in the LICENSE file at the top level of the distribution
// and at http://projectchrono.org/license-chrono.txt.
//

#ifndef CHTIMESTEPPER_H
#define CHTIMESTEPPER_H

#include <stdlib.h>
#include "core/ChApiCE.h"
#include "core/ChMath.h"
#include "core/ChShared.h"
#include "core/ChVectorDynamic.h"
#include "timestepper/ChState.h"
#include "timestepper/ChIntegrable.h"


namespace chrono 
{



/// Base class for timesteppers, that is
/// a time integrator which can advance a system state.
/// It operates on systems inherited from ChIntegrable.

class ChTimestepper : public ChShared
{
protected:
	ChIntegrable* integrable;
	double T;

	//ChVectorDynamic<>* mL;
public:
					/// Constructor
	ChTimestepper(ChIntegrable& mintegrable) 
				{
					integrable = &mintegrable;
					T = 0;
					//mL    = new ChVectorDynamic<>(1);
				};
	
					/// Destructor
	virtual ~ChTimestepper()
				{
					//delete mL;
				};

					/// Performs an integration timestep
	virtual void Advance(
				const double dt				///< timestep to advance
				) =0;


					/// Access the lagrangian multipliers, if any
	//virtual ChVectorDynamic<>& L() { return *mL; }

					/// Get the integrable object 
	ChIntegrable* GetIntegrable() { return integrable;}
					
					/// Get the current time 
	virtual double GetTime() { return T;}

					/// Set the current time 
	virtual void SetTime(double mt) { T = mt;}
};



/// Base class for 1st order timesteppers, that is
/// a time integrator for whatever ChIntegrable.

class ChTimestepperIorder : public ChTimestepper
{
protected:
	ChState* mY;
	ChStateDelta* mdYdt;
public:

	/// Constructor
	ChTimestepperIorder(ChIntegrable& mintegrable) 
		: ChTimestepper(mintegrable)
	{
		mY = new ChState(&mintegrable);
		mdYdt = new ChStateDelta(&mintegrable);
	};

	/// Destructor
	virtual ~ChTimestepperIorder()
	{
		delete mY;
		delete mdYdt;
	};

	/// Access the state at current time
	virtual ChState& Y() { return *mY; }

	/// Access the derivative of state at current time
	virtual ChStateDelta& dYdt() { return *mdYdt; }
};


/// Base class for 2nd order timesteppers, that is
/// a time integrator for whatever ChIntegrableIIorder
/// (special sub lass of integrable objects that have a state 
/// made with position and velocity y={x,v}, and dy/dt={v,a} 
/// with a=acceleration)

class ChTimestepperIIorder : public ChTimestepper
{
protected:
	ChState* mX;
	ChStateDelta* mV;
	ChStateDelta* mA;
public:

	/// Constructor
	ChTimestepperIIorder(ChIntegrableIIorder& mintegrable)
		: ChTimestepper(mintegrable)
	{
		mX = new ChState(&mintegrable);
		mV = new ChStateDelta(&mintegrable);
		mA = new ChStateDelta(&mintegrable);
	};

	/// Destructor
	virtual ~ChTimestepperIIorder()
	{
		delete mX;
		delete mV;
		delete mA;
	};

	/// Access the state, position part, at current time
	virtual ChState& X() { return *mX; }

	/// Access the state, speed part, at current time
	virtual ChStateDelta& V() { return *mV; }

	/// Access the acceleration, at current time
	virtual ChStateDelta& A() { return *mA; }
};



/// Base properties for implicit solvers (double inheritance)
class ChImplicitTimestepper 
{
private:
	int maxiters;
	double tolerance;

public:
					/// Constructors 
	ChImplicitTimestepper() :
		maxiters(10),
		tolerance(1e-10)
	{}

		/// Set the max number of iterations using the Newton Raphson procedure
	void   SetMaxiters(int miters) { maxiters = miters; }
		/// Get the max number of iterations using the Newton Raphson procedure
	double GetMaxiters() { return maxiters;}
	
		/// Set the tolerance for terminating the Newton Raphson procedure
	void   SetTolerance(double mtol) { tolerance = mtol; }
		/// Get the tolerance for terminating the Newton Raphson procedure
	double GetTolerance() { return tolerance; }
};

{'fraction_non_alphanumeric': 0.10891831126655009, 'fraction_numerical': 0.0034973769672745443, 'mean_word_length': 3.3898026315789473, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7126948', 'n_tokens_mistral': 2872, 'n_tokens_neox': 2575, 'n_words': 827}