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

#include <ALEHelper.h>

Inheritance diagram for Nektar::SolverUtils::ALEHelper:
[legend]

Public Member Functions

virtual ~ALEHelper ()=default
 
virtual SOLVER_UTILS_EXPORT void v_ALEInitObject (int spaceDim, Array< OneD, MultiRegions::ExpListSharedPtr > &fields)
 
SOLVER_UTILS_EXPORT void InitObject (int spaceDim, Array< OneD, MultiRegions::ExpListSharedPtr > &fields)
 
virtual SOLVER_UTILS_EXPORT void v_UpdateGridVelocity (const NekDouble &time)
 
virtual SOLVER_UTILS_EXPORT void v_ALEPreMultiplyMass (Array< OneD, Array< OneD, NekDouble > > &fields)
 
SOLVER_UTILS_EXPORT void ALEDoElmtInvMass (Array< OneD, Array< OneD, NekDouble > > &traceNormals, Array< OneD, Array< OneD, NekDouble > > &fields, NekDouble time)
 Update m_fields with u^n by multiplying by inverse mass matrix. That's then used in e.g. checkpoint output and L^2 error calculation.
 
SOLVER_UTILS_EXPORT void ALEDoElmtInvMassBwdTrans (const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
 
SOLVER_UTILS_EXPORT void MoveMesh (const NekDouble &time, Array< OneD, Array< OneD, NekDouble > > &traceNormals)
 
SOLVER_UTILS_EXPORT void ResetMatricesNormal (Array< OneD, Array< OneD, NekDouble > > &traceNormals)
 
SOLVER_UTILS_EXPORT void UpdateNormalsFlag ()
 
const Array< OneD, const Array< OneD, NekDouble > > & GetGridVelocity ()
 
bool & GetUpdateNormalsFlag ()
 
SOLVER_UTILS_EXPORT const Array< OneD, const Array< OneD, NekDouble > > & GetGridVelocityTrace ()
 
SOLVER_UTILS_EXPORT void ExtraFldOutputGridVelocity (std::vector< Array< OneD, NekDouble > > &fieldcoeffs, std::vector< std::string > &variables)
 
SOLVER_UTILS_EXPORT void ExtraFldOutputGrid (std::vector< Array< OneD, NekDouble > > &fieldcoeffs, std::vector< std::string > &variables)
 

Protected Attributes

Array< OneD, MultiRegions::ExpListSharedPtrm_fieldsALE
 
Array< OneD, Array< OneD, NekDouble > > m_gridVelocity
 
Array< OneD, Array< OneD, NekDouble > > m_gridVelocityTrace
 
std::vector< ALEBaseShPtrm_ALEs
 
bool m_ALESolver = false
 
bool m_meshDistorted = false
 
bool m_implicitALESolver = false
 
bool m_updateNormals = false
 
NekDouble m_prevStageTime = 0.0
 
int m_spaceDim
 

Detailed Description

Definition at line 86 of file ALEHelper.h.

Constructor & Destructor Documentation

◆ ~ALEHelper()

virtual Nektar::SolverUtils::ALEHelper::~ALEHelper ( )
virtualdefault

Member Function Documentation

◆ ALEDoElmtInvMass()

void Nektar::SolverUtils::ALEHelper::ALEDoElmtInvMass ( Array< OneD, Array< OneD, NekDouble > > &  traceNormals,
Array< OneD, Array< OneD, NekDouble > > &  fields,
NekDouble  time 
)

Update m_fields with u^n by multiplying by inverse mass matrix. That's then used in e.g. checkpoint output and L^2 error calculation.

Definition at line 135 of file ALEHelper.cpp.

139{
140 // @TODO: Look at geometric factor and junk only what is needed
141 // @TODO: Look at collections and see if they offer a speed up
142 for (int i = 0; i < m_fieldsALE.size(); ++i)
143 {
144 m_fieldsALE[i]->MultiplyByElmtInvMass(
145 fields[i],
146 m_fieldsALE[i]->UpdateCoeffs()); // @TODO: Potentially matrix free?
147 m_fieldsALE[i]->BwdTrans(m_fieldsALE[i]->GetCoeffs(),
148 m_fieldsALE[i]->UpdatePhys());
149 }
150}
Array< OneD, MultiRegions::ExpListSharedPtr > m_fieldsALE
Definition ALEHelper.h:140

References m_fieldsALE.

Referenced by Nektar::SolverUtils::UnsteadySystem::v_DoSolve().

◆ ALEDoElmtInvMassBwdTrans()

void Nektar::SolverUtils::ALEHelper::ALEDoElmtInvMassBwdTrans ( const Array< OneD, const Array< OneD, NekDouble > > &  inarray,
Array< OneD, Array< OneD, NekDouble > > &  outarray 
)

Definition at line 152 of file ALEHelper.cpp.

155{
156 const int nc = m_fieldsALE[0]->GetNcoeffs();
157 int nVariables = inarray.size();
158
159 // General idea is that we are time-integrating the quantity (Mu), so we
160 // need to multiply input by inverse mass matrix to get coefficients u,
161 // and then backwards transform to physical space so we can apply the DG
162 // operator.
163 Array<OneD, NekDouble> tmp(nc);
164 for (int i = 0; i < nVariables; ++i)
165 {
166 outarray[i] = Array<OneD, NekDouble>(m_fieldsALE[0]->GetNpoints());
167 m_fieldsALE[i]->MultiplyByElmtInvMass(inarray[i], tmp);
168 m_fieldsALE[i]->BwdTrans(tmp, outarray[i]);
169 }
170}

References m_fieldsALE.

Referenced by Nektar::CFSImplicit::DoImplicitSolve(), Nektar::UnsteadyAdvection::DoOdeRhs(), Nektar::UnsteadyAdvectionDiffusion::DoOdeRhs(), Nektar::CompressibleFlowSystem::DoOdeRhs(), and Nektar::CompressibleFlowSystem::SetBoundaryConditions().

◆ ExtraFldOutputGrid()

void Nektar::SolverUtils::ALEHelper::ExtraFldOutputGrid ( std::vector< Array< OneD, NekDouble > > &  fieldcoeffs,
std::vector< std::string > &  variables 
)

Definition at line 497 of file ALEHelper.cpp.

501{
502 int nCoeffs = m_fieldsALE[0]->GetNcoeffs();
503 int nPhys = m_fieldsALE[0]->GetTotPoints();
504 // Adds extra output variables for grid velocity
505 std::string gridXName[3] = {"gridX", "gridY", "gridZ"};
506 Array<OneD, Array<OneD, NekDouble>> Xc(m_spaceDim);
507 for (int i = 0; i < m_spaceDim; ++i)
508 {
509 Xc[i] = Array<OneD, NekDouble>(nPhys, 0.0);
510 }
511
512 switch (m_spaceDim)
513 {
514 case 1:
515 {
516 m_fieldsALE[0]->GetCoords(Xc[0]);
517 break;
518 }
519 case 2:
520 {
521 m_fieldsALE[0]->GetCoords(Xc[0], Xc[1]);
522 break;
523 }
524 case 3:
525 {
526 m_fieldsALE[0]->GetCoords(Xc[0], Xc[1], Xc[2]);
527 break;
528 }
529 }
530
531 for (int i = 0; i < m_spaceDim; ++i)
532 {
533 Array<OneD, NekDouble> coeffs(nCoeffs);
534 m_fieldsALE[0]->FwdTransLocalElmt(Xc[i], coeffs);
535 fieldcoeffs.emplace_back(coeffs);
536 variables.emplace_back(gridXName[i]);
537 }
538}

References m_fieldsALE, and m_spaceDim.

Referenced by Nektar::CompressibleFlowSystem::v_ExtraFldOutput(), and Nektar::NavierStokesCFE::v_ExtraFldOutput().

◆ ExtraFldOutputGridVelocity()

void Nektar::SolverUtils::ALEHelper::ExtraFldOutputGridVelocity ( std::vector< Array< OneD, NekDouble > > &  fieldcoeffs,
std::vector< std::string > &  variables 
)

Definition at line 480 of file ALEHelper.cpp.

484{
485 int nCoeffs = m_fieldsALE[0]->GetNcoeffs();
486 // Adds extra output variables for grid velocity
487 std::string gridVarName[3] = {"gridVx", "gridVy", "gridVz"};
488 for (int i = 0; i < m_spaceDim; ++i)
489 {
490 Array<OneD, NekDouble> gridVel(nCoeffs, 0.0);
491 m_fieldsALE[0]->FwdTransLocalElmt(m_gridVelocity[i], gridVel);
492 fieldcoeffs.emplace_back(gridVel);
493 variables.emplace_back(gridVarName[i]);
494 }
495}
Array< OneD, Array< OneD, NekDouble > > m_gridVelocity
Definition ALEHelper.h:141

References m_fieldsALE, m_gridVelocity, and m_spaceDim.

Referenced by Nektar::UnsteadyAdvection::v_ExtraFldOutput(), Nektar::UnsteadyAdvectionDiffusion::v_ExtraFldOutput(), Nektar::CompressibleFlowSystem::v_ExtraFldOutput(), and Nektar::NavierStokesCFE::v_ExtraFldOutput().

◆ GetGridVelocity()

const Array< OneD, const Array< OneD, NekDouble > > & Nektar::SolverUtils::ALEHelper::GetGridVelocity ( )
inline

Definition at line 119 of file ALEHelper.h.

120 {
121 return m_gridVelocity;
122 }

References m_gridVelocity.

◆ GetGridVelocityTrace()

const Array< OneD, const Array< OneD, NekDouble > > & Nektar::SolverUtils::ALEHelper::GetGridVelocityTrace ( )

Definition at line 232 of file ALEHelper.cpp.

234{
235 return m_gridVelocityTrace;
236}
Array< OneD, Array< OneD, NekDouble > > m_gridVelocityTrace
Definition ALEHelper.h:142

References m_gridVelocityTrace.

Referenced by Nektar::CompressibleFlowSystem::InitAdvection().

◆ GetUpdateNormalsFlag()

bool & Nektar::SolverUtils::ALEHelper::GetUpdateNormalsFlag ( )
inline

Definition at line 124 of file ALEHelper.h.

125 {
126 return m_updateNormals;
127 }

References m_updateNormals.

Referenced by Nektar::CompressibleFlowSystem::InitAdvection().

◆ InitObject()

void Nektar::SolverUtils::ALEHelper::InitObject ( int  spaceDim,
Array< OneD, MultiRegions::ExpListSharedPtr > &  fields 
)

Definition at line 48 of file ALEHelper.cpp.

51{
52 // Create ALE objects for each interface zone
53 if (fields[0]->GetGraph() !=
54 nullptr) // homogeneous graphs are missing the graph data
55 {
56 for (auto &zone : fields[0]->GetGraph()->GetMovement()->GetZones())
57 {
58 switch (zone.second->GetMovementType())
59 {
61 m_ALEs.emplace_back(ALEFixedShPtr(
63 zone.second)));
64 break;
66 m_ALEs.emplace_back(ALETranslateShPtr(
68 zone.second)));
69 m_ALESolver = true;
70 break;
72 m_ALEs.emplace_back(ALERotateShPtr(
74 zone.second)));
75 m_ALESolver = true;
76 break;
78 WARNINGL0(false,
79 "Zone cannot have movement type of 'None'.");
80 default:
81 break;
82 }
83 }
84 }
85
86 // Update grid velocity
88
89 // Updates trace grid velocity
90 for (int i = 0; i < m_gridVelocityTrace.size(); ++i)
91 {
92 m_fieldsALE[0]->ExtractTracePhys(m_gridVelocity[i],
93 m_gridVelocityTrace[i], true);
94 }
95}
#define WARNINGL0(condition, msg)
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
virtual SOLVER_UTILS_EXPORT void v_UpdateGridVelocity(const NekDouble &time)
Definition ALEHelper.cpp:97
std::vector< ALEBaseShPtr > m_ALEs
Definition ALEHelper.h:143
std::shared_ptr< ALETranslate > ALETranslateShPtr
Definition ALEHelper.h:225
std::shared_ptr< ALERotate > ALERotateShPtr
Definition ALEHelper.h:226
std::shared_ptr< ALEFixed > ALEFixedShPtr
Definition ALEHelper.h:224

