Nektar++
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
Nektar::Newmark_BetaSolver Class Reference

#include <RigidSolver.h>

Public Member Functions

 Newmark_BetaSolver ()
 
 ~Newmark_BetaSolver ()
 
void SetNewmarkBeta (NekDouble beta, NekDouble gamma, NekDouble dt, Array< OneD, NekDouble > M, Array< OneD, NekDouble > C, Array< OneD, NekDouble > K, std::set< int > DirDoFs, int solveType)
 
void SolvePrescribed (Array< OneD, Array< OneD, NekDouble > > u, std::map< int, NekDouble > motionPrescribed)
 
void SolveFreeFixMat (Array< OneD, Array< OneD, NekDouble > > u, Array< OneD, NekDouble > force)
 
void SolveFreeVarMat (Array< OneD, Array< OneD, NekDouble > > u, Array< OneD, NekDouble > force, const NekDouble mass)
 
void SolveOneFree (Array< OneD, Array< OneD, NekDouble > > u, Array< OneD, NekDouble > force, const Array< OneD, NekDouble > theta, const NekDouble uy, const NekDouble mass)
 

Public Attributes

int m_rows
 
int m_motionDofs
 
std::vector< int > m_index
 
Array< OneD, NekDoublem_coeffs
 
Array< OneD, Array< OneD, NekDouble > > m_Matrix
 
Array< OneD, Array< OneD, NekDouble > > m_M
 
Array< OneD, Array< OneD, NekDouble > > m_C
 
Array< OneD, Array< OneD, NekDouble > > m_K
 

Detailed Description

Definition at line 62 of file RigidSolver.h.

Constructor & Destructor Documentation

◆ Newmark_BetaSolver()

Nektar::Newmark_BetaSolver::Newmark_BetaSolver ( )
inline

Definition at line 65 of file RigidSolver.h.

65{};

◆ ~Newmark_BetaSolver()

Nektar::Newmark_BetaSolver::~Newmark_BetaSolver ( )
inline

Definition at line 66 of file RigidSolver.h.

66{};

Member Function Documentation

◆ SetNewmarkBeta()

void Nektar::Newmark_BetaSolver::SetNewmarkBeta ( NekDouble  beta,
NekDouble  gamma,
NekDouble  dt,
Array< OneD, NekDouble M,
Array< OneD, NekDouble C,
Array< OneD, NekDouble K,
std::set< int >  DirDoFs,
int  solveType 
)

Definition at line 1021 of file RigidSolver.cpp.

1026{
1027 m_coeffs = Array<OneD, NekDouble>(5, 0.);
1028 m_coeffs[0] = 1. / (gamma * dt);
1029 m_coeffs[1] = 1. / gamma - 1.;
1030 m_coeffs[2] = beta * dt / gamma;
1031 m_coeffs[3] = dt * (1. - beta / gamma);
1032 m_coeffs[4] = (0.5 - beta / gamma) * dt * dt;
1033
1034 m_rows = sqrt(M.size());
1035 m_index.resize(m_rows, -1);
1036 m_motionDofs = 0;
1037 for (int i = 0; i < m_rows; ++i)
1038 {
1039 if (DirDoFs.find(i) == DirDoFs.end())
1040 {
1041 m_index[m_motionDofs++] = i;
1042 }
1043 }
1044 for (int i = 0, count = m_motionDofs; i < m_rows; ++i)
1045 {
1046 if (DirDoFs.find(i) != DirDoFs.end())
1047 {
1048 m_index[count++] = i;
1049 }
1050 }
1051 if (1 == solveType)
1052 {
1054 "2 Dofs if body is free only in x direction.");
1055 }
1056 if (m_motionDofs)
1057 {
1058 Array<OneD, NekDouble> temp;
1059 m_M = Array<OneD, Array<OneD, NekDouble>>(m_motionDofs);
1060 m_C = Array<OneD, Array<OneD, NekDouble>>(m_motionDofs);
1061 m_K = Array<OneD, Array<OneD, NekDouble>>(m_motionDofs);
1062 DNekMatSharedPtr inverseMatrix =
1064 m_motionDofs, 0.0, eFULL);
1065 for (int i = 0; i < m_motionDofs; ++i)
1066 {
1067 m_M[i] = Array<OneD, NekDouble>(m_rows, 0.);
1068 m_C[i] = Array<OneD, NekDouble>(m_rows, 0.);
1069 m_K[i] = Array<OneD, NekDouble>(m_rows, 0.);
1070 int offset = m_index[i] * m_rows;
1071 for (int j = 0; j < m_rows; ++j)
1072 {
1073 int ind = offset + m_index[j];
1074 m_M[i][j] = M[ind];
1075 m_C[i][j] = C[ind];
1076 m_K[i][j] = K[ind];
1077 NekDouble value =
1078 m_coeffs[0] * M[ind] + C[ind] + m_coeffs[2] * K[ind];
1079 if (j < m_motionDofs)
1080 {
1081 inverseMatrix->SetValue(i, j, value);
1082 }
1083 }
1084 }
1085
1086 m_Matrix = Array<OneD, Array<OneD, NekDouble>>(m_motionDofs);
1087 if (solveType == 0)
1088 {
1089 inverseMatrix->Invert();
1090 }
1091 for (int i = 0; i < m_motionDofs; ++i)
1092 {
1093 m_Matrix[i] = Array<OneD, NekDouble>(m_motionDofs, 0.);
1094 for (int j = 0; j < m_rows; ++j)
1095 {
1096 if (j < m_motionDofs)
1097 {
1098 m_Matrix[i][j] = inverseMatrix->GetValue(i, j);
1099 }
1100 }
1101 }
1102 }
1103}
#define ASSERTL0(condition, msg)
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
Array< OneD, Array< OneD, NekDouble > > m_M
Definition RigidSolver.h:86
Array< OneD, Array< OneD, NekDouble > > m_Matrix
Definition RigidSolver.h:85
Array< OneD, NekDouble > m_coeffs
Definition RigidSolver.h:84
std::vector< int > m_index
Definition RigidSolver.h:83
Array< OneD, Array< OneD, NekDouble > > m_C
Definition RigidSolver.h:87
Array< OneD, Array< OneD, NekDouble > > m_K
Definition RigidSolver.h:88
@ beta
Gauss Radau pinned at x=-1,.
Definition PointsType.h:59
std::shared_ptr< DNekMat > DNekMatSharedPtr
scalarT< T > sqrt(scalarT< T > in)
Definition scalar.hpp:290

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, Nektar::LibUtilities::beta, Nektar::eFULL, m_C, m_coeffs, m_index, m_K, m_M, m_Matrix, m_motionDofs, m_rows, and tinysimd::sqrt().

