Nektar++
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. More...
 
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)
 
const Array< OneD, const Array< OneD, NekDouble > > & GetGridVelocity ()
 
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)
 

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_ImplicitALESolver = false
 
NekDouble m_prevStageTime = 0.0
 
int m_spaceDim
 

Detailed Description

Definition at line 49 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 131 of file ALEHelper.cpp.

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

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 148 of file ALEHelper.cpp.

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

References m_fieldsALE.

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

◆ ExtraFldOutputGridVelocity()

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

Definition at line 389 of file ALEHelper.cpp.

393{
394 int nCoeffs = m_fieldsALE[0]->GetNcoeffs();
395 // Adds extra output variables for grid velocity
396 std::string gridVarName[3] = {"gridVx", "gridVy", "gridVz"};
397 for (int i = 0; i < m_spaceDim; ++i)
398 {
399 Array<OneD, NekDouble> gridVel(nCoeffs, 0.0);
400 m_fieldsALE[0]->FwdTransLocalElmt(m_gridVelocity[i], gridVel);
401 fieldcoeffs.emplace_back(gridVel);
402 variables.emplace_back(gridVarName[i]);
403 }
404}
Array< OneD, Array< OneD, NekDouble > > m_gridVelocity
Definition: ALEHelper.h:89

References m_fieldsALE, m_gridVelocity, and m_spaceDim.

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

◆ GetGridVelocity()

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

Definition at line 76 of file ALEHelper.h.

77 {
78 return m_gridVelocity;
79 }

References m_gridVelocity.

◆ GetGridVelocityTrace()

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

Definition at line 288 of file ALEHelper.cpp.

290{
291 return m_gridVelocityTrace;
292}
Array< OneD, Array< OneD, NekDouble > > m_gridVelocityTrace
Definition: ALEHelper.h:90

References m_gridVelocityTrace.

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}
#define WARNINGL0(condition, msg)
Definition: ErrorUtil.hpp:215
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:90
std::vector< ALEBaseShPtr > m_ALEs
Definition: ALEHelper.h:91
std::shared_ptr< ALETranslate > ALETranslateShPtr
Definition: ALEHelper.h:157
std::shared_ptr< ALERotate > ALERotateShPtr
Definition: ALEHelper.h:158
std::shared_ptr< ALEFixed > ALEFixedShPtr
Definition: ALEHelper.h:156

References Nektar::SpatialDomains::eFixed, Nektar::SpatialDomains::eNone, Nektar::SpatialDomains::eRotate, Nektar::SpatialDomains::eTranslate, m_ALEs, m_ALESolver, 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 168 of file ALEHelper.cpp.