References Nektar::SpatialDomains::eFixed, Nektar::SpatialDomains::eNone, Nektar::SpatialDomains::eRotate, Nektar::SpatialDomains::eTranslate, m_ALEs, m_ALESolver, m_fieldsALE, m_gridVelocity, m_gridVelocityTrace, v_UpdateGridVelocity(), and WARNINGL0.

Referenced by Nektar::UnsteadyAdvection::v_ALEInitObject(), Nektar::UnsteadyAdvectionDiffusion::v_ALEInitObject(), Nektar::CompressibleFlowSystem::v_ALEInitObject(), and Nektar::CFSImplicit::v_ALEInitObject().

◆ MoveMesh()

void Nektar::SolverUtils::ALEHelper::MoveMesh ( const NekDouble time,
Array< OneD, Array< OneD, NekDouble > > &  traceNormals 
)

Definition at line 172 of file ALEHelper.cpp.

174{
175 // Only move if timestepped
176 if (time == m_prevStageTime)
177 {
178 return;
179 }
180
181 auto curvedEdges = m_fieldsALE[0]->GetGraph()->GetCurvedEdges();
182 auto curvedFaces = m_fieldsALE[0]->GetGraph()->GetCurvedFaces();
183
184 LibUtilities::Timer timer;
185 timer.Start();
186 m_fieldsALE[0]->GetGraph()->GetMovement()->PerformMovement(
187 time); // @TODO: Moved out of loop!
188 timer.Stop();
189 timer.AccumulateRegion("Movement::PerformMovement");
190
191 ResetMatricesNormal(traceNormals);
193 // Recompute grid velocity.
195
196 // Updates trace grid velocity
197 for (int i = 0; i < m_gridVelocityTrace.size(); ++i)
198 {
199 m_fieldsALE[0]->ExtractTracePhys(m_gridVelocity[i],
200 m_gridVelocityTrace[i], true);
201 }
202
203 // Set the flag to exchange coords in InterfaceMapDG to true
204 m_fieldsALE[0]->GetGraph()->GetMovement()->GetCoordExchangeFlag() = true;
205
206 m_prevStageTime = time;
207}
SOLVER_UTILS_EXPORT void UpdateNormalsFlag()
SOLVER_UTILS_EXPORT void ResetMatricesNormal(Array< OneD, Array< OneD, NekDouble > > &traceNormals)

