25template <MInt nDim,
class SysEqn>
34 for(
MInt dir = 0; dir <
nDim; dir++) {
42template <MInt nDim,
class SysEqn>
44 mAlloc(fvSolver().m_levelSetValues, lsSolver().m_noSets,
"fvSolver().m_levelSetValues", AT_);
45 mAlloc(fvSolver().m_curvatureG, lsSolver().m_noSets,
"fvSolver().m_curvatureG", AT_);
48 lsSolver().m_time = -99;
49 lsSolver().m_time = a_time();
58template <MInt nDim,
class SysEqn>
60 for(
MInt s = 0; s < lsSolver().m_noSets; s++) {
61 fvSolver().m_levelSetValues[s].resize(fvSolver().a_noCells());
62 fvSolver().m_curvatureG[s].resize(fvSolver().a_noCells());
65 transferGapCellProperty();
66 transferLevelSetValues();
67 computeGCellTimeStep();
73template <MInt nDim,
class SysEqn>
75 if(!lsSolver().m_combustion && !lsSolver().m_levelSetMb) {
76 if(lsSolver().m_semiLagrange) {
77 returnStep_semiLagrange();
85template <MInt nDim,
class SysEqn>
87 lsSolver().m_time = a_time();
89 transferLevelSetValues();
90 transferGapCellProperty();
93 if(!lsSolver().m_combustion && !lsSolver().m_levelSetMb && !lsSolver().m_semiLagrange && !lsSolver().m_LSSolver) {
101template <MInt nDim,
class SysEqn>
105 for(
MInt s = 0; s < lsSolver().m_noSets; s++) {
106 fvSolver().m_levelSetValues[s].clear();
107 fvSolver().m_levelSetValues[s].resize(fvSolver().a_noCells());
108 fvSolver().m_curvatureG[s].clear();
109 fvSolver().m_curvatureG[s].resize(fvSolver().a_noCells());
112 transferLevelSetValues();
119template <MInt nDim,
class SysEqn>
124 m_fvSolverId = fvSolver().m_solverId;
125 m_lsSolverId = lsSolver().m_solverId;
127 if(lsSolver().m_closeGaps) {
128 mAlloc(m_hadGapCells, lsSolver().m_noGapRegions,
"m_hadGapCells", 0, AT_);
129 mAlloc(m_hasGapCells, lsSolver().m_noGapRegions,
"m_hasGapCells", 0, AT_);
136template <MInt nDim,
class SysEqn>
140 ASSERT(lsSolver().a_maxGCellLevel() == fvSolver().maxRefinementLevel(),
"");
146template <MInt nDim,
class SysEqn>
162 m_maxVelocity = 14.5;
165 Context::getSolverProperty<MFloat>(
"maxLevelsetVelocityForTimestep", m_lsSolverId, AT_, &m_maxVelocity);
170 m_cfl = Context::getSolverProperty<MFloat>(
"cfl", m_lsSolverId, AT_);
175 m_G0regionId = Context::getSolverProperty<MInt>(
"G0regionId", m_fvSolverId, AT_, &m_G0regionId);
178 m_initialCrankAngle = F0;
180 m_initialCrankAngle =
181 Context::getSolverProperty<MFloat>(
"initialCrankAngle", m_fvSolverId, AT_, &m_initialCrankAngle);
184 m_timeStepMethod = 8;
186 m_timeStepMethod = Context::getSolverProperty<MInt>(
"timeStepMethod", m_lsSolverId, AT_);
189 m_solverMethod = Context::getSolverProperty<MString>(
"solverMethod", m_lsSolverId, AT_);
202 m_bandWidthRefMax = 5;
204 m_bandWidthRef = Context::getSolverProperty<MInt>(
"bandWidthRef", m_fvSolverId, AT_);
205 m_bandWidthRefMax = Context::getSolverProperty<MInt>(
"bandWidthRefMax", m_fvSolverId, AT_);
213template <MInt nDim,
class SysEqn>
217 if(m_timeStepMethod < 6 || m_timeStepMethod > 8) {
220 mTerm(1, AT_,
"Computation with pure LVS not possible with timeStepMethod other than 6 ,7 or 8! Please check!");
224 ASSERT(m_cfl > 0,
"Couldn't read cfl property for the ls-solver timestepping!");
226 if(m_timeStepMethod == 8) {
227 lsSolver().m_timeStep = m_cfl * lsSolver().m_gCellDistance;
229 }
else if(m_timeStepMethod == 6) {
230 lsSolver().m_timeStep = m_cfl * lsSolver().m_gCellDistance;
231 fvSolver().forceTimeStep(lsSolver().m_timeStep / a_timeRef());
233 }
else if(m_timeStepMethod == 7) {
234 lsSolver().m_timeStep = m_cfl * lsSolver().m_gCellDistance / m_maxVelocity;
235 fvSolver().forceTimeStep(lsSolver().m_timeStep / a_timeRef());
238 lsSolver().m_timeStep = lsTimeStep();
245template <MInt nDim,
class SysEqn>
249 fvSolver().m_time += lsTimeStep();
250 fvSolver().m_physicalTime += lsTimeStep() * a_timeRef();
258template <MInt nDim,
class SysEqn>
262 fvSolver().m_time += lsTimeStep() * a_timeRef();
263 fvSolver().m_physicalTime += lsTimeStep() * a_timeRef();
267template <MInt nDim,
class SysEqn>
269 MInt interpolationCells[8] = {0, 0, 0, 0, 0, 0, 0, 0};
272 position = lsSolver().setUpLevelSetInterpolationStencil(cellId, interpolationCells, point);
276 return lsSolver().interpolateLevelSet(interpolationCells, point, set);
278 return lsSolver().a_levelSetFunctionG(cellId, set);
283template <MInt nDim,
class SysEqn>
285 MInt noLevelSetFieldData = 0;
286 ASSERT(fvSolver().m_levelSet,
"");
288 if(lsSolver().m_writeOutAllLevelSetFunctions) {
289 noLevelSetFieldData += noLevelSetFieldData + 2 * a_noSets();
291 noLevelSetFieldData += 1;
293 if(lsSolver().m_writeOutAllCurvatures) {
294 noLevelSetFieldData += a_noSets();
296 noLevelSetFieldData += 1;
299 return noLevelSetFieldData;
303template <MInt nDim,
class SysEqn>
307 cerr0 <<
"Setting Sensors for Fv-Solver adaptation!" << endl;
309 MInt bandWidthRef = m_bandWidthRef;
310 MInt bandWidthRefmax = m_bandWidthRefMax;
312 MIntScratchSpace sendBufferSize(fvSolver().grid().noNeighborDomains(), AT_,
"sendBufferSize");
313 MIntScratchSpace receiveBufferSize(fvSolver().grid().noNeighborDomains(), AT_,
"receiveBufferSize");
316 for(
MInt c = 0; c < a_noFvGridCells(); c++)
320 MInt endSet = a_noSets();
321 if(lsSolver().m_buildCollectedLevelSetFunction) {
325 for(
MInt set = 0; set < endSet; set++) {
326 for(
MInt id = 0;
id < lsSolver().a_noG0Cells(set);
id++) {
327 MInt fvCellId = ls2fvIdParent(a_G0CellId(
id, set));
328 if(fvCellId < 0)
continue;
329 if(fvSolver().a_isHalo(fvCellId))
continue;
330 inList[fvCellId] = 1;
332 MInt parentId = fvSolver().c_parentId(fvCellId);
333 while(parentId > -1) {
334 if(parentId < a_noFvGridCells()) inList[parentId] = 1;
335 parentId = fvSolver().c_parentId(parentId);
341 MPI_Allreduce(&listCount, &listCount, 1, MPI_INT, MPI_SUM, fvSolver().mpiComm(), AT_,
"listCount",
"listCount");
344 if(fvSolver().domainId() == 0) cerr <<
"No G0-Cells found!" << endl;
347 fvSolver().exchangeData(&inList[0], 1);
349 for(
MInt level = fvSolver().minLevel(); level < fvSolver().maxRefinementLevel(); level++) {
350 if(level == fvSolver().maxRefinementLevel() - 1) bandWidthRef = bandWidthRefmax;
353 for(
MInt loopMarker = 1; loopMarker < bandWidthRef; loopMarker++) {
354 for(
MInt cellId = 0; cellId < a_noFvGridCells(); cellId++) {
355 if(fvSolver().a_level(cellId) != level)
continue;
356 if(inList[cellId] != loopMarker)
continue;
359 for(
MInt n = 0; n < fvSolver().m_noDirs; n++) {
360 MInt nghbrId = fvSolver().c_neighborId(cellId, n,
false);
361 if(nghbrId < 0)
continue;
362 if(inList[nghbrId] == 0) inList[nghbrId] = loopMarker + 1;
365 if(n == 0 || n == 1) {
366 for(
MInt nn = 2; nn < fvSolver().m_noDirs; nn++) {
367 MInt nghbrId2 = fvSolver().c_neighborId(nghbrId, nn,
false);
368 if(nghbrId2 < 0)
continue;
369 if(inList[nghbrId2] == 0) inList[nghbrId2] = loopMarker + 1;
372 if(n == 4 || n == 5) {
373 for(
MInt nn = 2; nn < 4; nn++) {
374 MInt nghbrId2 = fvSolver().c_neighborId(nghbrId, nn,
false);
375 if(nghbrId2 < 0)
continue;
376 if(inList[nghbrId2] == 0) inList[nghbrId2] = loopMarker + 1;
378 for(
MInt nnn = 0; nnn < 1; nnn++) {
379 MInt nghbrId3 = fvSolver().c_neighborId(nghbrId2, nnn,
false);
380 if(nghbrId3 < 0)
continue;
381 if(inList[nghbrId3] == 0) inList[nghbrId3] = loopMarker + 1;
388 fvSolver().exchangeData(&inList[0], 1);
397template <MInt nDim,
class SysEqn>
401 fvSolver().a_noSets() = a_noSets();
402 fvSolver().a_noLevelSetFieldData() = noLevelSetFieldData();
404 for(
MInt s = 0; s < lsSolver().m_noSets; s++) {
405 fvSolver().m_levelSetValues[s].resize(fvSolver().a_noCells());
408 for(
MInt s = 0; s < lsSolver().m_noSets; s++) {
409 for(
MInt fc = 0; fc < a_noFvCells(); fc++) {
410 MInt lsId = fv2lsIdParent(fc);
411 fvSolver().a_levelSetFunction(fc, s) = a_outsideGValue();
413 fvSolver().a_curvatureG(fc, s) = lsSolver().a_curvatureG(lsId, 0);
414 if(fvSolver().a_isInterface(fc)) {
417 for(
MInt d = 0; d < nDim; d++) {
418 point[d] = fvSolver().a_coordinate(fc, d);
420 fvSolver().a_levelSetFunction(fc, s) = interpolateLevelSet(fv2lsIdParent(fc), point, s);
422 fvSolver().a_levelSetFunction(fc, s) = lsSolver().a_levelSetFunctionG(fv2lsIdParent(fc), s);
432template <MInt nDim,
class SysEqn>
436 if(!lsSolver().m_closeGaps)
return;
437 if(lsSolver().m_noGapRegions <= 0)
return;
438 if((lsSolver().m_levelSetMb) && fvSolver().m_constructGField)
return;
440#ifdef COUPLING_DEBUG_
445 for(
MInt region = 0; region < lsSolver().m_noGapRegions; region++) {
446 m_hadGapCells[region] = 0;
447 m_hasGapCells[region] = 0;
451 for(
MInt fc = 0; fc < a_noFvGridCells(); fc++) {
452 if(fvSolver().a_isGapCell(fc)) {
453 MInt lsId = fv2lsId(fc);
454 ASSERT(lsId > -1,
"");
456 if(m_G0regionId > -1 && a_potentialGapCellClose(lsId) == m_G0regionId)
continue;
457 MInt regionId = a_potentialGapCellClose(lsId) - 2;
458 ASSERT(a_potentialGapCellClose(lsId) > 0 && a_potentialGapCellClose(lsId) <= lsSolver().m_noEmbeddedBodies,
"");
459 if(regionId > -1 && regionId < lsSolver().m_noGapRegions &&
globalTimeStep > 0) {
462 m_hadGapCells[regionId]++;
466 fvSolver().a_wasGapCell(fc) = fvSolver().a_isGapCell(fc);
468 fvSolver().a_wasGapCell(fc) =
false;
470 fvSolver().a_isGapCell(fc) =
false;
473 for(
MInt fc = a_noFvGridCells(); fc < a_noFvCells(); fc++) {
475 fvSolver().a_wasGapCell(fc) = fvSolver().a_isGapCell(fc);
477 fvSolver().a_wasGapCell(fc) =
false;
479 fvSolver().a_isGapCell(fc) =
false;
483 for(
MInt gCellId = 0; gCellId < lsSolver().a_noCells(); gCellId++) {
484 if(a_nearGapG(gCellId)) {
485 MInt fvId = ls2fvId(gCellId);
487 ASSERT(abs(abs(a_levelSetFunctionG(gCellId, 0)) - a_outsideGValue()) < 0.000001,
488 "ERROR, no fv-Cell found for relevant Gap-Cells!");
490 if(a_potentialGapCellClose(gCellId) > 0 && a_potentialGapCellClose(gCellId) <= lsSolver().m_noEmbeddedBodies) {
491 fvSolver().a_isGapCell(fvId) =
true;
492 MInt regionId = a_potentialGapCellClose(gCellId) - 2;
493 if(regionId > -1 && regionId < lsSolver().m_noGapRegions) {
494 m_hasGapCells[regionId]++;
502 if(m_G0regionId > -1) {
503 MInt noG0regionCells = 0;
504 for(
MInt gCellId = 0; gCellId < lsSolver().a_noCells(); gCellId++) {
505 if(lsSolver().a_potentialGapCellClose(gCellId) == m_G0regionId && lsSolver().a_gapWidth(gCellId) > 0) {
506 MInt fvId = ls2fvId(gCellId);
508 ASSERT(abs(abs(a_levelSetFunctionG(gCellId, 0)) - a_outsideGValue()) < 0.000001,
509 "ERROR, no fv-Cell found for relevant Gap-Cells!");
512 fvSolver().a_isGapCell(fvId) =
true;
513 ASSERT(!lsSolver().a_nearGapG(gCellId),
"");
516#if defined COUPLING_DEBUG_ || !defined NDEBUG
517 MPI_Allreduce(MPI_IN_PLACE, &noG0regionCells, 1, MPI_INT, MPI_SUM, fvSolver().mpiComm(), AT_,
"INPLACE",
519 if(lsSolver().domainId() == 0) {
520 cerr <<
" No of g0-region Cells " << noG0regionCells << endl;
527 if(lsSolver().m_restart &&
globalTimeStep == fvSolver().m_restartTimeStep) {
528 for(
MInt fc = a_noFvGridCells(); fc < a_noFvCells(); fc++) {
529 fvSolver().a_wasGapCell(fc) = fvSolver().a_isGapCell(fc);
531 for(
MInt region = 0; region < lsSolver().m_noGapRegions; region++) {
532 m_hadGapCells[region] = m_hasGapCells[region];
537 MPI_Allreduce(MPI_IN_PLACE, &m_hadGapCells[0], lsSolver().m_noGapRegions, MPI_INT, MPI_SUM, fvSolver().mpiComm(), AT_,
538 "INPLACE",
"m_hadGapCells");
540 MPI_Allreduce(MPI_IN_PLACE, &m_hasGapCells[0], lsSolver().m_noGapRegions, MPI_INT, MPI_SUM, fvSolver().mpiComm(), AT_,
541 "INPLACE",
"m_hasGapCells");
543 fvSolver().exchangeGapInfo();
545#if defined COUPLING_DEBUG_ || !defined NDEBUG
546 for(
MInt region = 0; region < lsSolver().m_noGapRegions; region++) {
547 if(lsSolver().domainId() == 0) {
548 cerr <<
globalTimeStep <<
" region " << region <<
" has " << m_hasGapCells[region] <<
" had "
549 << m_hadGapCells[region] << endl;
559template <MInt nDim,
class SysEqn>
563 if(!lsSolver().m_closeGaps)
return;
564 if((lsSolver().m_levelSetMb) && fvSolver().m_constructGField)
return;
566#ifdef COUPLING_DEBUG_
567 for(
MInt fc = 0; fc < a_noFvGridCells(); fc++) {
568 if(fvSolver().a_isGapCell(fc) || fvSolver().a_wasGapCell(fc)) {
569 MInt gc = lsSolver().grid().tree().grid2solver(fvSolver().grid().tree().solver2grid(fc));
571 ASSERT(lsSolver().a_potentialGapCellClose(gc) > 0
572 && lsSolver().a_potentialGapCellClose(gc) <= fvSolver().m_noEmbeddedBodies,
582template <MInt nDim,
class SysEqn>
586 if(lsSolver().m_constructGField)
return;
588 for(
MInt fc = 0; fc < a_noFvGridCells(); fc++) {
589 ASSERT(fvSolver().grid().tree().solver2grid(fc) >= 0,
"");
590 ASSERT(fvSolver().grid().solverFlag(fvSolver().grid().tree().solver2grid(fc), m_fvSolverId),
"");
591#ifdef COUPLING_DEBUG_
592 if(lsSolver().grid().solverFlag(fvSolver().grid().tree().solver2grid(fc), m_lsSolverId)) {
593 ASSERT(ls2fvId(fv2lsId(fc)) == fc,
594 to_string(fc) +
" " + to_string(fv2lsId(fc)) +
" " + to_string(ls2fvId(fv2lsId(fc))));
598 for(
MInt cellId = 0; cellId < a_noLsCells(); cellId++) {
599 ASSERT(lsSolver().grid().tree().solver2grid(cellId) >= 0,
"");
600 ASSERT(lsSolver().grid().solverFlag(lsSolver().grid().tree().solver2grid(cellId), m_lsSolverId),
"");
601#ifdef COUPLING_DEBUG_
602 if(fvSolver().grid().solverFlag(lsSolver().grid().tree().solver2grid(cellId), m_fvSolverId)) {
603 ASSERT(fv2lsId(ls2fvId(cellId)) == cellId,
604 to_string(cellId) +
" " + to_string(ls2fvId(cellId)) +
" " + to_string(fv2lsId(ls2fvId(cellId))));
609 if(!lsSolver().m_levelSetMb)
return;
612#ifdef COUPLING_DEBUG_
613 for(
MInt fc = 0; fc < a_noFvGridCells(); fc++) {
614 for(
MInt dir = 0; dir < nDim; dir++) {
615 if(lsSolver().grid().solverFlag(fvSolver().grid().tree().solver2grid(fc), m_lsSolverId)) {
616 ASSERT(abs(fvSolver().c_coordinate(fc, dir) - a_coordinateG(fv2lsId(fc), dir)) < 0.00000001,
"");
631template <MInt nDim,
class SysEqn>
635 MFloat elapsedTime = time;
637 MBool& first = m_static_computeBodyProperties_first;
638 MFloat(&litude)[m_maxNoEmbeddedBodies] = m_static_computeBodyProperties_amplitude;
639 MFloat(&freqFactor)[m_maxNoEmbeddedBodies] = m_static_computeBodyProperties_freqFactor;
640 MFloat(&initialBodyCenter)[m_maxNoEmbeddedBodies * 3] = m_static_computeBodyProperties_initialBodyCenter;
641 MFloat& Strouhal = m_static_computeBodyProperties_Strouhal;
642 MFloat(&mu)[m_maxNoEmbeddedBodies] = m_static_computeBodyProperties_mu;
643 MFloat(&mu2)[m_maxNoEmbeddedBodies] = m_static_computeBodyProperties_mu2;
644 MFloat(&liftStartAngle1)[m_maxNoEmbeddedBodies] = m_static_computeBodyProperties_liftStartAngle1;
645 MFloat(&liftEndAngle1)[m_maxNoEmbeddedBodies] = m_static_computeBodyProperties_liftEndAngle1;
646 MFloat(&liftStartAngle2)[m_maxNoEmbeddedBodies] = m_static_computeBodyProperties_liftStartAngle2;
647 MFloat(&liftEndAngle2)[m_maxNoEmbeddedBodies] = m_static_computeBodyProperties_liftEndAngle2;
648 MFloat(&circleStartAngle)[m_maxNoEmbeddedBodies] = m_static_computeBodyProperties_circleStartAngle;
649 MFloat(&normal)[m_maxNoEmbeddedBodies * 3] = m_static_computeBodyProperties_normal;
650 MInt(&bodyToFunction)[m_maxNoEmbeddedBodies] = m_static_computeBodyProperties_bodyToFunction;
651 MFloat& omega = m_static_computeBodyProperties_omega;
652 MFloat& rotAngle = m_static_computeBodyProperties_rotAngle;
655 MInt noEmbeddedBodies = lsSolver().m_noEmbeddedBodies;
657 if(noEmbeddedBodies > m_maxNoEmbeddedBodies) {
658 mTerm(1, AT_,
"Error in computeBodyProperties: too many embedded Bodies!");
663 for(
MInt k = 0; k < m_maxNoEmbeddedBodies; k++) {
666 bodyToFunction[k] = 1;
667 for(
MInt i = 0; i < nDim; i++) {
668 initialBodyCenter[k * nDim + i] = F0;
669 normal[k * nDim + i] = F0;
671 normal[k * nDim + 0] = 1.0;
672 liftStartAngle1[k] = F0;
673 liftEndAngle1[k] = PI;
674 liftStartAngle2[k] = 3.0 * PI;
675 liftEndAngle2[k] = 4.0 * PI;
676 circleStartAngle[k] = F0;
693 for(
MInt i = 0; i < noEmbeddedBodies; i++)
694 amplitude[i] = Context::getSolverProperty<MFloat>(
"amplitudes", m_lsSolverId, AT_, &litude[i], i);
708 for(
MInt i = 0; i < noEmbeddedBodies; i++)
709 freqFactor[i] = Context::getSolverProperty<MFloat>(
"freqFactors", m_lsSolverId, AT_, &freqFactor[i], i);
723 for(
MInt i = 0; i < noEmbeddedBodies; i++)
725 Context::getSolverProperty<MInt>(
"bodyMovementFunctions", m_lsSolverId, AT_, &bodyToFunction[i], i);
727 Strouhal = Context::getSolverProperty<MFloat>(
"Strouhal", m_lsSolverId, AT_, &Strouhal);
739 for(
MInt i = 0; i < noEmbeddedBodies; i++)
740 for(
MInt j = 0; j < nDim; j++)
741 initialBodyCenter[i * nDim + j] = Context::getSolverProperty<MFloat>(
742 "initialBodyCenters", m_lsSolverId, AT_, &initialBodyCenter[i * nDim + j], i * nDim + j);
744 for(
MInt i = 0; i < noEmbeddedBodies; i++)
745 for(
MInt j = 0; j < nDim; j++)
746 normal[i * nDim + j] = Context::getSolverProperty<MFloat>(
"bodyMotionNormals", m_lsSolverId, AT_,
747 &normal[i * nDim + j], i * nDim + j);
762 for(
MInt i = 0; i < noEmbeddedBodies; i++)
764 Context::getSolverProperty<MFloat>(
"liftStartAngles1", m_lsSolverId, AT_, &liftStartAngle1[i], i);
778 for(
MInt i = 0; i < noEmbeddedBodies; i++)
780 Context::getSolverProperty<MFloat>(
"liftStartAngles2", m_lsSolverId, AT_, &liftStartAngle2[i], i);
792 for(
MInt i = 0; i < noEmbeddedBodies; i++)
793 liftEndAngle1[i] = Context::getSolverProperty<MFloat>(
"liftEndAngles1", m_lsSolverId, AT_, &liftEndAngle1[i], i);
805 for(
MInt i = 0; i < noEmbeddedBodies; i++)
806 liftEndAngle2[i] = Context::getSolverProperty<MFloat>(
"liftEndAngles2", m_lsSolverId, AT_, &liftEndAngle2[i], i);
819 for(
MInt i = 0; i < noEmbeddedBodies; i++)
820 circleStartAngle[i] =
821 Context::getSolverProperty<MFloat>(
"circleStartAngles", m_lsSolverId, AT_, &circleStartAngle[i], i);
836 rotAngle = Context::getSolverProperty<MFloat>(
"rotAngle", m_lsSolverId, AT_, &rotAngle);
837 rotAngle *= -PI / 180;
840 const MFloat freq0 = Strouhal * a_UInfinity();
841 const MFloat freq02 = Strouhal;
842 for(
MInt k = 0; k < noEmbeddedBodies; k++) {
845 mu[k] = freqFactor[k] * freq0 * F2 * PI;
846 mu2[k] = freqFactor[k] * freq02 * F2 * PI;
851 for(
MInt i = 0; i < noEmbeddedBodies; i++) {
852 if(bodyToFunction[i] == 6 || bodyToFunction[i] == 7) {
853 liftStartAngle1[i] = liftStartAngle1[i] * PI;
854 liftEndAngle1[i] = liftEndAngle1[i] * PI - liftStartAngle1[i];
858 omega = freqFactor[body] * sqrt(a_TInfinity()) * a_Ma() * PI / (2.0 * amplitude[body]);
866 switch(bodyToFunction[body]) {
869 angle = mu[body] * elapsedTime - liftStartAngle1[body];
873 if(angle > liftEndAngle1[body]) angle = liftEndAngle1[body];
875 bodyData[0] = -amplitude[body] *
cos(angle);
877 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
879 bodyData[0] = -amplitude[body];
881 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
885 if((angle > 0 && angle < liftEndAngle1[body])) {
886 bodyData[0] = mu[body] * amplitude[body] * sin(angle);
889 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
894 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
898 if((angle > 0 && angle < liftEndAngle1[body])) {
899 bodyData[0] = mu[body] * mu[body] * amplitude[body] *
cos(angle);
901 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
905 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
911 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
919 angle = mu2[body] * elapsedTime;
923 if((angle > liftStartAngle1[body] && angle <= liftEndAngle1[body])
924 || (angle > liftStartAngle2[body] && angle <= liftEndAngle2[body])) {
925 bodyData[0] = amplitude[body] *
POW2(sin(mu2[body] * elapsedTime)) * normal[body * nDim + 0];
926 bodyData[1] = amplitude[body] *
POW2(sin(mu2[body] * elapsedTime)) * normal[body * nDim + 1];
927 IF_CONSTEXPR(nDim == 3)
928 bodyData[2] = amplitude[body] *
POW2(sin(mu2[body] * elapsedTime)) * normal[body * nDim + 2];
932 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
936 if((angle > liftStartAngle1[body] && angle <= liftEndAngle1[body])
937 || (angle > liftStartAngle2[body] && angle <= liftEndAngle2[body])) {
938 bodyData[0] = amplitude[body] * mu2[body] * sin(2 * mu2[body] * elapsedTime) * normal[body * nDim + 0];
939 bodyData[1] = amplitude[body] * mu2[body] * sin(2 * mu2[body] * elapsedTime) * normal[body * nDim + 1];
940 IF_CONSTEXPR(nDim == 3)
941 bodyData[2] = amplitude[body] * mu2[body] * sin(2 * mu2[body] * elapsedTime) * normal[body * nDim + 2];
945 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
949 if((angle > liftStartAngle1[body] && angle <= liftEndAngle1[body])
950 || (angle > liftStartAngle2[body] && angle <= liftEndAngle2[body])) {
951 bodyData[0] = 2 * amplitude[body] * mu2[body] * mu2[body] *
cos(2 * mu2[body] * elapsedTime)
952 * normal[body * nDim + 0];
953 bodyData[1] = 2 * amplitude[body] * mu2[body] * mu2[body] *
cos(2 * mu2[body] * elapsedTime)
954 * normal[body * nDim + 1];
955 IF_CONSTEXPR(nDim == 3)
956 bodyData[2] = 2 * amplitude[body] * mu2[body] * mu2[body] * cos(2 * mu2[body] * elapsedTime)
957 * normal[body * nDim + 2];
959 bodyData[0] = 2 * amplitude[body] * mu2[body] * mu2[body] * normal[body * nDim + 0];
960 bodyData[1] = 2 * amplitude[body] * mu2[body] * mu2[body] * normal[body * nDim + 1];
961 IF_CONSTEXPR(nDim == 3) bodyData[2] = 2 * amplitude[body] * mu2[body] * mu2[body] * normal[body * nDim + 2];
967 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
978 angle = mu2[body] * elapsedTime;
983 if(elapsedTime > F0) {
984 bodyData[0] = -amplitude[body] *
cos(mu2[body] * elapsedTime) * normal[body * nDim + 0];
985 bodyData[1] = -amplitude[body] *
cos(mu2[body] * elapsedTime) * normal[body * nDim + 1];
986 IF_CONSTEXPR(nDim == 3)
987 bodyData[2] = -amplitude[body] * cos(mu2[body] * elapsedTime) * normal[body * nDim + 2];
989 bodyData[0] = -amplitude[body] * normal[body * nDim + 0];
990 bodyData[1] = -amplitude[body] * normal[body * nDim + 1];
991 IF_CONSTEXPR(nDim == 3) bodyData[2] = -amplitude[body] * normal[body * nDim + 2];
995 if(elapsedTime > F0) {
996 bodyData[0] = mu2[body] * amplitude[body] * sin(mu2[body] * elapsedTime) * normal[body * nDim + 0];
997 bodyData[1] = mu2[body] * amplitude[body] * sin(mu2[body] * elapsedTime) * normal[body * nDim + 1];
998 IF_CONSTEXPR(nDim == 3)
999 bodyData[2] = mu2[body] * amplitude[body] * sin(mu2[body] * elapsedTime) * normal[body * nDim + 2];
1003 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1007 if(elapsedTime > F0) {
1009 mu2[body] * mu2[body] * amplitude[body] *
cos(mu2[body] * elapsedTime) * normal[body * nDim + 0];
1011 mu2[body] * mu2[body] * amplitude[body] *
cos(mu2[body] * elapsedTime) * normal[body * nDim + 1];
1012 IF_CONSTEXPR(nDim == 3)
1014 mu2[body] * mu2[body] * amplitude[body] * cos(mu2[body] * elapsedTime) * normal[body * nDim + 2];
1018 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1024 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1033 angle = mu2[body] * elapsedTime;
1035 switch(returnMode) {
1037 if((angle > liftStartAngle1[body] && angle <= liftEndAngle1[body])
1038 || (angle > liftStartAngle2[body] && angle <= liftEndAngle2[body])) {
1039 bodyData[0] = amplitude[body] *
cos(angle) * normal[body * nDim + 0];
1040 bodyData[1] = amplitude[body] *
cos(angle) * normal[body * nDim + 1];
1041 IF_CONSTEXPR(nDim == 3) bodyData[2] = amplitude[body] * cos(angle) * normal[body * nDim + 2];
1043 bodyData[0] = amplitude[body] * normal[body * nDim + 0];
1044 bodyData[1] = amplitude[body] * normal[body * nDim + 1];
1045 IF_CONSTEXPR(nDim == 3) bodyData[2] = amplitude[body] * normal[body * nDim + 2];
1049 if((angle > liftStartAngle1[body] && angle <= liftEndAngle1[body])
1050 || (angle > liftStartAngle2[body] && angle <= liftEndAngle2[body])) {
1051 bodyData[0] = -mu2[body] * amplitude[body] * sin(angle) * normal[body * nDim + 0];
1052 bodyData[1] = -mu2[body] * amplitude[body] * sin(angle) * normal[body * nDim + 1];
1053 IF_CONSTEXPR(nDim == 3) bodyData[2] = -mu2[body] * amplitude[body] * sin(angle) * normal[body * nDim + 2];
1057 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1061 if((angle > liftStartAngle1[body] && angle <= liftEndAngle1[body])
1062 || (angle > liftStartAngle2[body] && angle <= liftEndAngle2[body])) {
1063 bodyData[0] = -mu2[body] * mu2[body] * amplitude[body] *
cos(angle) * normal[body * nDim + 0];
1064 bodyData[1] = -mu2[body] * mu2[body] * amplitude[body] *
cos(angle) * normal[body * nDim + 1];
1065 IF_CONSTEXPR(nDim == 3)
1066 bodyData[2] = -mu2[body] * mu2[body] * amplitude[body] * cos(angle) * normal[body * nDim + 2];
1070 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1076 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1087 angle = mu2[body] * elapsedTime + circleStartAngle[body];
1089 switch(returnMode) {
1091 if(elapsedTime > F0) {
1092 bodyData[0] = amplitude[body] *
cos(angle);
1093 bodyData[1] = amplitude[body] * sin(angle);
1094 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1096 bodyData[0] = amplitude[body] *
cos(circleStartAngle[body]);
1097 bodyData[1] = amplitude[body] * sin(circleStartAngle[body]);
1098 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1102 if(elapsedTime > F0) {
1103 bodyData[0] = -amplitude[body] * sin(angle);
1104 bodyData[1] = amplitude[body] *
cos(angle);
1105 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1109 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1113 if(elapsedTime > F0) {
1114 bodyData[0] = -amplitude[body] *
cos(angle);
1115 bodyData[1] = -amplitude[body] * sin(angle);
1116 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1120 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1126 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1133 angle = omega * elapsedTime - liftStartAngle1[body];
1134 if(angle > liftEndAngle1[body]) angle = F0;
1137 switch(returnMode) {
1139 if(elapsedTime > F0) {
1140 bodyData[0] = -amplitude[body] *
cos(angle) * normal[body * nDim + 0];
1141 bodyData[1] = -amplitude[body] *
cos(angle) * normal[body * nDim + 1];
1142 IF_CONSTEXPR(nDim == 3) bodyData[2] = -amplitude[body] * cos(angle) * normal[body * nDim + 2];
1144 bodyData[0] = -amplitude[body] * normal[body * nDim + 0];
1145 bodyData[1] = -amplitude[body] * normal[body * nDim + 1];
1146 IF_CONSTEXPR(nDim == 3) bodyData[2] = -amplitude[body] * normal[body * nDim + 2];
1150 if(elapsedTime > F0) {
1151 bodyData[0] = omega * amplitude[body] * sin(angle) * normal[body * nDim + 0];
1152 bodyData[1] = omega * amplitude[body] * sin(angle) * normal[body * nDim + 1];
1153 IF_CONSTEXPR(nDim == 3) bodyData[2] = omega * amplitude[body] * sin(angle) * normal[body * nDim + 2];
1157 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1161 if(elapsedTime > F0) {
1162 bodyData[0] = omega * omega * amplitude[body] *
cos(angle) * normal[body * nDim + 0];
1163 bodyData[1] = omega * omega * amplitude[body] *
cos(angle) * normal[body * nDim + 1];
1164 IF_CONSTEXPR(nDim == 3)
1165 bodyData[2] = omega * omega * amplitude[body] * cos(angle) * normal[body * nDim + 2];
1169 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1175 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1186 angle = omega * elapsedTime - liftStartAngle1[body];
1187 if(angle > liftEndAngle1[body]) angle = F0;
1189 switch(returnMode) {
1192 bodyData[0] = amplitude[body] *
POW2(sin(angle)) * normal[body * nDim + 0];
1193 bodyData[1] = amplitude[body] *
POW2(sin(angle)) * normal[body * nDim + 1];
1194 IF_CONSTEXPR(nDim == 3) bodyData[2] = amplitude[body] *
POW2(sin(angle)) * normal[body * nDim + 2];
1198 IF_CONSTEXPR(nDim == 3) bodyData[2] = 0;
1203 bodyData[0] = amplitude[body] * omega * sin(2 * angle) * normal[body * nDim + 0];
1204 bodyData[1] = amplitude[body] * omega * sin(2 * angle) * normal[body * nDim + 1];
1205 IF_CONSTEXPR(nDim == 3) bodyData[2] = amplitude[body] * omega * sin(2 * angle) * normal[body * nDim + 2];
1209 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1214 bodyData[0] = 2 * amplitude[body] * omega * omega *
cos(2 * angle) * normal[body * nDim + 0];
1215 bodyData[1] = 2 * amplitude[body] * omega * omega *
cos(2 * angle) * normal[body * nDim + 1];
1216 IF_CONSTEXPR(nDim == 3)
1217 bodyData[2] = 2 * amplitude[body] * omega * omega * cos(2 * angle) * normal[body * nDim + 2];
1219 bodyData[0] = 2 * amplitude[body] * omega * omega * normal[body * nDim + 0];
1220 bodyData[1] = 2 * amplitude[body] * omega * omega * normal[body * nDim + 1];
1221 IF_CONSTEXPR(nDim == 3) bodyData[2] = 2 * amplitude[body] * omega * omega * normal[body * nDim + 2];
1227 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1237 angle = sqrt(a_TInfinity());
1239 if(std::isnan(angle)) {
1240 cerr <<
"ERROR in the initialisation of the ls-Solver coupling class!" << endl;
1244 switch(returnMode) {
1246 bodyData[0] = amplitude[body] * angle * elapsedTime * normal[body * nDim + 0];
1247 bodyData[1] = amplitude[body] * angle * elapsedTime * normal[body * nDim + 1];
1248 IF_CONSTEXPR(nDim == 3) bodyData[2] = amplitude[body] * angle * elapsedTime * normal[body * nDim + 2];
1251 bodyData[0] = amplitude[body] * angle * normal[body * nDim + 0];
1252 bodyData[1] = amplitude[body] * angle * normal[body * nDim + 1];
1253 IF_CONSTEXPR(nDim == 3) bodyData[2] = amplitude[body] * angle * normal[body * nDim + 2];
1258 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1264 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1272 angle = mu2[body] * elapsedTime;
1274 switch(returnMode) {
1276 if(angle >= liftStartAngle1[body] && angle <= liftEndAngle1[body]) {
1277 bodyData[0] = amplitude[body] * sin(angle) * normal[body * nDim + 0];
1278 bodyData[1] = amplitude[body] * sin(angle) * normal[body * nDim + 1];
1279 IF_CONSTEXPR(nDim == 3) bodyData[2] = amplitude[body] * sin(angle) * normal[body * nDim + 2];
1280 } else if(angle < liftStartAngle1[body]) {
1283 IF_CONSTEXPR(nDim == 3) bodyData[2] = 0;
1284 } else if(angle > liftEndAngle1[body]) {
1285 bodyData[0] = amplitude[body] * sin(liftEndAngle1[body]) * normal[body * nDim + 0];
1286 bodyData[1] = amplitude[body] * sin(liftEndAngle1[body]) * normal[body * nDim + 1];
1287 IF_CONSTEXPR(nDim == 3) bodyData[2] = amplitude[body] * sin(liftEndAngle1[body]) * normal[body * nDim + 2];
1291 if(angle > liftStartAngle1[body] && angle <= liftEndAngle1[body]) {
1292 bodyData[0] = mu2[body] * amplitude[body] *
cos(angle) * normal[body * nDim + 0];
1293 bodyData[1] = mu2[body] * amplitude[body] *
cos(angle) * normal[body * nDim + 1];
1294 IF_CONSTEXPR(nDim == 3) bodyData[2] = mu2[body] * amplitude[body] * cos(angle) * normal[body * nDim + 2];
1298 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1302 if(angle > liftStartAngle1[body] && angle <= liftEndAngle1[body]) {
1303 bodyData[0] = -mu2[body] * mu2[body] * amplitude[body] * sin(angle) * normal[body * nDim + 0];
1304 bodyData[1] = -mu2[body] * mu2[body] * amplitude[body] * sin(angle) * normal[body * nDim + 1];
1305 IF_CONSTEXPR(nDim == 3)
1306 bodyData[2] = -mu2[body] * mu2[body] * amplitude[body] * sin(angle) * normal[body * nDim + 2];
1310 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1316 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1330 const MFloat l = liftStartAngle1[body];
1331 const MFloat TDC = liftEndAngle1[body];
1332 const MFloat r = amplitude[body];
1334 MFloat phi = mu2[body] * elapsedTime;
1337 phi = phi + m_initialCrankAngle * PI / 180;
1339 switch(returnMode) {
1342 normal[body * nDim + 0] * (l + r + TDC - (r *
cos(phi) + sqrt(
POW2(l) -
POW2(r) *
POW2(sin(phi)))));
1344 normal[body * nDim + 1] * (l + r + TDC - (r *
cos(phi) + sqrt(
POW2(l) -
POW2(r) *
POW2(sin(phi)))));
1345 IF_CONSTEXPR(nDim == 3)
1347 normal[body * nDim + 2] * (l + r + TDC - (r * cos(phi) + sqrt(
POW2(l) -
POW2(r) *
POW2(sin(phi)))));
1349 if(lsSolver().domainId() == 0 && fabs(elapsedTime - a_physicalTime()) < 0.0000000001) {
1351 cerr <<
"Crank-angle-degree : " << cad << endl;
1352 if((cad / 45) > 0.989 && (cad / 45) < 1.01) {
1353 cerr <<
"Physical-Time : " << a_physicalTime() << endl;
1354 cerr <<
" " << a_physicalTime() * 0.002898783653689 << endl;
1356 cerr <<
"Piston-position : " << (l + r + TDC - (r *
cos(phi) + sqrt(
POW2(l) -
POW2(r) *
POW2(sin(phi)))))
1357 <<
" in m " << bodyData[1] * 0.075 << endl;
1358 cerr <<
"Piston-velocity : "
1360 * (r * sin(phi) + (
POW2(r) * sin(phi) *
cos(phi) / (sqrt(
POW2(l) -
POW2(r) *
POW2(sin(phi))))))
1366 bodyData[0] = normal[body * nDim + 0] * mu2[body]
1367 * (r * sin(phi) + (
POW2(r) * sin(phi) *
cos(phi) / (sqrt(
POW2(l) -
POW2(r) *
POW2(sin(phi))))));
1369 bodyData[1] = normal[body * nDim + 1] * mu2[body]
1370 * (r * sin(phi) + (
POW2(r) * sin(phi) *
cos(phi) / (sqrt(
POW2(l) -
POW2(r) *
POW2(sin(phi))))));
1371 IF_CONSTEXPR(nDim == 3)
1372 bodyData[2] = normal[body * nDim + 2] * mu2[body]
1373 * (r * sin(phi) + (
POW2(r) * sin(phi) * cos(phi) / (sqrt(
POW2(l) -
POW2(r) *
POW2(sin(phi))))));
1378 normal[body * nDim + 0] * mu2[body] * mu2[body]
1383 normal[body * nDim + 1] * mu2[body] * mu2[body]
1387 IF_CONSTEXPR(nDim == 3)
1389 normal[body * nDim + 2] * mu2[body] * mu2[body]
1397 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1413 MFloat IO = liftStartAngle1[body];
1414 MFloat IC = liftEndAngle1[body];
1415 MFloat EO = liftStartAngle2[body];
1416 MFloat EC = liftEndAngle2[body];
1424 switch(returnMode) {
1429 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1430 } else if(cad >= 0 && cad < IC) {
1431 MFloat phi_i = (cad - IO) * PI / 180;
1432 MFloat delta_i = (IC - IO) * PI / 180;
1433 MFloat freq_i = 1 / (delta_i / 2 / PI);
1436 bodyData[0] = normal[body * nDim + 0] * amplitude[body] * (1 - sin(freq_i * phi_i - phase));
1437 bodyData[1] = normal[body * nDim + 1] * amplitude[body] * (1 - sin(freq_i * phi_i - phase));
1438 IF_CONSTEXPR(nDim == 3)
1439 bodyData[2] = normal[body * nDim + 2] * amplitude[body] * (1 - sin(freq_i * phi_i - phase));
1441 } else if(cad > IC && cad < EO) {
1444 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1445 } else if(cad >= EO && cad < 720) {
1446 MFloat phi_e = (cad - EO) * PI / 180;
1447 MFloat delta_e = (EC - EO) * PI / 180;
1448 MFloat freq_e = 1 / (delta_e / 2 / PI);
1451 bodyData[0] = normal[body * nDim + 0] * amplitude[body] * (1 - sin(freq_e * phi_e - phase));
1452 bodyData[1] = normal[body * nDim + 1] * amplitude[body] * (1 - sin(freq_e * phi_e - phase));
1453 IF_CONSTEXPR(nDim == 3)
1454 bodyData[2] = normal[body * nDim + 2] * amplitude[body] * (1 - sin(freq_e * phi_e - phase));
1456 mTerm(1, AT_,
"Unexpected crank-angle-degree!");
1459 if(lsSolver().domainId() == 0 && fabs(elapsedTime - a_physicalTime()) < 0.0000000001) {
1460 cerr <<
"Crank-angle-degree : " << cad << endl;
1461 cerr <<
"Valve-position : " << bodyData[0] <<
" in mm" << bodyData[0] * 75 << endl;
1469 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1470 } else if(cad >= 0 && cad < IC) {
1471 MFloat phi_i = (cad - IO) * PI / 180;
1472 MFloat delta_i = (IC - IO) * PI / 180;
1473 MFloat freq_i = 1 / (delta_i / 2 / PI);
1476 bodyData[0] = -normal[body * nDim + 0] * amplitude[body] * mu2[body] * freq_i *
cos(freq_i * phi_i - phase);
1477 bodyData[1] = -normal[body * nDim + 1] * amplitude[body] * mu2[body] * freq_i *
cos(freq_i * phi_i - phase);
1478 IF_CONSTEXPR(nDim == 3)
1479 bodyData[2] = -normal[body * nDim + 2] * amplitude[body] * mu2[body] * freq_i * cos(freq_i * phi_i - phase);
1481 } else if(cad > IC && cad < EO) {
1484 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1485 } else if(cad >= EO && cad < 720) {
1486 MFloat phi_e = (cad - EO) * PI / 180;
1487 MFloat delta_e = (EC - EO) * PI / 180;
1488 MFloat freq_e = 1 / (delta_e / 2 / PI);
1491 bodyData[0] = -normal[body * nDim + 0] * amplitude[body] * mu2[body] * freq_e *
cos(freq_e * phi_e - phase);
1492 bodyData[1] = -normal[body * nDim + 1] * amplitude[body] * mu2[body] * freq_e *
cos(freq_e * phi_e - phase);
1493 IF_CONSTEXPR(nDim == 3)
1494 bodyData[2] = -normal[body * nDim + 2] * amplitude[body] * mu2[body] * freq_e * cos(freq_e * phi_e - phase);
1496 mTerm(1, AT_,
"Unexpected crank-angle-degree!");
1499 if(lsSolver().domainId() == 0 && fabs(elapsedTime - a_physicalTime()) < 0.0000000001) {
1500 cerr <<
"Valve-velocity : " << bodyData[0] << endl;
1508 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1509 } else if(cad >= 0 && cad < IC) {
1510 MFloat phi_i = (cad - IO) * PI / 180;
1511 MFloat delta_i = (IC - IO) * PI / 180;
1512 MFloat freq_i = 1 / (delta_i / 2 / PI);
1515 bodyData[0] = normal[body * nDim + 0] * amplitude[body] * mu2[body] * mu2[body] *
POW2(freq_i)
1516 * sin(freq_i * phi_i - phase);
1517 bodyData[1] = normal[body * nDim + 1] * amplitude[body] * mu2[body] * mu2[body] *
POW2(freq_i)
1518 * sin(freq_i * phi_i - phase);
1519 IF_CONSTEXPR(nDim == 3)
1520 bodyData[2] = normal[body * nDim + 2] * amplitude[body] * mu2[body] * mu2[body] *
POW2(freq_i)
1521 * sin(freq_i * phi_i - phase);
1523 } else if(cad > IC && cad < EO) {
1526 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1527 } else if(cad >= EO && cad < 720) {
1528 MFloat phi_e = (cad - EO) * PI / 180;
1529 MFloat delta_e = (EC - EO) * PI / 180;
1530 MFloat freq_e = 1 / (delta_e / 2 / PI);
1533 bodyData[0] = normal[body * nDim + 0] * amplitude[body] * mu2[body] * mu2[body] *
POW2(freq_e)
1534 * sin(freq_e * phi_e - phase);
1535 bodyData[1] = normal[body * nDim + 1] * amplitude[body] * mu2[body] * mu2[body] *
POW2(freq_e)
1536 * sin(freq_e * phi_e - phase);
1537 IF_CONSTEXPR(nDim == 3)
1538 bodyData[2] = normal[body * nDim + 2] * amplitude[body] * mu2[body] * mu2[body] *
POW2(freq_e)
1539 * sin(freq_e * phi_e - phase);
1541 mTerm(1, AT_,
"Unexpected crank-angle-degree!");
1547 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1562 MFloat scaleToMeter = 0.075;
1566 MFloat IO = liftStartAngle1[body];
1567 MFloat IC = liftEndAngle1[body];
1578 switch(returnMode) {
1583 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1584 } else if(cad >= IO && cad <= IC) {
1585 phi = (cad - IO) * PI / 180;
1586 delta = (IC - IO) * PI / 180;
1587 freq = 1 / (delta / 2 / PI);
1590 bodyData[0] = normal[body * nDim + 0] * amplitude[body] * (1 - sin(freq * phi - phase));
1591 bodyData[1] = normal[body * nDim + 1] * amplitude[body] * (1 - sin(freq * phi - phase));
1592 IF_CONSTEXPR(nDim == 3)
1593 bodyData[2] = normal[body * nDim + 2] * amplitude[body] * (1 - sin(freq * phi - phase));
1595 } else if(cad >= 720 + IO) {
1596 phi = (cad - (720 + IO)) * PI / 180;
1597 delta = (IC - IO) * PI / 180;
1598 freq = 1 / (delta / 2 / PI);
1601 bodyData[0] = normal[body * nDim + 0] * amplitude[body] * (1 - sin(freq * phi - phase));
1602 bodyData[1] = normal[body * nDim + 1] * amplitude[body] * (1 - sin(freq * phi - phase));
1603 IF_CONSTEXPR(nDim == 3)
1604 bodyData[2] = normal[body * nDim + 2] * amplitude[body] * (1 - sin(freq * phi - phase));
1606 } else if(cad >= IC && cad < 720 + IO) {
1609 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1611 mTerm(1, AT_,
"Unexpected crank-angle-degree!");
1614 if(lsSolver().domainId() == 0 && fabs(elapsedTime - a_physicalTime()) < 0.0000000001) {
1615 cerr <<
"Crank-angle-degree : " << cad << endl;
1616 cerr <<
"dimensionless-Inlet-Valve-position : " << amplitude[body] * (1 - sin(freq * phi - phase)) << endl;
1617 cerr <<
"dimensional-Inlet-Valve-position : "
1618 << amplitude[body] * (1 - sin(freq * phi - phase)) * scaleToMeter <<
" in m " << endl;
1619 cerr <<
"dimensionless-Inlet-Valve-velocity : "
1620 << -amplitude[body] * mu2[body] * freq *
cos(freq * phi - phase) << endl;
1628 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1629 } else if(cad >= IO && cad <= IC) {
1630 phi = (cad - IO) * PI / 180;
1631 delta = (IC - IO) * PI / 180;
1632 freq = 1 / (delta / 2 / PI);
1635 bodyData[0] = -normal[body * nDim + 0] * amplitude[body] * mu2[body] * freq *
cos(freq * phi - phase);
1636 bodyData[1] = -normal[body * nDim + 1] * amplitude[body] * mu2[body] * freq *
cos(freq * phi - phase);
1637 IF_CONSTEXPR(nDim == 3)
1638 bodyData[2] = -normal[body * nDim + 2] * amplitude[body] * mu2[body] * freq * cos(freq * phi - phase);
1640 } else if(cad >= 720 + IO) {
1641 phi = (cad - (720 + IO)) * PI / 180;
1642 delta = (IC - IO) * PI / 180;
1643 freq = 1 / (delta / 2 / PI);
1646 bodyData[0] = -normal[body * nDim + 0] * amplitude[body] * mu2[body] * freq *
cos(freq * phi - phase);
1647 bodyData[1] = -normal[body * nDim + 1] * amplitude[body] * mu2[body] * freq *
cos(freq * phi - phase);
1648 IF_CONSTEXPR(nDim == 3)
1649 bodyData[2] = -normal[body * nDim + 2] * amplitude[body] * mu2[body] * freq * cos(freq * phi - phase);
1651 } else if(cad >= IC && cad < 720 + IO) {
1654 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1656 mTerm(1, AT_,
"Unexpected crank-angle-degree!");
1664 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1665 } else if(cad >= IO && cad <= IC) {
1666 phi = (cad - IO) * PI / 180;
1667 delta = (IC - IO) * PI / 180;
1668 freq = 1 / (delta / 2 / PI);
1671 bodyData[0] = normal[body * nDim + 0] * amplitude[body] * mu2[body] * mu2[body] *
POW2(freq)
1672 * sin(freq * phi - phase);
1673 bodyData[1] = normal[body * nDim + 1] * amplitude[body] * mu2[body] * mu2[body] *
POW2(freq)
1674 * sin(freq * phi - phase);
1675 IF_CONSTEXPR(nDim == 3)
1676 bodyData[2] = normal[body * nDim + 2] * amplitude[body] * mu2[body] * mu2[body] *
POW2(freq)
1677 * sin(freq * phi - phase);
1679 } else if(cad >= 720 + IO) {
1680 phi = (cad - (720 + IO)) * PI / 180;
1681 delta = (IC - IO) * PI / 180;
1682 freq = 1 / (delta / 2 / PI);
1685 bodyData[0] = normal[body * nDim + 0] * amplitude[body] * mu2[body] * mu2[body] *
POW2(freq)
1686 * sin(freq * phi - phase);
1687 bodyData[1] = normal[body * nDim + 1] * amplitude[body] * mu2[body] * mu2[body] *
POW2(freq)
1688 * sin(freq * phi - phase);
1689 IF_CONSTEXPR(nDim == 3)
1690 bodyData[2] = normal[body * nDim + 2] * amplitude[body] * mu2[body] * mu2[body] *
POW2(freq)
1691 * sin(freq * phi - phase);
1693 } else if(cad >= IC && cad < 720 + IO) {
1696 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1698 mTerm(1, AT_,
"Unexpected crank-angle-degree!");
1704 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1729 MFloat EO = liftStartAngle1[body];
1730 MFloat EC = liftEndAngle1[body];
1731 MFloat scaleToMeter = 0.075;
1742 switch(returnMode) {
1744 if(cad < EO && cad >= EC) {
1747 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1748 } else if(cad >= EO && cad < 720) {
1749 phi = (cad - EO) * PI / 180;
1750 delta = (720 + EC - EO) * PI / 180;
1751 freq = 1 / (delta / 2 / PI);
1754 bodyData[0] = normal[body * nDim + 0] * amplitude[body] * (1 - sin(freq * phi - phase));
1755 bodyData[1] = normal[body * nDim + 1] * amplitude[body] * (1 - sin(freq * phi - phase));
1756 IF_CONSTEXPR(nDim == 3)
1757 bodyData[2] = normal[body * nDim + 2] * amplitude[body] * (1 - sin(freq * phi - phase));
1759 } else if(cad < EC) {
1760 phi = -(EC - cad) * PI / 180;
1761 delta = (720 + EC - EO) * PI / 180;
1762 freq = 1 / (delta / 2 / PI);
1765 bodyData[0] = normal[body * nDim + 0] * amplitude[body] * (1 - sin(freq * phi - phase));
1766 bodyData[1] = normal[body * nDim + 1] * amplitude[body] * (1 - sin(freq * phi - phase));
1767 IF_CONSTEXPR(nDim == 3)
1768 bodyData[2] = normal[body * nDim + 2] * amplitude[body] * (1 - sin(freq * phi - phase));
1771 mTerm(1, AT_,
"Unexpected crank-angle-degree!");
1774 if(lsSolver().domainId() == 0 && fabs(elapsedTime - a_physicalTime()) < 0.0000000001) {
1775 cerr <<
"Crank-angle-degree : " << cad << endl;
1776 cerr <<
"dimensionless-Outlet-Valve-position : " << amplitude[body] * (1 - sin(freq * phi - phase)) << endl;
1777 cerr <<
"dimensional-Outlet-Valve-position : "
1778 << amplitude[body] * (1 - sin(freq * phi - phase)) * scaleToMeter <<
" in m " << endl;
1779 cerr <<
"dimensionless-Outlet-Valve-velocity : "
1780 << -amplitude[body] * mu2[body] * freq *
cos(freq * phi - phase) << endl;
1785 if(cad < EO && cad >= EC) {
1788 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1789 } else if(cad >= EO && cad < 720) {
1790 phi = (cad - EO) * PI / 180;
1791 delta = (720 + EC - EO) * PI / 180;
1792 freq = 1 / (delta / 2 / PI);
1795 bodyData[0] = -normal[body * nDim + 0] * amplitude[body] * mu2[body] * freq *
cos(freq * phi - phase);
1796 bodyData[1] = -normal[body * nDim + 1] * amplitude[body] * mu2[body] * freq *
cos(freq * phi - phase);
1797 IF_CONSTEXPR(nDim == 3)
1798 bodyData[2] = -normal[body * nDim + 2] * amplitude[body] * mu2[body] * freq * cos(freq * phi - phase);
1801 } else if(cad < EC) {
1802 phi = -(EC - cad) * PI / 180;
1803 delta = (720 + EC - EO) * PI / 180;
1804 freq = 1 / (delta / 2 / PI);
1807 bodyData[0] = -normal[body * nDim + 0] * amplitude[body] * mu2[body] * freq *
cos(freq * phi - phase);
1808 bodyData[1] = -normal[body * nDim + 1] * amplitude[body] * mu2[body] * freq *
cos(freq * phi - phase);
1809 IF_CONSTEXPR(nDim == 3)
1810 bodyData[2] = -normal[body * nDim + 2] * amplitude[body] * mu2[body] * freq * cos(freq * phi - phase);
1812 mTerm(1, AT_,
"Unexpected crank-angle-degree!");
1817 if(cad < EO && cad >= EC) {
1820 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1821 } else if(cad >= EO && cad < 720) {
1822 phi = (cad - EO) * PI / 180;
1823 delta = (720 + EC - EO) * PI / 180;
1824 freq = 1 / (delta / 2 / PI);
1827 bodyData[0] = normal[body * nDim + 0] * amplitude[body] * mu2[body] * mu2[body] *
POW2(freq)
1828 * sin(freq * phi - phase);
1829 bodyData[1] = normal[body * nDim + 1] * amplitude[body] * mu2[body] * mu2[body] *
POW2(freq)
1830 * sin(freq * phi - phase);
1831 IF_CONSTEXPR(nDim == 3)
1832 bodyData[2] = normal[body * nDim + 2] * amplitude[body] * mu2[body] * mu2[body] *
POW2(freq)
1833 * sin(freq * phi - phase);
1835 } else if(cad < EC) {
1836 phi = -(EC - cad) * PI / 180;
1837 delta = (720 + EC - EO) * PI / 180;
1838 freq = 1 / (delta / 2 / PI);
1841 bodyData[0] = normal[body * nDim + 0] * amplitude[body] * mu2[body] * mu2[body] *
POW2(freq)
1842 * sin(freq * phi - phase);
1843 bodyData[1] = normal[body * nDim + 1] * amplitude[body] * mu2[body] * mu2[body] *
POW2(freq)
1844 * sin(freq * phi - phase);
1845 IF_CONSTEXPR(nDim == 3)
1846 bodyData[2] = normal[body * nDim + 2] * amplitude[body] * mu2[body] * mu2[body]
1847 * (1 +
POW2(freq) * sin(freq * phi - phase));
1849 mTerm(1, AT_,
"Unexpected crank-angle-degree!");
1855 IF_CONSTEXPR(nDim == 3) bodyData[2] = F0;
1860 mTerm(1, AT_, "function type not implemented. Please check bodyMovementFunctions property!");
1864 if(returnMode == 1) {
1865 for(
MInt dir = 0; dir < nDim; dir++) {
1866 bodyData[dir] += initialBodyCenter[body * nDim + dir];
1872 if(rotAngle > 0 || rotAngle < 0) {
1873 MFloat tmp0 = bodyData[0] *
cos(rotAngle) + bodyData[1] * sin(rotAngle);
1874 MFloat tmp1 = bodyData[1] *
cos(rotAngle) - bodyData[0] * sin(rotAngle);
1877 bodyData[2] = bodyData[2];
1885template <MInt nDim,
class SysEqn>
1889 MFloat& Strouhal = m_static_crankAngle_Strouhal;
1890 MBool& first = m_static_crankAngle_first;
1893 Strouhal = Context::getSolverProperty<MFloat>(
"Strouhal", m_lsSolverId, AT_, &Strouhal);
1897 const MFloat mu2 = Strouhal * F2 * PI;
1898 MFloat cad = mu2 * elapsedTime;
1899 const MInt maxNoCycles = 20;
1901 for(
MInt cycle = maxNoCycles; cycle > 0; cycle--) {
1902 if(cad >= 4 * PI * cycle) cad = cad - 4 * PI * cycle;
1904 cad = cad * 180 / PI;
1907 cad = cad + m_initialCrankAngle;
void mAlloc(T *&a, const MLong N, const MString &objectName, MString function)
allocates memory for one-dimensional array 'a' of size N
static MBool propertyExists(const MString &name, MInt solver=m_noSolvers)
This function checks if a property exists in general.
solverType & lsSolver() const
MFloat interpolateLevelSet(MInt cellId, MFloat *point, MInt set)
void finalizeCouplerInit() override
void checkProperties() override
Checks property-data which is read in by both ls-and Fv-Solver.
void testGapProperty()
transfers the LevelSetValues from the levelset to the moving boundary Part
MBool returnStep()
mimics the behaviour of the rungeKuttaStep() methods with respect to increasing time
void computeBodyProperties(MInt returnMode, MFloat *bodyData, MInt body, MFloat time)
void setLsInList(MIntScratchSpace &)
static constexpr MInt nDim
MFloat a_meanCoord(MInt dir) const
void returnStep_semiLagrange()
mimics the behaviour of the rungeKuttaStep() methods with respect to increasing time
void computeGCellTimeStep()
computes the gcell time step
void transferGapCellProperty()
Sets the gapcell-property.
void readProperties() override
MInt noLevelSetFieldData()
void testCoupling()
transfers the LevelSetValues from the levelset to the moving boundary Part
void preCouple(MInt) override
void transferLevelSetValues()
Sets the Levelset-Values in fvSolver.
void postAdaptation() override
finalizeAdaptation
void postCouple(MInt recipeStep=0) override
void initData()
Initialize coupling-class-specific Data.
MFloat crankAngle(MFloat)
help-function for engine calculations which returns the crank-angle for a given time
CouplingLsFv(const MInt couplingId, LsSolver *ls, FvCartesianSolver *fv)
This class is a ScratchSpace.
MInt string2enum(MString theString)
This global function translates strings in their corresponding enum values (integer values)....
@ MAIA_RUNGE_KUTTA_LEVELSET
@ MAIA_SEMI_LAGRANGE_LEVELSET
void mTerm(const MInt errorCode, const MString &location, const MString &message)
constexpr Real POW4(const Real x)
constexpr Real POW3(const Real x)
constexpr Real POW2(const Real x)
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
T cos(const T a, const T b, const T x)
Cosine slope filter.
MFloat crankAngle(const MFloat time, const MFloat Strouhal, const MFloat offset, const MInt mode)
help-function for engine calculations which returns the crank-angle for a given time,...