diff --git a/src/GooseFEM/Dynamics.cpp b/src/GooseFEM/Dynamics.cpp index 6f039b7..b25555c 100644 --- a/src/GooseFEM/Dynamics.cpp +++ b/src/GooseFEM/Dynamics.cpp @@ -1,90 +1,90 @@ /* ================================================================================================= (c - GPLv3) T.W.J. de Geus (Tom) | tom@geus.me | www.geus.me | github.com/tdegeus/GooseFEM ================================================================================================= */ #ifndef GOOSEFEM_DYNAMCS_CPP #define GOOSEFEM_DYNAMCS_CPP // ------------------------------------------------------------------------------------------------- #include "Dynamics.h" // ======================================= GooseFEM::Dynamics ======================================= namespace GooseFEM { namespace Dynamics { // ------------------------------------------------------------------------------------------------- inline void velocityVerlet(Geometry &g, double dt) { // local variables and history ColD V; ColD A; ColD V_n = g.dofs_v(); ColD A_n = g.dofs_a(); // (1) new positions - g.set_x( g.x() + dt * g.v() + 0.5 * std::pow(dt,2.) * g.a() ); + g.set_u( g.u() + dt * g.v() + 0.5 * std::pow(dt,2.) * g.a() ); // (2a) estimate new velocity // - new velocity V = V_n + dt * A_n; // - update particles g.set_v(V); // - solve for accelerations A = g.solve(); // - new velocity V = V_n + .5 * dt * ( A_n + A ); // - update particles g.set_v(V); // (2b) new velocity // - solve for accelerations A = g.solve(); // - new velocity V = V_n + .5 * dt * ( A_n + A ); // - update particles g.set_v(V); // (3) new accelerations // - solve for accelerations A = g.solve(); // - update particles g.set_a(A); // process time-step g.timestep(dt); } // ------------------------------------------------------------------------------------------------- inline size_t quasiStaticVelocityVerlet(Geometry &g, double dt, double tol) { // reset residuals g.reset(); // zero-initialize iteration counter size_t iiter = 0; // loop until convergence while ( true ) { // - update iteration counter iiter++; // - time-step velocityVerlet(g,dt); // - check for convergence if ( g.stop(tol) ) return iiter; } } // ------------------------------------------------------------------------------------------------- }} // namespace ... // ================================================================================================= #endif diff --git a/src/GooseFEM/Dynamics.h b/src/GooseFEM/Dynamics.h index 34836ca..c8c9a1a 100644 --- a/src/GooseFEM/Dynamics.h +++ b/src/GooseFEM/Dynamics.h @@ -1,67 +1,67 @@ /* ================================================================================================= (c - GPLv3) T.W.J. de Geus (Tom) | tom@geus.me | www.geus.me | github.com/tdegeus/GooseFEM ================================================================================================= */ #ifndef GOOSEFEM_DYNAMICS_H #define GOOSEFEM_DYNAMICS_H // ------------------------------------------------------------------------------------------------- #include "GooseFEM.h" // ======================================= GooseFEM::Dynamics ======================================= namespace GooseFEM { namespace Dynamics { // ------------------------------------------------------------------------------------------------- class Geometry { public: // solve for DOF-accelerations [ndof] virtual ColD solve() const { return ColD(); }; // reset residuals, check for convergence virtual void reset() { return; } virtual bool stop(double tol) { UNUSED(tol); return false; }; // process time-step virtual void timestep(double dt) { UNUSED(dt); return; }; // return nodal vectors [nnode, ndim] - virtual MatD x() const { return MatD(); }; + virtual MatD u() const { return MatD(); }; virtual MatD v() const { return MatD(); }; virtual MatD a() const { return MatD(); }; // return DOF values [ndof] virtual ColD dofs_v() const { return ColD(); }; virtual ColD dofs_a() const { return ColD(); }; // overwrite nodal vectors [nnode, ndim] - virtual void set_x(const MatD &pvector) { UNUSED(pvector); return; }; + virtual void set_u(const MatD &nodevec) { UNUSED(nodevec); return; }; // overwrite nodal vectors, reconstructed from DOF values [ndof] virtual void set_v(const ColD &dofval) { UNUSED(dofval); return; }; virtual void set_a(const ColD &dofval) { UNUSED(dofval); return; }; }; // ------------------------------------------------------------------------------------------------- // evaluate one time step inline void velocityVerlet(Geometry &geometry, double dt); // iterate until all nodes have come to a rest inline size_t quasiStaticVelocityVerlet(Geometry &geometry, double dt, double tol); // ------------------------------------------------------------------------------------------------- }} // namespace ... // ================================================================================================= #endif