Referenced by Nektar::RigidSolver::SetNewmarkBetaSolver().

◆ SolveFreeFixMat()

void Nektar::Newmark_BetaSolver::SolveFreeFixMat ( Array< OneD, Array< OneD, NekDouble > >  u,
Array< OneD, NekDouble force 
)

Definition at line 1146 of file RigidSolver.cpp.

1148{
1149 if (m_motionDofs)
1150 {
1151 Array<OneD, NekDouble> bm(m_motionDofs, 0.);
1152 Array<OneD, NekDouble> bk(m_motionDofs, 0.);
1153 for (int j = 0; j < m_motionDofs; ++j)
1154 {
1155 int j1 = m_index[j];
1156 bm[j] = m_coeffs[0] * u[1][j1] + m_coeffs[1] * u[2][j1];
1157 bk[j] = u[0][j1] + m_coeffs[3] * u[1][j1] + m_coeffs[4] * u[2][j1];
1158 }
1159 Array<OneD, NekDouble> rhs(m_motionDofs, 0.);
1160 for (int i = 0; i < m_motionDofs; ++i)
1161 {
1162 rhs[i] = force[m_index[i]];
1163 for (int j = 0; j < m_motionDofs; ++j)
1164 {
1165 rhs[i] += m_M[i][j] * bm[j] - m_K[i][j] * bk[j];
1166 }
1167 for (int j = m_motionDofs; j < m_rows; ++j)
1168 {
1169 int j1 = m_index[j];
1170 rhs[i] -= m_M[i][j] * u[2][j1] + m_C[i][j] * u[1][j1] +
1171 m_K[i][j] * u[0][j1];
1172 }
1173 }
1174 for (int j = 0; j < m_motionDofs; ++j)
1175 {
1176 int j1 = m_index[j];
1177 u[1][j1] = Vmath::Dot(m_motionDofs, m_Matrix[j], 1, rhs, 1);
1178 u[0][j1] = m_coeffs[2] * u[1][j1] + bk[j];
1179 u[2][j1] = m_coeffs[0] * u[1][j1] - bm[j];
1180 }
1181 }
1182}
T Dot(int n, const T *w, const T *x)
dot product
Definition Vmath.hpp:761

References Vmath::Dot(), m_C, m_coeffs, m_index, m_K, m_M, m_Matrix, m_motionDofs, and m_rows.

Referenced by Nektar::RigidSolver::SolveInertialFrame().

◆ SolveFreeVarMat()

void Nektar::Newmark_BetaSolver::SolveFreeVarMat ( Array< OneD, Array< OneD, NekDouble > >  u,
Array< OneD, NekDouble force,
const NekDouble  mass 
)

Definition at line 784 of file RigidSolver.cpp.