References Nektar::LibUtilities::Timer::AccumulateRegion(), m_fieldsALE, m_gridVelocity, m_gridVelocityTrace, m_prevStageTime, ResetMatricesNormal(), Nektar::LibUtilities::Timer::Start(), Nektar::LibUtilities::Timer::Stop(), UpdateNormalsFlag(), and v_UpdateGridVelocity().

Referenced by Nektar::UnsteadyAdvection::DoOdeProjection(), and Nektar::CompressibleFlowSystem::DoOdeProjection().

◆ ResetMatricesNormal()

void Nektar::SolverUtils::ALEHelper::ResetMatricesNormal ( Array< OneD, Array< OneD, NekDouble > > &  traceNormals)

Definition at line 209 of file ALEHelper.cpp.

211{
212 // Now update matrices and normal for each movement zone
213 for (auto &ALE : m_ALEs)
214 {
215 ALE->ResetMatricesNormal(traceNormals, m_fieldsALE);
216 }
217}

References m_ALEs, and m_fieldsALE.

Referenced by MoveMesh().

◆ UpdateNormalsFlag()

void Nektar::SolverUtils::ALEHelper::UpdateNormalsFlag ( )

Definition at line 219 of file ALEHelper.cpp.

220{
221 // check all update nromal definitions and return true if any are true
222 for (auto &ALE : m_ALEs)
223 {
224 if (ALE->UpdateNormalsFlag())
225 {
226 m_updateNormals = ALE->UpdateNormalsFlag();
227 break;
228 }
229 }
230}

