Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90890361
Dynamics.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Nov 5, 17:13
Size
2 KB
Mime Type
text/x-c
Expires
Thu, Nov 7, 17:13 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22152437
Attached To
rGOOSEFEM GooseFEM
Dynamics.cpp
View Options
/* =================================================================================================
(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
Verlet
(
Geometry
&
g
,
double
dt
)
{
// history
ColD
V
;
ColD
A
;
ColD
V_n
=
g
.
dofs_v
();
ColD
A_n
=
g
.
dofs_a
();
// new displacement
g
.
set_u
(
g
.
u
()
+
dt
*
g
.
v
()
+
0.5
*
std
::
pow
(
dt
,
2.
)
*
g
.
a
()
);
// new acceleration
A
=
g
.
solve
();
g
.
set_a
(
A
);
// new velocity
g
.
set_v
(
V_n
+
.5
*
dt
*
(
A_n
+
A
)
);
// finalize
g
.
timestep
(
dt
);
}
// -------------------------------------------------------------------------------------------------
inline
void
velocityVerlet
(
Geometry
&
g
,
double
dt
)
{
// history
ColD
V
;
ColD
A
;
ColD
V_n
=
g
.
dofs_v
();
ColD
A_n
=
g
.
dofs_a
();
// new displacement
g
.
set_u
(
g
.
u
()
+
dt
*
g
.
v
()
+
0.5
*
std
::
pow
(
dt
,
2.
)
*
g
.
a
()
);
// estimate new velocity
g
.
set_v
(
V_n
+
dt
*
A_n
);
A
=
g
.
solve
();
g
.
set_v
(
V_n
+
.5
*
dt
*
(
A_n
+
A
)
);
// new velocity
A
=
g
.
solve
();
g
.
set_v
(
V_n
+
.5
*
dt
*
(
A_n
+
A
)
);
// new acceleration
A
=
g
.
solve
();
g
.
set_a
(
A
);
// finalize
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
Event Timeline
Log In to Comment