Nektar++
Public Member Functions | Public Attributes | List of all members
Nektar::SolverUtils::Newmark_BetaSolver Class Reference

#include <ForcingMovingReferenceFrame.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)
 
void SolvePrescribed (Array< OneD, Array< OneD, NekDouble > > u, std::map< int, NekDouble > motionPrescribed)
 
void SolveFree (Array< OneD, Array< OneD, NekDouble > > u, Array< OneD, NekDouble > force)
 
void Solve (Array< OneD, Array< OneD, NekDouble > > u, Array< OneD, NekDouble > force, std::map< int, NekDouble > motionPrescribed)
 

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 65 of file ForcingMovingReferenceFrame.h.

Constructor & Destructor Documentation

◆ Newmark_BetaSolver()

Nektar::SolverUtils::Newmark_BetaSolver::Newmark_BetaSolver ( )
inline

Definition at line 68 of file ForcingMovingReferenceFrame.h.

68{};

◆ ~Newmark_BetaSolver()

Nektar::SolverUtils::Newmark_BetaSolver::~Newmark_BetaSolver ( )
inline

Definition at line 69 of file ForcingMovingReferenceFrame.h.

69{};

Member Function Documentation

◆ SetNewmarkBeta()

void Nektar::SolverUtils::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 
)

Definition at line 1007 of file ForcingMovingReferenceFrame.cpp.

1012{
1013 m_coeffs = Array<OneD, NekDouble>(5, 0.);
1014 m_coeffs[0] = 1. / (gamma * dt);
1015 m_coeffs[1] = 1. / gamma - 1.;
1016 m_coeffs[2] = beta * dt / gamma;
1017 m_coeffs[3] = dt * (1. - beta / gamma);
1018 m_coeffs[4] = (0.5 - beta / gamma) * dt * dt;
1019
1020 m_rows = sqrt(M.size());
1021 m_index.resize(m_rows, -1);
1022 m_motionDofs = 0;
1023 for (int i = 0; i < m_rows; ++i)
1024 {
1025 if (DirDoFs.find(i) == DirDoFs.end())
1026 {
1027 m_index[m_motionDofs++] = i;
1028 }
1029 }
1030 for (int i = 0, count = m_motionDofs; i < m_rows; ++i)
1031 {
1032 if (DirDoFs.find(i) != DirDoFs.end())
1033 {
1034 m_index[count++] = i;
1035 }
1036 }
1037 if (m_motionDofs)
1038 {
1039 Array<OneD, NekDouble> temp;
1040 m_Matrix = Array<OneD, Array<OneD, NekDouble>>(m_motionDofs);
1041 m_M = Array<OneD, Array<OneD, NekDouble>>(m_motionDofs);
1042 m_C = Array<OneD, Array<OneD, NekDouble>>(m_motionDofs);
1043 m_K = Array<OneD, Array<OneD, NekDouble>>(m_motionDofs);
1044 DNekMatSharedPtr inverseMatrix =
1046 m_motionDofs, 0.0, eFULL);
1047 for (int i = 0; i < m_motionDofs; ++i)
1048 {
1049 m_Matrix[i] = Array<OneD, NekDouble>(m_motionDofs, 0.);
1050 m_M[i] = Array<OneD, NekDouble>(m_rows, 0.);
1051 m_C[i] = Array<OneD, NekDouble>(m_rows, 0.);
1052 m_K[i] = Array<OneD, NekDouble>(m_rows, 0.);
1053 int offset = m_index[i] * m_rows;
1054 for (int j = 0; j < m_rows; ++j)
1055 {
1056 int ind = offset + m_index[j];
1057 m_M[i][j] = M[ind];
1058 m_C[i][j] = C[ind];
1059 m_K[i][j] = K[ind];
1060 NekDouble value =
1061 m_coeffs[0] * M[ind] + C[ind] + m_coeffs[2] * K[ind];
1062 if (j < m_motionDofs)
1063 {
1064 inverseMatrix->SetValue(i, j, value);
1065 }
1066 }
1067 }
1068 inverseMatrix->Invert();
1069 for (int i = 0; i < m_motionDofs; ++i)
1070 {
1071 for (int j = 0; j < m_rows; ++j)
1072 {
1073 if (j < m_motionDofs)
1074 {
1075 m_Matrix[i][j] = inverseMatrix->GetValue(i, j);
1076 }
1077 }
1078 }
1079 }
1080}
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
Array< OneD, Array< OneD, NekDouble > > m_K
Array< OneD, Array< OneD, NekDouble > > m_Matrix
Array< OneD, Array< OneD, NekDouble > > m_C
Array< OneD, Array< OneD, NekDouble > > m_M
@ beta
Gauss Radau pinned at x=-1,.
Definition: PointsType.h:59
std::shared_ptr< DNekMat > DNekMatSharedPtr
Definition: NekTypeDefs.hpp:75
double NekDouble
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:285

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), 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::SolverUtils::ForcingMovingReferenceFrame::InitBodySolver().

◆ Solve()

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

Definition at line 1123 of file ForcingMovingReferenceFrame.cpp.

1126{
1127 SolvePrescribed(u, motionPrescribed);
1128 SolveFree(u, force);
1129}
void SolveFree(Array< OneD, Array< OneD, NekDouble > > u, Array< OneD, NekDouble > force)
void SolvePrescribed(Array< OneD, Array< OneD, NekDouble > > u, std::map< int, NekDouble > motionPrescribed)