787{
788 Array<OneD, NekDouble> bm(m_motionDofs, 0.);
789 Array<OneD, NekDouble> bk(m_motionDofs, 0.);
790 double *dMatrix = new double[m_motionDofs * m_motionDofs];
791 int *ipiv = new int[m_motionDofs];
792 double *drhs = new double[m_motionDofs];
793 int info;
794
795 for (int j = 0; j < m_motionDofs; ++j)
796 {
797 int j1 = m_index[j];
798 bm[j] = m_coeffs[0] * u[1][j1] + m_coeffs[1] * u[2][j1];
799 bk[j] = u[0][j1] + m_coeffs[3] * u[1][j1] + m_coeffs[4] * u[2][j1];
800 }
801 Array<OneD, NekDouble> rhs(m_motionDofs, 0.);
802 for (int i = 0; i < m_motionDofs; ++i)
803 {
804 rhs[i] = force[m_index[i]];
805 for (int j = 0; j < m_motionDofs; ++j)
806 {
807 rhs[i] += m_M[i][j] * bm[j] - m_K[i][j] * bk[j];
808 }
809 for (int j = m_motionDofs; j < m_rows; ++j)
810 {
811 int j1 = m_index[j];
812 rhs[i] -= m_M[i][j] * u[2][j1] + m_C[i][j] * u[1][j1] +
813 m_K[i][j] * u[0][j1];
814 }
815 }
816 for (int i = 0; i < m_motionDofs; ++i)
817 {
818 drhs[i] = rhs[i];
819 for (int j = 0; j < m_motionDofs; ++j)
820 {
821 dMatrix[j * m_motionDofs + i] = m_Matrix[i][j];
822 }
823 }
824 dMatrix[1] += mass * u[1][m_rows - 1];
825 dMatrix[m_motionDofs] += -mass * u[1][m_rows - 1];
826
828 info);
829 Lapack::Dgetrs('N', m_motionDofs, 1, dMatrix, m_motionDofs, ipiv, drhs,
830 m_motionDofs, info);
831 for (int j = 0; j < m_motionDofs; ++j)
832 {
833 int j1 = m_index[j];
834 u[1][j1] = drhs[j];
835 }
836
837 for (int j = 0; j < m_motionDofs; ++j)
838 {
839 int j1 = m_index[j];
840 u[0][j1] = m_coeffs[2] * u[1][j1] + bk[j];
841 u[2][j1] = m_coeffs[0] * u[1][j1] - bm[j];
842 }
843
844 delete[] dMatrix;
845 delete[] drhs;
846 delete[] ipiv;
847}
static void Dgetrs(const char &trans, const int &n, const int &nrhs, const double *a, const int &lda, int *ipiv, double *b, const int &ldb, int &info)
General matrix LU backsolve.
Definition Lapack.hpp:297
static void DoSgetrf(const int &m, const int &n, double *a, const int &lda, int *ipiv, int &info)
General matrix LU factorisation.
Definition Lapack.hpp:276

References Lapack::Dgetrs(), Lapack::DoSgetrf(), m_C, m_coeffs, m_index, m_K, m_M, m_Matrix, m_motionDofs, and m_rows.

Referenced by Nektar::RigidSolver::SolveBodyFrame().

◆ SolveOneFree()

void Nektar::Newmark_BetaSolver::SolveOneFree ( Array< OneD, Array< OneD, NekDouble > >  u,
Array< OneD, NekDouble force,
const Array< OneD, NekDouble theta,
const NekDouble  uy,
const NekDouble  mass 
)

e_x \cdot M [du0, du1, du2] + m (e_x \times Omega) \cdot u = F \cdot e_x e_x = (c, -s, 0) (c M00 - s M10, c M01 - s M11, c M02 - s M 12) [du0, du1, du2]^T + (-s Omega, -c Omega, 0) [u0, u1, u2]^T = c F0 - s F1 equation 2, e_y \cdot (u0, u1) = uy = s * u0 + c * u1

Definition at line 1192 of file RigidSolver.cpp.

1196{
1197 int iOmega = m_rows - 1;
1198 NekDouble c = cos(theta[2]), s = sin(theta[2]);
1199 NekDouble C00, C01, C10, C11, M0, M1, M2, F0, F1;
1200 M0 = c * m_M[0][0] - s * m_M[1][0];
1201 M1 = c * m_M[0][1] - s * m_M[1][1];
1202 M2 = c * m_M[0][iOmega] - s * m_M[1][iOmega];
1203 C00 = m_coeffs[0] * M0 - s * u[1][iOmega] * mass;
1204 C01 = m_coeffs[0] * M1 - c * u[1][iOmega] * mass;
1205 C10 = s;
1206 C11 = c;
1207 F1 = uy;
1208 // F0
1209 Array<OneD, NekDouble> bm(m_motionDofs, 0.);
1210 Array<OneD, NekDouble> bk(m_motionDofs, 0.);
1211 for (int j = 0; j < m_motionDofs; ++j)
1212 {
1213 bm[j] = m_coeffs[0] * u[1][j] + m_coeffs[1] * u[2][j];
1214 bk[j] = u[0][j] + m_coeffs[3] * u[1][j] + m_coeffs[4] * u[2][j];
1215 }
1216 F0 = c * force[0] - s * force[1];
1217 F0 = F0 + M0 * bm[0] + M1 * bm[1] - M2 * u[2][iOmega];
1218 // solve
1219 NekDouble det = 1. / (C00 * C11 - C01 * C10);
1220 u[1][0] = det * (C11 * F0 - C01 * F1);
1221 u[1][1] = det * (-C10 * F0 + C00 * F1);
1222 for (int j = 0; j < m_motionDofs; ++j)
1223 {
1224 u[0][j] = m_coeffs[2] * u[1][j] + bk[j];
1225 u[2][j] = m_coeffs[0] * u[1][j] - bm[j];
1226 }
1227}

