Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/gsDynamicSolvers/gsDynamicBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class gsDynamicBase

public:

/// @brief Callback that is evaluated before each timestep.
Comment thread
mhodzelmans marked this conversation as resolved.
typedef std::function<bool(const T, const T, const gsOptionList &)> StepCallback_t;
Comment thread
mhodzelmans marked this conversation as resolved.
Outdated

virtual ~gsDynamicBase() {};

/// Constructor
Expand Down Expand Up @@ -193,8 +196,15 @@ class gsDynamicBase
/// Perform one arc-length step
Comment thread
mhodzelmans marked this conversation as resolved.
Outdated
virtual gsStatus step(T dt)
{
if (m_preStepCallback && !m_preStepCallback(m_time,dt,m_options))
{
m_status = gsStatus::OtherError;
return m_status;
}

gsStatus status = this->_step(m_time,dt,m_U,m_V,m_A);
m_time += dt;
m_status = status;
return status;
}

Expand Down Expand Up @@ -239,6 +249,19 @@ class gsDynamicBase
virtual void setVelocities(const gsVector<T> & V) {this->setV(V);}
virtual void setAccelerations(const gsVector<T> & A) {this->setA(A);}

/// @brief Set a function that is called before each timestep. WARNING: This
/// callback is only performed for the non-const step().
virtual void setPreStepCallback(const StepCallback_t & callback)
{
m_preStepCallback = callback;
}

/// @brief Clear the pre-step callback.
virtual void clearPreStepCallback()
{
m_preStepCallback = StepCallback_t();
}

/// Access the options
virtual gsOptionList & options() {return m_options;};

Expand Down Expand Up @@ -335,6 +358,8 @@ class gsDynamicBase
Residual_t m_residual;
TResidual_t m_Tresidual;

StepCallback_t m_preStepCallback;

mutable typename gsSparseSolver<T>::uPtr m_solver; // Cholesky by default

protected:
Expand Down
2 changes: 2 additions & 0 deletions src/gsStructuralAnalysisTools/gsStructuralAnalysisTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
Author(s): H.M. Verhelst (2019-..., TU Delft)
*/

#pragma once

#include <functional>
#include <gsCore/gsLinearAlgebra.h>

Expand Down
Loading