References SolveFree(), and SolvePrescribed().

Referenced by Nektar::SolverUtils::ForcingMovingReferenceFrame::SolveBodyMotion().

◆ SolveFree()

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

Definition at line 1131 of file ForcingMovingReferenceFrame.cpp.

1133{
1134 if (m_motionDofs)
1135 {
1136 Array<OneD, NekDouble> bm(m_motionDofs, 0.);
1137 Array<OneD, NekDouble> bk(m_motionDofs, 0.);
1138 for (int j = 0; j < m_motionDofs; ++j)
1139 {
1140 int j1 = m_index[j];
1141 bm[j] = m_coeffs[0] * u[1][j1] + m_coeffs[1] * u[2][j1];
1142 bk[j] = u[0][j1] + m_coeffs[3] * u[1][j1] + m_coeffs[4] * u[2][j1];
1143 }
1144 Array<OneD, NekDouble> rhs(m_motionDofs, 0.);
1145 for (int i = 0; i < m_motionDofs; ++i)
1146 {
1147 rhs[i] = force[m_index[i]];
1148 for (int j = 0; j < m_motionDofs; ++j)
1149 {
1150 rhs[i] += m_M[i][j] * bm[j] - m_K[i][j] * bk[j];
1151 }
1152 for (int j = m_motionDofs; j < m_rows; ++j)
1153 {
1154 int j1 = m_index[j];
1155 rhs[i] -= m_M[i][j] * u[2][j1] + m_C[i][j] * u[1][j1] +
1156 m_K[i][j] * u[0][j1];
1157 }
1158 }
1159 for (int j = 0; j < m_motionDofs; ++j)
1160 {
1161 int j1 = m_index[j];
1162 u[1][j1] = Vmath::Dot(m_motionDofs, m_Matrix[j], 1, rhs, 1);
1163 u[0][j1] = m_coeffs[2] * u[1][j1] + bk[j];
1164 u[2][j1] = m_coeffs[0] * u[1][j1] - bm[j];
1165 }
1166 }
1167}
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 Solve(), and Nektar::SolverUtils::ForcingMovingReferenceFrame::SolveBodyMotion().

◆ SolvePrescribed()

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

Definition at line 1082 of file ForcingMovingReferenceFrame.cpp.

1085{
1086 for (int i = 0; i < m_rows; ++i)
1087 {
1088 if (motionPrescribed.find(i) != motionPrescribed.end())
1089 {
1090 int i0 = i + m_rows;
1091 int i2 = i0 + m_rows;
1092 NekDouble bm = 0., bk = 0.;
1093 if (motionPrescribed.find(i2) == motionPrescribed.end())
1094 {
1095 bm = m_coeffs[0] * u[1][i] + m_coeffs[1] * u[2][i];
1096 }
1097 if (motionPrescribed.find(i0) == motionPrescribed.end())
1098 {
1099 bk = u[0][i] + m_coeffs[3] * u[1][i] + m_coeffs[4] * u[2][i];
1100 }
1101
1102 u[1][i] = motionPrescribed[i];
1103 if (motionPrescribed.find(i2) == motionPrescribed.end())
1104 {
1105 u[2][i] = m_coeffs[0] * u[1][i] - bm;
1106 }
1107 else
1108 {
1109 u[2][i] = motionPrescribed[i2];
1110 }
1111 if (motionPrescribed.find(i0) == motionPrescribed.end())
1112 {
1113 u[0][i] = m_coeffs[2] * u[1][i] + bk;
1114 }
1115 else
1116 {
1117 u[0][i] = motionPrescribed[i0];
1118 }
1119 }
1120 }
1121}

References m_coeffs, and m_rows.

Referenced by Solve(), Nektar::SolverUtils::ForcingMovingReferenceFrame::SolveBodyMotion(), and Nektar::SolverUtils::ForcingMovingReferenceFrame::UpdateBoundaryConditions().

Member Data Documentation

◆ m_C

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

Definition at line 86 of file ForcingMovingReferenceFrame.h.

Referenced by SetNewmarkBeta(), and SolveFree().

◆ m_coeffs

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

Definition at line 83 of file ForcingMovingReferenceFrame.h.

Referenced by SetNewmarkBeta(), SolveFree(), and SolvePrescribed().

◆ m_index

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

Definition at line 82 of file ForcingMovingReferenceFrame.h.

Referenced by SetNewmarkBeta(), and SolveFree().

◆ m_K

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

Definition at line 87 of file ForcingMovingReferenceFrame.h.

Referenced by SetNewmarkBeta(), and SolveFree().

◆ m_M

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

Definition at line 85 of file ForcingMovingReferenceFrame.h.

Referenced by SetNewmarkBeta(), and SolveFree().

◆ m_Matrix

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

Definition at line 84 of file ForcingMovingReferenceFrame.h.

Referenced by SetNewmarkBeta(), and SolveFree().

◆ m_motionDofs

int Nektar::SolverUtils::Newmark_BetaSolver::m_motionDofs

Definition at line 81 of file ForcingMovingReferenceFrame.h.

Referenced by SetNewmarkBeta(), and SolveFree().

◆ m_rows

int Nektar::SolverUtils::Newmark_BetaSolver::m_rows

Definition at line 80 of file ForcingMovingReferenceFrame.h.

Referenced by SetNewmarkBeta(), SolveFree(), and SolvePrescribed().