References m_coeffs, m_M, m_motionDofs, and m_rows.

Referenced by Nektar::RigidSolver::SolveRotOneFree().

◆ SolvePrescribed()

void Nektar::Newmark_BetaSolver::SolvePrescribed ( Array< OneD, Array< OneD, NekDouble > >  u,
std::map< int, NekDouble motionPrescribed 
)

Definition at line 1105 of file RigidSolver.cpp.

1108{
1109 for (int i = 0; i < m_rows; ++i)
1110 {
1111 if (motionPrescribed.find(i) != motionPrescribed.end())
1112 {
1113 int i0 = i + m_rows;
1114 int i2 = i0 + m_rows;
1115 NekDouble bm = 0., bk = 0.;
1116 if (motionPrescribed.find(i2) == motionPrescribed.end())
1117 {
1118 bm = m_coeffs[0] * u[1][i] + m_coeffs[1] * u[2][i];
1119 }
1120 if (motionPrescribed.find(i0) == motionPrescribed.end())
1121 {
1122 bk = u[0][i] + m_coeffs[3] * u[1][i] + m_coeffs[4] * u[2][i];
1123 }
1124
1125 u[1][i] = motionPrescribed[i];
1126 if (motionPrescribed.find(i2) == motionPrescribed.end())
1127 {
1128 u[2][i] = m_coeffs[0] * u[1][i] - bm;
1129 }
1130 else
1131 {
1132 u[2][i] = motionPrescribed[i2];
1133 }
1134 if (motionPrescribed.find(i0) == motionPrescribed.end())
1135 {
1136 u[0][i] = m_coeffs[2] * u[1][i] + bk;
1137 }
1138 else
1139 {
1140 u[0][i] = motionPrescribed[i0];
1141 }
1142 }
1143 }
1144}

References m_coeffs, and m_rows.

Referenced by Nektar::RigidSolver::SolveBodyFrame(), Nektar::RigidSolver::SolveInertialFrame(), and Nektar::RigidSolver::SolveRotOneFree().

Member Data Documentation

◆ m_C

Array<OneD, Array<OneD, NekDouble> > Nektar::Newmark_BetaSolver::m_C

Definition at line 87 of file RigidSolver.h.

Referenced by SetNewmarkBeta(), SolveFreeFixMat(), and SolveFreeVarMat().

◆ m_coeffs

Array<OneD, NekDouble> Nektar::Newmark_BetaSolver::m_coeffs

◆ m_index

std::vector<int> Nektar::Newmark_BetaSolver::m_index

Definition at line 83 of file RigidSolver.h.

Referenced by SetNewmarkBeta(), SolveFreeFixMat(), and SolveFreeVarMat().

◆ m_K

Array<OneD, Array<OneD, NekDouble> > Nektar::Newmark_BetaSolver::m_K

Definition at line 88 of file RigidSolver.h.

Referenced by SetNewmarkBeta(), SolveFreeFixMat(), and SolveFreeVarMat().

◆ m_M

Array<OneD, Array<OneD, NekDouble> > Nektar::Newmark_BetaSolver::m_M

Definition at line 86 of file RigidSolver.h.

Referenced by SetNewmarkBeta(), SolveFreeFixMat(), SolveFreeVarMat(), and SolveOneFree().

◆ m_Matrix

Array<OneD, Array<OneD, NekDouble> > Nektar::Newmark_BetaSolver::m_Matrix

Definition at line 85 of file RigidSolver.h.

Referenced by SetNewmarkBeta(), SolveFreeFixMat(), and SolveFreeVarMat().

◆ m_motionDofs

int Nektar::Newmark_BetaSolver::m_motionDofs

Definition at line 82 of file RigidSolver.h.

Referenced by SetNewmarkBeta(), SolveFreeFixMat(), SolveFreeVarMat(), and SolveOneFree().

◆ m_rows

int Nektar::Newmark_BetaSolver::m_rows