170{
171 // Only move if timestepped
172 if (time == m_prevStageTime)
173 {
174 return;
175 }
176
177 auto curvedEdges = m_fieldsALE[0]->GetGraph()->GetCurvedEdges();
178 auto curvedFaces = m_fieldsALE[0]->GetGraph()->GetCurvedFaces();
179
180 LibUtilities::Timer timer;
181 timer.Start();
182 m_fieldsALE[0]->GetGraph()->GetMovement()->PerformMovement(
183 time); // @TODO: Moved out of loop!
184 timer.Stop();
185 timer.AccumulateRegion("Movement::PerformMovement");
186
187 // The order of the resets below is v important to avoid errors
188 for (auto &field : m_fieldsALE)
189 {
190 field->ResetMatrices();
191 }
192
193 // Loop over all elements and faces and edges and reset geometry
194 // information. Only need to do this on the first field as the geometry
195 // information is shared.
196 for (auto &zone : m_fieldsALE[0]->GetGraph()->GetMovement()->GetZones())
197 {
198 if (zone.second->GetMoved())
199 {
200 auto conEl = zone.second->GetConstituentElements();
201 for (const auto &i : conEl)
202 {
203 for (const auto &j : i)
204 {
205 j->ResetNonRecursive(curvedEdges, curvedFaces);
206 }
207 }
208
209 // We need to rebuild geometric factors on the trace elements
210 for (const auto &i : conEl[m_fieldsALE[0]->GetShapeDimension() -
211 1]) // This only takes the trace elements
212 {
213 m_fieldsALE[0]
214 ->GetTrace()
215 ->GetExpFromGeomId(i->GetGlobalID())
216 ->Reset();
217 }
218 }
219 }
220
221 for (auto &field : m_fieldsALE)
222 {
223 for (auto &zone : field->GetGraph()->GetMovement()->GetZones())
224 {
225 if (zone.second->GetMoved())
226 {
227 auto conEl = zone.second->GetConstituentElements();
228 // Loop over zone elements expansions and rebuild geometric
229 // factors
230 for (const auto &i :
231 conEl[0]) // This only takes highest dimensioned elements
232 {
233 field->GetExpFromGeomId(i->GetGlobalID())->Reset();
234 }
235 }
236 }
237 }
238
239 for (auto &zone : m_fieldsALE[0]->GetGraph()->GetMovement()->GetZones())
240 {
241 if (zone.second->GetMoved())
242 {
243 auto conEl = zone.second->GetConstituentElements();
244 // Loop over zone elements expansions and rebuild geometric factors
245 // and recalc trace normals
246 for (const auto &i :
247 conEl[0]) // This only takes highest dimensioned elements
248 {
249 int nfaces = m_fieldsALE[0]
250 ->GetExpFromGeomId(i->GetGlobalID())
251 ->GetNtraces();
252 for (int j = 0; j < nfaces; ++j)
253 {
254 m_fieldsALE[0]
255 ->GetExpFromGeomId(i->GetGlobalID())
256 ->ComputeTraceNormal(j);
257 }
258 }
259 }
260 }
261
262 for (auto &field : m_fieldsALE)
263 {
264 // Reset collections (despite the default being eNoCollection it does
265 // remember the last auto-tuned values), eNoImpType gives lots of output
266 field->CreateCollections(Collections::eNoCollection);
267 }
268
269 // Reload new trace normals in to the solver cache
270 m_fieldsALE[0]->GetTrace()->GetNormals(traceNormals);
271
272 // Recompute grid velocity.
274
275 // Updates trace grid velocity
276 for (int i = 0; i < m_gridVelocityTrace.size(); ++i)
277 {
278 m_fieldsALE[0]->ExtractTracePhys(m_gridVelocity[i],
280 }
281
282 // Set the flag to exchange coords in InterfaceMapDG to true
283 m_fieldsALE[0]->GetGraph()->GetMovement()->GetCoordExchangeFlag() = true;
284
285 m_prevStageTime = time;
286}

References Nektar::LibUtilities::Timer::AccumulateRegion(), Nektar::Collections::eNoCollection, FilterPython_Function::field, m_fieldsALE, m_gridVelocity, m_gridVelocityTrace, m_prevStageTime, Nektar::LibUtilities::Timer::Start(), Nektar::LibUtilities::Timer::Stop(), and v_UpdateGridVelocity().

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

◆ 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 108 of file ALEHelper.cpp.

110{
111 if (m_ALESolver)
112 {
113 const int nm = m_fieldsALE[0]->GetNcoeffs();
114 MultiRegions::GlobalMatrixKey mkey(StdRegions::eMass);
115
116 // Premultiply each field by the mass matrix
117 for (int i = 0; i < m_fieldsALE.size(); ++i)
118 {
119 fields[i] = Array<OneD, NekDouble>(nm);
120 m_fieldsALE[i]->GeneralMatrixOp(mkey, m_fieldsALE[i]->GetCoeffs(),
121 fields[i]);
122 }
123 }
124}

References Nektar::StdRegions::eMass, m_ALESolver, 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 90 of file ALEHelper.cpp.

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

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

Definition at line 91 of file ALEHelper.h.

Referenced by InitObject(), and v_UpdateGridVelocity().

◆ 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

◆ m_prevStageTime

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

Definition at line 94 of file ALEHelper.h.

Referenced by MoveMesh().

◆ m_spaceDim

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