Smith  0.1
Smith is an implicit thermal structural mechanics simulation code.
time_integration_rule.hpp
Go to the documentation of this file.
1 // Copyright (c) Lawrence Livermore National Security, LLC and
2 // other Smith Project Developers. See the top-level LICENSE file for
3 // details.
4 //
5 // SPDX-License-Identifier: (BSD-3-Clause)
6 
14 #pragma once
15 
16 #include "smith/physics/common.hpp"
17 
18 namespace smith {
19 
27 
29  template <typename T1, typename T2>
30  SMITH_HOST_DEVICE auto value(const TimeInfo& /*t*/, const T1& field_new, const T2& /*field_old*/) const
31  {
32  return field_new;
33  }
34 
36  template <typename T1, typename T2>
37  SMITH_HOST_DEVICE auto dot(const TimeInfo& t, const T1& field_new, const T2& field_old) const
38  {
39  return (1.0 / t.dt()) * (field_new - field_old);
40  }
41 };
42 
48 
56 
58  template <typename T1, typename T2, typename T3, typename T4>
59  SMITH_HOST_DEVICE auto value([[maybe_unused]] const TimeInfo& t, [[maybe_unused]] const T1& field_new,
60  [[maybe_unused]] const T2& field_old, [[maybe_unused]] const T3& velo_old,
61  [[maybe_unused]] const T4& accel_old) const
62  {
63  return field_new;
64  }
65 
67  template <typename T1, typename T2, typename T3, typename T4>
68  SMITH_HOST_DEVICE auto dot([[maybe_unused]] const TimeInfo& t, [[maybe_unused]] const T1& field_new,
69  [[maybe_unused]] const T2& field_old, [[maybe_unused]] const T3& velo_old,
70  [[maybe_unused]] const T4& accel_old) const
71  {
72  return (2.0 / t.dt()) * (field_new - field_old) - velo_old;
73  }
74 
76  template <typename T1, typename T2, typename T3, typename T4>
77  SMITH_HOST_DEVICE auto ddot([[maybe_unused]] const TimeInfo& t, [[maybe_unused]] const T1& field_new,
78  [[maybe_unused]] const T2& field_old, [[maybe_unused]] const T3& velo_old,
79  [[maybe_unused]] const T4& accel_old) const
80  {
81  auto dt = t.dt();
82  return (4.0 / (dt * dt)) * (field_new - field_old) - (4.0 / dt) * velo_old - accel_old;
83  }
84 };
85 
86 } // namespace smith
#define SMITH_HOST_DEVICE
Macro that evaluates to __host__ __device__ when compiling with nvcc or amdclang and does nothing on ...
Definition: accelerator.hpp:37
A file defining some enums and structs that are used by the different physics modules.
Accelerator functionality.
Definition: smith.cpp:36
encodes rules for time discretizing first order odes (involving first time derivatives)....
SMITH_HOST_DEVICE auto dot(const TimeInfo &t, const T1 &field_new, const T2 &field_old) const
evaluate time derivative discretization of the ode state as used by the integration rule
SMITH_HOST_DEVICE auto value(const TimeInfo &, const T1 &field_new, const T2 &) const
evaluate value of the ode state as used by the integration rule
encodes rules for time discretizing second order odes (involving first and second time derivatives)....
SMITH_HOST_DEVICE auto value([[maybe_unused]] const TimeInfo &t, [[maybe_unused]] const T1 &field_new, [[maybe_unused]] const T2 &field_old, [[maybe_unused]] const T3 &velo_old, [[maybe_unused]] const T4 &accel_old) const
evaluate value of the ode state as used by the integration rule
SMITH_HOST_DEVICE auto dot([[maybe_unused]] const TimeInfo &t, [[maybe_unused]] const T1 &field_new, [[maybe_unused]] const T2 &field_old, [[maybe_unused]] const T3 &velo_old, [[maybe_unused]] const T4 &accel_old) const
evaluate time derivative discretization of the ode state as used by the integration rule
SMITH_HOST_DEVICE auto ddot([[maybe_unused]] const TimeInfo &t, [[maybe_unused]] const T1 &field_new, [[maybe_unused]] const T2 &field_old, [[maybe_unused]] const T3 &velo_old, [[maybe_unused]] const T4 &accel_old) const
evaluate time derivative discretization of the ode state as used by the integration rule
struct storing time and timestep information
Definition: common.hpp:18
double dt() const
accessor for dt
Definition: common.hpp:29