References m_ALEs, and m_updateNormals.

Referenced by MoveMesh().

◆ v_ALEInitObject()

void Nektar::SolverUtils::ALEHelper::v_ALEInitObject ( int  spaceDim,
Array< OneD, MultiRegions::ExpListSharedPtr > &  fields 
)
virtual

◆ v_ALEPreMultiplyMass()

void Nektar::SolverUtils::ALEHelper::v_ALEPreMultiplyMass ( Array< OneD, Array< OneD, NekDouble > > &  fields)
virtual

Definition at line 115 of file ALEHelper.cpp.

117{
118 const int nm = m_fieldsALE[0]->GetNcoeffs();
119 MultiRegions::GlobalMatrixKey mkey(StdRegions::eMass);
120
121 // Premultiply each field by the mass matrix
122 for (int i = 0; i < m_fieldsALE.size(); ++i)
123 {
124 fields[i] = Array<OneD, NekDouble>(nm);
125 m_fieldsALE[i]->GeneralMatrixOp(mkey, m_fieldsALE[i]->GetCoeffs(),
126 fields[i]);
127 }
128}

References Nektar::StdRegions::eMass, and m_fieldsALE.

Referenced by Nektar::SolverUtils::UnsteadySystem::v_DoSolve().

◆ v_UpdateGridVelocity()

