MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
lscartesiansolver.h
Go to the documentation of this file.
1// Copyright (C) 2024 The m-AIA AUTHORS
2//
3// This file is part of m-AIA (https://git.rwth-aachen.de/aia/m-AIA/m-AIA)
4//
5// SPDX-License-Identifier: LGPL-3.0-only
6
7#ifndef LSSOLVER_H_
8#define LSSOLVER_H_
9
10#include <algorithm>
11#include "GRID/cartesiangrid.h"
12#include "cartesiansolver.h"
13#include "enums.h"
16
17#define ENSURE_VALID_GCELLID(gCellId) \
18 do { \
19 ASSERT(gCellId >= 0 && /*gCellId < m_cells.size() &&*/ gCellId < m_maxNoCells, \
20 "gCellId " << gCellId << " out-of-bounds [0, " << m_maxNoCells << ") m_cells.size: " << m_cells.size()); \
21 } while(false)
22
23#define ENSURE_VALID_DIM(dim) \
24 do { \
25 ASSERT(dim >= 0 && dim < nDim, "dim " << dim << " out-of-bounds [0, " << nDim << ")"); \
26 } while(false)
27
28#define ENSURE_VALID_DIR(dir) \
29 do { \
30 ASSERT(dir >= 0 && dir < 2 * nDim, "dir " << dir << " out-of-bounds [0, " << 2 * nDim << ")"); \
31 } while(false)
32
33#define ENSURE_VALID_SET(set) \
34 do { \
35 ASSERT(set >= 0 && set < m_maxNoSets, "set " << set << " out-of-bounds [0," << m_maxNoSets << ")"); \
36 } while(false)
37template <MInt nDim_>
39 private:
40 // vectors dot product
41 MFloat dot(const MFloat p[3], const MFloat q[3]) { return p[0] * q[0] + p[1] * q[1] + p[2] * q[2]; }
42
43 void cross(const MFloat p[3], const MFloat q[3], MFloat r[3]) {
44 r[0] = (p[1] * q[2]) - (q[1] * p[2]);
45 r[1] = (p[2] * q[0]) - (q[2] * p[0]);
46 r[2] = (p[0] * q[1]) - (q[0] * p[1]);
47 }
48
49 // compute the transformation matrix for the current geometrical element
51 // Step 1: get vertices in global coordinates
52 MFloat v[3][3] = {{F0, F0, F0}, {F0, F0, F0}, {F0, F0, F0}};
53 MInt noVertices = nDim_;
54
55 for(MInt i = 0; i < noVertices; i++) {
56 for(MInt j = 0; j < nDim_; j++) {
57 v[i][j] = el->m_vertices[i][j];
58 }
59 }
60
61 // Step 2: define the transformation matrix for the current geometrical element
62 IF_CONSTEXPR(nDim_ == 2) {
63 MFloat theta_rad = 0;
64 MFloat dx = v[1][0] - v[0][0];
65 if(approx(dx, 0.0, MFloatEps))
66 theta_rad = 3.141592654 / 2.0;
67 else
68 theta_rad = atan((v[1][1] - v[0][1]) / dx);
69
70 tr[0][0] = cos(theta_rad);
71 tr[0][1] = sin(theta_rad);
72 tr[2][0] = 0;
73 tr[1][0] = -sin(theta_rad);
74 tr[1][1] = cos(theta_rad);
75 tr[2][1] = 0;
76 tr[0][2] = 0;
77 tr[1][2] = 0;
78 tr[2][2] = 0;
79 }
80 else {
81 // Euclidean frame
82 MFloat xm[3] = {1, 0, 0};
83 MFloat ym[3] = {0, 1, 0};
84 MFloat zm[3] = {0, 0, 1};
85 // n subscript means rotated coordinates
86 // set zn = normal vector
87 MFloat zn[3];
88 for(MInt i = 0; i < 3; i++) {
89 zn[i] = el->m_normal[i];
90 }
91
92 // set xn to the direction of first edge
93 MFloat xn[3];
94 for(MInt i = 0; i < 3; i++) {
95 xn[i] = v[1][i] - v[0][i];
96 }
97
98 // Normalize xn
99 MFloat mag = sqrt(pow(xn[0], 2) + pow(xn[1], 2) + pow(xn[2], 2));
100 for(MFloat& i : xn) {
101 i = i / mag;
102 }
103
104 // yn is the outer product of zn x xn
105 MFloat yn[3];
106 cross(zn, xn, yn);
107 // defining transformation matrix
108 tr[0][0] = dot(xn, xm);
109 tr[0][1] = dot(xn, ym);
110 tr[0][2] = dot(xn, zm);
111 tr[1][0] = dot(yn, xm);
112 tr[1][1] = dot(yn, ym);
113 tr[1][2] = dot(yn, zm);
114 tr[2][0] = dot(zn, xm);
115 tr[2][1] = dot(zn, ym);
116 tr[2][2] = dot(zn, zm);
117 }
118 }
119
120 public:
121 // rotate the coordinates q into the geometrical element coordinates
122 inline void rotation(const MFloat q[3], MFloat r[3], MFloat tr[3][3]) {
123 for(MInt i = 0; i < 3; i++) {
124 r[i] = 0;
125 for(MInt j = 0; j < 3; j++) {
126 r[i] += tr[i][j] * q[j];
127 }
128 }
129 }
130
131 // check if point q is inside the geometrical triangulated element after the projection
133 // Set transformation matrix
134 transformationmatrix(el, tr);
135
136 // Copy vertices to vv[][]
137 MFloat vv[3][3] = {{F0, F0, F0}, {F0, F0, F0}, {F0, F0, F0}};
138
139 MFloat noVertices;
140 noVertices = nDim_;
141
142 for(MInt i = 0; i < noVertices; i++)
143 for(MInt j = 0; j < nDim_; j++) {
144 vv[i][j] = el->m_vertices[i][j];
145 }
146
147 // Rotation of vertices
148 MFloat ro[3] = {0.0, 0.0, 0.0}, uv[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, quv[2] = {0.0, 0.0};
149 for(MInt i = 0; i < noVertices; i++) {
150 rotation(vv[i], ro, tr);
151 for(MInt j = 0; j < nDim_ - 1; j++) {
152 uv[(nDim_ - 1) * i + j] = ro[j];
153 }
154 }
155
156 // Rotation of q
157 rotation(q, ro, tr);
158 for(MInt j = 0; j < nDim_ - 1; j++)
159 quv[j] = ro[j];
160
161 // Move origin to q
162 for(MInt j = 0; j < nDim_ - 1; j++) {
163 for(MInt i = 0; i < noVertices; i++)
164 uv[(nDim_ - 1) * i + j] -= quv[j];
165 }
166
167 // Define intersection
168 IF_CONSTEXPR(nDim_ == 2) {
169 MInt SH = 0, NSH = 0;
170
171 if(uv[0] > 0)
172 SH = 1;
173 else if(approx(uv[0], 0.0, MFloatEps))
174 SH = 0;
175 else
176 SH = -1;
177
178 if(uv[1] > 0)
179 NSH = 1;
180 else if(approx(uv[1], 0.0, MFloatEps))
181 NSH = 0;
182 else
183 NSH = -1;
184
185 if((SH != NSH) || (SH == 0) || (NSH == 0)) return 1;
186 }
187 else {
188 MInt NC = 0;
189
190 for(MInt i = 0; i < noVertices; i++) {
191 MInt ni = (i + 1) % 3; // next i
192 // cast ray in +u direction
193 MInt SH = 0, NSH = 0;
194
195 if(uv[i * 2 + 1] > 0)
196 SH = 1;
197 else if(approx(uv[i * 2 + 1], 0.0, MFloatEps))
198 SH = 0;
199 else
200 SH = -1;
201
202 if(uv[ni * 2 + 1] > 0)
203 NSH = 1;
204 else if(approx(uv[ni * 2 + 1], 0.0, MFloatEps))
205 NSH = 0;
206 else
207 NSH = -1;
208
209 // predict intersection
210 if(SH == 0 && NSH == 0) {
211 NC = 1;
212 break;
213 } // horizontal line through origin
214 else if((SH == 0 && approx(uv[i * 2 + 0], 0.0, MFloatEps))
215 || (NSH == 0 && approx(uv[ni * 2 + 0], 0.0, MFloatEps))) {
216 NC = 1;
217 break;
218 } else if(approx((uv[i * 2 + 0]
219 - uv[i * 2 + 1] * (uv[ni * 2 + 0] - uv[i * 2 + 0]) / (uv[ni * 2 + 1] - uv[i * 2 + 1])),
220 0.0, MFloatEps)) {
221 NC = 1;
222 break;
223 } // line through origin
224 else if(SH != NSH) {
225 if((uv[i * 2 + 0] > 0) && (uv[ni * 2 + 0] > 0))
226 NC++; // there is intersection in +u
227 else if((uv[i * 2 + 0] > 0) || (uv[ni * 2 + 0] > 0)) { // there can be an intersection in +u
228 // need to calculate
229 if((uv[i * 2 + 0] - uv[i * 2 + 1] * (uv[ni * 2 + 0] - uv[i * 2 + 0]) / (uv[ni * 2 + 1] - uv[i * 2 + 1]))
230 > 0)
231 NC++;
232 }
233 }
234 }
235 if((NC % 2) != 0) {
236 return 1;
237 }
238 }
239 return 0;
240 }
241};
242
243namespace maia {
244namespace ls {
245
246// Create struct for easy timer identification
247struct Timers_ {
248 // Enum to store timer "names"
249 enum {
254
256
261
262 // Special enum value used to initialize timer array
263 _count
264 };
265};
266
267} // namespace ls
268} // namespace maia
269
270template <MInt nDim_, class SysEqn>
271class LsFvCombustion;
272
273template <MInt nDim_, class SysEqn>
274class LsFvMb;
275
276template <MInt nDim_, class SysEqn>
277class CouplingLsFv;
278
279template <RansMethod _>
280struct RANSModelConstants;
281
282template <MInt nDim_>
283class FvSysEqnNS;
284
285template <MInt nDim_, class RANSModel>
286class FvSysEqnRANS;
287
288class Coupling;
289
290template <MInt nDim_>
291class LsCartesianSolver : public maia::CartesianSolver<nDim_, LsCartesianSolver<nDim_>> {
292 public:
293 // Type for cell properties
296 using PropertyReference = typename GCellCollector::BitsetType::reference;
297
298 protected:
300
301 private:
302
303 MPI_Request* mpi_request = nullptr;
304 MPI_Request* mpi_recive = nullptr;
305
307 // Timers
308 // Timer group which holds all solver-wide timers
310 // Stores all solver-wide timers
311 std::array<MInt, Timers::_count> m_timers{};
312
313 public:
314 static constexpr MInt nDim = nDim_;
315 friend class LsFvCombustion<nDim, FvSysEqnNS<nDim>>;
319 friend class LsFvMb<nDim, FvSysEqnNS<nDim>>;
323 friend class CouplingLsFv<nDim, FvSysEqnNS<nDim>>;
327
329
330 // returns the time of the lsSolver
331 // overrides the Solver-function
332 MFloat time() const override {
334 // NOTE: the time is copied and updated from the coupler in transferTimeStep
335 return m_time;
336 } else {
337 ASSERT(!m_combustion, "");
338 return globalTimeStep;
339 }
340 };
341
343 MFloat timeStep() const { return m_timeStep; }
344 MInt noVariables() const override { return 1; };
345 virtual void saveSolverSolution(const MBool, const MBool){};
346 virtual void cleanUp(){};
347
348 static constexpr const MInt m_noCorners = (nDim == 2) ? 4 : 8;
349
351 using Grid = typename CartesianSolver::Grid;
352 using GridProxy = typename CartesianSolver::GridProxy;
353
354 // used CartesianSolver
355 using CartesianSolver::grid;
357
359
361 Geom& geometry() const { return *m_geometry; }
362
363 using CartesianSolver::disableDlbTimers;
364 using CartesianSolver::domainId;
365 using CartesianSolver::domainOffset;
366 using CartesianSolver::enableDlbTimers;
367 using CartesianSolver::exchangeData;
368 using CartesianSolver::haloCellId;
369 using CartesianSolver::isActive;
370 using CartesianSolver::m_freeIndices;
371 using CartesianSolver::m_initFromRestartFile;
372 using CartesianSolver::m_maxNoSets;
373 using CartesianSolver::m_restart;
374 using CartesianSolver::m_restartFile;
375 using CartesianSolver::m_restartInterval;
376 using CartesianSolver::m_restartTimeStep;
377 using CartesianSolver::m_solutionInterval;
378 using CartesianSolver::m_solverId;
379 using CartesianSolver::m_useNonSpecifiedRestartFile;
380 using CartesianSolver::maxLevel;
381 using CartesianSolver::maxNoGridCells;
382 using CartesianSolver::maxRefinementLevel;
383 using CartesianSolver::maxUniformRefinementLevel;
384 using CartesianSolver::minLevel;
385 using CartesianSolver::mpiComm;
386 using CartesianSolver::neighborDomain;
387 using CartesianSolver::noDomains;
388 using CartesianSolver::noHaloCells;
389 using CartesianSolver::noNeighborDomains;
390 using CartesianSolver::noWindowCells;
391 using CartesianSolver::outputDir;
392 using CartesianSolver::readSolverSamplingVarNames;
393 using CartesianSolver::restartDir;
394 using CartesianSolver::returnIdleRecord;
395 using CartesianSolver::returnLoadRecord;
396 using CartesianSolver::solverId;
397 using CartesianSolver::solverMethod;
398 using CartesianSolver::startLoadTimer;
399 using CartesianSolver::stopLoadTimer;
400 using CartesianSolver::updateDomainInfo;
401 using CartesianSolver::windowCellId;
402
403 public:
404
405 // Ls-Solver-Constructor:
406 LsCartesianSolver<nDim_>(MInt, const MBool*, GridProxy& gridProxy_, Geom& geometry_, const MPI_Comm comm);
407
410
411 MInt noSolverTimers(const MBool allTimings) override {
412#ifdef MAIA_TIMER_FUNCTION
413 TERMM_IF_COND(!allTimings, "FIXME: reduced timings mode not yet supported by LS.");
414 static const MInt noAdditionTimers = 7;
415 return 2 + noAdditionTimers;
416#else
417 return 2;
418#endif
419 }
420
421 //----------------------------------------------------------------------------------------------------
422 MInt maxLevel() const { return grid().maxLevel(); }
423 // cellLengthAtGCell
424 MFloat c_cellLengthAtCell(const MInt gCellId) const { return grid().cellLengthAtLevel(a_level(gCellId)); }
425 MFloat cellVolumeAtCell(const MInt gCellId) const { return grid().cellVolumeAtLevel(a_level(gCellId)); }
426
427 MFloat c_cellLengthAtLevel(const MInt level) const { return grid().cellLengthAtLevel(level); }
428
429 // This also exists in the FV-Solver...
430 static constexpr MInt s_maxNoEmbeddedBodies = 20;
431 static constexpr const MInt m_noDirs = 2 * nDim;
432
433 MInt noInternalCells() const override { return grid().noInternalCells(); }
434
435 void extendVelocity(const MInt set);
436 //------------------------------Collecor-Accessors-----------------------------------------------
437
438 MInt a_noCells() const { return m_cells.size(); }
439 // this appends a new cell at the end
441 m_cells.append();
442 }
443
445 void a_resetPropertiesSolver(const MInt cellId) { m_cells.resetProperties(cellId); }
446
447 maia::ls::cell::BitsetType::reference a_isBndryCellG(const MInt cellId) {
448 ENSURE_VALID_GCELLID(cellId);
449 return m_cells.isBndryG(cellId);
450 }
451 MBool a_isBndryCellG(const MInt cellId) const {
452 ENSURE_VALID_GCELLID(cellId);
453 return m_cells.isBndryG(cellId);
454 }
455
456 MInt a_maxGCellLevel(const MInt set = -1) const {
457 if(!m_gCellLevelJump) {
458 return m_maxGCellLevel[0];
459 } else {
460 ENSURE_VALID_SET(set);
461 return m_maxGCellLevel[set];
462 }
463 }
465 MFloat& a_extensionVelocityG(const MInt cellId, const MInt dim, const MInt set) {
466 ENSURE_VALID_DIM(dim);
467 ENSURE_VALID_SET(set);
468 ENSURE_VALID_GCELLID(cellId);
469 return m_cells.fExt(cellId, dim, set);
470 }
472 MFloat a_extensionVelocityG(const MInt cellId, const MInt dim, const MInt set) const {
473 ENSURE_VALID_DIM(dim);
474 ENSURE_VALID_SET(set);
475 ENSURE_VALID_GCELLID(cellId);
476 return m_cells.fExt(cellId, dim, set);
477 }
478
479 maia::ls::cell::BitsetTypeSet::reference a_inBandG(const MInt cellId, const MInt set) {
480 ENSURE_VALID_GCELLID(cellId);
481 ENSURE_VALID_SET(set);
482 return m_cells.inBand(cellId, set);
483 }
484 MBool a_inBandG(const MInt cellId, const MInt set) const {
485 ENSURE_VALID_GCELLID(cellId);
486 ENSURE_VALID_SET(set);
487 return m_cells.inBand(cellId, set);
488 }
489
490 maia::ls::cell::BitsetTypeSet::reference a_isGBoundaryCellG(const MInt cellId, const MInt set) {
491 ENSURE_VALID_GCELLID(cellId);
492 ENSURE_VALID_SET(set);
493 return m_cells.isGBndryCell(cellId, set);
494 }
495 MBool a_isGBoundaryCellG(const MInt cellId, const MInt set) const {
496 ENSURE_VALID_GCELLID(cellId);
497 ENSURE_VALID_SET(set);
498 return m_cells.isGBndryCell(cellId, set);
499 }
500
501 MBool a_isGZeroCell(const MInt cellId, const MInt set) const {
502 ENSURE_VALID_GCELLID(cellId);
503 ENSURE_VALID_SET(set);
504 return m_cells.isGZero(cellId, set);
505 }
506
507 maia::ls::cell::BitsetTypeSet::reference a_isGZeroCell(const MInt cellId, const MInt set) {
508 ENSURE_VALID_GCELLID(cellId);
509 ENSURE_VALID_SET(set);
510 return m_cells.isGZero(cellId, set);
511 }
512
513 MBool a_wasGZeroCell(const MInt cellId, const MInt set) const {
514 ENSURE_VALID_GCELLID(cellId);
515 ENSURE_VALID_SET(set);
516 return m_cells.wasGZero(cellId, set);
517 }
518
519 maia::ls::cell::BitsetTypeSet::reference a_wasGZeroCell(const MInt cellId, const MInt set) {
520 ENSURE_VALID_GCELLID(cellId);
521 ENSURE_VALID_SET(set);
522 return m_cells.wasGZero(cellId, set);
523 }
524
526 maia::ls::cell::BitsetTypeSet::reference a_hasPositiveSign(const MInt cellId, const MInt set) {
527 ENSURE_VALID_GCELLID(cellId);
528 ENSURE_VALID_SET(set);
529 return m_cells.hasPositiveSign(cellId, set);
530 }
531
533 MBool a_hasPositiveSign(const MInt cellId, const MInt set) const {
534 ENSURE_VALID_GCELLID(cellId);
535 ENSURE_VALID_SET(set);
536 return m_cells.hasPositiveSign(cellId, set);
537 }
539 MInt a_levelSetSign(const MInt cellId, const MInt set) { return a_hasPositiveSign(cellId, set) ? 1 : -1; }
540
542 MFloat& a_normalVectorG(const MInt cellId, const MInt dim, const MInt set) {
543 ENSURE_VALID_DIM(dim);
544 ENSURE_VALID_SET(set);
545 ENSURE_VALID_GCELLID(cellId);
546 return m_cells.normalVector(cellId, dim, set);
547 }
549 MFloat a_normalVectorG(const MInt cellId, const MInt dim, const MInt set) const {
550 ENSURE_VALID_DIM(dim);
551 ENSURE_VALID_SET(set);
552 ENSURE_VALID_GCELLID(cellId);
553 return m_cells.normalVector(cellId, dim, set);
554 }
555
556 maia::ls::cell::BitsetType::reference a_nearGapG(const MInt cellId) {
557 ENSURE_VALID_GCELLID(cellId);
558 return m_cells.nearGap(cellId);
559 }
560 MBool a_nearGapG(const MInt cellId) const {
561 ENSURE_VALID_GCELLID(cellId);
562 return m_cells.nearGap(cellId);
563 }
564
565 maia::ls::cell::BitsetType::reference a_regridTriggerG(const MInt cellId) {
566 ENSURE_VALID_GCELLID(cellId);
567 return m_cells.regridTrigger(cellId);
568 }
569 MBool a_regridTriggerG(const MInt cellId) const {
570 ENSURE_VALID_GCELLID(cellId);
571 return m_cells.regridTrigger(cellId);
572 }
574 MInt& a_bodyIdG(const MInt cellId, const MInt set) {
575 ENSURE_VALID_SET(set);
576 ENSURE_VALID_GCELLID(cellId);
577 return m_cells.bodyId(cellId, set);
578 }
580 MInt a_bodyIdG(const MInt cellId, const MInt set) const {
581 ENSURE_VALID_SET(set);
582 ENSURE_VALID_GCELLID(cellId);
583 return m_cells.bodyId(cellId, set);
584 }
585
587 MInt& a_secondBodyId(const MInt cellId) {
588 ENSURE_VALID_GCELLID(cellId);
589 return m_cells.secondBodyId(cellId);
590 }
592 MInt a_secondBodyId(const MInt cellId) const {
593 ENSURE_VALID_GCELLID(cellId);
594 return m_cells.secondBodyId(cellId);
595 }
596
598 MFloat& a_curvatureG(const MInt cellId, const MInt set) {
599 ENSURE_VALID_SET(set);
600 ENSURE_VALID_GCELLID(cellId);
601 return m_cells.curvature(cellId, set);
602 }
604 MFloat a_curvatureG(const MInt cellId, const MInt set) const {
605 ENSURE_VALID_SET(set);
606 ENSURE_VALID_GCELLID(cellId);
607 return m_cells.curvature(cellId, set);
608 }
609
611 MFloat& a_levelSetFunctionG(const MInt cellId, const MInt set) {
612 ENSURE_VALID_SET(set);
613 ENSURE_VALID_GCELLID(cellId);
614 return m_cells.gFunction(cellId, set);
615 }
617 MFloat a_levelSetFunctionG(const MInt cellId, const MInt set) const {
618 ENSURE_VALID_SET(set);
619 ENSURE_VALID_GCELLID(cellId);
620 return m_cells.gFunction(cellId, set);
621 }
622
624 MFloat& a_oldLevelSetFunctionG(const MInt cellId, const MInt set) {
625 ENSURE_VALID_SET(set);
626 ENSURE_VALID_GCELLID(cellId);
627 // return m_oldLevelSetFunction[ IDX_LSSET( cellId, set) ];
628 return m_cells.oldGFunction(cellId, set);
629 }
631 MFloat a_oldLevelSetFunctionG(const MInt cellId, const MInt set) const {
632 ENSURE_VALID_SET(set);
633 ENSURE_VALID_GCELLID(cellId);
634 // return m_oldLevelSetFunction[ IDX_LSSET( cellId, set) ];
635 return m_cells.oldGFunction(cellId, set);
636 }
637
639 MFloat& a_levelSetFunctionSlope(const MInt cellId, const MInt dim, const MInt set) {
640 ENSURE_VALID_DIM(dim);
641 ENSURE_VALID_SET(set);
642 ENSURE_VALID_GCELLID(cellId);
643 return m_cells.levelSetFunctionSlope(cellId, dim, set);
644 }
646 MFloat a_levelSetFunctionSlope(const MInt cellId, const MInt dim, const MInt set) const {
647 ENSURE_VALID_DIM(dim);
648 ENSURE_VALID_SET(set);
649 ENSURE_VALID_GCELLID(cellId);
650 return m_cells.levelSetFunctionSlope(cellId, dim, set);
651 }
652
654 MFloat& a_levelSetRHS(const MInt cellId, const MInt set) {
655 ENSURE_VALID_SET(set);
656 ENSURE_VALID_GCELLID(cellId);
657 return m_cells.levelSetRHS(cellId, set);
658 }
660 MFloat a_levelSetRHS(const MInt cellId, const MInt set) const {
661 ENSURE_VALID_SET(set);
662 ENSURE_VALID_GCELLID(cellId);
663 return m_cells.levelSetRHS(cellId, set);
664 }
665
667 MFloat& a_correctedBurningVelocity(const MInt cellId, const MInt set) {
668 ENSURE_VALID_SET(set);
669 ENSURE_VALID_GCELLID(cellId);
670 return m_cells.correctedBurningVelocity(cellId, set);
671 }
673 MFloat correctedBurningVelocity(const MInt cellId, const MInt set) const {
674 ENSURE_VALID_SET(set);
675 ENSURE_VALID_GCELLID(cellId);
676 return m_cells.correctedBurningVelocity(cellId, set);
677 }
678
680 MLong& a_containingCell(const MInt cellId, const MInt body) { return m_cells.containingCell(cellId, body); }
682 MLong a_containingCell(const MInt cellId, const MInt body) const { return m_cells.containingCell(cellId, body); }
683
685 MInt& a_containingDomain(const MInt cellId, const MInt body) { return m_cells.containingDomain(cellId, body); }
687 MInt a_containingDomain(const MInt cellId, const MInt body) const { return m_cells.containingDomain(cellId, body); }
688
690 MFloat& a_gapWidth(const MInt id) { return m_cells.gapWidth(id); }
692 MFloat a_gapWidth(const MInt id) const { return m_cells.gapWidth(id); }
693
697 MInt a_potentialGapCell(const MInt id) const { return m_cells.potentialGapCell(id); }
698
703
704 MFloat& a_meanCoord(const MInt dir) { return m_meanCoord[dir]; }
705
706 MFloat a_meanCoord(const MInt dir) const { return m_meanCoord[dir]; }
707
708 //------------------------------Grid-Accessors-----------------------------------------------
709
710 // helper accessor, needed in the cartesiansolver
711 // lsSolver does not have solver additional cells as the fvSolver(ghost- or splitCells)
712 MInt c_noCells() const { return a_noCells(); }
713
714 // a_parentGId
715 MInt c_parentId(const MInt gCellId) const {
716 ENSURE_VALID_GCELLID(gCellId);
717 return grid().tree().parent(gCellId);
718 }
719
720 // a_noChildrenG
721 MInt c_noChildren(const MInt gCellId) const {
722 ENSURE_VALID_GCELLID(gCellId);
723 return grid().tree().noChildren(gCellId);
724 }
725
726 // a_childGId
727 MInt c_childId(const MInt gCellId, const MInt pos) const {
728 ENSURE_VALID_GCELLID(gCellId);
729 return grid().tree().child(gCellId, pos);
730 }
731
732 // a_coordinateG
734 MFloat c_coordinate(const MInt gCellId, const MInt dim) const {
735 ENSURE_VALID_DIM(dim);
736 ENSURE_VALID_GCELLID(gCellId);
737 return grid().tree().coordinate(gCellId, dim);
738 }
739
740 // a_neighborGId
741 MInt c_neighborId(const MInt gCellId, const MInt dir) const {
742 ENSURE_VALID_DIR(dir);
743 ENSURE_VALID_GCELLID(gCellId);
744
745 if(grid().tree().neighbor(gCellId, dir) > -1) {
746 return grid().tree().neighbor(gCellId, dir);
747 } else if(m_levelSetBC == "SYMMETRIC") {
748 return gCellId;
749 } else if(m_levelSetBC == "NONE") {
750 return -1;
751 } else {
752 mTerm(1, AT_, "Return of the neighborId should have happend by now!");
753 return gCellId;
754 }
755 }
756
758 MInt a_bandNghbrIdsG(const MInt cellId, const MInt dir, const MInt set) const {
759 ENSURE_VALID_DIR(dir);
760 ENSURE_VALID_SET(set);
761 ENSURE_VALID_GCELLID(cellId);
762
763 if(a_hasNeighbor(cellId, dir) && a_inBandG(c_neighborId(cellId, dir), set)) {
764 return c_neighborId(cellId, dir);
765 } else {
766 return cellId;
767 }
768 }
769
770 // a_hasNeighborG
772 MInt a_hasNeighbor(const MInt gCellId, const MInt dir) const {
773 ENSURE_VALID_DIR(dir);
774 ENSURE_VALID_GCELLID(gCellId);
775 if(gCellId > a_noCells() - 1) return -1;
776 return grid().tree().hasNeighbor(gCellId, dir);
777 }
778
780 MBool a_isWindow(const MInt gCellId) const {
781 ENSURE_VALID_GCELLID(gCellId);
782 return m_cells.hasProperty(gCellId, LsCell::IsWindow);
783 }
785 maia::ls::cell::BitsetType::reference a_isWindow(const MInt gCellId) {
786 ENSURE_VALID_GCELLID(gCellId);
787 return m_cells.hasProperty(gCellId, LsCell::IsWindow);
788 }
789
790 MLong c_globalId(const MInt gCellId) const {
791 ENSURE_VALID_GCELLID(gCellId);
792 return grid().tree().globalId(gCellId);
793 }
794
795 MInt a_domainId(const MLong gGlobalId) { return grid().findNeighborDomainId(gGlobalId); }
796
797 MInt a_localId(const MLong gGlobalId) { return grid().globalToLocalId(gGlobalId); }
798
799 MBool c_isLeafCell(const MInt gCellId) const {
800 ENSURE_VALID_GCELLID(gCellId);
801 return grid().tree().isLeafCell(gCellId);
802 }
803
805 MBool a_isHalo(const MInt gCellId) const {
806 ENSURE_VALID_GCELLID(gCellId);
807 return m_cells.hasProperty(gCellId, LsCell::IsHalo);
808 }
810 maia::ls::cell::BitsetType::reference a_isHalo(const MInt gCellId) {
811 ENSURE_VALID_GCELLID(gCellId);
812 return m_cells.hasProperty(gCellId, LsCell::IsHalo);
813 }
814
815 // a_levelG
817 MInt a_level(const MInt gCellId) const {
818 ENSURE_VALID_GCELLID(gCellId);
819 return grid().tree().level(gCellId);
820 }
821
822 //------------------------------Other-Accessors-----------------------------------------------
823
825 MFloat& a_flameSpeedG(const MInt cellId, const MInt set) {
826 ENSURE_VALID_SET(set);
827 ENSURE_VALID_GCELLID(cellId);
828 return m_flameSpeed;
829 }
831 MFloat a_flameSpeedG(const MInt cellId, const MInt set) const {
832 ENSURE_VALID_GCELLID(cellId);
833 ENSURE_VALID_SET(set);
834 return m_flameSpeed;
835 }
836
839 // If lsSolver is inactive on one of the ranks we need this allreduce!
840 if(grid().hasInactiveRanks()) {
841 this->startLoadTimer(AT_);
842 MPI_Allreduce(MPI_IN_PLACE, &m_forceAdaptation, 1, MPI_C_BOOL, MPI_LOR, grid().raw().mpiComm(), AT_,
843 "MPI_IN_PLACE", "m_forceAdaptation");
844 this->stopLoadTimer(AT_);
845 }
846 return m_forceAdaptation;
847 }
848
849 constexpr MInt a_bandCellId(MInt id, MInt set) const { return m_bandCells[set][id]; }
850 constexpr MInt a_internalBandCellId(MInt id, MInt set) const { return m_internalBandCells[set][id]; }
851 constexpr MInt a_bandBndryCellId(MInt id, MInt set) const { return m_bandBndryCells[set][id]; }
852 constexpr MInt a_G0CellId(MInt id, MInt set) const { return m_G0Cells[set][id]; }
853 constexpr MInt a_gBndryCellId(MInt id, MInt set) const { return m_gBndryCells[set][id]; }
854
855 constexpr MInt a_noBandCells(MInt set) const { return m_bandCells[set].size(); }
856 constexpr MInt a_noInternalBandCells(MInt set) const { return m_internalBandCells[set].size(); }
857 constexpr MInt a_noBandBndryCells(MInt set) const { return m_bandBndryCells[set].size(); }
858 constexpr MInt a_noG0Cells(MInt set) const { return m_G0Cells[set].size(); }
859 constexpr MInt a_noGBndryCells(MInt set) const { return m_gBndryCells[set].size(); }
860
861 MInt& a_bandLayer(MInt id, MInt set) { return m_bandLayer[IDX_LSSET(id, set)]; }
862 MInt a_bandLayer(MInt id, MInt set) const { return m_bandLayer[IDX_LSSET(id, set)]; }
863
864 MInt& a_internalBandLayer(MInt id, MInt set) { return m_internalBandLayer[IDX_LSSET(id, set)]; }
865 MInt a_internalBandLayer(MInt id, MInt set) const { return m_internalBandLayer[IDX_LSSET(id, set)]; }
866
867 MInt getCurrentTimeStep() const override { return globalTimeStep; }
868
870
871 //------------------------- Data -------------------------------------------
872
873 // semi-Lagrange levelSet-related
878
879 // ls-Collectore Type mode:
881
882 // rotating levelSet-related
891 std::vector<MInt> m_newCells;
892 std::map<MInt, MInt> m_swapIds;
893 std::vector<MInt> m_bodiesToCompute;
895 MInt* m_cellDomIds = nullptr;
898 MFloat* m_omega = nullptr;
900
903
907
909
910 // adaptation-related
911 std::map<MInt, MInt> m_refinedCells;
919
920 std::map<MInt, MInt> m_oldG0Cells;
922
923 // general levelSet properties
927
932 MBool* m_computeSet = nullptr;
935 MBool* m_changedSet = nullptr;
959
996
997 // level-set variables
998 MInt* m_cellList = nullptr;
999 std::vector<MInt>* m_bandCells = nullptr;
1000 std::vector<MInt>* m_internalBandCells = nullptr;
1001 MInt* m_bandLayer = nullptr;
1003 std::vector<MInt>* m_bandBndryCells = nullptr;
1004 std::vector<MInt>* m_G0Cells = nullptr;
1005 std::vector<MInt>* m_gBndryCells = nullptr;
1008 MFloat* m_gRKalpha = nullptr;
1010
1013 MFloat* m_signG = nullptr;
1014 MFloat** m_phiRatio = nullptr;
1016 MFloat* m_d = nullptr;
1017
1018 // exchange buffers:
1023
1025
1026 // More level-set related properties. Most of them are used in FV Solver as well and exist in both solvers right now
1027 //
1032
1033 // levelSet-Solver Types:
1041
1043
1044 // combustion-related properties
1061 // Somewhere in the code it says this is 'ghost fluid method' related..
1062 // maybe this can be removed along with functions where this is used.
1082
1083
1088
1090
1091 // balance
1093
1094 // time related
1099
1100 // ... identifyBodies
1104
1105 // gap-Handling:
1112 std::vector<MFloat> m_minGapWidth;
1113 std::vector<MFloat> m_minGapWidthDt1;
1119 MFloat* m_gapSign = nullptr;
1120
1129
1131
1133
1134 private:
1136
1137 // ... computeBodyProperties
1155
1156 std::set<std::pair<MFloat, MFloat>>* m_forcedMotionInput = nullptr;
1157
1158 // ... setUpPotentialGapCells
1170
1171
1172 // crankAngle
1175
1182
1184
1185 //------------------ functions ----------------------------------------------
1186 public:
1187 void initSolver() override;
1190 void createGgridCG(MBool = false);
1192 void buildLevelSetTube(MInt mode = -1);
1197 virtual void writeRestartLevelSetFileCG(MBool, const MString&, const MString&);
1198
1199 // grid controller related mesh adaptation functions
1200 void prepareAdaptation() override;
1201 void setSensors(std::vector<std::vector<MFloat>>& sensors,
1202 std::vector<MFloat>& sensorWeight,
1203 std::vector<std::bitset<64>>& sensorCellFlag,
1204 std::vector<MInt>& sensorSolverId) override;
1205 void postAdaptation() override;
1206 void finalizeAdaptation() override;
1207
1208 // Sensors
1209 void sensorInterface(std::vector<std::vector<MFloat>>& sensors, std::vector<std::bitset<64>>& sensorCellFlag,
1210 std::vector<MFloat>& sensorWeight, MInt sensorOffset, MInt sen) override;
1211
1212 void removeChilds(const MInt) override;
1213 void removeCell(const MInt) override;
1214 void refineCell(const MInt) override;
1215 void swapCells(const MInt, const MInt) override;
1216 void swapProxy(const MInt cellId0, const MInt cellId1) override;
1217 MInt cellOutside(const MFloat*, const MInt, const MInt) override;
1223 void resizeGridMap() override;
1225 void getContainingCellFromNeighbor(MInt body, MInt cellId, MFloat* xCoord, MFloat* xOld);
1227 void finalizeInitSolver() override;
1233 void setInterfaceList(MIntScratchSpace& interfaceCells);
1234 // balancing:
1236 void resetSolver() override;
1237 void balance(const MInt* const noCellsToReceiveByDomain, const MInt* const noCellsToSendByDomain,
1238 const MInt* const targetDomainsByCell, const MInt oldNoCells) override;
1239 void balancePre() override;
1240 void balancePost() override;
1241 void finalizeBalance() override;
1242
1243
1244 MBool hasSplitBalancing() const override { return true; }
1245 void localToGlobalIds() override;
1246 MInt noCellDataDlb() const override {
1247 if(grid().isActive()) {
1248 // a_levelSetFunctionG(cellId, set)
1249 // a_regridTriggerG(cellId)
1250 MInt cellData = 2;
1251 if(m_semiLagrange) {
1252 // a_oldLevelSetFunctionG(cellId, set)
1253 // m_initialGCell[cellId]
1254 // m_containingCell[b*m_maxNoGCells+cellId]
1255 cellData += 1 + 2 * (MInt)(!m_reconstructOldG && m_LsRotate);
1256 } else {
1257 // a_curvatureG(cellId, 0)
1258 // a_normalVectorG(cellId, dim, 0)
1259 // a_levelSetFunctionSlope(cellId, dim, 0)
1260 cellData += 3;
1261 }
1262 return cellData;
1263 } else {
1264 return 0;
1265 }
1266 };
1267
1268 MInt cellDataTypeDlb(const MInt dataId) const override {
1269 if(dataId == 0) {
1270 return MFLOAT;
1271 } else if(dataId == 1) {
1272 return MINT;
1273 } else if(dataId < 5) {
1274 if(m_semiLagrange) {
1275 if(dataId == 2)
1276 return MFLOAT;
1277 else if(dataId > 2) {
1279 return MINT;
1280 } else
1281 TERMM(1, "solverCelldataType: invalid data id for !m_reconstructOldG && m_LsRotate");
1282 }
1283 } else {
1284 return MFLOAT;
1285 }
1286 } else
1287 TERMM(1, "solverCelldataType: invalid data id");
1288 // This should not be reached, just for compiler
1289 return 0;
1290 };
1291
1292 MInt cellDataSizeDlb(const MInt dataId, const MInt gridCellId) override;
1293
1295 void getCellDataDlb(const MInt dataId, const MInt oldNoCells, const MInt* const bufferIdToCellId,
1296 MInt* const data) override;
1297 void getCellDataDlb(const MInt dataId, const MInt oldNoCells, const MInt* const bufferIdToCellId,
1298 MFloat* const data) override;
1299
1301 void setCellDataDlb(const MInt dataId, const MInt* const data) override;
1302 void setCellDataDlb(const MInt dataId, const MFloat* const data) override;
1303
1304 // Partitioning
1305 void setCellWeights(MFloat*) override;
1306 MInt noLoadTypes() const override;
1307 void getDefaultWeights(MFloat* weights, std::vector<MString>& names) const override;
1308 void getLoadQuantities(MInt* const loadQuantities) const override;
1309 MFloat getCellLoad(const MInt cellId, const MFloat* const weights) const override;
1310 void getSolverTimings(std::vector<std::pair<MString, MFloat>>& solverTimings, const MBool allTimings) override;
1311 void limitWeights(MFloat*) override;
1312 void getDomainDecompositionInformation(std::vector<std::pair<MString, MInt>>& domainInfo) override;
1313
1315 void rotateLevelSet(MInt returnMode, MFloat* cellData, MInt body, const MFloat* xCoord, const MFloat* xCenter,
1316 const MFloat* angle);
1317 void processRotatingLevelSet(MFloat& phi, MInt& cellId, MInt& domId, MFloat* point, MInt set);
1318 MInt checkSecondLayerCells(std::vector<MInt>& diag2Cells, std::map<MInt, std::vector<MInt>>& dirCode, MFloat* point);
1319 void prepareGlobalComm(MInt* noCellsToDom);
1322
1323 // functions that used to be in fvlevelsetsolver.h
1324 //
1326 void levelSetConstrainedReinitialization(MInt methodId, MInt startSet, MInt endSet, MInt gapMode);
1327 void levelSetHighOrderConstrainedReinitialization(MInt methodId, MInt startSet, MInt endSet, MInt gapMode);
1328 void maintainOuterBandLayers(MInt order, MInt startSet, MInt endSet);
1332 void reinitBand(MInt startSet, MInt endSet);
1339 void constructGFieldFromSTL(MInt ConstructFlag);
1340 void rotateSTL(MInt direction);
1341 void rotateSTL(MInt direction, MInt body, MFloat* center);
1344 // void fastBuildLevelSetTube();
1345 void setBandNewArrivals(MInt computingSet = -1);
1348 void determineG0Cells(MInt computingSet = -1);
1349 void determineBandCells(MInt mode = -1);
1351 void resetOutsideCells(MInt mode = -1);
1353 void computeCurvature(MInt mode = -1);
1364 void computeBodyPropertiesForced(MInt returnMode, MFloat* bodyData, MInt body, MFloat time,
1365 MBool printPosition = false);
1366 void identifyBodies(MInt mode = 0);
1367 void setUpLevelSetInterpolationStencil(MInt cellId, MInt* interpolationCells, MInt position);
1368 void shiftOldLevelSetField(MInt dir, MInt set, MInt body);
1378
1380 void regionGrowing(MInt cellId, MInt region);
1381 void setChildRegions(MInt cellId, MInt region);
1382
1388 MBool inCell(MInt cellId, MFloat* point);
1391 MFloat firstOrderEikonalSolver(MInt cellListSize, MInt maxIterations, MInt set);
1392 MFloat secondOrderEikonalSolver(MFloat* q, const MInt* nghbrs, MInt cellListSize, MInt maxIterations,
1393 MInt set); // used by sohel
1394 MFloat fifthOrderEikonalSolver(MInt cellListSize, MInt maxIterations, MInt* crCells, MInt noCRCells, MFloat* factors,
1395 MInt crMode, MInt set);
1396 MFloat computeDistanceFromSTL(MFloat* target, MInt* closestElement, MFloat* closestPoint, MInt set,
1397 MFloat sphereRadiusFactor = F5);
1398 MFloat interpolateOldLevelSet(MInt* interpolationCells, MFloat* point, MInt referenceSet);
1399 MFloat interpolateLevelSet(MInt* interpolationCells, MFloat* point, MInt referenceSet);
1401 MInt hyperbolicExtensionOpt(MFloat* q, MInt* cellList, MInt cellListSize, MFloat convergenceCriterion, MInt set);
1403 MInt getContainingCell(MInt startCell, MFloat* point, MInt set = -1);
1404 MInt setUpLevelSetInterpolationStencil(MInt cellId, MInt* interpolationCells, MFloat* point);
1405
1407 template <typename T>
1408 void exchangeBuffersGlobal(T* sendBuffer, T* receiveBuffer, MInt*, MInt*, MInt*, MInt*, MInt, MInt offset = 1);
1409
1411 void preTimeStep() override;
1412 void postTimeStep() override;
1415 MBool finalizeLevelSet_(const MInt t_levelSet, const MInt t_output);
1418
1420 void writeRestartFile(const MBool, const MBool, const MString, MInt* recalcIdTree) override;
1421 void reIntAfterRestart(MBool) override;
1423 MFloat reduceData(const MInt, MFloat* data, const MInt dataBlockSize = 1);
1424
1426
1428
1429 private:
1430 void reInitSolver(const MBool);
1432
1433 template <MBool currentLevelSet>
1435 template <typename T>
1436 void exchangeDataLS(T* data, const MInt dataSize = 1);
1437};
1438
1439#undef ENSURE_VALID_GCELLID
1440#undef ENSURE_VALID_DIM
1441#undef ENSURE_VALID_DIR
1442#undef ENSURE_VALID_SET
1443
1444#endif // ifndef LSSOLVER_H_
GridCell
Grid cell Property Labels.
MInt PointInsideTriangle(GeometryElement< nDim_ > *el, MFloat q[3], MFloat tr[3][3])
void transformationmatrix(GeometryElement< nDim_ > *el, MFloat tr[3][3])
void rotation(const MFloat q[3], MFloat r[3], MFloat tr[3][3])
MFloat dot(const MFloat p[3], const MFloat q[3])
void cross(const MFloat p[3], const MFloat q[3], MFloat r[3])
MFloat ** m_vertices
MInt getContainingCellHalo(MFloat *point)
MInt * m_initGFieldFromSTLBndCndIds
MFloat & a_oldLevelSetFunctionG(const MInt cellId, const MInt set)
Returns the old levelSetFunction of the cell cellId.
MFloat a_oldLevelSetFunctionG(const MInt cellId, const MInt set) const
Returns the old levelSetFunction of the cell cellId.
MInt a_bodyIdG(const MInt cellId, const MInt set) const
Returns bodyId of the cell cellId for set set.
void initializeIntegrationScheme_semiLagrange()
void updateAllLowerGridLevels(MInt mode=-1)
void reInitSolver(const MBool)
void identifyBodies(MInt mode=0)
sets a_bodyIdG(gCells,set) for all sets exept for the collected levelset (this is done in buildCollec...
MInt a_localId(const MLong gGlobalId)
void removeChilds(const MInt) override
Coarsen the given cell.
MBool a_isHalo(const MInt gCellId) const
Returns IsHalo of the cell cellId.
void shiftOldLevelSetField(MInt dir, MInt set, MInt body)
void exchangeAllLevelSetData()
void resizeGridMap() override
Swap the given cells.
MFloat a_meanCoord(const MInt dir) const
MFloat & a_curvatureG(const MInt cellId, const MInt set)
Returns curvature of the cell cellId for set set.
void setUpPotentialGapCells()
Set up cells, that may be tagged as gap cells during the solver run! Initialises the arrays,...
void postAdaptation() override
post adaptation for split adaptation within the adaptation loop
MBool finalizeLevelSet_(const MInt t_levelSet, const MInt t_output)
void setUpBodyToSetTable()
void getLoadQuantities(MInt *const loadQuantities) const override
void restartLocalizedLevelSetCG()
MFloat m_static_computeBodyProperties_initialBodyCenter[s_maxNoEmbeddedBodies *3]
MBool a_regridTriggerG(const MInt cellId) const
maia::ls::cell::BitsetType::reference a_nearGapG(const MInt cellId)
MInt c_noCells() const
MInt c_neighborId(const MInt gCellId, const MInt dir) const
MFloat m_static_identifyBodies_initialInsidePoints[s_maxNoEmbeddedBodies *3]
constexpr MInt a_bandBndryCellId(MInt id, MInt set) const
MFloat * m_semiLagrange_xRot_ref
MBool m_static_setUpPotentialGapCells_first
MInt checkSecondLayerCells(std::vector< MInt > &diag2Cells, std::map< MInt, std::vector< MInt > > &dirCode, MFloat *point)
std::map< MInt, MInt > m_refinedCells
MFloat * m_semiLagrange_xShift_ref
maia::ls::cell::BitsetType::reference a_regridTriggerG(const MInt cellId)
typename maia::grid::tree::Tree< nDim_ >::Cell Cell
MBool m_writeOutAllCorrectedBurningVelocity
void setSensors(std::vector< std::vector< MFloat > > &sensors, std::vector< MFloat > &sensorWeight, std::vector< std::bitset< 64 > > &sensorCellFlag, std::vector< MInt > &sensorSolverId) override
set solver sensors for split adaptation within the adaptation loop
void regionGrowing(MInt cellId, MInt region)
MFloat m_static_computeBodyProperties_rotAngle
MFloat & a_levelSetFunctionSlope(const MInt cellId, const MInt dim, const MInt set)
Returns ls-FunctionSlope of the cell cellId for set dim set.
MFloat secondOrderEikonalSolver(MFloat *q, const MInt *nghbrs, MInt cellListSize, MInt maxIterations, MInt set)
MFloat m_static_computeBodyProperties_freqFactor[s_maxNoEmbeddedBodies]
void computeCurvature(MInt mode=-1)
static constexpr const MInt m_noCorners
typename CartesianSolver::Grid Grid
MFloat m_static_computeBodyProperties_Strouhal
void postTimeStep() override
void getCellDataDlb(const MInt dataId, const MInt oldNoCells, const MInt *const bufferIdToCellId, MInt *const data) override
Return solver data for DLB.
MFloat m_static_computeBodyProperties_liftEndAngle2[s_maxNoEmbeddedBodies]
MBool semiLagrangeTimeStep()
constexpr MInt a_internalBandCellId(MInt id, MInt set) const
MInt getCurrentTimeStep() const override
constexpr MInt a_noGBndryCells(MInt set) const
MFloat getCellLoad(const MInt cellId, const MFloat *const weights) const override
MFloat m_static_identifyBodies_shiftTime
typename CartesianSolver::GridProxy GridProxy
MFloat * m_bodyAngularVelocity
MFloat crankAngle(const MFloat, const MInt)
MInt a_maxGCellLevel(const MInt set=-1) const
void determineSteadyFlameLength()
std::vector< MFloat > m_minGapWidth
void determinePropagationSpeed()
std::vector< MInt > m_newCells
void finalizeLevelSetInitialization()
void globalToLocalIdsContainingCells()
MInt noVariables() const override
Return the number of variables.
maia::ls::cell::BitsetTypeSet::reference a_isGZeroCell(const MInt cellId, const MInt set)
MFloat m_static_computeBodyProperties_liftStartAngle2[s_maxNoEmbeddedBodies]
MBool a_nearGapG(const MInt cellId) const
void exchangeLeafDataLS()
MInt & a_potentialGapCell(const MInt id)
Returns the potential gap cellcellId.
MPI_Request * mpi_request
MFloat m_static_setUpPotentialGapCells_radius[s_maxNoEmbeddedBodies]
void exchangeIntBuffers(MInt *, MInt *, MInt, MInt)
void spatiallyAdaptiveCorrectionFromSTL()
this function does a correction based on the curvature of the geometry. The high curvature regions ar...
MFloat m_dampingDistanceFlameBaseExtVel
void preTimeStep() override
MBool a_wasGZeroCell(const MInt cellId, const MInt set) const
void extendVelocity(const MInt set)
MInt noInternalCells() const override
Return the number of internal cells within this solver.
void initializeGField()
Initializes the solver values with the values of the undisturbed flow The values are given by the pro...
void resetSolver() override
Reset the solver/solver for load balancing.
MInt noSolverTimers(const MBool allTimings) override
void resetContainingGCells()
MFloat m_static_computeBodyProperties_circleStartAngle[s_maxNoEmbeddedBodies]
void rotateLevelSet(MInt returnMode, MFloat *cellData, MInt body, const MFloat *xCoord, const MFloat *xCenter, const MFloat *angle)
LsControlPoint< nDim > m_gCtrlPnt
MFloat & a_levelSetFunctionG(const MInt cellId, const MInt set)
Returns levelSetFunction of the cell cellId.
void initLocalizedLevelSetCG()
void computeBodyPropertiesForced(MInt returnMode, MFloat *bodyData, MInt body, MFloat time, MBool printPosition=false)
returns a specific property of the specifuec body used to provide a unique function for both level-se...
void processRotatingLevelSet(MFloat &phi, MInt &cellId, MInt &domId, MFloat *point, MInt set)
void determineMinMaxMeanInterfacePosition()
MFloat c_cellLengthAtCell(const MInt gCellId) const
MBool prepareRestart(MBool, MBool &) override
Prepare the solvers for a grid-restart.
MBool a_isBndryCellG(const MInt cellId) const
void initializeGControlPoint()
this function is used to initialize the control point.
void getDomainDecompositionInformation(std::vector< std::pair< MString, MInt > > &domainInfo) override
MBool solutionStep() override
constexpr MInt a_bandCellId(MInt id, MInt set) const
MBool m_writeReinitializationStatistics
MFloat firstOrderEikonalSolver(MInt cellListSize, MInt maxIterations, MInt set)
void computeLevelSetRHS()
MInt a_potentialGapCellClose(const MInt id) const
Returns the potential gap cell closecellId.
CHECKNORMAL< nDim > * m_checkNormal
MBool a_isGZeroCell(const MInt cellId, const MInt set) const
void setInterfaceList(MIntScratchSpace &interfaceCells)
Geometry< nDim > Geom
void initializeIntegrationScheme()
MInt m_static_setUpPotentialGapCells_bodyClose[s_maxNoEmbeddedBodies]
void computeZeroLevelSetArcLength()
MFloat cellVolumeAtCell(const MInt gCellId) const
MFloat m_static_computeBodyProperties_liftEndAngle1[s_maxNoEmbeddedBodies]
MFloat m_static_computeBodyProperties_temperature[s_maxNoEmbeddedBodies]
MBool inCell(MInt cellId, MFloat *point)
void swapProxy(const MInt cellId0, const MInt cellId1) override
Swap the given cells.
MFloat * m_semiLagrange_xRot_STL
maia::ls::cell::BitsetType::reference a_isHalo(const MInt gCellId)
Returns IsHalo of the cell cellId.
MInt a_domainId(const MLong gGlobalId)
MInt cellOutside(const MFloat *, const MInt, const MInt) override
Check whether cell is outside the fluid domain.
void createBaseGgridCG()
void allocateLevelSetMemory()
void computeExtensionVelocityGEQUPVMarksteinOpt(MFloat *FfluidDensity, MInt set)
std::vector< MFloat > m_minGapWidthDt1
std::vector< MInt > * m_G0Cells
MFloat * m_maxFlameFrontPosition
MInt a_level(const MInt gCellId) const
Returns the level of the gcell gCellId.
void exchangeDataLS(T *data, const MInt dataSize=1)
void determineMinMaxMeanRegionInterfacePosition(MFloat xRegN, MFloat xRegP, MFloat yRegN, MFloat yRegP, MInt set)
MFloat & a_meanCoord(const MInt dir)
MBool m_static_computeBodyProperties_first
MInt hyperbolicExtensionOpt(MFloat *q, MInt *cellList, MInt cellListSize, MFloat convergenceCriterion, MInt set)
MInt noLoadTypes() const override
void setGCellBndryProperty()
void levelSetReinitialization(MInt mode=1)
MFloat m_static_setUpPotentialGapCells_normal[s_maxNoEmbeddedBodies *3]
void updateLowerGridLevels(MInt mode=-1)
void levelSetRestriction()
std::array< MInt, Timers::_count > m_timers
constexpr MInt a_noG0Cells(MInt set) const
MBool m_buildCollectedLevelSetFunction
void levelSetGapCorrect()
std::map< MInt, MInt > m_oldG0Cells
void initializeCollectedLevelSet(MInt mode)
MFloat m_static_computeBodyProperties_omega
void initAzimuthalExchange()
MInt a_secondBodyId(const MInt cellId) const
Returns secondBodyId of the cell cellId for set set.
MFloat a_levelSetFunctionG(const MInt cellId, const MInt set) const
Returns levelSetFunction of the cell cellId.
void resetOutsideCells(MInt mode=-1)
void exchangeLs(MFloat *, MInt, MInt)
MBool levelSetReinitializationTrigger()
void applyLevelSetBoundaryConditions()
void computeNormalVectorsPeriodic()
void finalizeInitSolver() override
MInt m_static_setUpPotentialGapCells_noGapRegionsClose
void rotateSTL(MInt direction, MInt body, MFloat *center)
maia::ls::cell::BitsetTypeSet::reference a_wasGZeroCell(const MInt cellId, const MInt set)
void updateContainingGCells(MInt mode=0)
void levelSetHighOrderConstrainedReinitialization(MInt methodId, MInt startSet, MInt endSet, MInt gapMode)
void buildMultipleLevelSet(MInt mode=1)
MInt c_noChildren(const MInt gCellId) const
void computeCurvaturePeriodic()
MFloat m_static_setUpPotentialGapCells_heightClose[s_maxNoEmbeddedBodies]
MFloat m_static_computeBodyProperties_liftStartAngle1[s_maxNoEmbeddedBodies]
void swapCells(const MInt, const MInt) override
Swap the given cells.
void exchangeBuffersGlobal(T *sendBuffer, T *receiveBuffer, MInt *, MInt *, MInt *, MInt *, MInt, MInt offset=1)
void prepareAdaptation() override
prepare adaptation for split adaptation before the adaptation loop
void generateListOfGExchangeCellsCG()
MFloat m_static_computeBodyProperties_mu2[s_maxNoEmbeddedBodies]
constexpr MInt a_gBndryCellId(MInt id, MInt set) const
MInt determineLevelSetSignFromSTL(MFloat *target, MInt set)
this function checks if the "target" coordinates is inside(return 1) or outside (return -1) STL and r...
MBool m_writeOutAllExtensionVelocities
MBool m_writeOutAllLevelSetFunctions
MFloat & a_normalVectorG(const MInt cellId, const MInt dim, const MInt set)
Returns normalVector of the cell cellId for index n.
void writeRestartFile(const MBool, const MBool, const MString, MInt *recalcIdTree) override
MFloat timeStep() const
Returns the timeStep.
void fastBuildLevelSetTubeCG()
MInt a_noCells() const
static constexpr MInt nDim
void removeCell(const MInt) override
Remove the given cell.
void reBuildCollectedLevelSet(MInt mode)
static constexpr MInt s_maxNoEmbeddedBodies
MFloat a_levelSetRHS(const MInt cellId, const MInt set) const
Returns ls-RHS of the cell cellId for set set.
void levelSetGapRecorrect()
MFloat m_static_setUpPotentialGapCells_centerClose[s_maxNoEmbeddedBodies *3]
void localToGlobalIdsContainingCells()
MFloat interpolateLevelSet(MInt *interpolationCells, MFloat *point, MInt referenceSet)
MInt cellDataTypeDlb(const MInt dataId) const override
MInt a_hasNeighbor(const MInt gCellId, const MInt dir) const
Returns noNeighborIds of the gcell CellId variables varId.
std::vector< MInt > * m_gBndryCells
void a_resetPropertiesSolver(const MInt cellId)
Returns property p of the cell cellId.
void readLevelSetProperties()
MInt noCellDataDlb() const override
Methods to inquire solver data information.
virtual void writeRestartLevelSetFileCG(MBool, const MString &, const MString &)
MFloat a_flameSpeedG(const MInt cellId, const MInt set) const
Returns flameSpeed of the cell cellId for index n.
MFloat ** m_correctedDistances
void balance(const MInt *const noCellsToReceiveByDomain, const MInt *const noCellsToSendByDomain, const MInt *const targetDomainsByCell, const MInt oldNoCells) override
MFloat computeDistanceFromSTL(MFloat *target, MInt *closestElement, MFloat *closestPoint, MInt set, MFloat sphereRadiusFactor=F5)
void localToGlobalIds() override
std::vector< MInt > m_bodiesToCompute
MFloat fifthOrderEikonalSolver(MInt cellListSize, MInt maxIterations, MInt *crCells, MInt noCRCells, MFloat *factors, MInt crMode, MInt set)
void setUpLevelSetInterpolationStencil(MInt cellId, MInt *interpolationCells, MInt position)
void reIntAfterRestart(MBool) override
GCellCollector m_cells
MBool a_inBandG(const MInt cellId, const MInt set) const
void updateBndryCellList()
MFloat * m_minFlameFrontPosition
void prepareGlobalComm(MInt *noCellsToDom)
MFloat c_cellLengthAtLevel(const MInt level) const
constexpr MInt a_noBandBndryCells(MInt set) const
MBool m_fourthOrderNormalCurvatureComputation
MInt setUpLevelSetInterpolationStencil(MInt cellId, MInt *interpolationCells, MFloat *point)
void buildCollectedLevelSet(MInt mode=1)
void allocateRotatingLs()
MBool a_isGBoundaryCellG(const MInt cellId, const MInt set) const
maia::ls::cell::BitsetType::reference a_isBndryCellG(const MInt cellId)
MFloat & a_levelSetRHS(const MInt cellId, const MInt set)
Returns ls-RHS of the cell cellId for set set.
void sensorInterface(std::vector< std::vector< MFloat > > &sensors, std::vector< std::bitset< 64 > > &sensorCellFlag, std::vector< MFloat > &sensorWeight, MInt sensorOffset, MInt sen) override
MFloat * m_bodyAngularAcceleration
constexpr MInt a_noBandCells(MInt set) const
void resetOldOutsideCells()
virtual void saveSolverSolution(const MBool, const MBool)
maia::ls::cell::BitsetTypeSet::reference a_hasPositiveSign(const MInt cellId, const MInt set)
Returns the hasPositiveSigncellId for the setset.
maia::ls::cell::BitsetTypeSet::reference a_isGBoundaryCellG(const MInt cellId, const MInt set)
void saveRestartFile(const MBool, MInt *)
MInt a_bandNghbrIdsG(const MInt cellId, const MInt dir, const MInt set) const
Returns bandNeighborId of the cell cellId for index n.
void getCellDataDlb(const MInt dataId, const MInt oldNoCells, const MInt *const bufferIdToCellId, MFloat *const data) override
MLong c_globalId(const MInt gCellId) const
MFloat a_curvatureG(const MInt cellId, const MInt set) const
Returns curvature of the cell cellId for set set.
MInt loadLevelSetGridFlowVarsParCG(const MChar *fileName)
MFloat a_extensionVelocityG(const MInt cellId, const MInt dim, const MInt set) const
Returns fExt of the cell cellId for index n.
void copyWindowToHaloIds()
void buildLevelSetTube(MInt mode=-1)
MFloat & a_gapWidth(const MInt id)
Returns the gap widthcellId.
void balancePre() override
std::vector< MInt > * m_internalBandCells
MFloat a_levelSetFunctionSlope(const MInt cellId, const MInt dim, const MInt set) const
Returns ls-FunctionSlope of the cell cellId for set dim set.
MFloat a_normalVectorG(const MInt cellId, const MInt dim, const MInt set) const
Returns normalVector of the cell cellId for index n.
MInt & a_potentialGapCellClose(const MInt id)
Returns the potential gap cell closecellId.
virtual void cleanUp()
MInt & a_containingDomain(const MInt cellId, const MInt body)
Returns the containing DomaincellId.
void finalizeAdaptation() override
finalize adaptation for split sadptation after the adaptation loop
MFloat m_static_computeBodyProperties_mu[s_maxNoEmbeddedBodies]
void refineCell(const MInt) override
Refine the given cell.
MFloat & a_flameSpeedG(const MInt cellId, const MInt set)
Returns flameSpeed of the cell cellId for index n.
maia::ls::cell::BitsetTypeSet::reference a_inBandG(const MInt cellId, const MInt set)
MFloat m_static_crankAngle_initialCad
MPI_Request * mpi_recive
MFloat a_gapWidth(const MInt id) const
Returns the gap widthcellId.
MInt cellDataSizeDlb(const MInt dataId, const MInt gridCellId) override
void getSolverTimings(std::vector< std::pair< MString, MFloat > > &solverTimings, const MBool allTimings) override
std::map< MInt, MInt > m_swapIds
MInt getContainingCell(MFloat *point)
MBool levelSetAdaptationTrigger()
void rotateSTL(MInt direction)
MFloat m_static_computeBodyProperties_amplitude[s_maxNoEmbeddedBodies]
MBool a_isWindow(const MInt gCellId) const
Returns IsWindow of the cell cellId.
MBool forceAdaptation() override
Returns the levelSet-Adaptation-forcing.
MInt c_parentId(const MInt gCellId) const
void reconstructOldGField()
void maintainOuterBandLayers(MInt order, MInt startSet, MInt endSet)
MBool levelSetSolver()
MFloat m_static_setUpPotentialGapCells_normalClose[s_maxNoEmbeddedBodies *3]
void finalizeBalance() override
MBool m_static_createBaseGgrid_firstRun
MFloat m_static_computeBodyProperties_normal[s_maxNoEmbeddedBodies *3]
MInt & a_secondBodyId(const MInt cellId)
Returns secondBodyId of the cell cellId for set set.
void determinePeriodicDistance()
MFloat m_static_setUpPotentialGapCells_height[s_maxNoEmbeddedBodies]
typename maia::CartesianSolver< nDim, LsCartesianSolver > CartesianSolver
constexpr MInt a_noInternalBandCells(MInt set) const
std::vector< MInt > * m_bandCells
MFloat c_coordinate(const MInt gCellId, const MInt dim) const
Returns the coordinate of the cell cellId for direction dim.
void setChildRegions(MInt cellId, MInt region)
MInt a_bandLayer(MInt id, MInt set) const
MInt m_static_computeBodyProperties_bodyToFunction[s_maxNoEmbeddedBodies]
void reinitBand(MInt startSet, MInt endSet)
constexpr MInt a_G0CellId(MInt id, MInt set) const
MInt c_childId(const MInt gCellId, const MInt pos) const
MLong & a_containingCell(const MInt cellId, const MInt body)
Returns the containing cellcellId.
MFloat & a_extensionVelocityG(const MInt cellId, const MInt dim, const MInt set)
Returns fExt of the cell cellId for index n.
MInt a_potentialGapCell(const MInt id) const
Returns the potential gap cellcellId.
MFloat m_filterFlameTubeEdgesDistance
MInt a_containingDomain(const MInt cellId, const MInt body) const
Returns the containing DomaincellId.
void setCellDataDlb(const MInt dataId, const MFloat *const data) override
void getContainingCellFromNeighbor(MInt body, MInt cellId, MFloat *xCoord, MFloat *xOld)
MInt a_internalBandLayer(MInt id, MInt set) const
void constructGFieldFromSTL(MInt ConstructFlag)
Used for initializing G field into the domain. ConstructFlag == 0: only reinitialization part will be...
MInt & a_bodyIdG(const MInt cellId, const MInt set)
Returns bodyId of the cell cellId for set set.
void setBandNewArrivals(MInt computingSet=-1)
void createGgridCG(MBool=false)
MBool m_interpolateFlowFieldToFlameFront
maia::ls::cell::BitsetType::reference a_isWindow(const MInt gCellId)
Returns IsWindow of the cell cellId.
MBool regridLevelSet()
MBool _levelSetSolutionStep()
void setCellDataDlb(const MInt dataId, const MInt *const data) override
Set solver data for DLB.
void determineG0Cells(MInt computingSet=-1)
void balancePost() override
void determineBandCells(MInt mode=-1)
void levelSetConstrainedReinitialization(MInt methodId, MInt startSet, MInt endSet, MInt gapMode)
MInt a_levelSetSign(const MInt cellId, const MInt set)
Returns the signed (MInt) version of hasPositiveSigncellId for the setset.
MFloat interpolateOldLevelSet(MInt *interpolationCells, MFloat *point, MInt referenceSet)
MFloat m_static_setUpPotentialGapCells_center[s_maxNoEmbeddedBodies *3]
MLong a_containingCell(const MInt cellId, const MInt body) const
Returns the containing cellcellId.
MFloat m_static_setUpPotentialGapCells_radiusClose[s_maxNoEmbeddedBodies]
MBool a_hasPositiveSign(const MInt cellId, const MInt set) const
Returns the hasPositiveSigncellId for the setset.
MBool m_static_semiLagrangeTimeStep_firstTime
MBool c_isLeafCell(const MInt gCellId) const
MInt getContainingCell(MInt startCell, MFloat *point, MInt set=-1)
MFloat * m_meanFlameFrontPosition
MBool hasSplitBalancing() const override
Return if load balancing for solver is split into multiple methods or implemented in balance()
MFloat & a_correctedBurningVelocity(const MInt cellId, const MInt set)
Returns corrected burning velocity of the cell cellId for set set.
void getDefaultWeights(MFloat *weights, std::vector< MString > &names) const override
MFloat correctedBurningVelocity(const MInt cellId, const MInt set) const
Returns corrected burning velocity of the cell cellId for set set.
void computeNormalVectorsAtFront()
void computeNormalVectors(MInt mode=-1)
void initSolver() override
void computeGCellTimeStep()
CHECKNORMAL< nDim > & checkNormal() const
MInt & a_internalBandLayer(MInt id, MInt set)
MBool localGapCellsExist()
Geom & geometry() const
Access the solver's geometry.
typename GCellCollector::BitsetType::reference PropertyReference
std::vector< MInt > * m_bandBndryCells
std::set< std::pair< MFloat, MFloat > > * m_forcedMotionInput
static constexpr const MInt m_noDirs
MFloat time() const override
Return the time.
MString m_levelSetDiscretizationScheme
void setCellWeights(MFloat *) override
Set cell weights.
MInt & a_bandLayer(MInt id, MInt set)
void limitWeights(MFloat *) override
MFloat reduceData(const MInt, MFloat *data, const MInt dataBlockSize=1)
Definition: lsfvmb.h:24
This class is a ScratchSpace.
Definition: scratch.h:758
void startLoadTimer(const MString name)
Definition: solver.h:293
MPI_Comm mpiComm() const
Return the MPI communicator used by this solver.
Definition: solver.h:380
void stopLoadTimer(const MString &name)
Definition: solver.h:295
constexpr MInt size() const
Return size (i.e., currently used number of nodes)
Definition: container.h:89
void append(const MInt count)
Append nodes to end of tree.
Definition: container.h:223
void resetProperties(const MInt id)
Reset all properties.
MFloat & oldGFunction(const MInt id, const MInt set)
MInt & bodyId(const MInt id, const MInt set)
MFloat & correctedBurningVelocity(const MInt id, const MInt set)
MFloat & curvature(const MInt id, const MInt set)
MInt & containingDomain(const MInt id, const MInt body)
MFloat & gFunction(const MInt id, const MInt set)
Accessors.
MBool inBand(const MInt id, const MInt set) const
MFloat & normalVector(const MInt id, const MInt dim, const MInt set)
MInt & potentialGapCellClose(const MInt id)
MFloat & fExt(const MInt id, const MInt dim, const MInt set)
MBool regridTrigger(const MInt id) const
properties:
MFloat & levelSetRHS(const MInt id, const MInt set)
BitsetType::reference hasProperty(const MInt id, const LsCell p)
Accessor for properties.
MBool nearGap(const MInt id) const
MBool hasPositiveSign(const MInt id, const MInt set) const
MLong & containingCell(const MInt id, const MInt body)
MBool wasGZero(const MInt id, const MInt set) const
MInt & potentialGapCell(const MInt id)
MBool isGBndryCell(const MInt id, const MInt set) const
MBool isBndryG(const MInt id) const
MBool isGZero(const MInt id, const MInt set) const
MFloat & levelSetFunctionSlope(const MInt id, const MInt dim, const MInt set)
@ RANS_SA_DV
Definition: enums.h:54
@ RANS_FS
Definition: enums.h:55
@ RANS_KOMEGA
Definition: enums.h:56
@ MINT
Definition: enums.h:269
@ MFLOAT
Definition: enums.h:269
void mTerm(const MInt errorCode, const MString &location, const MString &message)
Definition: functions.cpp:29
MBool approx(const T &, const U &, const T)
Definition: functions.h:272
MInt globalTimeStep
int32_t MInt
Definition: maiatypes.h:62
std::basic_string< char > MString
Definition: maiatypes.h:55
double MFloat
Definition: maiatypes.h:52
int64_t MLong
Definition: maiatypes.h:64
bool MBool
Definition: maiatypes.h:58
char MChar
Definition: maiatypes.h:56
MInt id
Definition: maiatypes.h:71
int MPI_Allreduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm, const MString &name, const MString &sndvarname, const MString &rcvvarname)
same as MPI_Allreduce
Namespace for auxiliary functions/classes.