Nektar++
Loading...
Searching...
No Matches
EquationSystems/VelocityCorrectionScheme.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: VelocityCorrectionScheme.cpp
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description: Velocity Correction Scheme for the Incompressible
32// Navier Stokes equations
33//
34///////////////////////////////////////////////////////////////////////////////
35
43
45
46namespace Nektar
47{
48
49using namespace MultiRegions;
50
53 "VelocityCorrectionScheme", VelocityCorrectionScheme::create);
54
57 "SolverType", "VelocityCorrectionScheme", eVelocityCorrectionScheme);
58
59/**
60 * Constructor. Creates ...
61 *
62 * \param
63 * \param
64 */
68 : UnsteadySystem(pSession, pGraph), IncNavierStokes(pSession, pGraph),
69 m_varCoeffLap(StdRegions::NullVarCoeffMap)
70{
71}
72
74{
75 int n;
76
77 // The base initialisation calls v_GetSystemSingularChecks().
78 m_MHD.hasLorentzForce = DefinedForcing("ForcingLorentz");
80 m_explicitDiffusion = false;
81
82 // Set m_pressure to point to last field of m_fields;
83 if (StringUtils::IEquals(m_session->GetVariable(m_fields.size() - 1), "p"))
84 {
85 m_nConvectiveFields = m_fields.size() - 1;
87 if (m_MHD.hasLorentzForce)
88 {
89 ASSERTL0(m_fields.size() >= m_velocity.size() + 2,
90 "Need to define an electric potential field immediately "
91 "before pressure for ForcingLorentz.");
92 m_nConvectiveFields = m_fields.size() - 2;
94 }
95 }
96 else
97 {
98 ASSERTL0(false, "Need to set up pressure field definition");
99 }
100
101 // Determine diffusion coefficients for each field
103 for (n = 0; n < m_nConvectiveFields; ++n)
104 {
105 std::string varName = m_session->GetVariable(n);
106 if (m_session->DefinesFunction("DiffusionCoefficient", varName))
107 {
109 m_session->GetFunction("DiffusionCoefficient", varName);
110 m_diffCoeff[n] = ffunc->Evaluate();
111 }
112 }
113
114 // Integrate only the convective fields
115 for (n = 0; n < m_nConvectiveFields; ++n)
116 {
117 m_intVariables.push_back(n);
118 }
119
121 SetUpSVV();
122
123 // check to see if it is explicity turned off
124 m_session->MatchSolverInfo("GJPStabilisation", "False",
126
127 // if GJPStabilisation set to False bool will be true and
128 // if not false so negate/revese bool
130
131 m_session->MatchSolverInfo("GJPNormalVelocity", "True", m_useGJPNormalVel,
132 false);
133
135 {
136 ASSERTL0(
137 !StringUtils::IEquals(m_session->GetSolverInfo("GJPStabilisation"),
138 "SemiImplicit"),
139 "Can not specify GJPNormalVelocity with"
140 " GJPStabilisation set to SemiImplicit");
141 }
142
143 m_session->LoadParameter("GJPJumpScale", m_GJPJumpScale, 1.0);
144
145 m_session->MatchSolverInfo("SmoothAdvection", "True", m_SmoothAdvection,
146 false);
147
148 // set explicit time-intregration class operators
151
152 // set implicit time-intregration class operators
155
156 // Set up bits for flowrate.
157 m_session->LoadParameter("Flowrate", m_flowrate, 0.0);
158 m_session->LoadParameter("IO_FlowSteps", m_flowrateSteps, 0);
159 m_session->LoadParameter("IO_FlowStepsPrecision", m_flowrateStepsPrecision,
160 6);
161}
162
164{
165 // creation of the extrapolation object
168 {
169 std::string vExtrapolation = v_GetExtrapolateStr();
170 if (m_session->DefinesSolverInfo("Extrapolation"))
171 {
172 vExtrapolation = v_GetSubSteppingExtrapolateStr(
173 m_session->GetSolverInfo("Extrapolation"));
174 }
176 vExtrapolation, m_session, m_fields, m_pressure, m_velocity,
178
179 m_extrapolation->SetForcing(m_forcing);
180 m_extrapolation->SubSteppingTimeIntegration(m_intScheme);
181 m_extrapolation->GenerateBndElmtExpansion();
182 m_extrapolation->GenerateHOPBCMap(m_session);
186 }
187}
188
189/**
190 * @brief Set up the Stokes solution used to impose constant flowrate
191 * through a boundary.
192 *
193 * This routine solves a Stokes equation using a unit forcing direction,
194 * specified by the user to be in the desired flow direction. This field can
195 * then be used to correct the end of each timestep to impose a constant
196 * volumetric flow rate through a user-defined boundary.
197 *
198 * There are three modes of operation:
199 *
200 * - Standard two-dimensional or three-dimensional simulations (e.g. pipes
201 * or channels)
202 * - 3DH1D simulations where the forcing is not in the homogeneous
203 * direction (e.g. channel flow, where the y-direction of the 2D mesh
204 * is perpendicular to the wall);
205 * - 3DH1D simulations where the forcing is in the homogeneous direction
206 * (e.g. pipe flow in the z-direction).
207 *
208 * In the first two cases, the user should define:
209 * - the `Flowrate` parameter, which dictates the volumetric flux through
210 * the reference area
211 * - tag a boundary region with the `Flowrate` user-defined type to define
212 * the reference area
213 * - define a `FlowrateForce` function with components `ForceX`, `ForceY`
214 * and `ForceZ` that defines a unit forcing in the appropriate direction.
215 *
216 * In the latter case, the user should define only the `Flowrate`; the
217 * reference area is taken to be the homogeneous plane and the force is
218 * assumed to be the unit z-vector \f$ \hat{e}_z \f$.
219 *
220 * This routine solves a single timestep of the Stokes problem
221 * (premultiplied by the backwards difference coefficient):
222 *
223 * \f[ \frac{\partial\mathbf{u}}{\partial t} = -\nabla p +
224 * \nu\nabla^2\mathbf{u} + \mathbf{f} \f]
225 *
226 * with a zero initial condition to obtain a field \f$ \mathbf{u}_s \f$. The
227 * flowrate is then corrected at each timestep \f$ n \f$ by adding the
228 * correction \f$ \alpha\mathbf{u}_s \f$ where
229 *
230 * \f[ \alpha = \frac{\overline{Q} - Q(\mathbf{u^n})}{Q(\mathbf{u}_s)} \f]
231 *
232 * where \f$ Q(\cdot)\f$ is the volumetric flux through the appropriate
233 * surface or line, which is implemented in
234 * VelocityCorrectionScheme::MeasureFlowrate. For more details, see chapter
235 * 3.2 of the thesis of D. Moxey (University of Warwick, 2011).
236 */
238{
239 m_flowrateBndID = -1;
240 m_flowrateArea = 0.0;
241
243 m_fields[0]->GetBndConditions();
244
245 std::string forces[] = {"X", "Y", "Z"};
246 Array<OneD, NekDouble> flowrateForce(m_spacedim, 0.0);
247
248 // Set up flowrate forces.
249 bool defined = true;
250 for (int i = 0; i < m_spacedim; ++i)
251 {
252 std::string varName = std::string("Force") + forces[i];
253 defined = m_session->DefinesFunction("FlowrateForce", varName);
254
255 if (!defined && m_HomogeneousType == eHomogeneous1D)
256 {
257 break;
258 }
259
260 ASSERTL0(defined,
261 "A 'FlowrateForce' function must defined with components "
262 "[ForceX, ...] to define direction of flowrate forcing");
263
265 m_session->GetFunction("FlowrateForce", varName);
266 flowrateForce[i] = ffunc->Evaluate();
267 }
268
269 // Define flag for case with homogeneous expansion and forcing not in the
270 // z-direction
271 m_homd1DFlowinPlane = false;
272 if (defined && m_HomogeneousType == eHomogeneous1D)
273 {
274 m_homd1DFlowinPlane = true;
275 }
276
277 // For 3DH1D simulations, if force isn't defined then assume in
278 // z-direction.
279 if (!defined)
280 {
281 flowrateForce[2] = 1.0;
282 }
283
284 // Find the boundary condition that is tagged as the flowrate boundary.
285 for (size_t i = 0; i < bcs.size(); ++i)
286 {
287 if (StringUtils::IEquals(bcs[i]->GetUserDefined(), "Flowrate"))
288 {
289 m_flowrateBndID = i;
290 break;
291 }
292 }
293
294 int tmpBr = m_flowrateBndID;
295 m_comm->AllReduce(tmpBr, LibUtilities::ReduceMax);
297 "One boundary region must be marked using the 'Flowrate' "
298 "user-defined type to monitor the volumetric flowrate.");
299
300 // Extract an appropriate expansion list to represents the boundary.
301 if (m_flowrateBndID >= 0)
302 {
303 // For a boundary, extract the boundary itself.
304 m_flowrateBnd = m_fields[0]->GetBndCondExpansions()[m_flowrateBndID];
305 }
307 {
308 // For 3DH1D simulations with no force specified, find the mean
309 // (0th) plane.
310 Array<OneD, unsigned int> zIDs = m_fields[0]->GetZIDs();
311 int tmpId = -1;
312
313 for (size_t i = 0; i < zIDs.size(); ++i)
314 {
315 if (zIDs[i] == 0)
316 {
317 tmpId = i;
318 break;
319 }
320 }
321
322 ASSERTL1(tmpId <= 0, "Should be either at location 0 or -1 if not "
323 "found");
324
325 if (tmpId != -1)
326 {
327 m_flowrateBnd = m_fields[0]->GetPlane(tmpId);
328 }
329 }
330
331 // At this point, some processors may not have m_flowrateBnd
332 // set if they don't contain the appropriate boundary. To
333 // calculate the area, we integrate 1.0 over the boundary
334 // (which has been set up with the appropriate subcommunicator
335 // to avoid deadlock), and then communicate this to the other
336 // processors with an AllReduce.
337 if (m_flowrateBnd)
338 {
339 Array<OneD, NekDouble> inArea(m_flowrateBnd->GetNpoints(), 1.0);
340 m_flowrateArea = m_flowrateBnd->Integral(inArea);
341 }
343
344 // In homogeneous case with forcing not aligned to the z-direction,
345 // redefine m_flowrateBnd so it is a 1D expansion
348 {
349 // For 3DH1D simulations with no force specified, find the mean
350 // (0th) plane.
351 Array<OneD, unsigned int> zIDs = m_fields[0]->GetZIDs();
352 m_planeID = -1;
353
354 for (size_t i = 0; i < zIDs.size(); ++i)
355 {
356 if (zIDs[i] == 0)
357 {
358 m_planeID = i;
359 break;
360 }
361 }
362
363 ASSERTL1(m_planeID <= 0, "Should be either at location 0 or -1 "
364 "if not found");
365
366 if (m_planeID != -1)
367 {
369 m_fields[0]->GetBndCondExpansions()[m_flowrateBndID]->GetPlane(
370 m_planeID);
371 }
372 }
373
374 // Set up some storage for the Stokes solution (to be stored in
375 // m_flowrateStokes) and its initial condition (inTmp), which holds the
376 // unit forcing.
377 int nqTot = m_fields[0]->GetNpoints();
380
381 for (int i = 0; i < m_spacedim; ++i)
382 {
383 inTmp[i] = Array<OneD, NekDouble>(nqTot, flowrateForce[i] * aii_dt);
385
387 {
388 Array<OneD, NekDouble> inTmp2(nqTot);
389 m_fields[i]->HomogeneousFwdTrans(nqTot, inTmp[i], inTmp2);
390 m_fields[i]->SetWaveSpace(true);
391 inTmp[i] = inTmp2;
392 }
393
394 Vmath::Zero(m_fields[i]->GetNcoeffs(), m_fields[i]->UpdateCoeffs(), 1);
395 }
396
397 // Create temporary extrapolation object to avoid issues with
398 // m_extrapolation for HOPBCs using higher order timestepping schemes.
399 // Zero pressure BCs in Neumann boundaries that may have been
400 // set in the advection step.
402 m_pressure->GetBndConditions();
404 m_pressure->GetBndCondExpansions();
405 for (size_t n = 0; n < PBndConds.size(); ++n)
406 {
407 if (PBndConds[n]->GetBoundaryConditionType() ==
409 {
410 Vmath::Zero(PBndExp[n]->GetNcoeffs(), PBndExp[n]->UpdateCoeffs(),
411 1);
412 }
413 }
414
415 // Finally, calculate the solution and the flux of the Stokes
416 // solution. We set m_greenFlux to maximum numeric limit, which signals
417 // to SolveUnsteadyStokesSystem that we don't need to apply a flowrate
418 // force.
419 m_greenFlux = std::numeric_limits<NekDouble>::max();
420 m_flowrateAiidt = aii_dt;
421
422 // Save the number of convective field in case it is not set
423 // to spacedim. Only need velocity components for stokes forcing
424 int SaveNConvectiveFields = m_nConvectiveFields;
426 // Save Dirichlet BCs and set to zero for Stokes solve
427 std::map<std::pair<int, int>, Array<OneD, NekDouble>> SaveDirBCs;
428 for (int i = 0; i < m_nConvectiveFields; ++i)
429 {
430 const Array<OneD, const ExpListSharedPtr> &BndCondExp =
431 m_fields[i]->GetBndCondExpansions();
432
433 for (int j = 0; j < BndCondExp.size(); ++j)
434 {
435 if (m_fields[i]
436 ->GetBndConditions()[j]
437 ->GetBoundaryConditionType() == SpatialDomains::eDirichlet)
438 {
439 Array<OneD, NekDouble> bndcoeffs =
440 m_fields[i]->UpdateBndCondExpansion(j)->UpdateCoeffs();
441 SaveDirBCs[std::make_pair(i, j)] =
442 Array<OneD, NekDouble>(bndcoeffs.size(), bndcoeffs.data());
443 Vmath::Zero(bndcoeffs.size(), bndcoeffs, 1);
444 }
445 }
446 }
447 SolveUnsteadyStokesSystem(inTmp, m_flowrateStokes, 0.0, aii_dt);
448 // Reset Dirichlet BCs
449 for (int i = 0; i < m_nConvectiveFields; ++i)
450 {
451 for (int j = 0; j < m_fields[i]->GetBndCondExpansions().size(); ++j)
452 {
453 if (m_fields[i]
454 ->GetBndConditions()[j]
455 ->GetBoundaryConditionType() == SpatialDomains::eDirichlet)
456 {
457 Array<OneD, NekDouble> bndcoeffs =
458 m_fields[i]->UpdateBndCondExpansion(j)->UpdateCoeffs();
459 Vmath::Vcopy(bndcoeffs.size(), SaveDirBCs[std::make_pair(i, j)],
460 1, bndcoeffs, 1);
461 }
462 }
463 }
464
465 m_nConvectiveFields = SaveNConvectiveFields;
467
468 // If the user specified IO_FlowSteps, open a handle to store output.
469 if (m_comm->GetRank() == 0 && m_flowrateSteps &&
470 !m_flowrateStream.is_open())
471 {
472 std::string filename = m_session->GetSessionName();
473 filename += ".prs";
474 m_flowrateStream.open(filename.c_str());
475 m_flowrateStream.setf(std::ios::scientific, std::ios::floatfield);
476 m_flowrateStream << "# step time dP" << std::endl
477 << "# -------------------------------------------"
478 << std::endl;
479 }
480
481 // Replace pressure BCs with those evaluated from advection step
482 m_extrapolation->CopyPressureHBCsToPbndExp();
483}
484
485/**
486 * @brief Measure the volumetric flow rate through the volumetric flow rate
487 * reference surface.
488 *
489 * This routine computes the volumetric flow rate
490 *
491 * \f[
492 * Q(\mathbf{u}) = \frac{1}{\mu(R)} \int_R \mathbf{u} \cdot d\mathbf{s}
493 * \f]
494 *
495 * through the boundary region \f$ R \f$.
496 */
498 const Array<OneD, Array<OneD, NekDouble>> &inarray)
499{
500 NekDouble flowrate = 0.0;
501
502 if (m_flowrateBnd && m_flowrateBndID >= 0)
503 {
504 // If we're an actual boundary, calculate the vector flux through
505 // the boundary.
507
509 {
510 // General case
511 for (int i = 0; i < m_spacedim; ++i)
512 {
513 m_fields[i]->ExtractPhysToBnd(m_flowrateBndID, inarray[i],
514 boundary[i]);
515 }
516 flowrate = m_flowrateBnd->VectorFlux(boundary);
517 }
518 else if (m_planeID == 0)
519 {
520 // Homogeneous with forcing in plane. Calculate flux only on
521 // the meanmode - calculateFlux necessary for hybrid
522 // parallelisation.
523 for (int i = 0; i < m_spacedim; ++i)
524 {
525 m_fields[i]->GetPlane(m_planeID)->ExtractPhysToBnd(
526 m_flowrateBndID, inarray[i], boundary[i]);
527 }
528
529 // the flowrate is calculated on the mean mode so it needs to be
530 // multiplied by LZ to be consistent with the general case.
531 flowrate = m_flowrateBnd->VectorFlux(boundary) *
532 m_session->GetParameter("LZ");
533 }
534 }
536 {
537 // 3DH1D case with no Flowrate boundary defined: compute flux
538 // through the zero-th (mean) plane.
539 flowrate = m_flowrateBnd->Integral(inarray[2]);
540 }
541
542 // Communication to obtain the total flowrate
544 {
545 m_comm->GetColumnComm()->AllReduce(flowrate, LibUtilities::ReduceSum);
546 }
547 else
548 {
549 m_comm->GetSpaceComm()->AllReduce(flowrate, LibUtilities::ReduceSum);
550 }
551 return flowrate / m_flowrateArea;
552}
553
555{
556 if (m_flowrateSteps > 0)
557 {
558 if (m_comm->GetRank() == 0 && (step + 1) % m_flowrateSteps == 0)
559 {
561 << std::setw(8) << step
562 << std::setw(m_flowrateStepsPrecision + 10) << m_time
563 << std::setw(m_flowrateStepsPrecision + 10) << std::fixed
564 << std::setprecision(m_flowrateStepsPrecision) << m_alpha
565 << std::endl;
566 }
567 }
568
570}
571
572/**
573 *
574 */
576{
577 AdvectionSystem::v_GenerateSummary(s);
578 SolverUtils::AddSummaryItem(s, "Splitting Scheme",
579 "Velocity correction (strong press. form)");
580
581 if (m_extrapolation->GetSubStepName().size())
582 {
583 SolverUtils::AddSummaryItem(s, "Substepping",
584 m_extrapolation->GetSubStepName());
585 }
586
587 std::string dealias = m_homogen_dealiasing ? "Homogeneous1D" : "";
589 {
590 dealias += (dealias == "" ? "" : " + ") + std::string("spectral/hp");
591 }
592 if (dealias != "")
593 {
594 SolverUtils::AddSummaryItem(s, "Dealiasing", dealias);
595 }
596
597 std::string smoothing = m_useSpecVanVisc ? "spectral/hp" : "";
598 if (smoothing != "")
599 {
601 {
603 s, "Smoothing-SpecHP",
604 "SVV (" + smoothing + " Exp Kernel(cut-off = " +
605 boost::lexical_cast<std::string>(m_sVVCutoffRatio) +
606 ", diff coeff = " +
607 boost::lexical_cast<std::string>(m_sVVDiffCoeff) + "))");
608 }
609 else
610 {
612 {
614 s, "Smoothing-SpecHP",
615 "SVV (" + smoothing + " Power Kernel (Power ratio =" +
616 boost::lexical_cast<std::string>(m_sVVCutoffRatio) +
617 ", diff coeff = " +
618 boost::lexical_cast<std::string>(m_sVVDiffCoeff) +
619 "*Uh/p))");
620 }
621 else
622 {
624 s, "Smoothing-SpecHP",
625 "SVV (" + smoothing + " DG Kernel (diff coeff = " +
626 boost::lexical_cast<std::string>(m_sVVDiffCoeff) +
627 "*Uh/p))");
628 }
629 }
630 }
631
633 {
635 s, "Smoothing-Homo1D",
636 "SVV (Homogeneous1D - Exp Kernel(cut-off = " +
637 boost::lexical_cast<std::string>(m_sVVCutoffRatioHomo1D) +
638 ", diff coeff = " +
639 boost::lexical_cast<std::string>(m_sVVDiffCoeffHomo1D) + "))");
640 }
641
643 {
645 s, "GJP Stab. Impl. ",
646 m_session->GetSolverInfo("GJPStabilisation"));
647 SolverUtils::AddSummaryItem(s, "GJP Stab. JumpScale", m_GJPJumpScale);
648
649 if (StringUtils::IEquals(m_session->GetSolverInfo("GJPStabilisation"),
650 "Explicit"))
651 {
653 s, "GJP Normal Velocity",
654 m_session->GetSolverInfo("GJPNormalVelocity"));
655 }
656 }
657}
658
659/**
660 *
661 */
662void VelocityCorrectionScheme::v_DoInitialise(bool dumpInitialConditions)
663{
665
666 for (int i = 0; i < m_nConvectiveFields; ++i)
667 {
669 }
670
671 m_flowrateAiidt = 0.0;
672
673 AdvectionSystem::v_DoInitialise(dumpInitialConditions);
674
675 // Set up Field Meta Data for output files
676 m_fieldMetaDataMap["Kinvis"] = boost::lexical_cast<std::string>(m_kinvis);
677 m_fieldMetaDataMap["TimeStep"] =
678 boost::lexical_cast<std::string>(m_timestep);
679
680 // set boundary conditions here so that any normal component
681 // correction are imposed before they are imposed on initial
682 // field below
684 std::map<std::string, NekDouble> params;
685 params["Time"] = m_time;
686 params["velocity"] = 1.;
690 m_IncNavierStokesBCs->Update(fields, Adv, params);
691
692 // Ensure the initial conditions have correct BCs
693 for (size_t i = 0; i < m_fields.size(); ++i)
694 {
695 m_fields[i]->ImposeDirichletConditions(m_fields[i]->UpdateCoeffs());
696 m_fields[i]->LocalToGlobal();
697 m_fields[i]->GlobalToLocal();
698 m_fields[i]->BwdTrans(m_fields[i]->GetCoeffs(),
699 m_fields[i]->UpdatePhys());
700 }
701
703 {
704 // initialise GJP in first field and copy to other convective fields
705 if (m_fields[0]->GetGJPData() == nullptr)
706 {
707 std::dynamic_pointer_cast<MultiRegions::ContField>(m_fields[0])
708 ->InitGJPData();
709 }
710 for (unsigned i = 1; i < m_nConvectiveFields; ++i)
711 {
712 std::dynamic_pointer_cast<MultiRegions::ContField>(m_fields[i])
713 ->SetGJPData(m_fields[0]->GetGJPData());
714 }
715 }
716}
717
718/**
719 *
720 */
722{
723 size_t nfields = m_fields.size() - 1;
724 for (size_t k = 0; k < nfields; ++k)
725 {
726 // Backward Transformation in physical space for time evolution
727 m_fields[k]->BwdTrans(m_fields[k]->GetCoeffs(),
728 m_fields[k]->UpdatePhys());
729 }
730}
731
732/**
733 *
734 */
736{
737
738 size_t nfields = m_fields.size() - 1;
739 for (size_t k = 0; k < nfields; ++k)
740 {
741 // Forward Transformation in physical space for time evolution
742 m_fields[k]->FwdTransLocalElmt(m_fields[k]->GetPhys(),
743 m_fields[k]->UpdateCoeffs());
744 }
745}
746
747/**
748 *
749 */
751{
752 int vVar = m_session->GetVariables().size();
753 Array<OneD, bool> vChecks(vVar, false);
754 vChecks[vVar - 1] = true;
755 if (m_MHD.hasLorentzForce)
756 {
757 vChecks[vVar - 2] = true;
758 }
759 return vChecks;
760}
761
762/**
763 *
764 */
766{
767 return m_session->GetVariables().size() - 1;
768}
769
770/**
771 * Explicit part of the method - Advection, Forcing + HOPBCs
772 */
774 const Array<OneD, const Array<OneD, NekDouble>> &inarray,
775 Array<OneD, Array<OneD, NekDouble>> &outarray, const NekDouble time)
776{
778 timer.Start();
779 EvaluateAdvectionTerms(inarray, outarray, time);
780 timer.Stop();
781 timer.AccumulateRegion("Advection Terms");
782
783 // Smooth advection
785 {
786 for (int i = 0; i < m_nConvectiveFields; ++i)
787 {
788 m_pressure->SmoothField(outarray[i]);
789 }
790 }
791
792 // Add forcing terms
793 for (auto &x : m_forcing)
794 {
795 x->Apply(m_fields, inarray, outarray, time);
796 }
797
798 // Calculate High-Order pressure boundary conditions
799 timer.Start();
800 std::map<std::string, NekDouble> params;
801 params["Kinvis"] = m_kinvis;
802 params["Time"] = time + m_timestep;
803 params["pressure"] = 1.;
804 if (m_MHD.implicitLorentzDamping > 0.0)
805 {
806 params["ImplicitLorentzDamping"] = m_MHD.implicitLorentzDamping;
807 }
809 m_extrapolation->EvaluatePressureBCs(inarray, outarray, m_kinvis);
810 m_IncNavierStokesBCs->Update(inarray, outarray, params);
811 timer.Stop();
812 timer.AccumulateRegion("Pressure BCs");
813}
814
815/**
816 * Implicit part of the method - Poisson + nConv*Helmholtz
817 */
819 const Array<OneD, const Array<OneD, NekDouble>> &inarray,
821 [[maybe_unused]] const NekDouble time, const NekDouble aii_Dt)
822{
823 // Set up flowrate if we're starting for the first time or the value of
824 // aii_Dt has changed.
825 if (m_flowrate > 0.0 && (aii_Dt != m_flowrateAiidt))
826 {
827 SetupFlowrate(aii_Dt);
828 }
829
830 size_t physTot = m_fields[0]->GetTotPoints();
831
832 // Substep the pressure boundary condition if using substepping
833 m_extrapolation->SubStepSetPressureBCs(inarray, aii_Dt, m_kinvis);
834
835 // Set up forcing term for pressure Poisson equation
837 timer.Start();
838 SetUpPressureForcing(inarray, m_F, aii_Dt);
839 timer.Stop();
840 timer.AccumulateRegion("Pressure Forcing");
841
842 // Solve Pressure System
843 timer.Start();
844 SolvePressure(m_F[0]);
845 timer.Stop();
846 timer.AccumulateRegion("Pressure Solve");
847
848 // Set up forcing term for Helmholtz problems
849 timer.Start();
850 SolveSolid(time);
851 SetUpViscousForcing(inarray, m_F, aii_Dt);
852 timer.Stop();
853 timer.AccumulateRegion("Viscous Forcing");
854
855 // Solve velocity system
856 timer.Start();
857 SolveViscous(m_F, inarray, outarray, aii_Dt);
858 timer.Stop();
859 timer.AccumulateRegion("Viscous Solve");
860
861 // Apply flowrate correction
862 if (m_flowrate > 0.0 &&
863 m_greenFlux != std::numeric_limits<NekDouble>::max())
864 {
865 NekDouble currentFlux = MeasureFlowrate(outarray);
866 m_alpha = (m_flowrate - currentFlux) / m_greenFlux;
867
868 for (int i = 0; i < m_spacedim; ++i)
869 {
870 Vmath::Svtvp(physTot, m_alpha, m_flowrateStokes[i], 1, outarray[i],
871 1, outarray[i], 1);
872 // Enusre coeff space is updated for next time step
873 m_fields[i]->FwdTransLocalElmt(outarray[i],
874 m_fields[i]->UpdateCoeffs());
875 // Impsoe symmetry of flow on coeff space (good to enfore
876 // periodicity).
877 m_fields[i]->LocalToGlobal();
878 m_fields[i]->GlobalToLocal();
879 }
880 }
881}
882
887
889{
890 // update velocity boundary condition
893 std::map<std::string, NekDouble> params;
894 params["Time"] = time;
895 params["velocity"] = 1.;
897 m_IncNavierStokesBCs->Update(fields, Adv, params);
898}
899
900/**
901 * Forcing term for Poisson solver solver
902 */
904 const Array<OneD, const Array<OneD, NekDouble>> &fields,
906{
907 size_t i;
908 size_t physTot = m_fields[0]->GetTotPoints();
909 size_t nvel = m_velocity.size();
910
911 m_fields[0]->PhysDeriv(eX, fields[0], Forcing[0]);
912
913 for (i = 1; i < nvel; ++i)
914 {
915 // Use Forcing[1] as storage since it is not needed for the pressure
916 m_fields[i]->PhysDeriv(DirCartesianMap[i], fields[i], Forcing[1]);
917 Vmath::Vadd(physTot, Forcing[1], 1, Forcing[0], 1, Forcing[0], 1);
918 }
919
920 Vmath::Smul(physTot, 1.0 / aii_Dt, Forcing[0], 1, Forcing[0], 1);
921}
922
923/**
924 * Forcing term for Helmholtz solver
925 */
927 const Array<OneD, const Array<OneD, NekDouble>> &inarray,
929{
930 NekDouble aii_dtinv = 1.0 / aii_Dt;
931 size_t phystot = m_fields[0]->GetTotPoints();
932
933 // Grad p
934 m_pressure->BwdTrans(m_pressure->GetCoeffs(), m_pressure->UpdatePhys());
935
936 int nvel = m_velocity.size();
937 if (nvel == 2)
938 {
939 m_pressure->PhysDeriv(m_pressure->GetPhys(), Forcing[m_velocity[0]],
940 Forcing[m_velocity[1]]);
941 }
942 else
943 {
944 m_pressure->PhysDeriv(m_pressure->GetPhys(), Forcing[m_velocity[0]],
946 }
947
948 // zero convective fields.
949 for (int i = nvel; i < m_nConvectiveFields; ++i)
950 {
951 Vmath::Zero(phystot, Forcing[i], 1);
952 }
953
954 // Subtract inarray/(aii_dt) and divide by kinvis. Kinvis will
955 // need to be updated for the convected fields.
956 for (int i = 0; i < m_nConvectiveFields; ++i)
957 {
958 Vmath::Svtvp(phystot, -aii_dtinv, inarray[i], 1, Forcing[i], 1,
959 Forcing[i], 1);
960 Vmath::Smul(phystot, 1.0 / m_diffCoeff[i], &(Forcing[i])[0], 1,
961 &(Forcing[i])[0], 1);
962 }
963}
964
965/**
966 * Solve pressure system
967 */
970{
972 // Setup coefficient for equation
973 factors[StdRegions::eFactorLambda] = 0.0;
974
975 // Solver Pressure Poisson Equation
976 m_pressure->HelmSolve(Forcing, m_pressure->UpdateCoeffs(), factors);
977
978 // Add presure to outflow bc if using convective like BCs
979 m_extrapolation->AddPressureToOutflowBCs(m_kinvis);
980}
981
982/**
983 * Solve velocity system
984 */
987 const Array<OneD, const Array<OneD, NekDouble>> &inarray,
988 Array<OneD, Array<OneD, NekDouble>> &outarray, const NekDouble aii_Dt)
989{
993
994 AppendSVVFactors(factors, varFactorsMap);
995 ComputeGJPNormalVelocity(inarray, varCoeffMap);
996
997 // Solve Helmholtz system and put in Physical space
998 for (int i = 0; i < m_nConvectiveFields; ++i)
999 {
1000 // Add diffusion coefficient to GJP matrix operator (Implicit part)
1002 {
1004 }
1005
1007 for (int j = 0; j < m_velocity.size(); ++j)
1008 {
1009 if (m_velocity[j] == i)
1010 {
1011 implicitLorentzDamping = m_MHD.implicitLorentzDamping;
1012 break;
1013 }
1014 }
1015
1016 // Setup coefficients for equation. The Lorentz reaction term only
1017 // applies to velocity fields, not to any additional passive scalars.
1018 factors[StdRegions::eFactorLambda] =
1019 (1.0 / aii_Dt + implicitLorentzDamping) / m_diffCoeff[i];
1020 m_fields[i]->HelmSolve(Forcing[i], m_fields[i]->UpdateCoeffs(), factors,
1021 varCoeffMap, varFactorsMap);
1022 m_fields[i]->BwdTrans(m_fields[i]->GetCoeffs(), outarray[i]);
1023 }
1024}
1025
1027{
1028
1029 m_session->MatchSolverInfo("SpectralVanishingViscosity", "PowerKernel",
1030 m_useSpecVanVisc, false);
1031
1032 if (m_useSpecVanVisc)
1033 {
1035 }
1036 else
1037 {
1038 m_useHomo1DSpecVanVisc = false;
1039
1040 m_session->MatchSolverInfo("SpectralVanishingViscositySpectralHP",
1041 "PowerKernel", m_useSpecVanVisc, false);
1042 }
1043
1044 if (m_useSpecVanVisc)
1045 {
1046 m_IsSVVPowerKernel = true;
1047 }
1048 else
1049 {
1050 m_session->MatchSolverInfo("SpectralVanishingViscosity", "DGKernel",
1051 m_useSpecVanVisc, false);
1052 if (m_useSpecVanVisc)
1053 {
1055 }
1056 else
1057 {
1058 m_session->MatchSolverInfo("SpectralVanishingViscositySpectralHP",
1059 "DGKernel", m_useSpecVanVisc, false);
1060 }
1061
1062 if (m_useSpecVanVisc)
1063 {
1064 m_IsSVVPowerKernel = false;
1065 }
1066 }
1067
1068 // set up varcoeff kernel if PowerKernel or DG is specified
1069 if (m_useSpecVanVisc)
1070 {
1073 if (m_session->DefinesFunction("SVVVelocityMagnitude"))
1074 {
1075 if (m_comm->GetRank() == 0)
1076 {
1077 std::cout << "Seting up SVV velocity from "
1078 "SVVVelocityMagnitude section in session file"
1079 << std::endl;
1080 }
1081 size_t nvel = m_velocity.size();
1082 size_t phystot = m_fields[0]->GetTotPoints();
1083 SVVVelFields = Array<OneD, Array<OneD, NekDouble>>(nvel);
1084 std::vector<std::string> vars;
1085 for (size_t i = 0; i < nvel; ++i)
1086 {
1087 SVVVelFields[i] = Array<OneD, NekDouble>(phystot);
1088 vars.push_back(m_session->GetVariable(m_velocity[i]));
1089 }
1090
1091 // Load up files into m_fields;
1092 GetFunction("SVVVelocityMagnitude")->Evaluate(vars, SVVVelFields);
1093 }
1094
1096 SVVVarDiffCoeff(1.0, m_svvVarDiffCoeff, SVVVelFields);
1097 m_session->LoadParameter("SVVDiffCoeff", m_sVVDiffCoeff, 1.0);
1098 }
1099 else
1100 {
1102 m_session->LoadParameter("SVVDiffCoeff", m_sVVDiffCoeff, 0.1);
1103 }
1104
1105 // Load parameters for Spectral Vanishing Viscosity
1106 if (m_useSpecVanVisc == false)
1107 {
1108 m_session->MatchSolverInfo("SpectralVanishingViscosity", "True",
1109 m_useSpecVanVisc, false);
1110 if (m_useSpecVanVisc == false)
1111 {
1112 m_session->MatchSolverInfo("SpectralVanishingViscosity",
1113 "ExpKernel", m_useSpecVanVisc, false);
1114 }
1116
1117 if (m_useSpecVanVisc == false)
1118 {
1119 m_session->MatchSolverInfo("SpectralVanishingViscositySpectralHP",
1120 "True", m_useSpecVanVisc, false);
1121 if (m_useSpecVanVisc == false)
1122 {
1123 m_session->MatchSolverInfo(
1124 "SpectralVanishingViscositySpectralHP", "ExpKernel",
1125 m_useSpecVanVisc, false);
1126 }
1127 }
1128 }
1129
1130 // Case of only Homo1D kernel
1131 if (m_session->DefinesSolverInfo("SpectralVanishingViscosityHomo1D"))
1132 {
1133 m_session->MatchSolverInfo("SpectralVanishingViscosityHomo1D", "True",
1134 m_useHomo1DSpecVanVisc, false);
1135 if (m_useHomo1DSpecVanVisc == false)
1136 {
1137 m_session->MatchSolverInfo("SpectralVanishingViscosityHomo1D",
1138 "ExpKernel", m_useHomo1DSpecVanVisc,
1139 false);
1140 }
1141 }
1142
1143 m_session->LoadParameter("SVVCutoffRatio", m_sVVCutoffRatio, 0.75);
1144 m_session->LoadParameter("SVVCutoffRatioHomo1D", m_sVVCutoffRatioHomo1D,
1146 m_session->LoadParameter("SVVDiffCoeffHomo1D", m_sVVDiffCoeffHomo1D,
1148
1150 {
1151 ASSERTL0(
1153 "Expect to have three velocity fields with homogenous expansion");
1154
1156 {
1158 planes = m_fields[0]->GetZIDs();
1159
1160 size_t num_planes = planes.size();
1161 Array<OneD, NekDouble> SVV(num_planes, 0.0);
1162 NekDouble fac;
1163 size_t kmodes = m_fields[0]->GetHomogeneousBasis()->GetNumModes();
1164 size_t pstart;
1165
1166 pstart = m_sVVCutoffRatioHomo1D * kmodes;
1167
1168 for (size_t n = 0; n < num_planes; ++n)
1169 {
1170 if (planes[n] > pstart)
1171 {
1172 fac = (NekDouble)((planes[n] - kmodes) *
1173 (planes[n] - kmodes)) /
1174 ((NekDouble)((planes[n] - pstart) *
1175 (planes[n] - pstart)));
1176 SVV[n] = m_sVVDiffCoeffHomo1D * exp(-fac) / m_kinvis;
1177 }
1178 }
1179
1180 for (size_t i = 0; i < m_velocity.size(); ++i)
1181 {
1182 m_fields[m_velocity[i]]->SetHomo1DSpecVanVisc(SVV);
1183 }
1184 }
1185 }
1186}
1187
1189 const NekDouble velmag, Array<OneD, NekDouble> &diffcoeff,
1190 const Array<OneD, Array<OneD, NekDouble>> &vel)
1191{
1192 size_t phystot = m_fields[0]->GetTotPoints();
1193 size_t nel = m_fields[0]->GetNumElmts();
1194 size_t nvel, cnt;
1195
1197
1198 Vmath::Fill(nel, velmag, diffcoeff, 1);
1199
1200 if (vel != NullNekDoubleArrayOfArray)
1201 {
1202 Array<OneD, NekDouble> Velmag(phystot);
1203 nvel = vel.size();
1204 // calculate magnitude of v
1205 Vmath::Vmul(phystot, vel[0], 1, vel[0], 1, Velmag, 1);
1206 for (size_t n = 1; n < nvel; ++n)
1207 {
1208 Vmath::Vvtvp(phystot, vel[n], 1, vel[n], 1, Velmag, 1, Velmag, 1);
1209 }
1210 Vmath::Vsqrt(phystot, Velmag, 1, Velmag, 1);
1211
1212 cnt = 0;
1214 // calculate mean value of vel mag.
1215 for (size_t i = 0; i < nel; ++i)
1216 {
1217 size_t nq = m_fields[0]->GetExp(i)->GetTotPoints();
1218 tmp = Velmag + cnt;
1219 diffcoeff[i] = m_fields[0]->GetExp(i)->Integral(tmp);
1220 Vmath::Fill(nq, 1.0, tmp, 1);
1221 NekDouble area = m_fields[0]->GetExp(i)->Integral(tmp);
1222 diffcoeff[i] = diffcoeff[i] / area;
1223 cnt += nq;
1224 }
1225 }
1226 else
1227 {
1228 nvel = m_expdim;
1229 }
1230
1231 for (size_t e = 0; e < nel; e++)
1232 {
1233 LocalRegions::ExpansionSharedPtr exp = m_fields[0]->GetExp(e);
1234 NekDouble h = 0;
1235
1236 // Find maximum length of edge.
1237 size_t nEdge = exp->GetGeom()->GetNumEdges();
1238 for (size_t i = 0; i < nEdge; ++i)
1239 {
1240 h = std::max(h, exp->GetGeom()->GetEdge(i)->GetVertex(0)->dist(
1241 *(exp->GetGeom()->GetEdge(i)->GetVertex(1))));
1242 }
1243
1244 int p = 0;
1245 for (int i = 0; i < m_expdim; ++i)
1246 {
1247 p = std::max(p, exp->GetBasisNumModes(i) - 1);
1248 }
1249
1250 diffcoeff[e] *= h / p;
1251 }
1252}
1253
1256 StdRegions::VarFactorsMap &varFactorsMap)
1257{
1258
1259 if (m_useSpecVanVisc)
1260 {
1264 {
1266 {
1269 }
1270 else
1271 {
1274 }
1275 }
1276 }
1277}
1278
1279/*
1280 * Calculate Normal velocity on Trace (boundary of elements)
1281 * for GJP stabilisation.
1282 * We only use this for explicit stabilisation. The Semi-Implicit
1283 * operator uses a constant u_{norm} = 1.0
1284 */
1286 const Array<OneD, const Array<OneD, NekDouble>> &inarray,
1287 StdRegions::VarCoeffMap &varcoeffs)
1288{
1290 {
1292 std::dynamic_pointer_cast<MultiRegions::ContField>(m_fields[0]);
1293
1294 cfield->InitGJPData();
1295
1296 MultiRegions::GJPStabilisationSharedPtr GJPData = cfield->GetGJPData();
1297
1298 int nTracePts = GJPData->GetNumTracePts();
1299 Array<OneD, NekDouble> unorm(nTracePts, 1.0);
1300 Array<OneD, NekDouble> Fwd(nTracePts), Bwd(nTracePts);
1302 GJPData->GetTraceNormals();
1303
1304 m_fields[0]->GetFwdBwdTracePhys(inarray[0], Fwd, Bwd, true, true);
1305 Vmath::Vmul(nTracePts, Fwd, 1, traceNormals[0], 1, unorm, 1);
1306
1307 // Evaluate u.n on trace
1308 for (int f = 1; f < m_fields[0]->GetCoordim(0); ++f)
1309 {
1310 m_fields[0]->GetFwdBwdTracePhys(inarray[f], Fwd, Bwd, true, true);
1311 Vmath::Vvtvp(nTracePts, Fwd, 1, traceNormals[f], 1, unorm, 1, unorm,
1312 1);
1313 }
1314 Vmath::Vabs(nTracePts, unorm, 1, unorm, 1);
1315 varcoeffs[StdRegions::eVarCoeffGJPNormVel] = unorm;
1316 }
1317}
1318
1320 const std::vector<std::string> &strFrameData,
1321 const Array<OneD, NekDouble> &movingFrameData,
1322 std::map<std::string, NekDouble> &params)
1323{
1324 for (size_t i = 0; i < strFrameData.size(); ++i)
1325 {
1326 if (std::fabs(movingFrameData[i]) != 0.0)
1327 {
1328 params[strFrameData[i]] = movingFrameData[i];
1329 }
1330 }
1331}
1332
1333/**
1334 * Solve total electric field
1335 */
1337 const Array<OneD, Array<OneD, NekDouble>> &movEfield,
1338 Array<OneD, Array<OneD, NekDouble>> &totEfield)
1339{
1340 SetEPInsulatorBCs(movEfield);
1341 int physTot = m_fields[0]->GetTotPoints();
1342 m_fields[0]->PhysDeriv(MultiRegions::eX, movEfield[0], m_F[0]);
1343 for (size_t i = 1; i < m_spacedim; ++i)
1344 {
1345 // Use m_F[1] as storage since it is not needed for the m_epotential
1346 m_fields[i]->PhysDeriv(MultiRegions::DirCartesianMap[i], movEfield[i],
1347 m_F[1]);
1348 Vmath::Vadd(physTot, m_F[1], 1, m_F[0], 1, m_F[0], 1);
1349 }
1351 // Setup coefficient for equation
1352 factors[StdRegions::eFactorLambda] = 0.0;
1353
1354 // Solver electric potential Poisson Equation
1355 m_epotential->HelmSolve(m_F[0], m_epotential->UpdateCoeffs(), factors);
1356 m_epotential->BwdTrans(m_epotential->GetCoeffs(),
1357 m_epotential->UpdatePhys());
1358 if (m_spacedim == 2)
1359 {
1360 m_epotential->PhysDeriv(m_epotential->GetPhys(), m_F[0], m_F[1]);
1361 }
1362 else if (m_spacedim == 3)
1363 {
1364 m_epotential->PhysDeriv(m_epotential->GetPhys(), m_F[0], m_F[1],
1365 m_F[2]);
1366 }
1367 for (size_t i = 0; i < m_spacedim; ++i)
1368 {
1369 Vmath::Vsub(physTot, movEfield[i], 1, m_F[i], 1, totEfield[i], 1);
1370 }
1371}
1372
1374 const Array<OneD, Array<OneD, NekDouble>> &movEfield)
1375{
1376 std::string insulatorBCName = "Insulator";
1378 m_epotential->GetBndConditions();
1380 m_epotential->GetBndCondExpansions();
1381 // calculate electric potential flux
1382 for (int n = 0; n < BndConds.size(); ++n)
1383 {
1384 if (StringUtils::IEquals(BndConds[n]->GetUserDefined(),
1385 insulatorBCName))
1386 {
1387 int npts = BndExp[n]->GetTotPoints();
1388 // allocate boundary condition storage
1390 for (int i = 0; i < m_spacedim; ++i)
1391 {
1392 bcs[i] = Array<OneD, NekDouble>(npts, 0.);
1393 m_epotential->ExtractPhysToBnd(n, movEfield[i], bcs[i]);
1394 }
1395 BndExp[n]->NormVectorIProductWRTBase(bcs,
1396 BndExp[n]->UpdateCoeffs());
1397 }
1398 }
1399}
1400} // namespace Nektar
#define ASSERTL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
This class is the base class for Navier Stokes problems.
void SetBoundaryConditions(NekDouble time)
time dependent boundary conditions updating
MultiRegions::ExpListSharedPtr m_pressure
Pointer to field holding pressure field.
bool m_SmoothAdvection
bool to identify if advection term smoothing is requested
IncBoundaryConditionsSharedPtr m_IncNavierStokesBCs
bool DefinedForcing(const std::string &sForce)
void v_InitObject(bool DeclareField=true) override
Initialisation object for EquationSystem.
ExtrapolateSharedPtr m_extrapolation
Array< OneD, int > m_velocity
int which identifies which components of m_fields contains the velocity (u,v,w);
EquationType m_equationType
equation type;
int m_nConvectiveFields
Number of fields to be convected;.
void EvaluateAdvectionTerms(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
tBasePtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
static std::string RegisterEnumValue(std::string pEnum, std::string pString, int pEnumValue)
Registers an enumeration value.
void DefineImplicitSolve(FuncPointerT func, ObjectPointerT obj)
void AccumulateRegion(std::string, int iolevel=0)
Accumulate elapsed time for a region.
Definition Timer.cpp:70
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
SolverUtils::AdvectionSharedPtr m_advObject
Advection term.
SOLVER_UTILS_EXPORT bool v_PostIntegrate(int step) override
int m_spacedim
Spatial dimension (>= expansion dim).
LibUtilities::CommSharedPtr m_comm
Communicator.
NekDouble m_timestep
Time step size.
NekDouble m_time
Current time of simulation.
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
std::vector< std::string > m_strFrameData
variable name in m_movingFrameData
SOLVER_UTILS_EXPORT int GetNcoeffs()
bool m_specHP_dealiasing
Flag to determine if dealisising is usde for the Spectral/hp element discretisation.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
bool m_homogen_dealiasing
Flag to determine if dealiasing is used for homogeneous simulations.
SOLVER_UTILS_EXPORT int GetTotPoints()
LibUtilities::FieldMetaDataMap m_fieldMetaDataMap
Map to identify relevant solver info to dump in output fields.
Array< OneD, NekDouble > m_movingFrameData
Moving reference frame status in the body frame X, Y, Z, Theta_x, Theta_y, Theta_z,...
SOLVER_UTILS_EXPORT SessionFunctionSharedPtr GetFunction(std::string name, const MultiRegions::ExpListSharedPtr &field=MultiRegions::NullExpListSharedPtr, bool cache=false)
Get a SessionFunction by name.
Defines a forcing term to be explicitly applied.
Definition Forcing.h:72
Base class for unsteady solvers.
LibUtilities::TimeIntegrationSchemeOperators m_ode
The time integration scheme operators to use.
LibUtilities::TimeIntegrationSchemeSharedPtr m_intScheme
Wrapper to the time integration scheme.
bool m_explicitDiffusion
Indicates if explicit or implicit treatment of diffusion is used.
NekDouble m_greenFlux
Flux of the Stokes function solution.
MultiRegions::ExpListSharedPtr m_flowrateBnd
Flowrate reference surface.
Array< OneD, NekDouble > m_svvVarDiffCoeff
Array of coefficient if power kernel is used in SVV.
void v_TransCoeffToPhys(void) override
Virtual function for transformation to physical space.
NekDouble MeasureFlowrate(const Array< OneD, Array< OneD, NekDouble > > &inarray)
Measure the volumetric flow rate through the volumetric flow rate reference surface.
NekDouble m_sVVDiffCoeffHomo1D
Diffusion coefficient of SVV modes in homogeneous 1D Direction.
void v_TransPhysToCoeff(void) override
Virtual function for transformation to coefficient space.
MultiRegions::ExpListSharedPtr m_epotential
Pointer to field holding electric potential field.
bool m_IsSVVPowerKernel
Identifier for Power Kernel otherwise DG kernel.
static SolverUtils::EquationSystemSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Creates an instance of this class.
NekDouble m_sVVCutoffRatio
cutt off ratio from which to start decayhing modes
NekDouble m_sVVDiffCoeff
Diffusion coefficient of SVV modes.
void v_GenerateSummary(SolverUtils::SummaryList &s) override
Print a summary of time stepping parameters.
void EvaluateAdvection_SetPressureBCs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
Array< OneD, Array< OneD, NekDouble > > m_flowrateStokes
Stokes solution used to impose flowrate.
void SolveUnsteadyStokesSystem(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time, const NekDouble a_iixDt)
int m_flowrateStepsPrecision
Decimal precision of flow rate (alpha)
bool m_useGJPStabilisation
bool to identify if GJP semi-implicit is active.
virtual void v_SolvePressure(const Array< OneD, NekDouble > &Forcing)
void AddMovingFrameDataToParams(const std::vector< std::string > &strFrameData, const Array< OneD, NekDouble > &movingFrameData, std::map< std::string, NekDouble > &params)
VelocityCorrectionScheme(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
void AppendSVVFactors(StdRegions::ConstFactorMap &factors, StdRegions::VarFactorsMap &varFactorsMap)
void SolveEfield(const Array< OneD, Array< OneD, NekDouble > > &movEfield, Array< OneD, Array< OneD, NekDouble > > &totEfield)
void SetUpViscousForcing(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &Forcing, const NekDouble aii_Dt)
virtual void v_SolveUnsteadyStokesSystem(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time, const NekDouble a_iixDt)
void SetupFlowrate(NekDouble aii_dt)
Set up the Stokes solution used to impose constant flowrate through a boundary.
void SetUpPressureForcing(const Array< OneD, const Array< OneD, NekDouble > > &fields, Array< OneD, Array< OneD, NekDouble > > &Forcing, const NekDouble aii_Dt)
void SolveViscous(const Array< OneD, const Array< OneD, NekDouble > > &Forcing, const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble aii_Dt)
virtual void v_SetUpPressureForcing(const Array< OneD, const Array< OneD, NekDouble > > &fields, Array< OneD, Array< OneD, NekDouble > > &Forcing, const NekDouble aii_Dt)
bool m_useSpecVanVisc
bool to identify if spectral vanishing viscosity is active.
struct Nektar::VelocityCorrectionScheme::@2 m_MHD
Quasi-static MHD configuration.
NekDouble implicitLorentzDamping
Coefficient sigma |B|^2 treated in the velocity Helmholtz solve.
Array< OneD, NekDouble > m_diffCoeff
Diffusion coefficients (will be kinvis for velocities)
int m_flowrateSteps
Interval at which to record flowrate data.
void SVVVarDiffCoeff(const NekDouble velmag, Array< OneD, NekDouble > &diffcoeff, const Array< OneD, Array< OneD, NekDouble > > &vel=NullNekDoubleArrayOfArray)
virtual void v_SolveViscous(const Array< OneD, const Array< OneD, NekDouble > > &Forcing, const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble aii_Dt)
NekDouble m_flowrateArea
Area of the boundary through which we are measuring the flowrate.
std::ofstream m_flowrateStream
Output stream to record flowrate.
virtual void v_SetUpViscousForcing(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &Forcing, const NekDouble aii_Dt)
virtual void v_EvaluateAdvection_SetPressureBCs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
void SetEPInsulatorBCs(const Array< OneD, Array< OneD, NekDouble > > &movEfield)
void v_InitObject(bool DeclareField=true) override
Initialisation object for the unsteady diffusion problem.
NekDouble m_flowrateAiidt
Value of aii_dt used to compute Stokes flowrate solution.
void SolvePressure(const Array< OneD, NekDouble > &Forcing)
void v_DoInitialise(bool dumpInitialConditions=true) override
Sets up initial conditions.
int m_planeID
Plane ID for cases with homogeneous expansion.
bool m_useHomo1DSpecVanVisc
bool to identify if spectral vanishing viscosity is active.
bool m_useGJPNormalVel
bool to identify if GJP normal Velocity should be applied in explicit approach
int m_flowrateBndID
Boundary ID of the flowrate reference surface.
virtual std::string v_GetSubSteppingExtrapolateStr(const std::string &instr)
void ComputeGJPNormalVelocity(const Array< OneD, const Array< OneD, NekDouble > > &inarray, StdRegions::VarCoeffMap &varcoeffs)
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Equation > EquationSharedPtr
Definition Equation.h:135
std::shared_ptr< Expansion > ExpansionSharedPtr
Definition Expansion.h:66
MultiRegions::Direction const DirCartesianMap[]
Definition ExpList.h:95
std::shared_ptr< GJPStabilisation > GJPStabilisationSharedPtr
std::shared_ptr< ContField > ContFieldSharedPtr
Definition ContField.h:330
std::vector< std::pair< std::string, std::string > > SummaryList
Definition Misc.h:46
EquationSystemFactory & GetEquationSystemFactory()
void AddSummaryItem(SummaryList &l, const std::string &name, const std::string &value)
Adds a summary item to the summary info list.
Definition Misc.cpp:46
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition MeshGraph.h:287
std::map< StdRegions::ConstFactorType, Array< OneD, NekDouble > > VarFactorsMap
static VarFactorsMap NullVarFactorsMap
std::map< ConstFactorType, NekDouble > ConstFactorMap
static VarCoeffMap NullVarCoeffMap
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap
bool IEquals(std::string_view a, std::string_view b)
@ eUnsteadyNavierStokes
@ eVelocityCorrectionScheme
static Array< OneD, Array< OneD, NekDouble > > NullNekDoubleArrayOfArray
ExtrapolateFactory & GetExtrapolateFactory()
static Array< OneD, NekDouble > NullNekDouble1DArray
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
Definition Vmath.hpp:342
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
Definition Vmath.hpp:74
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Svtvp (scalar times vector plus vector): z = alpha*x + y.
Definition Vmath.hpp:398
void Vabs(int n, const T *x, const int incx, T *y, const int incy)
vabs: y = |x|
Definition Vmath.hpp:354
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition Vmath.hpp:368
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
Definition Vmath.hpp:182
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
Definition Vmath.hpp:102
void Zero(int n, T *x, const int incx)
Zero vector.
Definition Vmath.hpp:275
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition Vmath.hpp:56
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition Vmath.hpp:828
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
Definition Vmath.hpp:222