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 1008 of file ForcingMovingReferenceFrame.cpp.

1013{
1014 m_coeffs = Array<OneD, NekDouble>(5, 0.);
1015 m_coeffs[0] = 1. / (gamma * dt);
1016 m_coeffs[1] = 1. / gamma - 1.;
1017 m_coeffs[2] = beta * dt / gamma;
1018 m_coeffs[3] = dt * (1. - beta / gamma);
1019 m_coeffs[4] = (0.5 - beta / gamma) * dt * dt;
1020
1021 m_rows = sqrt(M.size());
1022 m_index.resize(m_rows, -1);
1023 m_motionDofs = 0;
1024 for (int i = 0; i < m_rows; ++i)
1025 {
1026 if (DirDoFs.find(i) == DirDoFs.end())
1027 {
1028 m_index[m_motionDofs++] = i;
1029 }
1030 }
1031 for (int i = 0, count = m_motionDofs; i < m_rows; ++i)
1032 {
1033 if (DirDoFs.find(i) != DirDoFs.end())
1034 {
1035 m_index[count++] = i;
1036 }
1037 }
1038 if (m_motionDofs)
1039 {
1040 Array<OneD, NekDouble> temp;
1041 m_Matrix = Array<OneD, Array<OneD, NekDouble>>(m_motionDofs);
1042 m_M = Array<OneD, Array<OneD, NekDouble>>(m_motionDofs);
1043 m_C = Array<OneD, Array<OneD, NekDouble>>(m_motionDofs);
1044 m_K = Array<OneD, Array<OneD, NekDouble>>(m_motionDofs);
1045 DNekMatSharedPtr inverseMatrix =
1047 m_motionDofs, 0.0, eFULL);
1048 for (int i = 0; i < m_motionDofs; ++i)
1049 {
1050 m_Matrix[i] = Array<OneD, NekDouble>(m_motionDofs, 0.);
1051 m_M[i] = Array<OneD, NekDouble>(m_rows, 0.);
1052 m_C[i] = Array<OneD, NekDouble>(m_rows, 0.);
1053 m_K[i] = Array<OneD, NekDouble>(m_rows, 0.);
1054 int offset = m_index[i] * m_rows;
1055 for (int j = 0; j < m_rows; ++j)
1056 {
1057 int ind = offset + m_index[j];
1058 m_M[i][j] = M[ind];
1059 m_C[i][j] = C[ind];
1060 m_K[i][j] = K[ind];
1061 NekDouble value =
1062 m_coeffs[0] * M[ind] + C[ind] + m_coeffs[2] * K[ind];
1063 if (j < m_motionDofs)
1064 {
1065 inverseMatrix->SetValue(i, j, value);
1066 }
1067 }
1068 }
1069 inverseMatrix->Invert();
1070 for (int i = 0; i < m_motionDofs; ++i)
1071 {
1072 for (int j = 0; j < m_rows; ++j)
1073 {
1074 if (j < m_motionDofs)
1075 {
1076 m_Matrix[i][j] = inverseMatrix->GetValue(i, j);
1077 }
1078 }
1079 }
1080 }
1081}
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:294

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 1124 of file ForcingMovingReferenceFrame.cpp.

1127{
1128 SolvePrescribed(u, motionPrescribed);
1129 SolveFree(u, force);
1130}
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 1132 of file ForcingMovingReferenceFrame.cpp.

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

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

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().