void Nektar::SolverUtils::ALEHelper::v_UpdateGridVelocity ( const NekDouble time)
virtual

Definition at line 97 of file ALEHelper.cpp.

98{
99
100 // Reset grid velocity to 0
101 for (int i = 0; i < m_spaceDim; ++i)
102 {
103 std::fill(m_gridVelocity[i].begin(), m_gridVelocity[i].end(), 0.0);
104 }
105 if (m_ALESolver)
106 {
107 // Now update for each movement zone, adding the grid velocities
108 for (auto &ALE : m_ALEs)
109 {
110 ALE->UpdateGridVel(time, m_fieldsALE, m_gridVelocity);
111 }
112 }
113}

References m_ALEs, m_ALESolver, m_fieldsALE, m_gridVelocity, and m_spaceDim.

Referenced by InitObject(), MoveMesh(), and Nektar::SolverUtils::UnsteadySystem::v_DoInitialise().

Member Data Documentation

◆ m_ALEs

std::vector<ALEBaseShPtr> Nektar::SolverUtils::ALEHelper::m_ALEs
protected

◆ m_ALESolver

bool Nektar::SolverUtils::ALEHelper::m_ALESolver = false
protected

◆ m_fieldsALE

Array<OneD, MultiRegions::ExpListSharedPtr> Nektar::SolverUtils::ALEHelper::m_fieldsALE
protected

◆ m_gridVelocity

Array<OneD, Array<OneD, NekDouble> > Nektar::SolverUtils::ALEHelper::m_gridVelocity
protected

◆ m_gridVelocityTrace

Array<OneD, Array<OneD, NekDouble> > Nektar::SolverUtils::ALEHelper::m_gridVelocityTrace
protected

◆ m_implicitALESolver

bool Nektar::SolverUtils::ALEHelper::m_implicitALESolver = false
protected

Definition at line 150 of file ALEHelper.h.

Referenced by Nektar::CFSImplicit::v_ALEInitObject().

◆ m_meshDistorted

bool Nektar::SolverUtils::ALEHelper::m_meshDistorted = false
protected

◆ m_prevStageTime

NekDouble Nektar::SolverUtils::ALEHelper::m_prevStageTime = 0.0
protected

Definition at line 154 of file ALEHelper.h.

Referenced by MoveMesh().

◆ m_spaceDim

int Nektar::SolverUtils::ALEHelper::m_spaceDim
protected

◆ m_updateNormals

bool Nektar::SolverUtils::ALEHelper::m_updateNormals = false
protected

Definition at line 152 of file ALEHelper.h.

Referenced by GetUpdateNormalsFlag(), and UpdateNormalsFlag().