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 50 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.

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

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

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

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

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

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 77 of file ALEHelper.h.

78 {
79 return m_gridVelocity;
80 }

References m_gridVelocity.

◆ GetGridVelocityTrace()

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

Definition at line 289 of file ALEHelper.cpp.

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

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.

50{
51 boost::ignore_unused(spaceDim, fields);
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:92
std::shared_ptr< ALETranslate > ALETranslateShPtr
Definition: ALEHelper.h:158
std::shared_ptr< ALERotate > ALERotateShPtr
Definition: ALEHelper.h:159
std::shared_ptr< ALEFixed > ALEFixedShPtr
Definition: ALEHelper.h:157

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

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

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

Reimplemented in Nektar::UnsteadyAdvection, Nektar::UnsteadyAdvectionDiffusion, Nektar::CompressibleFlowSystem, and Nektar::CFSImplicit.

Definition at line 42 of file ALEHelper.cpp.

44{
45 boost::ignore_unused(spaceDim, fields);
46}

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

◆ 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 92 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 95 of file ALEHelper.h.

Referenced by MoveMesh().

◆ m_spaceDim

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